summaryrefslogtreecommitdiffstats
path: root/hwaccess.c
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2017-03-13 13:48:03 +0100
committerPatrick Georgi <pgeorgi@google.com>2017-05-04 12:24:12 +0200
commitd2a03b3e43043b596a79803bcb93f70e513bbb50 (patch)
tree9f91e409309d3a823d795075e187caaa9b764227 /hwaccess.c
parenta52731d78478056039f935f8fad86007132fd2a7 (diff)
downloadflashrom-d2a03b3e43043b596a79803bcb93f70e513bbb50.tar.gz
flashrom-d2a03b3e43043b596a79803bcb93f70e513bbb50.tar.bz2
flashrom-d2a03b3e43043b596a79803bcb93f70e513bbb50.zip
Remove undefined behavior
Per clang-3.9, the compiler fails on #define ...defined(...) statements as they're undefined behavior (apparently with different behavior between gcc/clang and msvc, too). See clang's cfe repo commit r258128 for details. Change-Id: I82b6235e11b425fae45eebbe06b08f81c5bdbb98 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/18792 Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'hwaccess.c')
-rw-r--r--hwaccess.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/hwaccess.c b/hwaccess.c
index aede7e3ad..2bf6f4205 100644
--- a/hwaccess.c
+++ b/hwaccess.c
@@ -37,9 +37,21 @@
#error "Unknown operating system"
#endif
-#define USE_IOPL (IS_LINUX || IS_MACOSX || defined(__NetBSD__) || defined(__OpenBSD__))
-#define USE_DEV_IO (defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__))
-#define USE_IOPERM (defined(__gnu_hurd__))
+#if IS_LINUX || IS_MACOSX || defined(__NetBSD__) || defined(__OpenBSD__)
+#define USE_IOPL 1
+#else
+#define USE_IOPL 0
+#endif
+#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__)
+#define USE_DEV_IO 1
+#else
+#define USE_DEV_IO 0
+#endif
+#if defined(__gnu_hurd__)
+#define USE_IOPERM 1
+#else
+#define USE_IOPERM 0
+#endif
#if USE_IOPERM
#include <sys/io.h>