summaryrefslogtreecommitdiffhomepage
path: root/patches/libffi-3.2.1.local.patch
blob: d5c7fbdc9f51bf67968ace12febedac7e121de51 (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
diff -ru --new-file a/configure b/configure
--- a/configure	2014-11-12 06:59:57.000000000 -0500
+++ b/configure	2016-01-25 18:26:47.000000000 -0500
@@ -17133,7 +17133,7 @@
   i?86-*-freebsd* | i?86-*-openbsd*)
 	TARGET=X86_FREEBSD; TARGETDIR=x86
 	;;
-  i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix*)
+  i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2* | i?86-*-interix* | i?86-*-midipix*)
 	TARGET=X86_WIN32; TARGETDIR=x86
 	# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
 	# We must also check with_cross_host to decide if this is a native
@@ -17161,7 +17161,7 @@
 	TARGET=X86_DARWIN; TARGETDIR=x86
 	;;
 
-  x86_64-*-cygwin* | x86_64-*-mingw*)
+  x86_64-*-cygwin* | x86_64-*-mingw* | x86_64-*-midipix*)
 	TARGET=X86_WIN64; TARGETDIR=x86
 	# All mingw/cygwin/win32 builds require -no-undefined for sharedlib.
 	# We must also check with_cross_host to decide if this is a native
diff -ru --new-file a/src/closures.c b/src/closures.c
--- a/src/closures.c	2014-11-08 07:47:24.000000000 -0500
+++ b/src/closures.c	2016-01-25 17:57:43.000000000 -0500
@@ -26,6 +26,25 @@
    DEALINGS IN THE SOFTWARE.
    ----------------------------------------------------------------------- */
 
+#ifdef __midipix__
+
+#include <stdlib.h>
+
+void * ffi_closure_alloc (size_t size, void ** code)
+{
+	if (code)
+		return (*code = malloc(size));
+	else
+		return 0;
+}
+
+void ffi_closure_free (void * addr)
+{
+	free(addr);
+}
+
+#else
+
 #if defined __linux__ && !defined _GNU_SOURCE
 #define _GNU_SOURCE 1
 #endif
@@ -686,3 +705,4 @@
 
 # endif /* ! FFI_MMAP_EXEC_WRIT */
 #endif /* FFI_CLOSURES */
+#endif
diff -ru --new-file a/src/x86/ffi.c b/src/x86/ffi.c
--- a/src/x86/ffi.c	2014-11-08 07:47:24.000000000 -0500
+++ b/src/x86/ffi.c	2016-01-25 17:52:14.000000000 -0500
@@ -31,8 +31,12 @@
 #if !defined(__x86_64__) || defined(_WIN64) || defined(__CYGWIN__)
 
 #ifdef _WIN64
+#ifdef __midipix__
+/* not needed */
+#else
 #include <windows.h>
 #endif
+#endif
 
 #include <ffi.h>
 #include <ffi_common.h>
diff -ru --new-file a/src/x86/win32.S b/src/x86/win32.S
--- a/src/x86/win32.S	2014-11-11 09:41:37.000000000 -0500
+++ b/src/x86/win32.S	2016-01-25 18:36:49.000000000 -0500
@@ -1344,6 +1344,14 @@
         .align 4
 .LEFDE5:
 
+#ifdef __midipix__
+	.section .got$ffi_call_win32,"r"
+	.global __imp_ffi_call_win32
+__imp_ffi_call_win32:
+	.long	ffi_call_win32
+	.linkonce discard
+#endif
+
 #endif /* !_MSC_VER */
 
 #if defined __ELF__ && defined __linux__
diff -ru --new-file a/src/x86/win64.S b/src/x86/win64.S
--- a/src/x86/win64.S	2014-11-08 07:47:24.000000000 -0500
+++ b/src/x86/win64.S	2016-01-25 17:47:17.000000000 -0500
@@ -516,5 +516,15 @@
 	pop	%rbp
 	retq
 	.seh_endproc
