Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 329499 | Differences between
and this patch

Collapse All | Expand All

(-)file_not_specified_in_diff (-6 / +80 lines)
Line  Link Here
0
-- a/Modules/_ctypes/libffi/configure.ac
0
++ b/Modules/_ctypes/libffi/configure.ac
Lines 379-384 Link Here
379
    AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
379
    AC_DEFINE(USING_PURIFY, 1, [Define this if you are using Purify and want to suppress spurious messages.])
380
  fi)
380
  fi)
381
381
382
AC_ARG_ENABLE(emutramp,
383
[  --enable-emutramp       enable emulated trampolines],
384
  if test "$enable_emutramp" = "yes"; then
385
    AC_DEFINE(FFI_EMUTRAMP, 1, [Define this if you want to enable emulated trampolines])
386
  fi)
387
382
if test -n "$with_cross_host" &&
388
if test -n "$with_cross_host" &&
383
   test x"$with_cross_host" != x"no"; then
389
   test x"$with_cross_host" != x"no"; then
384
  toolexecdir='$(exec_prefix)/$(target_alias)'
390
  toolexecdir='$(exec_prefix)/$(target_alias)'
385
-- a/Modules/_ctypes/libffi/src/closures.c
391
++ b/Modules/_ctypes/libffi/src/closures.c
Lines 61-66 Link Here
61
# endif
61
# endif
62
#endif
62
#endif
63
63
64
#if FFI_EMUTRAMP
65
# define FFI_MMAP_EXEC_EMUTRAMP 1
66
#endif
67
64
#if FFI_CLOSURES
68
#if FFI_CLOSURES
65
69
66
# if FFI_MMAP_EXEC_WRIT
70
# if FFI_MMAP_EXEC_WRIT
Lines 167-172 Link Here
167
171
168
#endif /* !FFI_MMAP_EXEC_SELINUX */
172
#endif /* !FFI_MMAP_EXEC_SELINUX */
169
173
174
#ifdef FFI_MMAP_EXEC_EMUTRAMP
175
#include <stdlib.h>
176
177
static int emutramp_enabled = -1;
178
179
static int
180
emutramp_enabled_check (void)
181
{
182
  if (getenv ("FFI_DISABLE_EMUTRAMP") == NULL)
183
    return 1;
184
  else
185
    return 0;
186
}
187
188
#define is_emutramp_enabled() (emutramp_enabled >= 0 ? emutramp_enabled \
189
                               : (emutramp_enabled = emutramp_enabled_check ()))
190
191
#else
192
193
#define is_emutramp_enabled() 0
194
195
#endif /* FFI_MMAP_EXEC_EMUTRAMP */
196
170
#elif defined (__CYGWIN__)
197
#elif defined (__CYGWIN__)
171
198
172
#include <sys/mman.h>
199
#include <sys/mman.h>
Lines 453-458 Link Here
453
  printf ("mapping in %zi\n", length);
480
  printf ("mapping in %zi\n", length);
454
#endif
481
#endif
455
482
483
  if (execfd == -1 && is_emutramp_enabled ())
484
    {
485
      ptr = mmap (start, length, prot & ~PROT_EXEC, flags, fd, offset);
486
      return ptr;
487
    }
488
456
  if (execfd == -1 && !is_selinux_enabled ())
489
  if (execfd == -1 && !is_selinux_enabled ())
457
    {
490
    {
458
      ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
491
      ptr = mmap (start, length, prot | PROT_EXEC, flags, fd, offset);
459
-- a/Modules/_ctypes/malloc_closure.c
492
++ b/Modules/_ctypes/malloc_closure.c
Lines 8-13 Link Here
8
# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
8
# if !defined(MAP_ANONYMOUS) && defined(MAP_ANON)
9
#  define MAP_ANONYMOUS MAP_ANON
9
#  define MAP_ANONYMOUS MAP_ANON
10
# endif
10
# endif
11
# if CTYPES_EMUTRAMP
12
#  include <stdlib.h>
13
# endif
11
#endif
14
#endif
12
#include "ctypes.h"
15
#include "ctypes.h"
13
16
Lines 34-39 Link Here
34
{
37
{
35
    ITEM *item;
38
    ITEM *item;
36
    int count, i;
39
    int count, i;
40
#ifndef MS_WIN32
41
    int prot = PROT_READ | PROT_WRITE | PROT_EXEC;
42
#if CTYPES_EMUTRAMP
43
    static int emutramp_enabled = -1;
44
    if (emutramp_enabled = -1) {
45
        if (getenv("FFI_DISABLE_EMUTRAMP") == NULL) {
46
             emutramp_enabled = 1;
47
             prot = PROT_READ | PROT_WRITE;
48
        } else {
49
             emutramp_enabled = 0;
50
        }
51
    }
52
# endif
53
#endif
37
54
38
/* determine the pagesize */
55
/* determine the pagesize */
39
#ifdef MS_WIN32
56
#ifdef MS_WIN32
Lines 66-72 Link Here
66
#else
83
#else
67
    item = (ITEM *)mmap(NULL,
84
    item = (ITEM *)mmap(NULL,
68
                        count * sizeof(ITEM),
85
                        count * sizeof(ITEM),
69
                        PROT_READ | PROT_WRITE | PROT_EXEC,
86
                        prot,
70
                        MAP_PRIVATE | MAP_ANONYMOUS,
87
                        MAP_PRIVATE | MAP_ANONYMOUS,
71
                        -1,
88
                        -1,
72
                        0);
89
                        0);
73
-- a/configure.in
90
++ b/configure.in
Lines 4267-4272 Link Here
4267
],
4267
],
4268
[AC_MSG_RESULT(no value specified)])
4268
[AC_MSG_RESULT(no value specified)])
4269
4269
4270
# Check for --enable-emutramp
4271
AC_MSG_CHECKING(for --enable-emutramp)
4272
AC_ARG_ENABLE(emutramp,
4273
  AS_HELP_STRING(
4274
    [--enable-emutramp],
4275
    [allocate non-executable memory for trampolines in _ctypes module]
4276
  ),
4277
[
4278
  AC_DEFINE(
4279
    CTYPES_EMUTRAMP, 1,
4280
    [Define if you want to allocate non-executable memory for trampolines in _ctypes module]
4281
  )
4282
  AC_MSG_RESULT(yes)
4283
],
4284
[AC_MSG_RESULT(no)])
4285
4270
case $ac_sys_system in
4286
case $ac_sys_system in
4271
AIX*)   
4287
AIX*)   
4272
  AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4288
  AC_DEFINE(HAVE_BROKEN_PIPE_BUF, 1, [Define if the system reports an invalid PIPE_BUF value.]) ;;
4273
-- a/setup.py
4289
++ b/setup.py
Lines 1683-1688 Link Here
1683
                from distutils.dir_util import mkpath
1683
                from distutils.dir_util import mkpath
1684
                mkpath(ffi_builddir)
1684
                mkpath(ffi_builddir)
1685
                config_args = []
1685
                config_args = []
1686
                if sysconfig.get_config_vars("CTYPES_EMUTRAMP"):
1687
                    config_args.append("--enable-emutramp")
1686
1688
1687
                # Pass empty CFLAGS because we'll just append the resulting
1689
                # Pass empty CFLAGS because we'll just append the resulting
1688
                # CFLAGS to Python's; -g or -O2 is to be avoided.
1690
                # CFLAGS to Python's; -g or -O2 is to be avoided.

Return to bug 329499