* 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
This commit is contained in:
naruse 2012-01-07 15:13:37 +00:00
Родитель 50675fdba1
Коммит 411fa36c73
3 изменённых файлов: 17 добавлений и 6 удалений

Просмотреть файл

@ -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> Sat Jan 7 22:25:50 2012 Narihiro Nakamura <authornari@gmail.com>
* gc.c: use Bitmap Marking algorithm to avoid copy-on-write of * gc.c: use Bitmap Marking algorithm to avoid copy-on-write of

Просмотреть файл

@ -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\ setuid setgid daemon select_large_fdset setenv unsetenv\
mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\ mktime timegm gmtime_r clock_gettime gettimeofday poll ppoll\
pread sendfile shutdown sigaltstack dl_iterate_phdr\ 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_CACHE_CHECK(for unsetenv returns a value, rb_cv_unsetenv_return_value,
[AC_TRY_COMPILE([ [AC_TRY_COMPILE([

13
gc.c
Просмотреть файл

@ -24,7 +24,6 @@
#include <stdio.h> #include <stdio.h>
#include <setjmp.h> #include <setjmp.h>
#include <sys/types.h> #include <sys/types.h>
#include <malloc.h>
#include <assert.h> #include <assert.h>
#ifdef HAVE_SYS_TIME_H #ifdef HAVE_SYS_TIME_H
@ -39,6 +38,10 @@
#include <windows.h> #include <windows.h>
#endif #endif
#if !defined(__MINGW32__) && !defined(_WIN32) && !defined(__CYGWIN__) &&!defined(HAVE_POSIX_MEMALIGN) &&defined(HAVE_MEMALIGN)
#include <malloc.h>
#endif
#ifdef HAVE_VALGRIND_MEMCHECK_H #ifdef HAVE_VALGRIND_MEMCHECK_H
# include <valgrind/memcheck.h> # include <valgrind/memcheck.h>
# ifndef VALGRIND_MAKE_MEM_DEFINED # ifndef VALGRIND_MAKE_MEM_DEFINED
@ -1061,16 +1064,16 @@ aligned_malloc(size_t aligned_size)
res = __mingw_aligned_malloc(aligned_size, aligned_size); res = __mingw_aligned_malloc(aligned_size, aligned_size);
#elif _WIN32 || defined __CYGWIN__ #elif _WIN32 || defined __CYGWIN__
res = _aligned_malloc(aligned_size, aligned_size); res = _aligned_malloc(aligned_size, aligned_size);
#else #elif defined(HAVE_POSIX_MEMALIGN)
# if _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
if (posix_memalign(&res, aligned_size, aligned_size) == 0) { if (posix_memalign(&res, aligned_size, aligned_size) == 0) {
return res; return res;
} else { } else {
return NULL; return NULL;
} }
# else #elif defined(HAVE_MEMALIGN)
res = memalign(aligned_size, aligned_size); res = memalign(aligned_size, aligned_size);
# endif #else
#error no memalign function
#endif #endif
return res; return res;
} }