Changeset c6ef870 in rtems


Ignore:
Timestamp:
Mar 20, 2015, 3:48:32 PM (5 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.11, master
Children:
2fe0f16d
Parents:
70757114
git-author:
Joel Sherrill <joel.sherrill@…> (03/20/15 15:48:32)
git-committer:
Joel Sherrill <joel.sherrill@…> (03/24/15 13:16:34)
Message:

sptests/spatomic01/init.c: Avoid integer overflow

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/sptests/spatomic01/init.c

    r70757114 rc6ef870  
    3636static void test_static_and_dynamic_initialization(void)
    3737{
    38   static Atomic_Uint static_uint =
    39     ATOMIC_INITIALIZER_UINT(0xc01dc0feU);
    40   static Atomic_Ulong static_ulong =
    41     ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
    42   static Atomic_Pointer static_ptr =
    43     ATOMIC_INITIALIZER_PTR(&static_ptr);
    44   static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
     38  #if (__SIZEOF_INT__ == 2)
     39    #define UINT_CONSTANT 0xc0feU
     40  #else
     41    #define UINT_CONSTANT 0xc01dc0feU
     42  #endif
     43
     44  static Atomic_Uint static_uint   = ATOMIC_INITIALIZER_UINT(UINT_CONSTANT);
     45  static Atomic_Ulong static_ulong = ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
     46  static Atomic_Pointer static_ptr = ATOMIC_INITIALIZER_PTR(&static_ptr);
     47  static Atomic_Flag static_flag  = ATOMIC_INITIALIZER_FLAG;
    4548
    4649  Atomic_Uint stack_uint;
     
    5154  puts("=== static and dynamic initialization test case ===");
    5255
    53   _Atomic_Init_uint(&stack_uint, 0xc01dc0feU);
     56  _Atomic_Init_uint(&stack_uint, UINT_CONSTANT);
    5457  _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
    5558  _Atomic_Init_ptr(&stack_ptr, &static_ptr);
Note: See TracChangeset for help on using the changeset viewer.