summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2018-06-15 16:53:27 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2018-06-21 11:21:04 +0200
commitfe46647ef5671095d17734792a1dcc675d54d34c (patch)
treed75f9586408ff4df3de9ccb2dbf4351ddf00e7ab /cpukit
parentstackchk: Add SMP support (diff)
downloadrtems-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')
-rw-r--r--cpukit/include/rtems/score/basedefs.h34
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)