Skip to content

Commit 8abf301

Browse files
author
Timothy Harvey
committed
Added #if control around GCC builtin functions so that the code can be
compiled using non-GCC compilers. JerryScript-DCO-1.0-Signed-off-by: Timothy Harvey [email protected]
1 parent db05d85 commit 8abf301

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

jerry-core/jrt/jrt.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,13 @@
4343
/*
4444
* Conditions' likeliness, unlikeliness.
4545
*/
46-
#define likely(x) __builtin_expect (!!(x), 1)
47-
#define unlikely(x) __builtin_expect (!!(x) , 0)
46+
#ifdef __GNUC__
47+
#define likely(x) __builtin_expect(!!(x), 1)
48+
#define unlikely(x) __builtin_expect(!!(x), 0)
49+
#else /* !__GNUC__ */
50+
#define likely(x) (x)
51+
#define unlikely(x) (x)
52+
#endif /* __GNUC__ */
4853

4954
/*
5055
* Normally compilers store const(ant)s in ROM. Thus saving RAM.
@@ -108,7 +113,11 @@ extern void __noreturn jerry_unreachable (const char *, const char *, const uint
108113
} \
109114
} while (0)
110115

116+
#ifdef __GNUC__
111117
#define JERRY_UNREACHABLE() __builtin_unreachable ()
118+
#else /* !__GNUC__ */
119+
#define JERRY_UNREACHABLE()
120+
#endif /* !__GNUC__ */
112121
#endif /* !JERRY_NDEBUG */
113122

114123
/**

jerry-libc/include/assert.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ extern "C"
2525
#endif /* __cplusplus */
2626

2727
#ifndef NDEBUG
28+
29+
#ifndef __GNUC__
30+
#define __builtin_expect(expression, expected_value) (expression)
31+
#endif /* !__GNUC__ */
32+
2833
#define assert(x) \
2934
do \
3035
{ \

0 commit comments

Comments
 (0)