diff options
author | V3n3RiX <venerix@koprulu.sector> | 2021-10-08 23:06:07 +0100 |
---|---|---|
committer | V3n3RiX <venerix@koprulu.sector> | 2021-10-08 23:06:07 +0100 |
commit | e23a08d0c97a0cc415aaa165da840b056f93c997 (patch) | |
tree | 4c5f7db60483518201fef36f8cc0712789a08db2 /dev-scheme/c-wrapper | |
parent | 391b5b359a346aff490103da7dddc85047f83830 (diff) |
gentoo resync : 08.10.2021
Diffstat (limited to 'dev-scheme/c-wrapper')
-rw-r--r-- | dev-scheme/c-wrapper/Manifest | 8 | ||||
-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) | 6 | ||||
-rw-r--r-- | dev-scheme/c-wrapper/files/c-wrapper-clang.patch | 71 | ||||
-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-gcc-5.patch | 42 | ||||
-rw-r--r-- | dev-scheme/c-wrapper/files/c-wrapper-local-typedef.patch | 149 |
7 files changed, 470 insertions, 27 deletions
diff --git a/dev-scheme/c-wrapper/Manifest b/dev-scheme/c-wrapper/Manifest index dcaf4dc8ecee..c53e6d9182ac 100644 --- a/dev-scheme/c-wrapper/Manifest +++ b/dev-scheme/c-wrapper/Manifest @@ -1,9 +1,13 @@ +AUX c-wrapper-clang.patch 3196 BLAKE2B f960f9008bb8114804ecc20cedbb0e8b46d1442317fb0e9376d741788c3d0c32bd4cf5058eba5d7f450f1ab49856b90857c6fe537b880afa524ed4ea434f981b SHA512 49326d99a9dccd72b7d2a6f3fa585c855aac82fd8e940e952a638b47e35378fa7883978084abfd0f5bfa0e8119e864fc18675edcf8444d64e6694b0e5a59940f AUX c-wrapper-closure.patch 205 BLAKE2B b633bbf97b3d76ab58b9a332ddc56f976b54f9eb3df0b235e7784e27141dda051e5d637839bf3be49c580845ad6898d9d526169abb14e6329642105dd5416c11 SHA512 284f08b6a8164d129dfe5e26500ca4946c037d0661614dfcab7caf4d5ce189ee299dbb70fa6a4d0f2ec5b0fdf9f1926891d07ce019fade329a0909c10586c790 -AUX c-wrapper-gcc-5.patch 2046 BLAKE2B 645b7ee67edd8e6d08fdf7f2dd591c745a420eb001cac6aede3f0393871bc538a96ee438ef8d66d5c49e16e493219a9f2607d242c79398e687b62aca22e7f1ee SHA512 174c8f364c1f9660ebb2034a7edbcd8ed640515c883b7cacd672286f70787df4314de2ad90aeca7c528f2522a8bd61c916b73fb06f4dd23e428c2dd55fb44fdd +AUX c-wrapper-extend-parser.patch 4899 BLAKE2B f0ba1b3e6866e48b8546535c63ca71b9e3f219348ecda3cc9281bef1801a5e1731767b4456d4071b62e5b9da94b7280ab3fa33bc396089cb6e0dee529b853d88 SHA512 a7c3d1ce4ab53478ccb6621c94ce12e3dcd8a967ea1589b210e2dfc91b2a1a6e4fb9b00c0e8ac6a054a0d9d905e662c178682ad43971b46153c825efff9a7319 +AUX c-wrapper-float128.patch 2198 BLAKE2B 5a17b735f99cd2af99b161421102e2d8eb4f081b85b83645b9d3bd209f30706a9441d4222a3d8c863304f4c028ab0a53677a1c25e5f16221e1b24d7293eefa8f SHA512 29386dd077dcd2a88dcd2fe13064863a9a36a59d0a59f34be04adb06bb923d548bc1aff3df9a208f25285d91cf0c1470ece08b188f74ae6526f918c72447456a +AUX c-wrapper-gcc-5.patch 1704 BLAKE2B 2f91221e5fad3c9871307c8da2f6650e02a6d645a56538359afad8cb817f02ec6eba407a76b852e854085d89650a6ff05ccd8e525e8be7b3ad57af87c4ac7a97 SHA512 96effd453715ca3725ff3288ceb237c9078499d43cb5be36dc2e15b9a4d274ff42d25bf212f47f2bfae2b79d9713addc12c0663f6fd8cc7c3229df8121f4b903 AUX c-wrapper-gentoo.patch 2015 BLAKE2B fedf622537151079df07aaa1091fe377b1e1ee8ebf95a4c8b290ca983376211e6897ddb14c8d3c8f38fc1a23073d5282c447b8e8d66578235b17bb3cddce76f1 SHA512 4184d3a4953478ff19374ff230bd7376eb8a8d7d90e1e91b1903b30af49f124d18b816639024a9b54a7099965ea2c5c8244ca64a7ce4db8f3fde32cbc13578d3 AUX c-wrapper-glibc-2.25.patch 727 BLAKE2B 0c0dce0bfb78a92ff4c2cf6176a7b7de129e143737be897a074f06f88b6923915ec36a9e3ddb5410010c662e8e11bb17b89742349c2a01a3066c1c49c08cc57a SHA512 769c92156395f121d8ba3776904c279c5b97f791f7606b74c682264430ed71f1af31ce8655286cae7dfebb75ea8addc2fb304a87eb5972314c5ab082700921ee AUX c-wrapper-info.patch 1920 BLAKE2B 62c60a2dd8783fc0a56d386e02faa8f04bdd570c7119999e51071414f8084f78d47acda9d916b576bea7ba35c65bd0d4c7519cbe52235a40c49e324139587df8 SHA512 1778eb0183e8f6e19fcb8071bb49e542d98f82b49932aeb5c8dc6638c50ea3b802efb5b92837f90854f47d4400b224e6895b3a6bea042b29a91f855fdf319de8 +AUX c-wrapper-local-typedef.patch 4576 BLAKE2B e128d6f1f5cc457b3968ed8b9c3cfe62ed94dc4c79a90d2b44226c525531daffb5fa2cfe5293ce0d1c7baaa947a0304a4c60c3046234ae957bf24162c4586de3 SHA512 bef1d6ab86473a440f6434aac257c41850f67443a0a5fbe83d139052509a855d594e18904a1e112989a9c8cbbc9d008e3f75a16a93e8c6d93cac370ffd5bf170 AUX c-wrapper-texinfo-6.7.patch 1052 BLAKE2B 6c042ee1a386d611be9bd1155fe930995b026eac5722e2264d8b73dee29b2a0371916f7f087c8b8a2031e34e70a064c8396d1870e0f759898e39eaf97d55a068 SHA512 ca2f1697cb81ba7a0cdcccfdab8fde71e94dd8ef8be570bebf9b4cceda0723c178114fc0c713f3998eb102ad19c17889197a80e8f5410032da96e0788d1fc2c8 DIST c-wrapper-0.6.1.tgz 843981 BLAKE2B af28cf60eebe0da32c90c030bfdae4457d20731c31220f7eaac33291ea1be104a7aab11fad0560fe6e3d36a5d3afafbd8795fddd633e0c26be226c29012afbc9 SHA512 a03a4d57d112d2c23dac3716bae081e3e6f02dcef261bd8dd518ed8519b43e28f9e61a36f7584b2bcb1762112c128d0b698cda422cc0c9d1190cbf7502ea04b0 -EBUILD c-wrapper-0.6.1-r1.ebuild 934 BLAKE2B 15453a8ac7702e0fab6bde100a6f1cfcdb7541d487b51d09c156ab84deff9589fc87518b3b14e916c1de6ae55a272aa6ea8d038ec0892f828f99ccd06fba196c SHA512 4d47e63118477a144b854be1761d384e0f82e0e362e4954b29396014af5eaf88b201a5276334c6ce13ffcd7280bb7872a8cdc812075d2ebfb0ca1e48fd060643 +EBUILD c-wrapper-0.6.1-r2.ebuild 1085 BLAKE2B 21d4b6838d8f8cf1fcfcbcf96110490e03a7d5825dce5cfcfbf9b51c6291f8ad150e65343d6b121c33a134f84c4155eddf17297c952755d5510cc21dc52a67c5 SHA512 56001852e10b64306397812af3d41b8e46021dc0514dc624f5acc192eddcd9bb9981b3af232faedb8d9dbcb46bcd12a2312d6d52b037769e9048d119821cbfc8 MISC metadata.xml 249 BLAKE2B a37da98d387308dab889eab2665b67e4176707f3c115a7a69cb7f4b19f9864b96bc2fe70efa105e627c4b57a7d626f6b23dc2709a225a9debada3356f3cf32a0 SHA512 a5095fb01e05f24583a962e36131b2f02cf2d1dd7a97051200e465ad97db014721de7c1857f5eb736cb0290682e8de833cb4c735f7de8d98cdfae1aed6d3d549 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 f0b7aece565f..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 @@ -1,4 +1,4 @@ -# Copyright 1999-2020 Gentoo Authors +# Copyright 1999-2021 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI="7" @@ -26,6 +26,10 @@ PATCHES=( "${FILESDIR}"/${PN}-glibc-2.25.patch "${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-clang.patch b/dev-scheme/c-wrapper/files/c-wrapper-clang.patch new file mode 100644 index 000000000000..ba39e74df9cf --- /dev/null +++ b/dev-scheme/c-wrapper/files/c-wrapper-clang.patch @@ -0,0 +1,71 @@ +--- a/src/c-parser.c ++++ b/src/c-parser.c +@@ -1667,14 +1667,25 @@ + ScmObj Scm_ParseMacroCode(ScmObj in, ScmObj macro_list) + { + static ScmObj trigger_line = SCM_FALSE; ++ static ScmObj is_gcc = SCM_TRUE; + ScmObj line_str; + ScmObj rx; ++ int n = 0; ++ int i; + + /* skip the first line '# 1 "<stdin>"' */ + Scm_ReadLineUnsafe(SCM_PORT(in)); + + if (SCM_FALSEP(trigger_line)) { +- trigger_line = SCM_MAKE_STR_IMMUTABLE("# 1 \"<stdin>\""); ++ ScmObj gcc = Scm_GlobalVariableRef(SCM_FIND_MODULE(CPARSER_MODULE_NAME, TRUE), SCM_SYMBOL(SCM_INTERN("GCC")), 0); ++ if (SCM_INTP(Scm_StringScanRight(SCM_STRING(gcc), SCM_STRING(SCM_MAKE_STR_IMMUTABLE("gcc")), SCM_STRING_SCAN_INDEX))) { ++ trigger_line = SCM_MAKE_STR_IMMUTABLE("# 1 \"<stdin>\""); ++ } else if (SCM_INTP(Scm_StringScanRight(SCM_STRING(gcc), SCM_STRING(SCM_MAKE_STR_IMMUTABLE("clang")), SCM_STRING_SCAN_INDEX))) { ++ trigger_line = SCM_MAKE_STR_IMMUTABLE("# 1 \"<stdin>\" 2"); ++ is_gcc = SCM_FALSE; ++ } else { ++ Scm_Error("unknown compiler"); ++ } + } + + while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) { +@@ -1683,22 +1694,33 @@ + } + } + +- rx = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+\\d+\\s+\"<stdin>\"")), 0); ++ rx = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+(\\d+)\\s+\"<stdin>\"")), 0); + line_str = Scm_ReadLineUnsafe(SCM_PORT(in)); +- while (!SCM_EOFP(line_str)) { +- ScmObj body_str = line_str; ++ for (i = 1; !SCM_EOFP(line_str); i++) { ++ ScmObj body_str; ++ ScmObj rm; ++ if (i < n) { ++ body_str = SCM_MAKE_STR_IMMUTABLE(""); ++ goto parse; ++ } ++ body_str = line_str; + while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in))) + && SCM_STRING_LENGTH(line_str) >= 13 + #ifdef SCM_REGEXP_MULTI_LINE +- && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) { ++ && SCM_REGMATCHP(rm = Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) { + #else +- && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str)))) { ++ && SCM_REGMATCHP(rm = Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str)))) { + #endif +- if (SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) { +- Scm_Error("[bug] unexpected EOF while parsing macro body"); ++ if (SCM_TRUEP(is_gcc)) { ++ if (SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) { ++ Scm_Error("[bug] unexpected EOF while parsing macro body"); ++ } ++ body_str = Scm_StringAppend2(SCM_STRING(body_str), SCM_STRING(line_str)); ++ } else { ++ n = SCM_INT_VALUE(Scm_StringToNumber(SCM_STRING(Scm_RegMatchSubstr(SCM_REGMATCH(rm), SCM_MAKE_INT(1))), 10, 0)); + } +- body_str = Scm_StringAppend2(SCM_STRING(body_str), SCM_STRING(line_str)); + } ++parse: + if (SCM_NULLP(macro_list)) { + Scm_Error("[bug] lost macro body"); + } else { 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-gcc-5.patch b/dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch index 98dfaa2f945c..46ab531b389a 100644 --- a/dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch +++ b/dev-scheme/c-wrapper/files/c-wrapper-gcc-5.patch @@ -4,46 +4,40 @@ { static ScmObj trigger_line = SCM_FALSE; ScmObj line_str; -+ ScmObj regexp = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+\\d+\\s+\"<stdin>\"")), 0); ++ ScmObj rx; /* skip the first line '# 1 "<stdin>"' */ Scm_ReadLineUnsafe(SCM_PORT(in)); -@@ -1682,16 +1683,30 @@ +@@ -1682,7 +1683,22 @@ } } - while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) { -- if (SCM_NULLP(macro_list)) { -+ line_str = SCM_NIL; -+ while (!SCM_NULLP(macro_list)) { ++ rx = Scm_RegComp(SCM_STRING(SCM_MAKE_STR_IMMUTABLE("^#\\s+\\d+\\s+\"<stdin>\"")), 0); ++ line_str = Scm_ReadLineUnsafe(SCM_PORT(in)); ++ while (!SCM_EOFP(line_str)) { + ScmObj body_str = line_str; -+ if (SCM_NULLP(body_str) -+ && SCM_EOFP(body_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) { - Scm_Error("[bug] lost macro body"); -- } else { -- ScmObj pos_name_args = SCM_CDAR(macro_list); -- macro_list = SCM_CDR(macro_list); -- Scm_FilenameSet(SCM_CAAR(pos_name_args)); -- Scm_LineNumberSet(SCM_INT_VALUE(SCM_CDAR(pos_name_args))); -- parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), line_str); - } + while (!SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in))) ++ && SCM_STRING_LENGTH(line_str) >= 13 +#ifdef SCM_REGEXP_MULTI_LINE -+ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(regexp), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) { ++ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str), SCM_UNDEFINED, SCM_UNDEFINED))) { +#else -+ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(regexp), SCM_STRING(line_str)))) { ++ && SCM_REGMATCHP(Scm_RegExec(SCM_REGEXP(rx), SCM_STRING(line_str)))) { +#endif + if (SCM_EOFP(line_str = Scm_ReadLineUnsafe(SCM_PORT(in)))) { + Scm_Error("[bug] unexpected EOF while parsing macro body"); + } + body_str = Scm_StringAppend2(SCM_STRING(body_str), SCM_STRING(line_str)); -+ line_str = SCM_NIL; + } -+ ScmObj pos_name_args = SCM_CDAR(macro_list); -+ macro_list = SCM_CDR(macro_list); -+ Scm_FilenameSet(SCM_CAAR(pos_name_args)); -+ Scm_LineNumberSet(SCM_INT_VALUE(SCM_CDAR(pos_name_args))); -+ parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), body_str); + if (SCM_NULLP(macro_list)) { + Scm_Error("[bug] lost macro body"); + } else { +@@ -1690,7 +1706,7 @@ + macro_list = SCM_CDR(macro_list); + Scm_FilenameSet(SCM_CAAR(pos_name_args)); + Scm_LineNumberSet(SCM_INT_VALUE(SCM_CDAR(pos_name_args))); +- parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), line_str); ++ parse_macro_body(SCM_CADR(pos_name_args), SCM_CDDR(pos_name_args), body_str); + } } - SCM_RETURN(SCM_UNDEFINED); 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) |