SHA256
1
0
forked from pool/emacs
emacs/gmalloc.patch
Dr. Werner Fink afd41024fc Accepting request 418413 from home:Andreas_Schwab:Factory
- emacs-24.4-glibc.patch: don't force system malloc, it doesn't work with
  glibc 2.24
- gmalloc.patch: fix portability bugs in gmalloc

OBS-URL: https://build.opensuse.org/request/show/418413
OBS-URL: https://build.opensuse.org/package/show/editors/emacs?expand=0&rev=195
2016-08-12 15:02:46 +00:00

114 lines
2.8 KiB
Diff

Index: emacs-24.5/src/emacs.c
===================================================================
--- emacs-24.5.orig/src/emacs.c
+++ emacs-24.5/src/emacs.c
@@ -723,6 +723,26 @@ main (int argc, char **argv)
stack_base = &dummy;
#endif
+#if defined HAVE_PERSONALITY_LINUX32 && defined __PPC64__
+ /* This code partly duplicates the HAVE_PERSONALITY_LINUX32 code
+ below. This duplication is planned to be fixed in a later
+ Emacs release. */
+# define ADD_NO_RANDOMIZE 0x0040000
+ int pers = personality (0xffffffff);
+ if (! (pers & ADD_NO_RANDOMIZE)
+ && 0 <= personality (pers | ADD_NO_RANDOMIZE))
+ {
+ /* Address randomization was enabled, but is now disabled.
+ Re-execute Emacs to get a clean slate. */
+ execvp (argv[0], argv);
+
+ /* If the exec fails, warn the user and then try without a
+ clean slate. */
+ perror (argv[0]);
+ }
+# undef ADD_NO_RANDOMIZE
+#endif
+
#ifdef G_SLICE_ALWAYS_MALLOC
/* This is used by the Cygwin build. It's not needed starting with
cygwin-1.7.24, but it doesn't do any harm. */
@@ -833,7 +853,7 @@ main (int argc, char **argv)
dumping = !initialized && (strcmp (argv[argc - 1], "dump") == 0
|| strcmp (argv[argc - 1], "bootstrap") == 0);
-#ifdef HAVE_PERSONALITY_LINUX32
+#if defined HAVE_PERSONALITY_LINUX32 && !defined __PPC64__
if (dumping && ! getenv ("EMACS_HEAP_EXEC"))
{
/* Set this so we only do this once. */
@@ -850,7 +870,7 @@ main (int argc, char **argv)
/* If the exec fails, try to dump anyway. */
emacs_perror (argv[0]);
}
-#endif /* HAVE_PERSONALITY_LINUX32 */
+#endif
#if defined (HAVE_SETRLIMIT) && defined (RLIMIT_STACK)
/* Extend the stack space available.
Index: emacs-24.5/src/gmalloc.c
===================================================================
--- emacs-24.5.orig/src/gmalloc.c
+++ emacs-24.5/src/gmalloc.c
@@ -42,6 +42,16 @@ License along with this library. If not
extern void emacs_abort (void);
#endif
+#undef malloc
+#undef realloc
+#undef calloc
+#undef free
+#define malloc gmalloc
+#define realloc grealloc
+#define calloc gcalloc
+#define aligned_alloc galigned_alloc
+#define free gfree
+
#ifdef __cplusplus
extern "C"
{
@@ -1747,6 +1757,42 @@ valloc (size_t size)
return aligned_alloc (pagesize, size);
}
+#undef malloc
+#undef realloc
+#undef calloc
+#undef aligned_alloc
+#undef free
+
+void *
+malloc (size_t size)
+{
+ return gmalloc (size);
+}
+
+void *
+calloc (size_t nmemb, size_t size)
+{
+ return gcalloc (nmemb, size);
+}
+
+void
+free (void *ptr)
+{
+ gfree (ptr);
+}
+
+void *
+aligned_alloc (size_t alignment, size_t size)
+{
+ return galigned_alloc (alignment, size);
+}
+
+void *
+realloc (void *ptr, size_t size)
+{
+ return grealloc (ptr, size);
+}
+
#ifdef GC_MCHECK
/* Standard debugging hooks for `malloc'.