1 /* With -fnon-call-exceptions 0 / 0 should not be eliminated. The .x
2 file sets the option. */
6 #elif defined (__powerpc__) || defined (__PPC__) || defined (__ppc__) || defined (__POWERPC__) || defined (__ppc)
7 /* On PPC division by zero does not trap. */
9 #elif defined (__SPU__)
10 /* On SPU division by zero does not trap. */
12 #elif defined (__sh__)
13 /* On SH division by zero does not trap. */
15 #elif defined (__aarch64__)
16 /* On AArch64 integer division by zero does not trap. */
18 #elif defined (__TMS320C6X__)
19 /* On TI C6X division by zero does not trap. */
21 #elif defined (__mips__) && !defined(__linux__)
22 /* MIPS divisions do trap by default, but libgloss targets do not
23 intercept the trap and raise a SIGFPE. The same is probably
24 true of other bare-metal environments, so restrict the test to
25 systems that use the Linux kernel. */
27 #elif defined (__mips16) && defined(__linux__)
28 /* Not all Linux kernels deal correctly the breakpoints generated by
29 MIPS16 divisions by zero. They show up as a SIGTRAP instead. */
31 #elif defined (__MICROBLAZE__)
32 /* We cannot rely on division by zero generating a trap. */
34 #elif defined (__epiphany__)
35 /* Epiphany does not have hardware division, and the software implementation
36 has truly undefined behaviour for division by 0. */
38 #elif defined (__m68k__) && !defined(__linux__)
39 /* Attempting to trap division-by-zero in this way isn't likely to work on
40 bare-metal m68k systems. */
42 #elif defined (__CRIS__)
43 /* No SIGFPE for CRIS integer division. */
45 #elif defined (__MMIX__)
46 /* By default we emit a sequence with DIVU, which "never signals an
47 exceptional condition, even when dividing by zero". */
49 #elif defined (__arc__)
50 /* No SIGFPE for ARC integer division. */
52 #elif defined (__arm__) && defined (__ARM_EABI__)
53 # ifdef __ARM_ARCH_EXT_IDIV__
54 /* Hardware division instructions may not trap, and handle trapping
55 differently anyway. Skip the test if we have those instructions. */
59 /* ARM division-by-zero behaviour is to call a helper function, which
60 can do several different things, depending on requirements. Emulate
61 the behaviour of other targets here by raising SIGFPE. */
62 int __attribute__((used
))
63 __aeabi_idiv0 (int return_value
)
70 #elif defined (__nios2__)
71 /* Nios II requires both hardware support and user configuration to
72 raise an exception on divide by zero. */
83 sigfpe (int signum
__attribute__ ((unused
)))
90 /* When optimizing, the compiler is smart enough to constant fold the
91 static unset variables i and j to produce 0 / 0, but it can't
92 eliminate the assignment to the global k. */
95 int k
__attribute__ ((used
));
101 signal (SIGFPE
, sigfpe
);