From 0d314033184e699e749f0fdf7aaae26f07363767 Mon Sep 17 00:00:00 2001 From: Nicholas Lowell Date: Wed, 29 Jul 2020 14:34:59 -0400 Subject: [PATCH] toolchain: define ZRESTRICT for restrict aliasing restrict keyword is not supported in C++, however GNUC does support __restrict for C/C++ so we can use that, however the complexity of toolchains requires a ZRESTRICT symbol that should be used throughout the codebase to not cause any conflicts or redefinition errors Signed-off-by: Nicholas Lowell --- include/toolchain/common.h | 8 ++++++++ include/toolchain/gcc.h | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/include/toolchain/common.h b/include/toolchain/common.h index 4b9d1f46b66..6b6df0f8d92 100644 --- a/include/toolchain/common.h +++ b/include/toolchain/common.h @@ -26,6 +26,14 @@ #define TASK_ENTRY_CPP extern "C" #endif +#ifndef ZRESTRICT +#ifndef __cplusplus +#define ZRESTRICT restrict +#else +#define ZRESTRICT +#endif +#endif + /* * Generate a reference to an external symbol. * The reference indicates to the linker that the symbol is required diff --git a/include/toolchain/gcc.h b/include/toolchain/gcc.h index cc2fdc7dc9b..4f1bd31dd01 100644 --- a/include/toolchain/gcc.h +++ b/include/toolchain/gcc.h @@ -63,6 +63,12 @@ #define BUILD_ASSERT(EXPR, MSG...) #endif +#ifdef __cplusplus +#define ZRESTRICT __restrict +#else +#define ZRESTRICT restrict +#endif + #include #include