forked from Imagelibrary/rtems
score: Macros to declare and define global symbols
Add RTEMS_DEFINE_GLOBAL_SYMBOL() and add RTEMS_DECLARE_GLOBAL_SYMBOL(). Update #3459.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -1493,6 +1493,15 @@ spmkdir_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spmkdir) \
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_spmisc01
|
||||
sp_tests += spmisc01
|
||||
sp_screens += spmisc01/spmisc01.scn
|
||||
sp_docs += spmisc01/spmisc01.doc
|
||||
spmisc01_SOURCES = spmisc01/init.c
|
||||
spmisc01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spmisc01) \
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
if TEST_spmountmgr01
|
||||
sp_tests += spmountmgr01
|
||||
sp_screens += spmountmgr01/spmountmgr01.scn
|
||||
|
||||
@@ -194,6 +194,7 @@ RTEMS_TEST_CHECK([spintrcritical23])
|
||||
RTEMS_TEST_CHECK([spintrcritical24])
|
||||
RTEMS_TEST_CHECK([splinkersets01])
|
||||
RTEMS_TEST_CHECK([spmkdir])
|
||||
RTEMS_TEST_CHECK([spmisc01])
|
||||
RTEMS_TEST_CHECK([spmountmgr01])
|
||||
RTEMS_TEST_CHECK([spmrsp01])
|
||||
RTEMS_TEST_CHECK([spmsgq_err01])
|
||||
|
||||
49
testsuites/sptests/spmisc01/init.c
Normal file
49
testsuites/sptests/spmisc01/init.c
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) 2018 embedded brains GmbH. All rights reserved.
|
||||
*
|
||||
* embedded brains GmbH
|
||||
* Dornierstr. 4
|
||||
* 82178 Puchheim
|
||||
* Germany
|
||||
* <rtems@embedded-brains.de>
|
||||
*
|
||||
* The license and distribution terms for this file may be
|
||||
* found in the file LICENSE in this distribution or at
|
||||
* http://www.rtems.org/license/LICENSE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <rtems.h>
|
||||
|
||||
#include <tmacros.h>
|
||||
|
||||
const char rtems_test_name[] = "SPMISC 1";
|
||||
|
||||
RTEMS_DECLARE_GLOBAL_SYMBOL(a_global_symbol);
|
||||
|
||||
RTEMS_DEFINE_GLOBAL_SYMBOL(a_global_symbol, 0xabc);
|
||||
|
||||
static void Init(rtems_task_argument arg)
|
||||
{
|
||||
TEST_BEGIN();
|
||||
rtems_test_assert((uintptr_t)a_global_symbol == 0xabc);
|
||||
TEST_END();
|
||||
rtems_test_exit(0);
|
||||
}
|
||||
|
||||
#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
|
||||
|
||||
#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
|
||||
|
||||
#define CONFIGURE_MAXIMUM_TASKS 1
|
||||
|
||||
#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
|
||||
|
||||
#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
|
||||
|
||||
#define CONFIGURE_INIT
|
||||
|
||||
#include <rtems/confdefs.h>
|
||||
13
testsuites/sptests/spmisc01/spmisc01.doc
Normal file
13
testsuites/sptests/spmisc01/spmisc01.doc
Normal file
@@ -0,0 +1,13 @@
|
||||
This file describes the directives and concepts tested by this test set.
|
||||
|
||||
test set name: spbasedefs01
|
||||
|
||||
directives:
|
||||
|
||||
- RTEMS_DECLARE_GLOBAL_SYMBOL()
|
||||
- RTEMS_DEFINE_GLOBAL_SYMBOL()
|
||||
|
||||
concepts:
|
||||
|
||||
- Ensure that RTEMS_* defines and macros defined by <rtems/score/basedefs.h>
|
||||
available via <rtems.h> work as expected.
|
||||
2
testsuites/sptests/spmisc01/spmisc01.scn
Normal file
2
testsuites/sptests/spmisc01/spmisc01.scn
Normal file
@@ -0,0 +1,2 @@
|
||||
*** BEGIN OF TEST SPMISC 1 ***
|
||||
*** END OF TEST SPMISC 1 ***
|
||||
Reference in New Issue
Block a user