* 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>
* 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\
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([

13
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;
}