lib atexit,getpagesize,mallinfo,mallopt,memalign,mstats
lib onexit,pvalloc,strdup,valloc,vmalloc
lib _malloc,__malloc,__libc_malloc
hdr alloca,malloc,stat,stdlib,unistd
tst mem_sbrk note{ brk()/sbrk() work as expected }end execute{
#define uchar unsigned char
/* allocate a big chunk */
if(!(brk0 = (uchar*)sbrk(0)) || brk0 == (uchar*)(-1))
if((brk1 = (uchar*)sbrk(0)) != brk0)
/* now return half of it */
if((brk0 = (uchar*)sbrk(0)) != brk1)
tst map_malloc note{ map malloc to _ast_malloc }end noexecute{
extern char* strdup _ARG_((const char*));
#define LOCAL() strdup("s")
extern void* calloc _ARG_((unsigned int, unsigned int));
#define LOCAL() calloc(1,1)
#define extern __declspec(dllexport)
static HT heap[1024 * 4];
static HT* hp = &heap[1];
#define MALLOC(n) if(user)return&heap[0];op=hp;hp+=(n+sizeof(HT)-1)/sizeof(HT);return(void*)op;
#define INTERCEPTED(p) (((char*)(p))==((char*)&heap[0]))
extern void free(void* p) { }
extern void _free(void* p) { }
extern void __free(void* p) { }
extern void __libc_free(void* p) { }
extern void* malloc(unsigned int n) { MALLOC(n); }
extern void* _malloc(unsigned int n) { MALLOC(n); }
extern void* __malloc(unsigned int n) { MALLOC(n); }
extern void* __libc_malloc(unsigned int n) { MALLOC(n); }
extern void free(p) char* p; { }
extern void _free(p) char* p; { }
extern void __free(p) char* p; { }
extern void __libc_free(p) char* p; { }
extern void* malloc(n) unsigned int n; { MALLOC(n); }
extern void* _malloc(n) unsigned int n; { MALLOC(n); }
extern void* __malloc(n) unsigned int n; { MALLOC(n); }
extern void* __libc_malloc(n) unsigned int n; { MALLOC(n); }
int main() { user = 1; return !INTERCEPTED(LOCAL()); }
tst map_malloc note{ map malloc to _ast_malloc -- wimp-o mach? }end noexecute{
void* calloc(unsigned n, unsigned m) { exit(1); }
void* calloc(n, m) unsigned n, m; { exit(1); }
lib alloca note{ alloca exists }end link{
tst mal_alloca note{ alloca is based on malloc() }end execute{
void* malloc(unsigned int size)
void* malloc(size) unsigned int size;
tst stk_down note{ stack grows downward }end execute{
else if(addr < &array[0])
int main() { return growdown() ? 0 : 1; }
#if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast
#define _std_malloc 1 /* defer to standard malloc */