+
+
+#ifdef __midipix__
+	.section .got$ffi_call_win64,"r"
+	.global __imp_ffi_call_win64
+__imp_ffi_call_win64:
+	.quad	ffi_call_win64
+	.linkonce discard
+#endif
+
 #endif /* !_MSC_VER */
 
--- libffi-3.2.1/src/x86/win32.S.orig2	2016-05-31 09:21:19.120895425 +0000
+++ libffi-3.2.1/src/x86/win32.S	2016-05-31 09:22:19.252894091 +0000
@@ -529,7 +529,9 @@
  
         # This assumes we are using gas.
         .balign 16
+#ifndef __midipix__
 FFI_HIDDEN(ffi_call_win32)
+#endif
         .globl	USCORE_SYMBOL(ffi_call_win32)
 #if defined(X86_WIN32) && !defined(__OS2__)
         .def	_ffi_call_win32;	.scl	2;	.type	32;	.endef
@@ -712,7 +714,9 @@
         ret
 .ffi_call_win32_end:
         .balign 16
+#ifndef __midipix__
 FFI_HIDDEN(ffi_closure_THISCALL)
+#endif
         .globl	USCORE_SYMBOL(ffi_closure_THISCALL)
 #if defined(X86_WIN32) && !defined(__OS2__)
         .def	_ffi_closure_THISCALL;	.scl	2;	.type	32;	.endef
@@ -725,7 +729,9 @@
         jmp	.ffi_closure_STDCALL_internal
 
         .balign 16
+#ifndef __midipix__
 FFI_HIDDEN(ffi_closure_FASTCALL)
+#endif
         .globl	USCORE_SYMBOL(ffi_closure_FASTCALL)
 #if defined(X86_WIN32) && !defined(__OS2__)
         .def	_ffi_closure_FASTCALL;	.scl	2;	.type	32;	.endef
@@ -737,7 +743,9 @@
         push	%edx
         push	%ecx
         jmp	.ffi_closure_STDCALL_internal
+#ifndef __midipix__
 FFI_HIDDEN(ffi_closure_REGISTER)
+#endif
         .globl	USCORE_SYMBOL(ffi_closure_REGISTER)
 #if defined(X86_WIN32) && !defined(__OS2__)
         .def	_ffi_closure_REGISTER;	.scl	2;	.type	32;	.endef
@@ -754,7 +762,9 @@
 .LFE1:
         # This assumes we are using gas.
         .balign 16
+#ifndef __midipix__
 FFI_HIDDEN(ffi_closure_SYSV)
+#endif
 #if defined(X86_WIN32)
         .globl	USCORE_SYMBOL(ffi_closure_SYSV)
 #if defined(X86_WIN32) && !defined(__OS2__)
@@ -898,7 +908,9 @@
 
 #ifdef X86_WIN32
         .balign 16
+#ifndef __midipix__
 FFI_HIDDEN(ffi_closure_raw_THISCALL)
+#endif
         .globl	USCORE_SYMBOL(ffi_closure_raw_THISCALL)
 #if defined(X86_WIN32) && !defined(__OS2__)
         .def	_ffi_closure_raw_THISCALL;	.scl	2;	.type	32;	.endef
@@ -1040,7 +1052,9 @@
 
         # This assumes we are using gas.
         .balign	16
+#ifndef __midipix__
 FFI_HIDDEN(ffi_closure_STDCALL)
+#endif
         .globl	USCORE_SYMBOL(ffi_closure_STDCALL)
 #if defined(X86_WIN32) && !defined(__OS2__)
         .def	_ffi_closure_STDCALL;	.scl	2;	.type	32;	.endef
@@ -1345,10 +1359,17 @@
 .LEFDE5:
 
 #ifdef __midipix__
+#if defined(SYMBOL_UNDERSCORE)
+	.section .got$ffi__call_win32,"r"
+	.global __imp__ffi_call_win32
+__imp__ffi_call_win32:
+	.long	_ffi_call_win32
+#else
 	.section .got$ffi_call_win32,"r"
 	.global __imp_ffi_call_win32
 __imp_ffi_call_win32:
 	.long	ffi_call_win32
+#endif
 	.linkonce discard
 #endif