From 400167f5128a14ba48b0d05b7b777b42c450c73f Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Mon, 2 Dec 2019 14:34:11 +0100 Subject: [PATCH] Support `lib/zt_common.h` to be used in assembler and add `_AC` macro MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Support `lib/zt_common.h` to be used in assembler files. In addition, add the macro `_AC` that can be used to make constant macros usable in both assembler and C code. Suggested-by: Philipp Rudo Reviewed-by: Stefan Haberland Reviewed-by: Philipp Rudo Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- include/lib/zt_common.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/lib/zt_common.h b/include/lib/zt_common.h index ddc75504..716e7d16 100644 --- a/include/lib/zt_common.h +++ b/include/lib/zt_common.h @@ -15,6 +15,21 @@ #define STRINGIFY_1(x) #x #define STRINGIFY(x) STRINGIFY_1(x) +/* Use this macro to make constant macros usable in both assembler and + * C code. + * + * Usage example: + * #define IMAGE_ENTRY _AC(0x10000, UL) + */ +#ifdef __ASSEMBLER__ +#define _AC(X, TYPE) X +#else +#define _AC(X, TYPE) X##TYPE +#endif + + +#ifndef __ASSEMBLER__ + #ifdef UNUSED #elif defined(__GNUC__) # define UNUSED(x) UNUSED_ ## x __attribute__((unused)) @@ -50,4 +65,5 @@ typedef signed short int s16; typedef unsigned char u8; typedef signed char s8; +#endif /* __ASSEMBLER__ */ #endif /* LIB_ZT_COMMON_H */