aboutsummaryrefslogtreecommitdiffstats
path: root/gc.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-07 15:13:37 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-01-07 15:13:37 +0000
commit411fa36c7344c3ef6f82a296131cae373e40f8f0 (patch)
treed2e01f6cd84fb63bdf5dfc893cf95c2770245a6c /gc.c
parent50675fdba1125a841ed494cb98737c97bd748900 (diff)
downloadruby-411fa36c7344c3ef6f82a296131cae373e40f8f0.tar.gz
* configure.in: check posix_memalign(3) and menalign(3).
* gc.c (aligned_malloc): use configure's result instead of _POSIX_C_SOURCE and _XOPEN_SOURCE because they can't be used to check availability at least on FreeBSD. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34226 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/gc.c b/gc.c
index 124b86cc9b..d99b9c496f 100644
--- a/gc.c
+++ b/gc.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <setjmp.h>
#include <sys/types.h>
-#include <malloc.h>
#include <assert.h>
#ifdef HAVE_SYS_TIME_H
@@ -39,6 +38,10 @@
#include <windows.h>
#endif
+#if !defined(__MINGW32__) && !defined(_WIN32) && !defined(__CYGWIN__) &&!defined(HAVE_POSIX_MEMALIGN) &&defined(HAVE_MEMALIGN)
+#include <malloc.h>
+#endif
+
#ifdef HAVE_VALGRIND_MEMCHECK_H
# include <valgrind/memcheck.h>
# ifndef VALGRIND_MAKE_MEM_DEFINED
@@ -1061,16 +1064,16 @@ aligned_malloc(size_t aligned_size)
res = __mingw_aligned_malloc(aligned_size, aligned_size);
#elif _WIN32 || defined __CYGWIN__
res = _aligned_malloc(aligned_size, aligned_size);
-#else
-# if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
+#elif defined(HAVE_POSIX_MEMALIGN)
if (posix_memalign(&res, aligned_size, aligned_size) == 0) {
return res;
} else {
return NULL;
}
-# else
+#elif defined(HAVE_MEMALIGN)
res = memalign(aligned_size, aligned_size);
-# endif
+#else
+#error no memalign function
#endif
return res;
}