diff --git a/configure.ac b/configure.ac index 5b6252390..4facd17c8 100644 --- a/configure.ac +++ b/configure.ac @@ -105,7 +105,7 @@ AC_LANG([C]) AC_C_CONST -AC_CHECK_FUNCS(strndup strtok_r sigaction) +AC_CHECK_FUNCS(strndup strtok_r sigaction malloc_trim) AC_CHECK_FUNCS(aligned_alloc posix_memalign _aligned_malloc) AC_FUNC_ALLOCA diff --git a/link-grammar/parse/extract-links.c b/link-grammar/parse/extract-links.c index ec0b2324f..91bac5988 100644 --- a/link-grammar/parse/extract-links.c +++ b/link-grammar/parse/extract-links.c @@ -282,7 +282,7 @@ void free_extractor(extractor_t * pex) pex->x_table_size = 0; pex->x_table = NULL; -#if defined __GLIBC__ +#if HAVE_MALLOC_TRIM // MST parsing can result in pathological cases, with almost a // billion elts in the Parse_choice_pool. This blows up the // resident-set size (RSS) over time. Avoid this issue by trimming. @@ -298,7 +298,7 @@ void free_extractor(extractor_t * pex) xfree((void *) pex, sizeof(extractor_t)); -#if defined __GLIBC__ +#if HAVE_MALLOC_TRIM // malloc_trim() is a gnu extension. An alternative would be // to call madvise(MADV_DONTNEED) but this is more complicated. if (trim) malloc_trim(0); diff --git a/link-grammar/resources.c b/link-grammar/resources.c index 18fa2bf91..19da17771 100644 --- a/link-grammar/resources.c +++ b/link-grammar/resources.c @@ -48,7 +48,7 @@ int getrusage(int who, struct rusage *rusage); /** Returns the CPU usage time, for this thread only, in seconds. */ static double current_usage_time(void) { -#if !defined(_WIN32) && !defined(__APPLE__) +#if defined RUSAGE_THREAD struct rusage u; getrusage (RUSAGE_THREAD, &u); return (u.ru_utime.tv_sec + ((double) u.ru_utime.tv_usec) / 1000000.0);