diff options
author | Akinori Hattori <hattya@gentoo.org> | 2021-10-03 22:43:10 +0900 |
---|---|---|
committer | Akinori Hattori <hattya@gentoo.org> | 2021-10-03 22:43:10 +0900 |
commit | 52cbbc65f4faf52f1129694581bd345af07ceccb (patch) | |
tree | 1d1f96cc8bd079172b08e09afbdf236850aeb7f9 /dev-scheme/c-wrapper | |
parent | app-i18n/ibus-typing-booster: drop old (diff) | |
download | gentoo-52cbbc65f4faf52f1129694581bd345af07ceccb.tar.gz gentoo-52cbbc65f4faf52f1129694581bd345af07ceccb.tar.bz2 gentoo-52cbbc65f4faf52f1129694581bd345af07ceccb.zip |
dev-scheme/c-wrapper: apply patches from Arch
Package-Manager: Portage-3.0.20, Repoman-3.0.3
Signed-off-by: Akinori Hattori <hattya@gentoo.org>
Diffstat (limited to 'dev-scheme/c-wrapper')
-rw-r--r-- | dev-scheme/c-wrapper/c-wrapper-0.6.1-r2.ebuild (renamed from dev-scheme/c-wrapper/c-wrapper-0.6.1-r1.ebuild) | 3 | ||||
-rw-r--r-- | dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch | 142 | ||||
-rw-r--r-- | dev-scheme/c-wrapper/files/c-wrapper-float128.patch | 79 | ||||
-rw-r--r-- | dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch | 149 |
4 files changed, 373 insertions, 0 deletions
diff --git a/dev-scheme/c-wrapper/c-wrapper-0.6.1-r1.ebuild b/dev-scheme/c-wrapper/c-wrapper-0.6.1-r2.ebuild index 35882c4965d7..3f8277774536 100644 --- a/dev-scheme/c-wrapper/c-wrapper-0.6.1-r1.ebuild +++ b/dev-scheme/c-wrapper/c-wrapper-0.6.1-r2.ebuild @@ -27,6 +27,9 @@ PATCHES=( "${FILESDIR}"/${PN}-info.patch "${FILESDIR}"/${PN}-texinfo-6.7.patch "${FILESDIR}"/${PN}-clang.patch + "${FILESDIR}"/${PN}-float128.patch + "${FILESDIR}"/${PN}-local-typedef.patch + "${FILESDIR}"/${PN}-extend-parser.patch ) HTML_DOCS=( doc/${PN}-ref{e,j}.html ) diff --git a/dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch b/dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch new file mode 100644 index 000000000000..998938a2c428 --- /dev/null +++ b/dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch @@ -0,0 +1,142 @@ +https://aur.archlinux.org/cgit/aur.git/tree/14_extend_parser.patch?h=gauche-c-wrapper + +Description: Include __int128, make statements before delcarations in functions possible and add some workaround to load x86intrin.h successfully. +Author: Fabian Brosda <fabi3141@gmx.de> +Last-Update: 2020-07-10 + +--- a/lib/c-wrapper/c-parser.scm ++++ b/lib/c-wrapper/c-parser.scm +@@ -181,6 +181,26 @@ + ,@(reverse init-list) + ,@statements))) + ++(define-maybe (%COMPOUND-STATEMENT-WITH-DECLARATION-EXT statements-before declaration-list statements) ++ (let ((var-list '()) ++ (init-list '())) ++ (for-each (lambda (declaration) ++ (let* ((type (type-of declaration)) ++ (identifier (name-of declaration)) ++ (init-val (value-of declaration))) ++ ;; TODO: typedef in compound_statement is not supported ++ (push! var-list `(,identifier (make ,type))) ++ (when init-val ++ (push! init-list ++ `(set! ((with-module c-wrapper.c-ffi ref) ,identifier) ++ ,init-val))))) ++ declaration-list) ++ `(begin ++ ,@statements-before ++ (let* ,(reverse var-list) ++ ,@(reverse init-list) ++ ,@statements)))) ++ + (define-maybe (%REF-ARRAY v index) + `((with-module c-wrapper.c-ffi ref) ,v ,(%INT index))) + +--- a/src/c-grammar.scm ++++ b/src/c-grammar.scm +@@ -122,6 +122,7 @@ + (LPAREN expr RPAREN) : (%EXPR-IN-PARENS $2) + (LPAREN compound_statement RPAREN) : (%COMPOUND-STATEMENT $2) + (LPAREN type_name RPAREN LCBRA initializer_list RCBRA) : #f ++ (LPAREN type_name RPAREN LCBRA initializer_list COMMA RCBRA) : #f + (objc_message_expr) : $1 + (objc_selector_expr) : $1 + (objc_protocol_expr) : #f +@@ -474,8 +475,8 @@ + (LCBRA RCBRA) : (%COMPOUND-STATEMENT '(0)) + (LCBRA statement_list RCBRA) : (%COMPOUND-STATEMENT $2) + (LCBRA declaration_list RCBRA) : (%COMPOUND-STATEMENT '(0)) +- (LCBRA declaration_list statement_list RCBRA) +- : (%COMPOUND-STATEMENT-WITH-DECLARATION $2 $3) ++ (LCBRA declaration_list statement_list RCBRA) : (%COMPOUND-STATEMENT-WITH-DECLARATION $2 $3) ++ (LCBRA statement_list declaration_list statement_list RCBRA) : (%COMPOUND-STATEMENT-WITH-DECLARATION-EXT $2 $3 $4) + (error RCBRA) : #f + ) + +--- a/src/c-lex.c ++++ b/src/c-lex.c +@@ -361,6 +361,7 @@ + "void", + "_Bool", + "_Float128", ++ "__int128", + NULL, + }; + int i; +--- a/src/c-parser.c ++++ b/src/c-parser.c +@@ -104,6 +104,7 @@ + DEFINE_SYM(void); + DEFINE_SYM(_Bool); + DEFINE_SYM(_Float128); ++DEFINE_SYM(__int128); + DEFINE_SYM(__builtin_va_list); + DEFINE_SYM(U_struct); + DEFINE_SYM(U_union); +@@ -472,7 +473,9 @@ + } else if (SCM_EQ(car, SYM(_Bool))) { + SCM_RETURN(SYM(c_int)); + } else if (SCM_EQ(car, SYM(_Float128))) { + SCM_RETURN(SYM(c_double)); ++ } else if (SCM_EQ(car, SYM(__int128))) { ++ SCM_RETURN(SYM(c_longlong)); + } else if (SCM_EQ(car, SYM(__builtin_va_list))) { + SCM_RETURN(SCM_LIST2(SCM_LIST3(SYM(with_module), SYM(c_wrapper_c_ffi), SYM(ptr)), SYM(c_void))); + } else if (SCM_PAIRP(car) && SCM_EQ(SCM_CAR(car), SYM(U_struct))) { +@@ -1024,7 +1027,11 @@ + Scm_ParserAttributeClear(); + td_list = Scm_MakeTypeDeclList(type_spec_list, declarator_list); + SCM_FOR_EACH(pair, td_list) { +- Scm_ArgPoolAdd(SCM_TYPE_DECL_NAME(SCM_CAR(pair))); ++ // hack to avoid segfault when loading x86intrin.h ++ // TODO: why is this necessary? ++ if (!SCM_EQ(SCM_CAR(pair), SCM_FALSE)) { ++ Scm_ArgPoolAdd(SCM_TYPE_DECL_NAME(SCM_CAR(pair))); ++ } + } + + SCM_RETURN(td_list); +@@ -1865,6 +1872,7 @@ + INIT_SYM(void, "void"); + INIT_SYM(_Bool, "_Bool"); + INIT_SYM(_Float128, "_Float128"); ++ INIT_SYM(__int128, "__int128"); + INIT_SYM(__builtin_va_list, "__builtin_va_list"); + INIT_SYM(U_struct, "STRUCT"); + INIT_SYM(U_union, "UNION"); +--- a/testsuite/Makefile.in ++++ b/testsuite/Makefile.in +@@ -78,6 +78,7 @@ + $(GOSH) -I../src -I../lib stdio-test.scm >> test.log + $(GOSH) -I../src -I../lib math-test.scm >> test.log + $(GOSH) -I../src -I../lib local-typedef.scm >> test.log ++ $(GOSH) -I../src -I../lib stmt-decl.scm >> test.log + $(GOSH) -I../src -I../lib inline-test.scm >> test.log + $(GOSH) -I../src -I../lib fptr_array-test.scm >> test.log + $(GOSH) -I../src -I../lib array_qualifier-test.scm >> test.log +--- a/testsuite/stmt_decl.h ++++ b/testsuite/stmt_decl.h +@@ -0,0 +1,6 @@ ++void f(int arg1) ++{ ++ arg1 = 3; ++ double tmp = arg1; ++ return tmp; ++} +--- a/testsuite/stmt-decl.scm ++++ b/testsuite/stmt-decl.scm +@@ -0,0 +1,13 @@ ++;;; ++;;; Test include math.h ++;;; ++ ++(use gauche.test) ++ ++(test-start "test for statement before and after declaration in c function") ++(use c-wrapper) ++ ++(c-include "stmt_decl.h") ++ ++;; epilogue ++(test-end) diff --git a/dev-scheme/c-wrapper/files/c-wrapper-float128.patch b/dev-scheme/c-wrapper/files/c-wrapper-float128.patch new file mode 100644 index 000000000000..acd2f04407dd --- /dev/null +++ b/dev-scheme/c-wrapper/files/c-wrapper-float128.patch @@ -0,0 +1,79 @@ +https://aur.archlinux.org/cgit/aur.git/tree/12_float128.patch?h=gauche-c-wrapper + +Description: Workaround for usage of math.h including type _Float128 +Author: Fabian Brosda <fabi3141@gmx.de> +Last-Update: 2020-07-10 + +--- a/src/c-lex.c ++++ b/src/c-lex.c +@@ -360,6 +360,7 @@ + "double", + "void", + "_Bool", ++ "_Float128", + NULL, + }; + int i; +--- a/src/c-parser.c ++++ b/src/c-parser.c +@@ -103,6 +103,7 @@ + DEFINE_SYM(double); + DEFINE_SYM(void); + DEFINE_SYM(_Bool); ++DEFINE_SYM(_Float128); + DEFINE_SYM(__builtin_va_list); + DEFINE_SYM(U_struct); + DEFINE_SYM(U_union); +@@ -470,6 +471,8 @@ + SCM_RETURN(SYM(c_void)); + } else if (SCM_EQ(car, SYM(_Bool))) { + SCM_RETURN(SYM(c_int)); ++ } else if (SCM_EQ(car, SYM(_Float128))) { ++ SCM_RETURN(SYM(c_double)); + } else if (SCM_EQ(car, SYM(__builtin_va_list))) { + SCM_RETURN(SCM_LIST2(SCM_LIST3(SYM(with_module), SYM(c_wrapper_c_ffi), SYM(ptr)), SYM(c_void))); + } else if (SCM_PAIRP(car) && SCM_EQ(SCM_CAR(car), SYM(U_struct))) { +@@ -1859,6 +1862,7 @@ + INIT_SYM(double, "double"); + INIT_SYM(void, "void"); + INIT_SYM(_Bool, "_Bool"); ++ INIT_SYM(_Float128, "_Float128"); + INIT_SYM(__builtin_va_list, "__builtin_va_list"); + INIT_SYM(U_struct, "STRUCT"); + INIT_SYM(U_union, "UNION"); +--- a/testsuite/Makefile.in ++++ b/testsuite/Makefile.in +@@ -73,6 +73,7 @@ + $(GOSH) -I../src -I../lib cwrappertest.scm >> test.log + $(GOSH) -I../src -I../lib struct_in_union-test.scm >> test.log + $(GOSH) -I../src -I../lib stdio-test.scm >> test.log ++ $(GOSH) -I../src -I../lib math-test.scm >> test.log + $(GOSH) -I../src -I../lib inline-test.scm >> test.log + $(GOSH) -I../src -I../lib fptr_array-test.scm >> test.log + $(GOSH) -I../src -I../lib array_qualifier-test.scm >> test.log +--- a/testsuite/math-test.scm ++++ b/testsuite/math-test.scm +@@ -0,0 +1,23 @@ ++;;; ++;;; Test include math.h ++;;; ++ ++(use gauche.test) ++ ++(test-start "c-wrapper (include math.h)") ++(use c-wrapper) ++ ++(c-include "math.h") ++ ++(test "trunc" ++ 1.0 ++ (lambda () ++ (trunc 1.9))) ++ ++(test "pow" ++ 625.0 ++ (lambda () ++ (pow 5 4))) ++ ++;; epilogue ++(test-end) diff --git a/dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch b/dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch new file mode 100644 index 000000000000..70f4ffcf4cd4 --- /dev/null +++ b/dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch @@ -0,0 +1,149 @@ +https://aur.archlinux.org/cgit/aur.git/plain/13_local_typedef.patch?h=gauche-c-wrapper + +Description: Basic support for typedefs inside functions +Author: Fabian Brosda <fabi3141@gmx.de> +Last-Update: 2020-07-10 + +--- a/src/c-parser.c ++++ b/src/c-parser.c +@@ -594,6 +594,26 @@ + } + } + ++static void emit_typedef(ScmObj type_decl_list) ++{ ++ ScmObj p; ++ ++ SCM_FOR_EACH(p, type_decl_list) { ++ ScmObj v = SCM_CAR(p); ++ ScmObj ctype = SCM_TYPE_DECL_CTYPE(v); ++ ScmObj new_ctype = SCM_TYPE_DECL_NAME(v); ++ ScmObj sym = CParser_ctype2class_symbol(new_ctype); ++ ++ Scm_DefChunkDictSetTypename(new_ctype, ++ Scm_MakeDefChunk(SYM(S_typedef), ++ new_ctype, ++ SCM_LIST1(sym), ++ SCM_LIST3(SYM(S_define), sym, ctype))); ++ Scm_InstallType(new_ctype); ++ } ++} ++ ++ + ScmObj Scm_MakeTypeDecl(ScmObj type_spec_list, ScmObj declarator) + { + ScmObj lst = SCM_NIL; +@@ -612,6 +632,7 @@ + + SCM_FOR_EACH(pair, type_spec_list) { + if (SCM_EQ(SCM_CAR(pair), SYM(U_typedef))) { ++ emit_typedef(Scm_Cons(Scm_MakeTypeDecl(SCM_CDR(pair), declarator), lst)); + continue; + } + lst = Scm_Cons(SCM_CAR(pair), lst); +@@ -1542,25 +1563,6 @@ + SCM_RETURN(SCM_UNDEFINED); + } + +-static void emit_typedef(ScmObj type_decl_list) +-{ +- ScmObj p; +- +- SCM_FOR_EACH(p, type_decl_list) { +- ScmObj v = SCM_CAR(p); +- ScmObj ctype = SCM_TYPE_DECL_CTYPE(v); +- ScmObj new_ctype = SCM_TYPE_DECL_NAME(v); +- ScmObj sym = CParser_ctype2class_symbol(new_ctype); +- +- Scm_DefChunkDictSetTypename(new_ctype, +- Scm_MakeDefChunk(SYM(S_typedef), +- new_ctype, +- SCM_LIST1(sym), +- SCM_LIST3(SYM(S_define), sym, ctype))); +- Scm_InstallType(new_ctype); +- } +-} +- + static void emit_define_extern(ScmObj declaration) + { + ScmObj ctype = SCM_TYPE_DECL_CTYPE(declaration); +--- a/testsuite/local_typedef.c ++++ b/testsuite/local_typedef.c +@@ -0,0 +1,6 @@ ++#include "local_typedef.h" ++ ++int local_typedef(void) ++{ ++ return helper(); ++} +--- a/testsuite/local_typedef.h ++++ b/testsuite/local_typedef.h +@@ -0,0 +1,8 @@ ++extern int local_typedef(void); ++ ++int helper(void) ++{ ++ typedef int _my_type; ++ _my_type ret = 1; ++ return ret; ++} +--- a/testsuite/local-typedef.scm ++++ b/testsuite/local-typedef.scm +@@ -0,0 +1,19 @@ ++;;; ++;;; Test local typedefs ++;;; ++ ++(use gauche.test) ++ ++(test-start "c-wrapper (local typedefs)") ++(use c-wrapper) ++ ++(c-load-library "./local_typedef") ++(c-include "./local_typedef.h") ++ ++(test "local_typedef" ++ 1 ++ (lambda () ++ (local_typedef))) ++ ++;; epilogue ++(test-end) +--- a/testsuite/Makefile.in ++++ b/testsuite/Makefile.in +@@ -57,6 +57,9 @@ + fptr_array.$(DYLIBEXT): fptr_array.o + $(CC) $(LDFLAGS) $@ $< + ++local_typedef.$(DYLIBEXT): local_typedef.o ++ $(CC) $(LDFLAGS) $@ $< ++ + gcc_extension.$(DYLIBEXT): gcc_extension.o + $(CC) $(LDFLAGS) $@ $< + +@@ -65,7 +68,7 @@ + + check: $(CHECK_TARGET) + +-check-c: ffitest.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT) ++check-c: ffitest.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT) local_typedef.$(DYLIBEXT) + @rm -f test.log + $(GOSH) -I../src -I../lib attr-test.scm >> test.log + $(GOSH) -I../src -I../lib ffitest.scm >> test.log +@@ -74,6 +77,7 @@ + $(GOSH) -I../src -I../lib struct_in_union-test.scm >> test.log + $(GOSH) -I../src -I../lib stdio-test.scm >> test.log + $(GOSH) -I../src -I../lib math-test.scm >> test.log ++ $(GOSH) -I../src -I../lib local-typedef.scm >> test.log + $(GOSH) -I../src -I../lib inline-test.scm >> test.log + $(GOSH) -I../src -I../lib fptr_array-test.scm >> test.log + $(GOSH) -I../src -I../lib array_qualifier-test.scm >> test.log +@@ -83,7 +87,7 @@ + $(GOSH) -I../src -I../lib -I../objc objc-test.scm >> test.log + + clean : +- rm -rf core ffitest.$(DYLIBEXT) objc-test.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT) *.o $(GENERATED) *~ test.log so_locations ++ rm -rf core ffitest.$(DYLIBEXT) objc-test.$(DYLIBEXT) fptr_array.$(DYLIBEXT) gcc_extension.$(DYLIBEXT) local_typedef.$(DYLIBEXT) *.o $(GENERATED) *~ test.log so_locations + + distclean : clean + rm -rf $(CONFIG_GENERATED) |