Try to fool $CC harder in ATF ptrace(2) tests in trigger_fpe()

A function that returns a value that is not used, can be optimized out by
a compiler. Try to fool the compiler with calling libc functions that shall
trigger a division by zero crash.

Sponsored by <The NetBSD Foundation>
This commit is contained in:
kamil 2018-05-27 17:16:39 +00:00
parent aaf79abf7f
commit d93c7a0a6b
1 changed files with 5 additions and 8 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: t_ptrace_wait.h,v 1.8 2018/05/26 15:15:17 kamil Exp $ */
/* $NetBSD: t_ptrace_wait.h,v 1.9 2018/05/27 17:16:39 kamil Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@ -554,17 +554,14 @@ trigger_ill(void)
#endif
}
static int __used
static void __used
trigger_fpe(void)
{
static volatile int a = 1;
static volatile int b = 0;
static volatile int c;
volatile int a = getpid();
volatile int b = atoi("0");
/* Division by zero causes CPU trap, translated to SIGFPE */
c = a / b;
return c;
usleep(a / b);
}
static void __used