diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-06-15 16:53:27 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2018-06-21 11:21:04 +0200 |
commit | fe46647ef5671095d17734792a1dcc675d54d34c (patch) | |
tree | d75f9586408ff4df3de9ccb2dbf4351ddf00e7ab /cpukit/include/rtems | |
parent | stackchk: Add SMP support (diff) | |
download | rtems-fe46647ef5671095d17734792a1dcc675d54d34c.tar.bz2 |
score: Macros to declare and define global symbols
Add RTEMS_DEFINE_GLOBAL_SYMBOL() and add RTEMS_DECLARE_GLOBAL_SYMBOL().
Update #3459.
Diffstat (limited to 'cpukit/include/rtems')
-rw-r--r-- | cpukit/include/rtems/score/basedefs.h | 34 |
1 files changed, 33 insertions, 1 deletions
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) |