From d93c7a0a6bba081c83197820b77c116da314977f Mon Sep 17 00:00:00 2001 From: kamil Date: Sun, 27 May 2018 17:16:39 +0000 Subject: [PATCH] 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 --- tests/lib/libc/sys/t_ptrace_wait.h | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/lib/libc/sys/t_ptrace_wait.h b/tests/lib/libc/sys/t_ptrace_wait.h index 1a4981290f24..73ff9d2aa225 100644 --- a/tests/lib/libc/sys/t_ptrace_wait.h +++ b/tests/lib/libc/sys/t_ptrace_wait.h @@ -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