#include <config.h>
#endif
-#if defined __cplusplus || (defined (__STDC__) && __STDC__) || \
- defined STDC_HEADERS || defined PROTOTYPES
+#if ((defined __cplusplus || (defined (__STDC__) && __STDC__) \
+ || defined STDC_HEADERS || defined PROTOTYPES) \
+ && ! defined (BROKEN_PROTOTYPES))
#undef PP
#define PP(args) args
#undef __ptr_t
#define __malloc_size_t size_t
#define __malloc_ptrdiff_t ptrdiff_t
#else
+#ifdef __GNUC__
+#include <stddef.h>
+#ifdef __SIZE_TYPE__
+#define __malloc_size_t __SIZE_TYPE__
+#endif
+#endif
+#ifndef __malloc_size_t
#define __malloc_size_t unsigned int
+#endif
#define __malloc_ptrdiff_t int
#endif
__ptr_t result;
unsigned long int adj;
- result = (*__morecore) (size);
+ /* align accepts an unsigned argument, but __morecore accepts a
+ signed one. This could lead to trouble if SIZE overflows a
+ signed int type accepted by __morecore. We just punt in that
+ case, since they are requesting a ludicrous amount anyway. */
+ if ((__malloc_ptrdiff_t)size < 0)
+ result = 0;
+ else
+ result = (*__morecore) (size);
adj = (unsigned long int) ((unsigned long int) ((char *) result -
(char *) NULL)) % BLOCKSIZE;
if (adj != 0)
#else
-__ptr_t (*__memalign_hook) PP ((size_t __size, size_t __alignment));
+__ptr_t (*__memalign_hook) PP ((__malloc_size_t __size,
+ __malloc_size_t __alignment));
__ptr_t
memalign (alignment, size)