зеркало из https://github.com/github/ruby.git
* gc.c (aligned_malloc, aligned_free): added fallback implementations
for platforms like OSX Leopard. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
3175fbf194
Коммит
1d006f353d
|
@ -1,3 +1,8 @@
|
|||
Sun Mar 18 18:31:45 2012 Yuki Sonoda (Yugui) <yugui@yugui.jp>
|
||||
|
||||
* gc.c (aligned_malloc, aligned_free): added fallback implementations
|
||||
for platforms like OSX Leopard.
|
||||
|
||||
Sun Mar 18 17:17:48 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* bignum.c (rb_big_pow): estimate result bit size more precisely.
|
||||
|
|
17
gc.c
17
gc.c
|
@ -1106,7 +1106,18 @@ aligned_malloc(size_t alignment, size_t size)
|
|||
#elif defined(HAVE_MEMALIGN)
|
||||
res = memalign(alignment, size);
|
||||
#else
|
||||
#error no memalign function
|
||||
char* aligned;
|
||||
res = malloc(alignment + size + sizeof(void*));
|
||||
aligned = (char*)res + alignment + sizeof(void*);
|
||||
aligned -= ((VALUE)aligned & (alignment - 1));
|
||||
((void**)aligned)[-1] = res;
|
||||
res = (void*)aligned;
|
||||
#endif
|
||||
|
||||
#if defined(_DEBUG) || defined(GC_DEBUG)
|
||||
/* alignment must be a power of 2 */
|
||||
assert((alignment - 1) & alignment == 0);
|
||||
assert(alignment % sizeof(void*) == 0);
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
@ -1118,8 +1129,10 @@ aligned_free(void *ptr)
|
|||
__mingw_aligned_free(ptr);
|
||||
#elif defined _WIN32 && !defined __CYGWIN__
|
||||
_aligned_free(ptr);
|
||||
#else
|
||||
#elif defined(HAVE_MEMALIGN) && defined(HAVE_POSIX_MEMALIGN)
|
||||
free(ptr);
|
||||
#else
|
||||
free(((void**)ptr)[-1]);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче