blob: f883dde50a16c4c9c7727a5863ead1ec3842f268 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/***********************************************************************/
/* */
/* Objective Caml */
/* */
/* Xavier Leroy, projet Cristal, INRIA Rocquencourt */
/* */
/* Copyright 1996 Institut National de Recherche en Informatique et */
/* en Automatique. All rights reserved. This file is distributed */
/* under the terms of the Q Public License version 1.0. */
/* */
/***********************************************************************/
/* $Id$ */
#include <stdio.h>
#include <signal.h>
#include <setjmp.h>
double foo;
void access_double(double *p)
{
foo = *p;
}
jmp_buf failure;
void sig_handler(int sig)
{
longjmp(failure, 1);
}
int main(void)
{
long n[10];
int res;
signal(SIGSEGV, sig_handler);
#ifdef SIGBUS
signal(SIGBUS, sig_handler);
#endif
if(setjmp(failure) == 0) {
access_double((double *) n);
access_double((double *) (n+1));
res = 0;
} else {
res = 1;
}
signal(SIGSEGV, SIG_DFL);
#ifdef SIGBUS
signal(SIGBUS, SIG_DFL);
#endif
exit(res);
}
|