fitzhardinge | f1beb25 | 2004-03-16 09:49:08 +0000 | [diff] [blame] | 1 | #include <stdio.h> |
thughes | a41a266 | 2004-03-16 10:51:40 +0000 | [diff] [blame] | 2 | #include <stdlib.h> |
fitzhardinge | f1beb25 | 2004-03-16 09:49:08 +0000 | [diff] [blame] | 3 | #include <signal.h> |
| 4 | |
| 5 | static void handler(int sig, siginfo_t *info, void *v) |
| 6 | { |
| 7 | printf("info: sig=%d code=%d addr=%p\n", |
| 8 | info->si_signo, info->si_code, info->si_addr); |
| 9 | exit(0); |
| 10 | } |
| 11 | |
| 12 | int main() |
| 13 | { |
| 14 | struct sigaction sa; |
| 15 | int val; |
| 16 | |
| 17 | sa.sa_sigaction = handler; |
| 18 | sigemptyset(&sa.sa_mask); |
| 19 | sa.sa_flags = SA_SIGINFO; |
| 20 | |
| 21 | sigaction(SIGSEGV, &sa, NULL); |
| 22 | |
| 23 | asm volatile("mov %1, %%fs; mov %%fs:0, %0" : "=r" (val) : "r"(4)); |
| 24 | |
| 25 | printf("val=%d\n", val); |
| 26 | |
| 27 | return 0; |
| 28 | } |