darwin.h (ENABLE_EXECUTE_STACK): New, use getpagesize not __sysctl.
authorGeoffrey Keating <geoffk@apple.com>
Thu, 28 Sep 2006 07:03:59 +0000 (07:03 +0000)
committerGeoffrey Keating <geoffk@gcc.gnu.org>
Thu, 28 Sep 2006 07:03:59 +0000 (07:03 +0000)
* config/darwin.h (ENABLE_EXECUTE_STACK): New, use getpagesize not
__sysctl.
* config/rs6000/darwin.h (ENABLE_EXECUTE_STACK): Remove.
* config/i386/darwin.h (ENABLE_EXECUTE_STACK): Remove.

From-SVN: r117274

gcc/ChangeLog
gcc/config/darwin.h
gcc/config/i386/darwin.h
gcc/config/rs6000/darwin.h

index 18fdc4dbd8c140166373a5c0265a7208ec5db5f7..9e95e5ffddf125ead7477d038c581d57d00cb719 100644 (file)
@@ -1,3 +1,10 @@
+2006-09-27  Geoffrey Keating  <geoffk@apple.com>
+
+       * config/darwin.h (ENABLE_EXECUTE_STACK): New, use getpagesize not
+       __sysctl.
+       * config/rs6000/darwin.h (ENABLE_EXECUTE_STACK): Remove.
+       * config/i386/darwin.h (ENABLE_EXECUTE_STACK): Remove.
+
 2006-09-28  Kaz Kojima  <kkojima@gcc.gnu.org>
 
        * config/sh/sh.md (divsi_inv_m0): Remove unused variable.
index 328754e8aeeffd08b64bd6303fdb64653d7cee81..6817dc83442927c4629c010da598bf2f549545f9 100644 (file)
@@ -886,4 +886,42 @@ void add_framework_path (char *);
 #define TARGET_ASM_OUTPUT_ANCHOR NULL
 #endif
 
+/* Attempt to turn on execute permission for the stack.  This may be
+    used by INITIALIZE_TRAMPOLINE of the target needs it (that is,
+    if the target machine can change execute permissions on a page).
+
+    There is no way to query the execute permission of the stack, so
+    we always issue the mprotect() call.
+
+    Unfortunately it is not possible to make this namespace-clean.
+
+    Also note that no errors should be emitted by this code; it is
+    considered dangerous for library calls to send messages to
+    stdout/stderr.  */
+
+#define ENABLE_EXECUTE_STACK                                            \
+extern void __enable_execute_stack (void *);                            \
+void                                                                    \
+__enable_execute_stack (void *addr)                                     \
+{                                                                       \
+   extern int mprotect (void *, size_t, int);                           \
+   extern int getpagesize (void);                                      \
+   static int size;                                                     \
+   static long mask;                                                    \
+                                                                        \
+   char *page, *end;                                                    \
+                                                                        \
+   if (size == 0)                                                       \
+     {                                                                  \
+       size = getpagesize();                                           \
+       mask = ~((long) size - 1);                                       \
+     }                                                                  \
+                                                                        \
+   page = (char *) (((long) addr) & mask);                              \
+   end  = (char *) ((((long) (addr + (TARGET_64BIT ? 48 : 40))) & mask) + size); \
+                                                                        \
+   /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */                        \
+   (void) mprotect (page, end - page, 7);                               \
+}
+
 #endif /* CONFIG_DARWIN_H */
index 51259dbdc4389f7d7c4725ce5f193bc21ccdd40b..61cdeb068906e33de08ee25370fe57e990f1353a 100644 (file)
@@ -204,53 +204,6 @@ extern void darwin_x86_file_end (void);
    : (n) >= 11 && (n) <= 18 ? (n) + 1                                  \
    : (n))
 
