summaryrefslogtreecommitdiff
path: root/dev-scheme/c-wrapper/files/c-wrapper-float128.patch
blob: acd2f04407dd6fe5da72dbe6a132db16a809f6ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
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)