File: double_catch.c

package info (click to toggle)
liboil 0.3.15-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 7,032 kB
  • ctags: 5,929
  • sloc: ansic: 47,058; xml: 12,229; sh: 8,957; perl: 1,095; asm: 1,072; makefile: 748
file content (51 lines) | stat: -rw-r--r-- 787 bytes parent folder | download | duplicates (2)
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

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif

#include <liboil/liboil.h>
#include <liboil/liboilfault.h>
#include <stdio.h>

#ifdef HAVE_I386
void unknown_insn(void *far)
{
  asm ("ud2");
}
#define HAVE_ILLEGAL_INSN
#endif

#ifdef HAVE_POWERPC
void unknown_insn(void *far)
{
  asm (".long 0");
}
#define HAVE_ILLEGAL_INSN
#endif

int main(void)
{
  oil_init();

#ifdef HAVE_ILLEGAL_INSN
  oil_fault_check_enable();

  if (oil_fault_check_try(unknown_insn, NULL)) {
    printf("didn't catch failure\n");
    return 1;
  }

  if (oil_fault_check_try(unknown_insn, NULL)) {
    printf("didn't catch failure\n");
    return 1;
  }

  oil_fault_check_disable();

  printf("OK\n");
#else
  printf("No illegal instruction for this architecture, test inconclusive\n");
#endif

  return 0;
}