-/* Attempt to turn on execute permission for the stack.  This may be
-    used by INITIALIZE_TRAMPOLINE of the target needs it (that is,
-    if the target machine can change execute permissions on a page).
-
-    There is no way to query the execute permission of the stack, so
-    we always issue the mprotect() call.
-
-    Note that we go out of our way to use namespace-non-invasive calls
-    here.  Unfortunately, there is no libc-internal name for mprotect().
-
-    Also note that no errors should be emitted by this code; it is
-    considered dangerous for library calls to send messages to
-    stdout/stderr.  */
-
-#define ENABLE_EXECUTE_STACK                                            \
-extern void __enable_execute_stack (void *);                            \
-void                                                                    \
-__enable_execute_stack (void *addr)                                     \
-{                                                                       \
-   extern int mprotect (void *, size_t, int);                           \
-   extern int __sysctl (int *, unsigned int, void *, size_t *,          \
-                       void *, size_t);                                 \
-                                                                        \
-   static int size;                                                     \
-   static long mask;                                                    \
-                                                                        \
-   char *page, *end;                                                    \
-                                                                        \
-   if (size == 0)                                                       \
-     {                                                                  \
-       int mib[2];                                                      \
-       size_t len;                                                      \
-                                                                        \
-       mib[0] = 6; /* CTL_HW */                                         \
-       mib[1] = 7; /* HW_PAGESIZE */                                    \
-       len = sizeof (size);                                             \
-       (void) __sysctl (mib, 2, &size, &len, NULL, 0);                  \
-       mask = ~((long) size - 1);                                       \
-     }                                                                  \
-                                                                        \
-   page = (char *) (((long) addr) & mask);                              \
-   end  = (char *) ((((long) (addr + TRAMPOLINE_SIZE)) & mask) + size); \
-                                                                        \
-   /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */                        \
-   (void) mprotect (page, end - page, 7);                               \
-}
-
 #undef REGISTER_TARGET_PRAGMAS
 #define REGISTER_TARGET_PRAGMAS() DARWIN_REGISTER_TARGET_PRAGMAS()
 
index 27b0bfb82f4bc9881371189dc7aaa9e3650c4e9f..6594c71ee7904879b3c7bbd0ebb14852380c60d2 100644 (file)
@@ -441,50 +441,3 @@ do {                                                                       \
   (TARGET_64BIT                                                        \
    || (darwin_macosx_version_min                               \
        && strverscmp (darwin_macosx_version_min, "10.3") >= 0))
-
-/* Attempt to turn on execute permission for the stack.  This may be
-    used by INITIALIZE_TRAMPOLINE of the target needs it (that is,
-    if the target machine can change execute permissions on a page).
-
-    There is no way to query the execute permission of the stack, so
-    we always issue the mprotect() call.
-
-    Note that we go out of our way to use namespace-non-invasive calls
-    here.  Unfortunately, there is no libc-internal name for mprotect().
-
-    Also note that no errors should be emitted by this code; it is
-    considered dangerous for library calls to send messages to
-    stdout/stderr.  */
-
-#define ENABLE_EXECUTE_STACK                                            \
-extern void __enable_execute_stack (void *);                            \
-void                                                                    \
-__enable_execute_stack (void *addr)                                     \
-{                                                                       \
-   extern int mprotect (void *, size_t, int);                           \
-   extern int __sysctl (int *, unsigned int, void *, size_t *,          \
-                       void *, size_t);                                 \
-                                                                        \
-   static int size;                                                     \
-   static long mask;                                                    \
-                                                                        \
-   char *page, *end;                                                    \
-                                                                        \
-   if (size == 0)                                                       \
-     {                                                                  \
-       int mib[2];                                                      \
-       size_t len;                                                      \
-                                                                        \
-       mib[0] = 6; /* CTL_HW */                                         \
-       mib[1] = 7; /* HW_PAGESIZE */                                    \
-       len = sizeof (size);                                             \
-       (void) __sysctl (mib, 2, &size, &len, NULL, 0);                  \
-       mask = ~((long) size - 1);                                       \
-     }                                                                  \
-                                                                        \
-   page = (char *) (((long) addr) & mask);                              \
-   end  = (char *) ((((long) (addr + (TARGET_64BIT ? 48 : 40))) & mask) + size); \
-                                                                        \
-   /* 7 == PROT_READ | PROT_WRITE | PROT_EXEC */                        \
-   (void) mprotect (page, end - page, 7);                               \
-}