diff options
| author | Paul Eggert | 2016-11-08 09:48:53 -0800 |
|---|---|---|
| committer | Paul Eggert | 2016-11-08 09:49:27 -0800 |
| commit | 3b5e6774ed9743fb726ac8c15341eaa09375cfbf (patch) | |
| tree | 08e5246f9f6311936689479346be05b801db4cf0 | |
| parent | 86baa208f84597068b3d55420eae0100a59e44b7 (diff) | |
| download | emacs-3b5e6774ed9743fb726ac8c15341eaa09375cfbf.tar.gz emacs-3b5e6774ed9743fb726ac8c15341eaa09375cfbf.zip | |
Port to FreeBSD 11 AMD
Problem reported by Ashish Shukla (Bug#24892). I tested
this on FreeBSD 11 x86-64 with HAVE_SBRK manually undefined.
* configure.ac (system_malloc): Set to 'yes' if there is no sbrk.
(sbrk): Check whether it exists.
* src/alloc.c (my_heap_start) [!GNU_LINUX]:
Do not define, since this function is now used only on GNU/Linux,
and sbrk might not exist on other platforms.
(malloc_initialize_hook) [!GNU_LINUX]:
Do not call my_heap_start, since its side effect will never be used.
(Fmemory_limit) [!HAVE_SBRK]: Do not call sbrk.
* src/unexelf.c (unexec) [!HAVE_SBRK]: Assume that nothing like
sbrk exists.
| -rw-r--r-- | configure.ac | 8 | ||||
| -rw-r--r-- | src/alloc.c | 6 | ||||
| -rw-r--r-- | src/unexelf.c | 4 |
3 files changed, 12 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index f67fe83081e..7450e2f7274 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -2151,14 +2151,14 @@ AC_CACHE_CHECK( | |||
| 2151 | fi]) | 2151 | fi]) |
| 2152 | doug_lea_malloc=$emacs_cv_var_doug_lea_malloc | 2152 | doug_lea_malloc=$emacs_cv_var_doug_lea_malloc |
| 2153 | 2153 | ||
| 2154 | system_malloc=$emacs_cv_sanitize_address | ||
| 2155 | |||
| 2156 | hybrid_malloc= | 2154 | hybrid_malloc= |
| 2155 | system_malloc=yes | ||
| 2157 | 2156 | ||
| 2158 | case "$opsys" in | 2157 | case "$opsys" in |
| 2159 | ## darwin ld insists on the use of malloc routines in the System framework. | 2158 | ## darwin ld insists on the use of malloc routines in the System framework. |
| 2160 | darwin | mingw32 | nacl | sol2-10) system_malloc=yes ;; | 2159 | darwin | mingw32 | nacl | sol2-10) ;; |
| 2161 | cygwin) hybrid_malloc=yes;; | 2160 | cygwin) hybrid_malloc=yes;; |
| 2161 | *) test "$ac_cv_func_sbrk" = yes && system_malloc=$emacs_cv_sanitize_address;; | ||
| 2162 | esac | 2162 | esac |
| 2163 | 2163 | ||
| 2164 | if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \ | 2164 | if test "${system_malloc}" != yes && test "${doug_lea_malloc}" != yes \ |
| @@ -4155,7 +4155,7 @@ AC_CHECK_HEADERS(valgrind/valgrind.h) | |||
| 4155 | 4155 | ||
| 4156 | AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]]) | 4156 | AC_CHECK_MEMBERS([struct unipair.unicode], [], [], [[#include <linux/kd.h>]]) |
| 4157 | 4157 | ||
| 4158 | AC_CHECK_FUNCS_ONCE(tzset) | 4158 | AC_CHECK_FUNCS_ONCE([sbrk tzset]) |
| 4159 | 4159 | ||
| 4160 | ok_so_far=yes | 4160 | ok_so_far=yes |
| 4161 | AC_CHECK_FUNC(socket, , ok_so_far=no) | 4161 | AC_CHECK_FUNC(socket, , ok_so_far=no) |
diff --git a/src/alloc.c b/src/alloc.c index a58dc13cbd7..90c6f9441fa 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -97,7 +97,7 @@ static bool valgrind_p; | |||
| 97 | #include "w32heap.h" /* for sbrk */ | 97 | #include "w32heap.h" /* for sbrk */ |
| 98 | #endif | 98 | #endif |
| 99 | 99 | ||
| 100 | #if defined DOUG_LEA_MALLOC || defined GNU_LINUX | 100 | #ifdef GNU_LINUX |
| 101 | /* The address where the heap starts. */ | 101 | /* The address where the heap starts. */ |
| 102 | void * | 102 | void * |
| 103 | my_heap_start (void) | 103 | my_heap_start (void) |
| @@ -130,7 +130,9 @@ malloc_initialize_hook (void) | |||
| 130 | 130 | ||
| 131 | if (! initialized) | 131 | if (! initialized) |
| 132 | { | 132 | { |
| 133 | #ifdef GNU_LINUX | ||
| 133 | my_heap_start (); | 134 | my_heap_start (); |
| 135 | #endif | ||
| 134 | malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; | 136 | malloc_using_checking = getenv ("MALLOC_CHECK_") != NULL; |
| 135 | } | 137 | } |
| 136 | else | 138 | else |
| @@ -7053,7 +7055,7 @@ We divide the value by 1024 to make sure it fits in a Lisp integer. */) | |||
| 7053 | { | 7055 | { |
| 7054 | Lisp_Object end; | 7056 | Lisp_Object end; |
| 7055 | 7057 | ||
| 7056 | #ifdef HAVE_NS | 7058 | #if defined HAVE_NS || !HAVE_SBRK |
| 7057 | /* Avoid warning. sbrk has no relation to memory allocated anyway. */ | 7059 | /* Avoid warning. sbrk has no relation to memory allocated anyway. */ |
| 7058 | XSETINT (end, 0); | 7060 | XSETINT (end, 0); |
| 7059 | #else | 7061 | #else |
diff --git a/src/unexelf.c b/src/unexelf.c index 551915712fb..748e7a42cfa 100644 --- a/src/unexelf.c +++ b/src/unexelf.c | |||
| @@ -329,7 +329,11 @@ unexec (const char *new_name, const char *old_name) | |||
| 329 | if (old_bss_index == -1) | 329 | if (old_bss_index == -1) |
| 330 | fatal ("no bss section found"); | 330 | fatal ("no bss section found"); |
| 331 | 331 | ||
| 332 | #ifdef HAVE_SBRK | ||
| 332 | new_break = sbrk (0); | 333 | new_break = sbrk (0); |
| 334 | #else | ||
| 335 | new_break = (byte *) old_bss_addr + old_bss_size; | ||
| 336 | #endif | ||
| 333 | new_bss_addr = (ElfW (Addr)) new_break; | 337 | new_bss_addr = (ElfW (Addr)) new_break; |
| 334 | bss_size_growth = new_bss_addr - old_bss_addr; | 338 | bss_size_growth = new_bss_addr - old_bss_addr; |
| 335 | new_data2_size = bss_size_growth; | 339 | new_data2_size = bss_size_growth; |