| 1 |
/* This testcase originally provoked an unaligned access fault on Alpha. |
| 2 |
|
| 3 |
Since Digital Unix and Linux (and probably others) by default fix |
| 4 |
these up in the kernel, the failure was not visible unless one |
| 5 |
is sitting at the console examining logs. |
| 6 |
|
| 7 |
So: If we know how, ask the kernel to deliver SIGBUS instead so |
| 8 |
that the test case visibly fails. */ |
| 9 |
|
| 10 |
void abort (void); |
| 11 |
void exit (int); |
| 12 |
|
| 13 |
#if defined(__alpha__) && defined(__linux__) |
| 14 |
#include <asm/sysinfo.h> |
| 15 |
#include <asm/unistd.h> |
| 16 |
|
| 17 |
int syscall (int, ...); |
| 18 |
|
| 19 |
static inline int |
| 20 |
setsysinfo(unsigned long op, void *buffer, unsigned long size, |
| 21 |
int *start, void *arg, unsigned long flag) |
| 22 |
{ |
| 23 |
syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag); |
| 24 |
} |
| 25 |
|
| 26 |
static void __attribute__((constructor)) |
| 27 |
trap_unaligned(void) |
| 28 |
{ |
| 29 |
unsigned int buf[2]; |
| 30 |
buf[0] = SSIN_UACPROC; |
| 31 |
buf[1] = UAC_SIGBUS | UAC_NOPRINT; |
| 32 |
setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0); |
| 33 |
} |
| 34 |
#endif /* alpha */ |
| 35 |
|
| 36 |
void foo(char *a, char *b) { } |
| 37 |
|
| 38 |
void showinfo() |
| 39 |
{ |
| 40 |
char uname[33] = "", tty[38] = "/dev/"; |
| 41 |
foo(uname, tty); |
| 42 |
} |
| 43 |
|
| 44 |
int main() |
| 45 |
{ |
| 46 |
showinfo (); |
| 47 |
exit (0); |
| 48 |
} |