Merge tag 'qemu-macppc-20230206' of https://github.com/mcayland/qemu into staging
[qemu.git] / tests / tcg / cris / libc / check_settls1.c
blob3abc3a9ea830b3b2d44b0e69548cb24af2678d40
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <errno.h>
4 #include <unistd.h>
6 #include <sys/syscall.h>
8 #ifndef SYS_set_thread_area
9 #define SYS_set_thread_area 243
10 #endif
12 int main (void)
14 unsigned long tp, old_tp;
15 int ret;
17 asm volatile ("move $pid,%0" : "=r" (old_tp));
18 old_tp &= ~0xff;
20 ret = syscall (SYS_set_thread_area, 0xf0);
21 if (ret != -1 || errno != EINVAL) {
22 syscall (SYS_set_thread_area, old_tp);
23 perror ("Invalid thread area accepted:");
24 abort();
27 ret = syscall (SYS_set_thread_area, 0xeddeed00);
28 if (ret != 0) {
29 perror ("Valid thread area not accepted: ");
30 abort ();
33 asm volatile ("move $pid,%0" : "=r" (tp));
34 tp &= ~0xff;
35 syscall (SYS_set_thread_area, old_tp);
37 if (tp != 0xeddeed00) {
38 * (volatile int *) 0 = 0;
39 perror ("tls2");
40 abort ();
43 printf ("pass\n");
44 return EXIT_SUCCESS;