Restore execute permissions
[platform/upstream/libffi.git] / patches / os2
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
8         ;;
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
18 @@ -44,7 +44,7 @@
19  #  define FFI_MMAP_EXEC_WRIT 1
20  #  define HAVE_MNTENT 1
21  # endif
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
26     executable memory. */
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;
30  
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__) */
38  
39  #define mmap dlmmap
40  #define munmap dlmunmap
41 @@ -207,7 +207,7 @@ static int dlmunmap(void *, size_t);
42  #undef mmap
43  #undef munmap
44  
45 -#if !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__)
46 +#if !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__)
47  
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
51  }
52  #endif
53  
54 -#endif /* !(defined(X86_WIN32) || defined(X86_WIN64)) || defined (__CYGWIN__) */
55 +#endif /* !(defined(X86_WIN32) || defined(X86_WIN64) || defined(__OS2__)) || defined (__CYGWIN__) */
56  
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 */
65  #endif  /* WIN32 */
66  
67 +#ifdef __OS2__
68 +#define INCL_DOS
69 +#include <os2.h>
70 +#define HAVE_MMAP 1
71 +#define HAVE_MORECORE 0
72 +#define LACKS_SYS_MMAN_H
73 +#endif  /* __OS2__ */
74 +
75  #if defined(DARWIN) || defined(_DARWIN)
76  /* Mac OSX docs advise not to use sbrk; it seems better to use mmap */
77  #ifndef HAVE_MORECORE
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)
81  
82 -#ifndef WIN32
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 */
89  
90  #define DIRECT_MMAP(s)       CALL_MMAP(s)
91 +
92 +#elif defined(__OS2__)
93 +
94 +/* OS/2 MMAP via DosAllocMem */
95 +static void* os2mmap(size_t size) {
96 +  void* ptr;
97 +  if (DosAllocMem(&ptr, size, OBJ_ANY|PAG_COMMIT|PAG_READ|PAG_WRITE) &&
98 +      DosAllocMem(&ptr, size, PAG_COMMIT|PAG_READ|PAG_WRITE))
99 +    return MFAIL;
100 +  return ptr;
101 +}
102 +
103 +#define os2direct_mmap(n)     os2mmap(n)
104 +
105 +/* This function supports releasing coalesed segments */
106 +static int os2munmap(void* ptr, size_t size) {
107 +  while (size) {
108 +    ULONG ulSize = size;
109 +    ULONG ulFlags = 0;
110 +    if (DosQueryMem(ptr, &ulSize, &ulFlags) != 0)
111 +      return -1;
112 +    if ((ulFlags & PAG_BASE) == 0 ||(ulFlags & PAG_COMMIT) == 0 ||
113 +        ulSize > size)
114 +      return -1;
115 +    if (DosFreeMem(ptr) != 0)
116 +      return -1;
117 +    ptr = ( void * ) ( ( char * ) ptr + ulSize );
118 +    size -= ulSize;
119 +  }
120 +  return 0;
121 +}
122 +
123 +#define CALL_MMAP(s)         os2mmap(s)
124 +#define CALL_MUNMAP(a, s)    os2munmap((a), (s))
125 +#define DIRECT_MMAP(s)       os2direct_mmap(s)
126 +
127  #else /* WIN32 */
128  
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.
132  */
133  
134 -#ifndef WIN32
135 +#if !defined(WIN32) && !defined(__OS2__)
136  /* By default use posix locks */
137  #include <pthread.h>
138  #define MLOCK_T pthread_mutex_t
139 @@ -1401,6 +1445,16 @@ static MLOCK_T morecore_mutex = PTHREAD_
140  
141  static MLOCK_T magic_init_mutex = PTHREAD_MUTEX_INITIALIZER;
142  
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)
148 +#if HAVE_MORECORE
149 +static MLOCK_T morecore_mutex;
150 +#endif /* HAVE_MORECORE */
151 +static MLOCK_T magic_init_mutex;
152 +
153  #else /* WIN32 */
154  /*
155     Because lock-protected regions have bounded times, and there
156 @@ -2492,10 +2546,15 @@ static int init_mparams(void) {
157      }
158      RELEASE_MAGIC_INIT_LOCK();
159  
160 -#ifndef WIN32
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;
170  #else /* WIN32 */
171      {
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.
179          .balign 16
180         .globl  _ffi_call_win32
181 +#ifndef __OS2__
182         .def    _ffi_call_win32;        .scl    2;      .type   32;     .endef
183 +#endif
184  _ffi_call_win32:
185  .LFB1:
186          pushl %ebp
187 @@ -547,7 +549,9 @@ _ffi_call_win32:
188          # This assumes we are using gas.
189          .balign 16
190         .globl  _ffi_closure_SYSV
191 +#ifndef __OS2__
192         .def    _ffi_closure_SYSV;      .scl    2;      .type   32;     .endef
193 +#endif
194  _ffi_closure_SYSV:
195  .LFB3:
196         pushl   %ebp
197 @@ -668,7 +672,9 @@ _ffi_closure_SYSV:
198          # This assumes we are using gas.
199          .balign 16
200         .globl  _ffi_closure_raw_SYSV
201 +#ifndef __OS2__
202         .def    _ffi_closure_raw_SYSV;  .scl    2;      .type   32;     .endef
203 +#endif
204  _ffi_closure_raw_SYSV:
205  .LFB4:
206         pushl   %ebp
207 @@ -784,7 +790,9 @@ _ffi_closure_raw_SYSV:
208          # This assumes we are using gas.
209         .balign 16
210         .globl  _ffi_closure_STDCALL
211 +#ifndef __OS2__
212         .def    _ffi_closure_STDCALL;   .scl    2;      .type   32;     .endef
213 +#endif
214  _ffi_closure_STDCALL:
215  .LFB5:
216         pushl   %ebp
217 @@ -890,7 +898,9 @@ _ffi_closure_STDCALL:
218  .ffi_closure_STDCALL_end:
219  .LFE5:
220  
221 +#ifndef __OS2__
222         .section        .eh_frame,"w"
223 +#endif
224  .Lframe1:
225  .LSCIE1:
226         .long   .LECIE1-.LASCIE1  /* Length of Common Information Entry */
227 Index: libffi/ltmain.sh
228 ===================================================================
229 --- libffi.orig/ltmain.sh
230 +++ libffi/ltmain.sh
231 @@ -1,6 +1,6 @@
232  # Generated from ltmain.m4sh.
233  
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
237  
238  # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
239 @@ -65,7 +65,7 @@
240  #       compiler:              $LTCC
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
247  #
248 @@ -73,9 +73,9 @@
249  
250  PROGRAM=ltmain.sh
251  PACKAGE=libtool
252 -VERSION=2.2.6
253 +VERSION=2.2.6b
254  TIMESTAMP=""
255 -package_revision=1.3012
256 +package_revision=1.3017
257  
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
264 @@ -9,15 +9,15 @@
265  
266  # Generated from ltversion.in.
267  
268 -# serial 3012 ltversion.m4
269 +# serial 3017 ltversion.m4
270  # This file is part of GNU Libtool
271  
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])
276  
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)
284  ])
285 Index: libffi/README
286 ===================================================================
287 --- libffi.orig/README
288 +++ libffi/README
289 @@ -75,6 +75,7 @@ tested:
290  | X86          | Linux            |
291  | X86          | Mac OSX          |
292  | X86          | OpenBSD          |
293 +| X86          | OS/2             |
294  | X86          | Solaris          |
295  | X86          | Windows/Cygwin   |
296  | X86          | Windows/MingW    |