From 98383707438a3e31ffd86a82b57fbe439945f777 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Fri, 5 Apr 2019 15:18:50 +0200 Subject: move patterns to include file --- test/monniaux/ternary/ternary.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'test/monniaux/ternary') diff --git a/test/monniaux/ternary/ternary.c b/test/monniaux/ternary/ternary.c index 61da9597..ed7de156 100644 --- a/test/monniaux/ternary/ternary.c +++ b/test/monniaux/ternary/ternary.c @@ -2,26 +2,14 @@ #include #include #include "../clock.h" +#include "../ternary.h" typedef uint32_t data; -static inline int32_t ternary_int32(int32_t a, int32_t b, int32_t c) { - return (((-((a) == 0)) & (c)) | ((-((a) != 0)) & (b))); -} -static inline uint32_t ternary_uint32(uint32_t a, uint32_t b, uint32_t c) { - return ternary_int32(a, b, c); -} - -#if defined(__COMPCERT__) && defined(__K1C__) -#define TERNARY(a, b, c) ternary_uint32((a), (b), (c)) -#else -#define TERNARY(a, b, c) ((a) ? (b) : (c)) -#endif - data silly_computation(void) { data x = 1; for(int i=0; i<10000; i++) { - x = x * TERNARY(x & 0x100, 45561U, 337777U); + x = x * TERNARY32(x & 0x100, 45561U, 337777U); } return x; } -- cgit