[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] emacs-25 4b1436b: Always define gmalloc etc. in src/gmallo
From: |
Paul Eggert |
Subject: |
[Emacs-diffs] emacs-25 4b1436b: Always define gmalloc etc. in src/gmalloc.c |
Date: |
Sat, 26 Dec 2015 20:13:01 +0000 |
branch: emacs-25
commit 4b1436b702d56eedd27a0777fc7232cdfb7ac4f6
Author: Wolfgang Jenkner <address@hidden>
Commit: Paul Eggert <address@hidden>
Always define gmalloc etc. in src/gmalloc.c
This is a work-around to prevent the compiler from using semantic
knowledge about malloc for optimization purposes. E.g., gcc 5.2
with -O2 replaces most of calloc's definition by a call to calloc;
see Bug#22085.
* src/gmalloc.c [!HYBRID_MALLOC] (malloc, realloc, calloc)
(aligned_alloc, free): Do not undef. Instead, define these as
functions (perhaps renamed to gmalloc etc.) in terms of gmalloc etc.
---
src/gmalloc.c | 36 +++++++++++++++++++++++++++++++++---
1 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/gmalloc.c b/src/gmalloc.c
index a88f4ab..90a52a1 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -60,7 +60,6 @@ extern void emacs_abort (void);
which HYBRID_MACRO is defined. Any other platform that wants to
define it will have to define the macros DUMPED and
ALLOCATED_BEFORE_DUMPING, defined below for Cygwin. */
-#ifdef HYBRID_MALLOC
#undef malloc
#undef realloc
#undef calloc
@@ -70,7 +69,6 @@ extern void emacs_abort (void);
#define calloc gcalloc
#define aligned_alloc galigned_alloc
#define free gfree
-#endif /* HYBRID_MALLOC */
#ifdef CYGWIN
extern void *bss_sbrk (ptrdiff_t size);
@@ -1711,13 +1709,13 @@ valloc (size_t size)
return aligned_alloc (pagesize, size);
}
-#ifdef HYBRID_MALLOC
#undef malloc
#undef realloc
#undef calloc
#undef aligned_alloc
#undef free
+#ifdef HYBRID_MALLOC
/* Declare system malloc and friends. */
extern void *malloc (size_t size);
extern void *realloc (void *ptr, size_t size);
@@ -1816,6 +1814,38 @@ hybrid_get_current_dir_name (void)
}
#endif
+#else /* ! HYBRID_MALLOC */
+
+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);
+}
+
#endif /* HYBRID_MALLOC */
#ifdef GC_MCHECK
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] emacs-25 4b1436b: Always define gmalloc etc. in src/gmalloc.c,
Paul Eggert <=