summaryrefslogtreecommitdiffstats
path: root/testsuites/sptests
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2015-03-20 10:48:32 -0500
committerJoel Sherrill <joel.sherrill@oarcorp.com>2015-03-24 08:16:34 -0500
commitc6ef8708c308c2f827b435a3b67779a388660594 (patch)
treef7a96e6a6671c6ba061758366665a3343894b3a0 /testsuites/sptests
parentsptests/sp34/changepri.c: Correct printf() warning (diff)
downloadrtems-c6ef8708c308c2f827b435a3b67779a388660594.tar.bz2
sptests/spatomic01/init.c: Avoid integer overflow
Diffstat (limited to 'testsuites/sptests')
-rw-r--r--testsuites/sptests/spatomic01/init.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/testsuites/sptests/spatomic01/init.c b/testsuites/sptests/spatomic01/init.c
index f98c5504ff..fbfd071832 100644
--- a/testsuites/sptests/spatomic01/init.c
+++ b/testsuites/sptests/spatomic01/init.c
@@ -35,13 +35,16 @@ static test_context test_instance;
static void test_static_and_dynamic_initialization(void)
{
- static Atomic_Uint static_uint =
- ATOMIC_INITIALIZER_UINT(0xc01dc0feU);
- static Atomic_Ulong static_ulong =
- ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
- static Atomic_Pointer static_ptr =
- ATOMIC_INITIALIZER_PTR(&static_ptr);
- static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
+ #if (__SIZEOF_INT__ == 2)
+ #define UINT_CONSTANT 0xc0feU
+ #else
+ #define UINT_CONSTANT 0xc01dc0feU
+ #endif
+
+ static Atomic_Uint static_uint = ATOMIC_INITIALIZER_UINT(UINT_CONSTANT);
+ static Atomic_Ulong static_ulong = ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
+ static Atomic_Pointer static_ptr = ATOMIC_INITIALIZER_PTR(&static_ptr);
+ static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
Atomic_Uint stack_uint;
Atomic_Ulong stack_ulong;
@@ -50,7 +53,7 @@ static void test_static_and_dynamic_initialization(void)
puts("=== static and dynamic initialization test case ===");
- _Atomic_Init_uint(&stack_uint, 0xc01dc0feU);
+ _Atomic_Init_uint(&stack_uint, UINT_CONSTANT);
_Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
_Atomic_Init_ptr(&stack_ptr, &static_ptr);
_Atomic_Flag_clear(&stack_flag, ATOMIC_ORDER_RELAXED);