summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2023-09-16 09:08:55 -0400
committerPeter Zhu <peter@peterzhu.ca>2023-09-16 09:08:55 -0400
commit209d5f8482d13a798f3ffd2faa6cbddb0f5b6724 (patch)
tree62cd193c94becd19104c2027f48ed3a4405b464e
parenta8afedce6dfdbab8807134daa926b0936b5cd9a4 (diff)
Fix malloc_trim on emscripten
``` gc.c:9746:5: error: implicit declaration of function 'malloc_trim' is invalid in C99 [-Werror,-Wimplicit-function-declaration] malloc_trim(0); ^ ``` http://rubyci.s3.amazonaws.com/crossruby/crossruby-master-wasm32_emscripten/log/20230916T104311Z.fail.html.gz
-rw-r--r--gc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/gc.c b/gc.c
index ffbbee7115..cc4406c0c9 100644
--- a/gc.c
+++ b/gc.c
@@ -48,7 +48,7 @@
# endif
#endif
-#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_TRIM)
+#ifdef HAVE_MALLOC_USABLE_SIZE
# ifdef RUBY_ALTERNATIVE_MALLOC_HEADER
/* Alternative malloc header is included in ruby/missing.h */
# elif defined(HAVE_MALLOC_H)
@@ -60,6 +60,10 @@
# endif
#endif
+#ifdef HAVE_MALLOC_TRIM
+# include <malloc.h>
+#endif
+
#if !defined(PAGE_SIZE) && defined(HAVE_SYS_USER_H)
/* LIST_HEAD conflicts with sys/queue.h on macOS */
# include <sys/user.h>