1 /* Test for the brk syscall wrapper. */
6 #include <sys/syscall.h>
8 /* Data segment end. */
10 static char *begin
= (char *)&_end
;
12 __attribute__((noinline
))
13 static int test_begin(void)
18 /* Check that a value at the break is inaccessible. */
22 /* Allocate one byte and check that the last byte is accessible and
24 tmp
= syscall(SYS_brk
, begin
+ 1);
29 /* Deallocate one byte and check that the last byte is now inaccessible. */
30 tmp
= syscall(SYS_brk
, begin
);
38 __attribute__((noinline
))
39 static void test_updown(void)
46 for (i
= 0; i
< MAX_SIZE
; i
++) {
47 tmp
= syscall(SYS_brk
, begin
+ i
);
52 for (i
= 0; i
< MAX_SIZE
; i
++) {
53 tmp
= syscall(SYS_brk
, begin
+ MAX_SIZE
- 1 - i
);
59 __attribute__((noinline
))
60 static void test_range(void)
64 tmp
= syscall(SYS_brk
, begin
- 1);
66 assert(errno
== ENOMEM
);
68 /* Unified limit for 64-bit and 32-bit version. */
69 unsigned long long impossible_limit
= 0xffffff4fffffffULL
;
70 tmp
= syscall(SYS_brk
, impossible_limit
);
72 assert(errno
== ENOMEM
);