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 #if defined(__alpha__) && defined(__linux__)
11 #include <asm/sysinfo.h>
12 #include <asm/unistd.h>
13 
14 static inline int
setsysinfo(unsigned long op,void * buffer,unsigned long size,int * start,void * arg,unsigned long flag)15 setsysinfo(unsigned long op, void *buffer, unsigned long size,
16            int *start, void *arg, unsigned long flag)
17 {
18   syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);
19 }
20 
21 static void __attribute__((constructor))
trap_unaligned(void)22 trap_unaligned(void)
23 {
24   unsigned int buf[2];
25   buf[0] = SSIN_UACPROC;
26   buf[1] = UAC_SIGBUS | UAC_NOPRINT;
27   setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);
28 }
29 #endif /* alpha */
30 
foo(char * a,char * b)31 void foo(char *a, char *b) { }
32 
showinfo()33 void showinfo()
34 {
35     char uname[33] = "", tty[38] = "/dev/";
36     foo(uname, tty);
37 }
38 
main()39 int main()
40 {
41   showinfo ();
42   exit (0);
43 }
44