From fe46647ef5671095d17734792a1dcc675d54d34c Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Fri, 15 Jun 2018 16:53:27 +0200 Subject: score: Macros to declare and define global symbols Add RTEMS_DEFINE_GLOBAL_SYMBOL() and add RTEMS_DECLARE_GLOBAL_SYMBOL(). Update #3459. --- cpukit/include/rtems/score/basedefs.h | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) (limited to 'cpukit') diff --git a/cpukit/include/rtems/score/basedefs.h b/cpukit/include/rtems/score/basedefs.h index 4e48d226e8..8169f6db8c 100644 --- a/cpukit/include/rtems/score/basedefs.h +++ b/cpukit/include/rtems/score/basedefs.h @@ -10,7 +10,7 @@ * COPYRIGHT (c) 1989-2007. * On-Line Applications Research Corporation (OAR). * - * Copyright (c) 2010, 2017 embedded brains GmbH. + * Copyright (c) 2010, 2018 embedded brains GmbH. * * The license and distribution terms for this file may be * found in the file LICENSE in this distribution or at @@ -249,6 +249,38 @@ #define RTEMS_OBFUSCATE_VARIABLE( _var ) (void) (_var) #endif +/** + * @brief Declares a global symbol with the specified name. + * + * This macro must be placed at file scope. + * + * The name must be a valid designator. + */ +#define RTEMS_DECLARE_GLOBAL_SYMBOL( _name ) \ + extern char _name[]; + +/** + * @brief Defines a global symbol with the specified name and value. + * + * This macro must be placed at file scope. + * + * The name must be a valid designator. + * + * On the value parameters macro expansion is performed and afterwards it is + * stringified. It must expand to an integer literal understood by the + * assembler. + */ +#if defined(__GNUC__) + #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) \ + __asm__( \ + "\t.globl " RTEMS_XSTRING( __USER_LABEL_PREFIX__ ) #_name \ + "\n\t.set " RTEMS_XSTRING( __USER_LABEL_PREFIX__ ) #_name \ + ", " RTEMS_STRING( _value ) "\n" \ + ) +#else + #define RTEMS_DEFINE_GLOBAL_SYMBOL( _name, _value ) +#endif + #if __cplusplus >= 201103L #define RTEMS_STATIC_ASSERT(cond, msg) \ static_assert(cond, # msg) -- cgit v1.2.3