From b7c6db94ae2b9532640609163099c738decb31e6 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 3 Dec 2013 14:48:20 +0000 Subject: [PATCH] gc.c: use malloc_size * configure.in: check malloc_size() available on BSD. * gc.c: use malloc_size() with malloc/malloc.h on BSD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43983 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ configure.in | 2 ++ gc.c | 8 +++++++- internal.h | 2 +- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 76013df34f..258b6d1af6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Tue Dec 3 23:48:18 2013 Nobuyoshi Nakada + + * configure.in: check malloc_size() available on BSD. + + * gc.c: use malloc_size() with malloc/malloc.h on BSD. + Tue Dec 3 23:06:20 2013 Narihiro Nakamura * object.c (rb_obj_clone): don't copy FL_WB_PROTECTED of a diff --git a/configure.in b/configure.in index 8bff18d6dd..88d24eefe8 100644 --- a/configure.in +++ b/configure.in @@ -1093,6 +1093,7 @@ AC_CHECK_HEADERS( \ atomic.h \ malloc.h \ malloc_np.h \ + malloc/malloc.h \ setjmpex.h ) @@ -1870,6 +1871,7 @@ AC_CHECK_FUNCS(lockf) AC_CHECK_FUNCS(log2) AC_CHECK_FUNCS(lstat) AC_CHECK_FUNCS(malloc_usable_size) +AC_CHECK_FUNCS(malloc_size) AC_CHECK_FUNCS(mblen) AC_CHECK_FUNCS(memalign) AC_CHECK_FUNCS(memrchr) diff --git a/gc.c b/gc.c index 0e6aad6f14..ddf607ce20 100644 --- a/gc.c +++ b/gc.c @@ -39,12 +39,18 @@ # ifdef _WIN32 # define HAVE_MALLOC_USABLE_SIZE # define malloc_usable_size(a) _msize(a) +# elif defined HAVE_MALLOC_SIZE +# define HAVE_MALLOC_USABLE_SIZE +# define malloc_usable_size(a) malloc_size(a) # endif -#else +#endif +#ifdef HAVE_MALLOC_USABLE_SIZE # ifdef HAVE_MALLOC_H # include # elif defined(HAVE_MALLOC_NP_H) # include +# elif defined(HAVE_MALLOC_MALLOC_H) +# include # endif #endif diff --git a/internal.h b/internal.h index 810159d313..0e47e8db0a 100644 --- a/internal.h +++ b/internal.h @@ -455,7 +455,7 @@ void rb_objspace_set_event_hook(const rb_event_flag_t event); void rb_gc_writebarrier_remember_promoted(VALUE obj); void ruby_gc_set_params(void); -#if HAVE_MALLOC_USABLE_SIZE || defined(_WIN32) +#if defined(HAVE_MALLOC_USABLE_SIZE) || defined(HAVE_MALLOC_SIZE) || defined(_WIN32) #define ruby_sized_xrealloc(ptr, new_size, old_size) ruby_xrealloc(ptr, new_size) #define ruby_sized_xfree(ptr, size) ruby_xfree(ptr) #define SIZED_REALLOC_N(var,type,n,old_n) REALLOC_N(var, type, n)