]>
Commit | Line | Data |
---|---|---|
ef96779b EI |
1 | #include <stdio.h> |
2 | #include <stdlib.h> | |
3 | #include <errno.h> | |
4 | #include <unistd.h> | |
5 | ||
6 | #include <sys/syscall.h> | |
7 | ||
8 | #ifndef SYS_set_thread_area | |
9 | #define SYS_set_thread_area 243 | |
10 | #endif | |
11 | ||
12 | int main (void) | |
13 | { | |
58f5c1eb | 14 | unsigned long tp, old_tp; |
ef96779b EI |
15 | int ret; |
16 | ||
58f5c1eb EI |
17 | asm volatile ("move $pid,%0" : "=r" (old_tp)); |
18 | old_tp &= ~0xff; | |
19 | ||
ef96779b EI |
20 | ret = syscall (SYS_set_thread_area, 0xf0); |
21 | if (ret != -1 || errno != EINVAL) { | |
58f5c1eb | 22 | syscall (SYS_set_thread_area, old_tp); |
ef96779b EI |
23 | perror ("Invalid thread area accepted:"); |
24 | abort(); | |
25 | } | |
26 | ||
27 | ret = syscall (SYS_set_thread_area, 0xeddeed00); | |
28 | if (ret != 0) { | |
29 | perror ("Valid thread area not accepted: "); | |
30 | abort (); | |
31 | } | |
32 | ||
58f5c1eb | 33 | asm volatile ("move $pid,%0" : "=r" (tp)); |
ef96779b | 34 | tp &= ~0xff; |
58f5c1eb | 35 | syscall (SYS_set_thread_area, old_tp); |
ef96779b EI |
36 | |
37 | if (tp != 0xeddeed00) { | |
58f5c1eb | 38 | * (volatile int *) 0 = 0; |
ef96779b EI |
39 | perror ("tls2"); |
40 | abort (); | |
41 | } | |
42 | ||
43 | printf ("pass\n"); | |
44 | return EXIT_SUCCESS; | |
45 | } |