aboutsummaryrefslogtreecommitdiff
path: root/riscv/common.h
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2020-11-18 14:15:44 -0800
committerAndrew Waterman <andrew@sifive.com>2020-11-18 14:15:44 -0800
commita081a013f3749f126c3c22a6dc9919314b61685d (patch)
tree59dce4439798f8aefa3b3798eac29b405e2e5f4c /riscv/common.h
parenta4994cba0d26915f46292a9ac7c4ce80094c4755 (diff)
downloadspike-a081a013f3749f126c3c22a6dc9919314b61685d.zip
spike-a081a013f3749f126c3c22a6dc9919314b61685d.tar.gz
spike-a081a013f3749f126c3c22a6dc9919314b61685d.tar.bz2
Only use __builtin_expect for __GNUC__
Diffstat (limited to 'riscv/common.h')
-rw-r--r--riscv/common.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/riscv/common.h b/riscv/common.h
index 3c523d0..d593df2 100644
--- a/riscv/common.h
+++ b/riscv/common.h
@@ -3,8 +3,13 @@
#ifndef _RISCV_COMMON_H
#define _RISCV_COMMON_H
-#define likely(x) __builtin_expect(x, 1)
-#define unlikely(x) __builtin_expect(x, 0)
+#ifdef __GNUC__
+# define likely(x) __builtin_expect(x, 1)
+# define unlikely(x) __builtin_expect(x, 0)
+#else
+# define likely(x) (x)
+# define unlikely(x) (x)
+#endif
#define NOINLINE __attribute__ ((noinline))