aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNoam Postavsky2017-10-31 13:31:46 -0400
committerNoam Postavsky2017-11-04 18:49:28 -0400
commit918a2dda07ebf16601a93d0464f62c4e846d8b39 (patch)
treef98b930dcbcfb83608c38d949254dabaeeddaec9
parent725ab635d9c4c0ecbd4b28df16d2b97337bbe989 (diff)
downloademacs-918a2dda07ebf16601a93d0464f62c4e846d8b39.tar.gz
emacs-918a2dda07ebf16601a93d0464f62c4e846d8b39.zip
Use hybrid malloc for FreeBSD (Bug#28308)
FreeBSD aarch64 does not provide sbrk, so gmalloc cannot be used; when using system malloc dumping does not work correctly (allocated data is invalid after dumping). * configure.ac: Set hybrid_malloc for freebsd. * src/gmalloc.c (gdefault_morecore) [!HAVE_SBRK]: Don't call sbrk.
-rw-r--r--configure.ac2
-rw-r--r--src/gmalloc.c11
2 files changed, 7 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac
index d397e8fa7e1..5579342c4e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2218,7 +2218,7 @@ test "$CANNOT_DUMP" = yes ||
2218case "$opsys" in 2218case "$opsys" in
2219 ## darwin ld insists on the use of malloc routines in the System framework. 2219 ## darwin ld insists on the use of malloc routines in the System framework.
2220 darwin | mingw32 | nacl | sol2-10) ;; 2220 darwin | mingw32 | nacl | sol2-10) ;;
2221 cygwin | qnxto) 2221 cygwin | qnxto | freebsd)
2222 hybrid_malloc=yes 2222 hybrid_malloc=yes
2223 system_malloc= ;; 2223 system_malloc= ;;
2224 *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;; 2224 *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;;
diff --git a/src/gmalloc.c b/src/gmalloc.c
index 2bda95ebd3d..a17d39c1eeb 100644
--- a/src/gmalloc.c
+++ b/src/gmalloc.c
@@ -1502,17 +1502,18 @@ extern void *__sbrk (ptrdiff_t increment);
1502static void * 1502static void *
1503gdefault_morecore (ptrdiff_t increment) 1503gdefault_morecore (ptrdiff_t increment)
1504{ 1504{
1505 void *result;
1506#ifdef HYBRID_MALLOC 1505#ifdef HYBRID_MALLOC
1507 if (!DUMPED) 1506 if (!DUMPED)
1508 { 1507 {
1509 return bss_sbrk (increment); 1508 return bss_sbrk (increment);
1510 } 1509 }
1511#endif 1510#endif
1512 result = (void *) __sbrk (increment); 1511#ifdef HAVE_SBRK
1513 if (result == (void *) -1) 1512 void *result = (void *) __sbrk (increment);
1514 return NULL; 1513 if (result != (void *) -1)
1515 return result; 1514 return result;
1515#endif
1516 return NULL;
1516} 1517}
1517 1518
1518void *(*__morecore) (ptrdiff_t) = gdefault_morecore; 1519void *(*__morecore) (ptrdiff_t) = gdefault_morecore;