diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2017-03-05 18:15:05 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2017-03-05 18:15:05 +0100 |
commit | 39cfc5731695c46a337606da9bc86a659dbad5b3 (patch) | |
tree | afbbdd276794d53bccdb17878b74913a7fd09341 /configure.ac | |
parent | c32a1997d0add7bf4a6d9b43d29bb3cac7a287b9 (diff) | |
download | sciteco-39cfc5731695c46a337606da9bc86a659dbad5b3.tar.gz |
replaced Linux-specific mallinfo()-based memory limiting with a more portable and faster hack
* Works by "hooking" into malloc() and friends and counting the
usable heap object sizes with malloc_usable_size().
Thus, it has no memory-overhead.
* Will work at least on Linux and (Free)BSD.
Other UNIXoid systems may work as well - this is tested by ./configure.
* Usually faster than even the fallback implementation since the
memory limit is hit earlier.
* A similar approach could be tried on Windows (TODO).
* A proper memory-limiting counting all malloc()s in the system can make
a huge difference as this test case shows:
sciteco -e '<@EU[X^E\a]"^E\a"%a>'
It will allocate gigabytes before hitting the 500MB memory limit...
* Fixed the UNIX-function checks on BSDs.
Diffstat (limited to 'configure.ac')
-rw-r--r-- | configure.ac | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/configure.ac b/configure.ac index 928749b..e47ac0d 100644 --- a/configure.ac +++ b/configure.ac @@ -159,20 +159,23 @@ AC_CHECK_FUNCS([memset setlocale strchr strrchr fstat], , [ AC_MSG_ERROR([Missing libc function]) ]) -# Library functions that should exist on UNIX/Linux -# and UNIXoid systems +# Library functions that we assume exist on UNIX/Linux +# and UNIXoid systems, so that G_OS_UNIX is sufficient +# to test for them. +# FIXME: Perhaps it would be more elegant to check whether +# glib defines G_OS_UNIX||G_OS_HAIKU instead... case $host in -*-*-darwin* | *-*-linux* | *-*-cygwin* | *-*-haiku*) - AC_CHECK_FUNCS([realpath fchown dup dup2], , [ +*-*-linux* | *-*-*bsd* | *-*-darwin* | *-*-cygwin* | *-*-haiku*) + AC_CHECK_FUNCS([realpath fchown dup dup2 dlsym], , [ AC_MSG_ERROR([Missing libc function]) ]) ;; esac -# Check for optional GNU libc features. -# Will probably only be found on Linux. -AC_CHECK_HEADERS([malloc.h]) -AC_CHECK_FUNCS([malloc_trim mallinfo]) +# Check for optional libc features. +# Will probably only be found on Linux/glibc or BSD. +AC_CHECK_HEADERS([malloc.h malloc_np.h]) +AC_CHECK_FUNCS([malloc_trim malloc_usable_size]) # # Config options |