From 2d162967480afa3a13ed7deaf6ce0309c93cce8d Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Thu, 4 Dec 2014 11:42:48 -0600 Subject: [PATCH] Work around an ORCA/C preprocessor bug that was causing shell conditionals not to work properly. The bug is that an #if condition may be mis-evaluated if it immediately follows a use of a function-like macro. I also modified a couple other places that could possibly trigger the bug (including a possibly more reliable fix for the instance of this problem I worked around earlier in include/xatonum.h). --- include/platform.h | 6 +++--- include/xatonum.h | 10 ++-------- shell/hush.c | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/include/platform.h b/include/platform.h index 8492a1e14..4b8ecae59 100644 --- a/include/platform.h +++ b/include/platform.h @@ -44,6 +44,9 @@ # define __const const #endif +/* used by unit test machinery to run registration functions before calling main() */ +#define INIT_FUNC __attribute__ ((constructor)) + #define UNUSED_PARAM __attribute__ ((__unused__)) #define NORETURN __attribute__ ((__noreturn__)) /* "The malloc attribute is used to tell the compiler that a function @@ -81,9 +84,6 @@ # define UNUSED_PARAM_RESULT #endif -/* used by unit test machinery to run registration functions before calling main() */ -#define INIT_FUNC __attribute__ ((constructor)) - /* -fwhole-program makes all symbols local. The attribute externally_visible * forces a symbol global. */ #if __GNUC_PREREQ(4,1) diff --git a/include/xatonum.h b/include/xatonum.h index 4d33bbdf2..5dd828363 100644 --- a/include/xatonum.h +++ b/include/xatonum.h @@ -28,6 +28,8 @@ type xato##T##_range(const char *str, type l, type u) FAST_FUNC; \ type xato##T##_sfx(const char *str, const struct suffix_mult *sfx) FAST_FUNC; \ type xato##T(const char *str) FAST_FUNC; \ +DECLARE_STR_CONV(long, l, ul) + /* Provides inline definitions of functions */ /* (useful for mapping them to the type of the same width) */ @@ -79,14 +81,6 @@ static ALWAYS_INLINE \ narrow xato##N(const char *str) \ { return xato##W(str); } \ -DECLARE_STR_CONV(long, l, ul) - -/* Without the explicit !defined(__ORCAC__) check, ORCA/C's preprocessor was - * falsely treating the following #if as true. I think this occurs because - * the preprocessor state is somehow corrupted. The added check seems to work - * around the bug; hopefully the corruption doesn't cause any other problems. - */ - /* Same for int -> [long] long */ #if !defined(__ORCAC__) && UINT_MAX == ULONG_MAX DEFINE_EQUIV_STR_CONV(int, i, l, u, ul) diff --git a/shell/hush.c b/shell/hush.c index eda7861af..87346c9b3 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -7833,7 +7833,7 @@ static int run_list(struct pipe *pi) } } last_followup = pi->followup; - IF_HAS_KEYWORDS(last_rword = rword;) + IF_HAS_KEYWORDS(last_rword = rword); /* ; outside to avoid ORCA/C bug */ #if ENABLE_HUSH_IF if (cond_code) { if (rword == RES_THEN) {