--- OpenBSD_malloc_Linux.c.bak 2008-02-17 21:05:03.000000000 +0200 +++ OpenBSD_malloc_Linux.c 2008-03-11 23:21:59.559945439 +0200 @@ -54,6 +54,7 @@ #include #include #include +#include //#include "thread_private.h" @@ -1926,20 +1927,12 @@ realloc(void *ptr, size_t size) return (r); } -#if defined(__i386__)||defined(__arm__)||defined(__powerpc__) -#define SIZE_MAX 0xffffffff -#endif -#if defined(__x86_64__) -#define SIZE_MAX 0xffffffffffffffff -#endif - void * calloc(size_t num, size_t size) { void *p; if (num && SIZE_MAX / num < size) { - fprintf(stderr,"OOOOPS"); errno = ENOMEM; return NULL; } @@ -1950,12 +1943,9 @@ calloc(size_t num, size_t size) return(p); } -static int ispowerof2 (size_t a) { - size_t b; - for (b = 1ULL << (sizeof(size_t)*NBBY - 1); b > 1; b >>= 1) - if (b == a) - return 1; - return 0; +static inline int ispowerof2 (size_t a) { + if (a == 1) return 0; + return (a&(a-1)) ? 0 : 1; } int posix_memalign(void **memptr, size_t alignment, size_t size)