1 Index: libffi/configure.ac
2 ===================================================================
3 --- libffi.orig/configure.ac
4 +++ libffi/configure.ac
5 @@ -84,7 +84,7 @@ case "$host" in
6 i?86-*-freebsd* | i?86-*-openbsd*)
7 TARGET=X86_FREEBSD; TARGETDIR=x86
9 - i?86-win32* | i?86-*-cygwin* | i?86-*-mingw*)
10 + i?86-win32* | i?86-*-cygwin* | i?86-*-mingw* | i?86-*-os2*)
11 TARGET=X86_WIN32; TARGETDIR=x86
12 # All mingw/cygwin/win32 builds require this for sharedlib
13 AM_LTLDFLAGS="-no-undefined"
14 Index: libffi/src/closures.c
15 ===================================================================
16 --- libffi.orig/src/closures.c
17 +++ libffi/src/closures.c
19 # define FFI_MMAP_EXEC_WRIT 1
20 # define HAVE_MNTENT 1
22 -# if defined(X86_WIN32) || defined(X86_WIN64)
23 +# if defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)
24 /* Windows systems may have Data Execution Protection (DEP) enabled,
25 which requires the use of VirtualMalloc/VirtualFree to alloc/free
27 @@ -193,11 +193,11 @@ static int dlmalloc_trim(size_t) MAYBE_U
28 static size_t dlmalloc_usable_size(void*) MAYBE_UNUSED;
29 static void dlmalloc_stats(void) MAYBE_UNUSED;
31 -#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
32 +#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
33 /* Use these for mmap and munmap within dlmalloc.c. */
34 static void *dlmmap(void *, size_t, int, int, int, off_t);
35 static int dlmunmap(void *, size_t);
36 -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
37 +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
40 #define munmap dlmunmap
41 @@ -207,7 +207,7 @@ static int dlmunmap(void *, size_t);
45 -#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
46 +#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
48 /* A mutex used to synchronize access to *exec* variables in this file. */
49 static pthread_mutex_t open_temp_exec_file_mutex = PTHREAD_MUTEX_INITIALIZER;
50 @@ -522,7 +522,7 @@ segment_holding_code (mstate m, char* ad
54 -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
55 +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
57 /* Allocate a chunk of memory with the given size. Returns a pointer
58 to the writable address, and sets *CODE to the executable
59 Index: libffi/src/dlmalloc.c
60 ===================================================================
61 --- libffi.orig/src/dlmalloc.c
62 +++ libffi/src/dlmalloc.c
63 @@ -459,6 +459,14 @@ DEFAULT_MMAP_THRESHOLD default: 25
64 #define MMAP_CLEARS 0 /* WINCE and some others apparently don't clear */
71 +#define HAVE_MORECORE 0
72 +#define LACKS_SYS_MMAN_H
75 #if defined(DARWIN) || defined(_DARWIN)
76 /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */
78 @@ -1288,7 +1296,7 @@ extern void* sbrk(ptrdiff_t);
79 #define IS_MMAPPED_BIT (SIZE_T_ONE)
80 #define USE_MMAP_BIT (SIZE_T_ONE)
83 +#if !defined(WIN32) && !defined (__OS2__)
84 #define CALL_MUNMAP(a, s) munmap((a), (s))
85 #define MMAP_PROT (PROT_READ|PROT_WRITE)
86 #if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
87 @@ -1311,6 +1319,42 @@ static int dev_zero_fd = -1; /* Cached f
88 #endif /* MAP_ANONYMOUS */
90 #define DIRECT_MMAP(s) CALL_MMAP(s)
92 +#elif defined(__OS2__)
94 +/* OS/2 MMAP via DosAllocMem */
95 +static void* os2mmap(size_t size) {
97 + if (DosAllocMem(&ptr, size, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) &&
98 + DosAllocMem(&ptr, size, PAG_COMMIT|PAG_READ|PAG_WRITE))
103 +#define os2direct_mmap(n) os2mmap(n)
105 +/* This function supports releasing coalesed segments */
106 +static int os2munmap(void* ptr, size_t size) {
108 + ULONG ulSize = size;
110 + if (DosQueryMem(ptr, &ulSize, &ulFlags) != 0)
112 + if ((ulFlags & PAG_BASE) == 0 ||(ulFlags & PAG_COMMIT) == 0 ||
115 + if (DosFreeMem(ptr) != 0)
117 + ptr = ( void * ) ( ( char * ) ptr + ulSize );
123 +#define CALL_MMAP(s) os2mmap(s)
124 +#define CALL_MUNMAP(a, s) os2munmap((a), (s))
125 +#define DIRECT_MMAP(s) os2direct_mmap(s)
129 /* Win32 MMAP via VirtualAlloc */
130 @@ -1387,7 +1431,7 @@ static int win32munmap(void* ptr, size_t
131 unique mparams values are initialized only once.
135 +#if !defined(WIN32) && !defined(__OS2__)
136 /* By default use posix locks */
138 #define MLOCK_T pthread_mutex_t
139 @@ -1401,6 +1445,16 @@ static MLOCK_T morecore_mutex = PTHREAD_
141 static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER;
143 +#elif defined(__OS2__)
144 +#define MLOCK_T HMTX
145 +#define INITIAL_LOCK(l) DosCreateMutexSem(0, l, 0, FALSE)
146 +#define ACQUIRE_LOCK(l) DosRequestMutexSem(*l, SEM_INDEFINITE_WAIT)
147 +#define RELEASE_LOCK(l) DosReleaseMutexSem(*l)
149 +static MLOCK_T morecore_mutex;
150 +#endif /* HAVE_MORECORE */
151 +static MLOCK_T magic_init_mutex;
155 Because lock-protected regions have bounded times, and there
156 @@ -2492,10 +2546,15 @@ static int init_mparams(void) {
158 RELEASE_MAGIC_INIT_LOCK();
161 +#if !defined(WIN32) && !defined(__OS2__)
162 mparams.page_size = malloc_getpagesize;
163 mparams.granularity = ((DEFAULT_GRANULARITY != 0)?
164 DEFAULT_GRANULARITY : mparams.page_size);
165 +#elif defined (__OS2__)
166 + /* if low-memory is used, os2munmap() would break
167 + if it were anything other than 64k */
168 + mparams.page_size = 4096u;
169 + mparams.granularity = 65536u;
172 SYSTEM_INFO system_info;
173 Index: libffi/src/x86/win32.S
174 ===================================================================
175 --- libffi.orig/src/x86/win32.S
176 +++ libffi/src/x86/win32.S
177 @@ -395,7 +395,9 @@ END
178 # This assumes we are using gas.
180 .globl _ffi_call_win32
182 .def _ffi_call_win32; .scl 2; .type 32; .endef
187 @@ -547,7 +549,9 @@ _ffi_call_win32:
188 # This assumes we are using gas.
190 .globl _ffi_closure_SYSV
192 .def _ffi_closure_SYSV; .scl 2; .type 32; .endef
197 @@ -668,7 +672,9 @@ _ffi_closure_SYSV:
198 # This assumes we are using gas.
200 .globl _ffi_closure_raw_SYSV
202 .def _ffi_closure_raw_SYSV; .scl 2; .type 32; .endef
204 _ffi_closure_raw_SYSV:
207 @@ -784,7 +790,9 @@ _ffi_closure_raw_SYSV:
208 # This assumes we are using gas.
210 .globl _ffi_closure_STDCALL
212 .def _ffi_closure_STDCALL; .scl 2; .type 32; .endef
214 _ffi_closure_STDCALL:
217 @@ -890,7 +898,9 @@ _ffi_closure_STDCALL:
218 .ffi_closure_STDCALL_end:
222 .section .eh_frame,"w"
226 .long .LECIE1-.LASCIE1 /* Length of Common Information Entry */
227 Index: libffi/ltmain.sh
228 ===================================================================
229 --- libffi.orig/ltmain.sh
232 # Generated from ltmain.m4sh.
234 -# ltmain.sh (GNU libtool) 2.2.6
235 +# ltmain.sh (GNU libtool) 2.2.6b
236 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
238 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
241 # compiler flags: $LTCFLAGS
242 # linker: $LD (gnu? $with_gnu_ld)
243 -# $progname: (GNU libtool) 2.2.6
244 +# $progname: (GNU libtool) 2.2.6b
245 # automake: $automake_version
246 # autoconf: $autoconf_version
255 -package_revision=1.3012
256 +package_revision=1.3017
258 # Be Bourne compatible
259 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
260 Index: libffi/m4/ltversion.m4
261 ===================================================================
262 --- libffi.orig/m4/ltversion.m4
263 +++ libffi/m4/ltversion.m4
266 # Generated from ltversion.in.
268 -# serial 3012 ltversion.m4
269 +# serial 3017 ltversion.m4
270 # This file is part of GNU Libtool
272 -m4_define([LT_PACKAGE_VERSION], [2.2.6])
273 -m4_define([LT_PACKAGE_REVISION], [1.3012])
274 +m4_define([LT_PACKAGE_VERSION], [2.2.6b])
275 +m4_define([LT_PACKAGE_REVISION], [1.3017])
277 AC_DEFUN([LTVERSION_VERSION],
278 -[macro_version='2.2.6'
279 -macro_revision='1.3012'
280 +[macro_version='2.2.6b'
281 +macro_revision='1.3017'
282 _LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
283 _LT_DECL(, macro_revision, 0)
286 ===================================================================
287 --- libffi.orig/README
289 @@ -75,6 +75,7 @@ tested:
295 | X86 | Windows/Cygwin |
296 | X86 | Windows/MingW |