2 # This file defines probes for local features that vmalloc requires.
3 # Such probes are interpreted by the "iffe" language interpreter.
4 # Results are stored in the FEATURE directory. Some of the
5 # {lib,hdr,sys,typ} tests may also be done in the AST features/lib;
6 # repeating them here allows for single standalone and AST sources.
11 lib atexit,getpagesize,mallinfo,mallopt,memalign,mstats
12 lib onexit,pvalloc,strdup,valloc,vmalloc
13 lib _malloc,__malloc,__libc_malloc
14 hdr alloca,malloc,stat,stdlib,unistd
15 mem mallinfo.arena,mstats.bytes_total malloc.h
19 tst mem_sbrk note{ brk()/sbrk() work as expected }end execute{
20 #include <sys/types.h>
23 #define uchar unsigned char
27 /* allocate a big chunk */
28 if(!(brk0 = (uchar*)sbrk(0)) || brk0 == (uchar*)(-1))
33 if((brk1 = (uchar*)sbrk(0)) != brk0)
36 /* now return half of it */
40 if((brk0 = (uchar*)sbrk(0)) != brk1)
47 tst map_malloc note{ map malloc to _ast_malloc }end noexecute{
49 int main() { return 1; }
54 extern char* strdup _ARG_((const char*));
55 #define LOCAL() strdup("s")
57 extern void* calloc _ARG_((unsigned int, unsigned int));
58 #define LOCAL() calloc(1,1)
61 #define extern __declspec(dllexport)
64 static HT heap[1024 * 4];
65 static HT* hp = &heap[1];
67 #define MALLOC(n) if(user)return&heap[0];op=hp;hp+=(n+sizeof(HT)-1)/sizeof(HT);return(void*)op;
68 #define INTERCEPTED(p) (((char*)(p))==((char*)&heap[0]))
70 extern void free(void* p) { }
71 extern void _free(void* p) { }
72 extern void __free(void* p) { }
73 extern void __libc_free(void* p) { }
74 extern void* malloc(unsigned int n) { MALLOC(n); }
75 extern void* _malloc(unsigned int n) { MALLOC(n); }
76 extern void* __malloc(unsigned int n) { MALLOC(n); }
77 extern void* __libc_malloc(unsigned int n) { MALLOC(n); }
79 extern void free(p) char* p; { }
80 extern void _free(p) char* p; { }
81 extern void __free(p) char* p; { }
82 extern void __libc_free(p) char* p; { }
83 extern void* malloc(n) unsigned int n; { MALLOC(n); }
84 extern void* _malloc(n) unsigned int n; { MALLOC(n); }
85 extern void* __malloc(n) unsigned int n; { MALLOC(n); }
86 extern void* __libc_malloc(n) unsigned int n; { MALLOC(n); }
89 int main() { user = 1; return !INTERCEPTED(LOCAL()); }
93 tst map_malloc note{ map malloc to _ast_malloc -- wimp-o mach? }end noexecute{
95 int main() { return 0; }
99 void* calloc(unsigned n, unsigned m) { exit(1); }
101 void* calloc(n, m) unsigned n, m; { exit(1); }
104 int main() { return 0; }
108 lib alloca note{ alloca exists }end link{
118 tst mal_alloca note{ alloca is based on malloc() }end execute{
120 int main() { return 1; }
126 void* malloc(unsigned int size)
128 void* malloc(size) unsigned int size;
140 tst stk_down note{ stack grows downward }end execute{
142 { static char* addr = 0;
148 else if(addr < &array[0])
152 int main() { return growdown() ? 0 : 1; }
156 #include "FEATURE/mmap"
157 #if _BLD_INSTRUMENT || cray || _UWIN && _BLD_ast
159 #define _std_malloc 1 /* defer to standard malloc */
162 #define _mem_mmap_anon 1
165 #define _mem_mmap_zero 1