aboutsummaryrefslogtreecommitdiffstats
path: root/src/gmalloc.c
diff options
context:
space:
mode:
authorYAMAMOTO Mitsuharu2019-04-27 18:33:39 +0900
committerYAMAMOTO Mitsuharu2019-04-27 18:33:39 +0900
commit886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28 (patch)
treeb5770d9fc10a704ad8aeb3474c6940121252c770 /src/gmalloc.c
parent015a6e1df2772bd43680df5cbeaffccf98a881da (diff)
parent8dc00b2f1e6523c634df3e24379afbe712a32b27 (diff)
downloademacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.tar.gz
emacs-886bedb36c7b959b7e6fc8ce8e0c04e144b0ae28.zip
Merge branch 'master' into harfbuzz
Diffstat (limited to 'src/gmalloc.c')
-rw-r--r--src/gmalloc.c23
1 files changed, 9 insertions, 14 deletions
diff --git a/src/gmalloc.c b/src/gmalloc.c
index ebba789f610..b6a96d55727 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -1,5 +1,5 @@
1/* Declarations for `malloc' and friends. 1/* Declarations for `malloc' and friends.
2 Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2018 Free 2 Copyright (C) 1990-1993, 1995-1996, 1999, 2002-2007, 2013-2019 Free
3 Software Foundation, Inc. 3 Software Foundation, Inc.
4 Written May 1989 by Mike Haertel. 4 Written May 1989 by Mike Haertel.
5 5
@@ -36,9 +36,7 @@ License along with this library. If not, see <https://www.gnu.org/licenses/>.
36#include <pthread.h> 36#include <pthread.h>
37#endif 37#endif
38 38
39#ifdef emacs 39#include "lisp.h"
40# include "lisp.h"
41#endif
42 40
43#include "ptr-bounds.h" 41#include "ptr-bounds.h"
44 42
@@ -78,7 +76,6 @@ extern void *(*__morecore) (ptrdiff_t);
78 76
79#ifdef HYBRID_MALLOC 77#ifdef HYBRID_MALLOC
80# include "sheap.h" 78# include "sheap.h"
81# define DUMPED bss_sbrk_did_unexec
82#endif 79#endif
83 80
84#ifdef __cplusplus 81#ifdef __cplusplus
@@ -1510,7 +1507,7 @@ static void *
1510gdefault_morecore (ptrdiff_t increment) 1507gdefault_morecore (ptrdiff_t increment)
1511{ 1508{
1512#ifdef HYBRID_MALLOC 1509#ifdef HYBRID_MALLOC
1513 if (!DUMPED) 1510 if (!definitely_will_not_unexec_p ())
1514 { 1511 {
1515 return bss_sbrk (increment); 1512 return bss_sbrk (increment);
1516 } 1513 }
@@ -1728,6 +1725,8 @@ extern int posix_memalign (void **memptr, size_t alignment, size_t size);
1728static bool 1725static bool
1729allocated_via_gmalloc (void *ptr) 1726allocated_via_gmalloc (void *ptr)
1730{ 1727{
1728 if (!__malloc_initialized)
1729 return false;
1731 size_t block = BLOCK (ptr); 1730 size_t block = BLOCK (ptr);
1732 size_t blockmax = _heaplimit - 1; 1731 size_t blockmax = _heaplimit - 1;
1733 return block <= blockmax && _heapinfo[block].busy.type != 0; 1732 return block <= blockmax && _heapinfo[block].busy.type != 0;
@@ -1739,7 +1738,7 @@ allocated_via_gmalloc (void *ptr)
1739void * 1738void *
1740hybrid_malloc (size_t size) 1739hybrid_malloc (size_t size)
1741{ 1740{
1742 if (DUMPED) 1741 if (definitely_will_not_unexec_p ())
1743 return malloc (size); 1742 return malloc (size);
1744 return gmalloc (size); 1743 return gmalloc (size);
1745} 1744}
@@ -1747,7 +1746,7 @@ hybrid_malloc (size_t size)
1747void * 1746void *
1748hybrid_calloc (size_t nmemb, size_t size) 1747hybrid_calloc (size_t nmemb, size_t size)
1749{ 1748{
1750 if (DUMPED) 1749 if (definitely_will_not_unexec_p ())
1751 return calloc (nmemb, size); 1750 return calloc (nmemb, size);
1752 return gcalloc (nmemb, size); 1751 return gcalloc (nmemb, size);
1753} 1752}
@@ -1765,7 +1764,7 @@ hybrid_free (void *ptr)
1765void * 1764void *
1766hybrid_aligned_alloc (size_t alignment, size_t size) 1765hybrid_aligned_alloc (size_t alignment, size_t size)
1767{ 1766{
1768 if (!DUMPED) 1767 if (!definitely_will_not_unexec_p ())
1769 return galigned_alloc (alignment, size); 1768 return galigned_alloc (alignment, size);
1770 /* The following is copied from alloc.c */ 1769 /* The following is copied from alloc.c */
1771#ifdef HAVE_ALIGNED_ALLOC 1770#ifdef HAVE_ALIGNED_ALLOC
@@ -1788,7 +1787,7 @@ hybrid_realloc (void *ptr, size_t size)
1788 return hybrid_malloc (size); 1787 return hybrid_malloc (size);
1789 if (!allocated_via_gmalloc (ptr)) 1788 if (!allocated_via_gmalloc (ptr))
1790 return realloc (ptr, size); 1789 return realloc (ptr, size);
1791 if (!DUMPED) 1790 if (!definitely_will_not_unexec_p ())
1792 return grealloc (ptr, size); 1791 return grealloc (ptr, size);
1793 1792
1794 /* The dumped emacs is trying to realloc storage allocated before 1793 /* The dumped emacs is trying to realloc storage allocated before
@@ -2022,11 +2021,7 @@ mabort (enum mcheck_status status)
2022#else 2021#else
2023 fprintf (stderr, "mcheck: %s\n", msg); 2022 fprintf (stderr, "mcheck: %s\n", msg);
2024 fflush (stderr); 2023 fflush (stderr);
2025# ifdef emacs
2026 emacs_abort (); 2024 emacs_abort ();
2027# else
2028 abort ();
2029# endif
2030#endif 2025#endif
2031} 2026}
2032 2027