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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.dg/] [setjmp-2.c] - Blame information for rev 826

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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