mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-05 15:15:44 +00:00
@@ -197,6 +197,18 @@
|
||||
#define RTEMS_ALIAS( _target )
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Instructs the compiler to define a weak function.
|
||||
*
|
||||
* Use this attribute for function definitions. Do not use it for function
|
||||
* declarations.
|
||||
*/
|
||||
#if defined(__GNUC__)
|
||||
#define RTEMS_WEAK __attribute__((__weak__))
|
||||
#else
|
||||
#define RTEMS_WEAK
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Instructs the compiler to generate a weak alias to the specified
|
||||
* target function.
|
||||
|
||||
@@ -1409,7 +1409,7 @@ if TEST_spmisc01
|
||||
sp_tests += spmisc01
|
||||
sp_screens += spmisc01/spmisc01.scn
|
||||
sp_docs += spmisc01/spmisc01.doc
|
||||
spmisc01_SOURCES = spmisc01/init.c
|
||||
spmisc01_SOURCES = spmisc01/init.c spmisc01/strong.c
|
||||
spmisc01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_spmisc01) \
|
||||
$(support_includes)
|
||||
endif
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include <tmacros.h>
|
||||
|
||||
#include "spmisc01.h"
|
||||
|
||||
const char rtems_test_name[] = "SPMISC 1";
|
||||
|
||||
RTEMS_INLINE_ROUTINE int inline_func(void)
|
||||
@@ -70,6 +72,16 @@ static int alias_func(void) RTEMS_ALIAS(noinline_func);
|
||||
|
||||
int weak_alias_func(void) RTEMS_WEAK_ALIAS(noinline_func);
|
||||
|
||||
RTEMS_WEAK int weak_or_strong(void)
|
||||
{
|
||||
return 99;
|
||||
}
|
||||
|
||||
RTEMS_WEAK int weak_2(void)
|
||||
{
|
||||
return 111;
|
||||
}
|
||||
|
||||
static char aligned_variable RTEMS_ALIGNED(64);
|
||||
|
||||
typedef struct {
|
||||
@@ -205,6 +217,9 @@ static void Init(rtems_task_argument arg)
|
||||
rtems_test_assert(sizeof(packed_struct) == 5);
|
||||
rtems_test_assert(alias_func() == 14);
|
||||
rtems_test_assert(weak_alias_func() == 14);
|
||||
pull_in_strong();
|
||||
rtems_test_assert(weak_or_strong() == 77);
|
||||
rtems_test_assert(weak_2() == 111);
|
||||
rtems_test_assert(((uintptr_t) &aligned_variable) % 64 == 0);
|
||||
rtems_test_assert(offsetof(aligned_member_struct, aligned_member) % 64 == 0);
|
||||
unreachable();
|
||||
|
||||
45
testsuites/sptests/spmisc01/spmisc01.h
Normal file
45
testsuites/sptests/spmisc01/spmisc01.h
Normal file
@@ -0,0 +1,45 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _SPMISC01_H
|
||||
#define _SPMISC01_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
int weak_or_strong(void);
|
||||
|
||||
void pull_in_strong(void);
|
||||
|
||||
int weak_2(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SPMISC01_H */
|
||||
47
testsuites/sptests/spmisc01/strong.c
Normal file
47
testsuites/sptests/spmisc01/strong.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* SPDX-License-Identifier: BSD-2-Clause */
|
||||
|
||||
/*
|
||||
* Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include "spmisc01.h"
|
||||
|
||||
int weak_or_strong(void)
|
||||
{
|
||||
return 77;
|
||||
}
|
||||
|
||||
void pull_in_strong(void)
|
||||
{
|
||||
/* Do nothing */
|
||||
}
|
||||
|
||||
RTEMS_WEAK int weak_2(void)
|
||||
{
|
||||
return 222;
|
||||
}
|
||||
Reference in New Issue
Block a user