aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--ChangeLog8
-rw-r--r--configure.in2
-rw-r--r--gc.c13
3 files changed, 17 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index b23f9adad2..b4651e3230 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun Jan 8 00:10:10 2012 NARUSE, Yui <naruse@ruby-lang.org>
+
+ * 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.
+
Sat Jan 7 22:25:50 2012 Narihiro Nakamura <authornari@gmail.com>
* gc.c: use Bitmap Marking algorithm to avoid copy-on-write of
diff --git a/configure.in b/configure.in
index 905efd1c6b..e8fc4ab91c 100644
--- a/configure.in
+++ b/configure.in
@@ -1393,7 +1393,7 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid fork spawnv syscall __syscall chroot ge
setuid setgid daemon select_large_fdset setenv unsetenv\
mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\
pread sendfile shutdown sigaltstack dl_iterate_phdr\
- dup3 pipe2)
+ dup3 pipe2 posix_memalign memalign)
AC_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value,
[AC_TRY_COMPILE([
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;
}