3 #include <sys/syscall.h>
7 // kernel brk() and libc brk() act quite differently...
12 void* orig_ds
= sbrk(0);
15 void* res
__attribute__((unused
));
16 #define EOL ((void*)( ~(long)0 ))
19 vals
[2] = ds
- 0x1; // small shrink
21 vals
[4] = ds
+ 0x1000; // small growth
22 vals
[5] = ds
+ 0x40000000; // too-big growth
23 vals
[6] = ds
+ 0x500; // shrink a little, but still above start size
24 vals
[7] = ds
- 0x1; // shrink below start size
25 // vals[8] = ds - 0x1000; // shrink a lot below start size (into text)
29 for (i
= 0; EOL
!= vals
[i
]; i
++) {
30 res
= (void*)syscall(__NR_brk
, vals
[i
]);
33 assert( 0 == brk(orig_ds
) ); // libc brk()
35 for (i
= 0; EOL
!= vals
[i
]; i
++) {
36 res
= (void*)(long)brk(vals
[i
]);