OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [torture/] [stackalign/] [setjmp-2.c] - Blame information for rev 754

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* { dg-do run { target i?86-*-linux* x86_64-*-linux* } } */
2
 
3
#include <setjmp.h>
4
#include <signal.h>
5
 
6
#ifndef NULL
7
#define NULL ((void *)0)
8
#endif
9
static jmp_buf segv_jmpbuf;
10
 
11
static void segv_handler(int seg)
12
{
13
   __builtin_longjmp(segv_jmpbuf, 1);
14
}
15
 
16
static int is_addressable(void *p, size_t size)
17
{
18
   volatile char * volatile cp = (volatile char *)p;
19
   volatile int ret;
20
   struct sigaction sa, origsa;
21
   sigset_t mask;
22
 
23
   sa.sa_handler = segv_handler;
24
   sa.sa_flags = 0;
25
   sigfillset(&sa.sa_mask);
26
   sigaction(SIGSEGV, &sa, &origsa);
27
   sigprocmask(SIG_SETMASK, NULL, &mask);
28
 
29
   if (__builtin_setjmp(segv_jmpbuf) == 0) {
30
      while(size--)
31
         *cp++;
32
      ret = 1;
33
    } else
34
      ret = 0;
35
 
36
   sigaction(SIGSEGV, &origsa, NULL);
37
   sigprocmask(SIG_SETMASK, &mask, NULL);
38
 
39
   return ret;
40
}
41
 
42
int main(int argc, char **argv)
43
{
44
   is_addressable(0x0, 1);
45
   return 0;
46
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.