From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 2B953158018 for ; Sun, 3 Oct 2021 13:43:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6058BE089A; Sun, 3 Oct 2021 13:43:33 +0000 (UTC) Received: from smtp.gentoo.org (mail.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 36C47E089A for ; Sun, 3 Oct 2021 13:43:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-CHACHA20-POLY1305 (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0996A342F05 for ; Sun, 3 Oct 2021 13:43:32 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5934D2C for ; Sun, 3 Oct 2021 13:43:30 +0000 (UTC) From: "Akinori Hattori" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Akinori Hattori" Message-ID: <1633268590.52cbbc65f4faf52f1129694581bd345af07ceccb.hattya@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: dev-scheme/c-wrapper/files/, dev-scheme/c-wrapper/ X-VCS-Repository: repo/gentoo X-VCS-Files: dev-scheme/c-wrapper/c-wrapper-0.6.1-r1.ebuild dev-scheme/c-wrapper/c-wrapper-0.6.1-r2.ebuild dev-scheme/c-wrapper/files/c-wrapper-extend-parser.patch dev-scheme/c-wrapper/files/c-wrapper-float128.patch dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch X-VCS-Directories: dev-scheme/c-wrapper/files/ dev-scheme/c-wrapper/ X-VCS-Committer: hattya X-VCS-Committer-Name: Akinori Hattori X-VCS-Revision: 52cbbc65f4faf52f1129694581bd345af07ceccb X-VCS-Branch: master Date: Sun, 3 Oct 2021 13:43:30 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 89339311-32af-4e9c-9bff-518aa013734d X-Archives-Hash: 81205431c3f2899bd063fad06bf5c4e3 commit: 52cbbc65f4faf52f1129694581bd345af07ceccb Author: Akinori Hattori gentoo org> AuthorDate: Sun Oct 3 13:43:10 2021 +0000 Commit: Akinori Hattori gentoo org> CommitDate: Sun Oct 3 13:43:10 2021 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=52cbbc65 dev-scheme/c-wrapper: apply patches from Arch Package-Manager: Portage-3.0.20, Repoman-3.0.3 Signed-off-by: Akinori Hattori gentoo.org> ...r-0.6.1-r1.ebuild => c-wrapper-0.6.1-r2.ebuild} | 3 + .../c-wrapper/files/c-wrapper-extend-parser.patch | 142 ++++++++++++++++++++ .../c-wrapper/files/c-wrapper-float128.patch | 79 +++++++++++ .../c-wrapper/files/c-wrapper-local-typedef.patch | 149 +++++++++++++++++++++ 4 files changed, 373 insertions(+) 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 similarity index 89% rename from dev-scheme/c-wrapper/c-wrapper-0.6.1-r1.ebuild rename to dev-scheme/c-wrapper/c-wrapper-0.6.1-r2.ebuild index 35882c4965d..3f827777453 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 00000000000..998938a2c42 --- /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 +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 00000000000..acd2f04407d --- /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 +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 00000000000..70f4ffcf4cd --- /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 +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)