Ignore:
Timestamp:
Feb 13, 2014, 2:38:52 PM (6 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, 5, master
Children:
ad56361
Parents:
cd2c655
git-author:
Sebastian Huber <sebastian.huber@…> (02/13/14 14:38:52)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/14/14 09:28:30)
Message:

score: Add Atomic_Uint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • testsuites/smptests/smpatomic01/init.c

    rcd2c655 r945853b7  
    8181  size_t worker_count;
    8282  rtems_id stop_worker_timer_id;
     83  Atomic_Uint atomic_int_value;
    8384  Atomic_Ulong atomic_value;
    8485  unsigned long per_worker_value[CPU_COUNT];
     
    384385static void test_static_and_dynamic_initialization(void)
    385386{
     387  static Atomic_Uint static_uint =
     388    ATOMIC_INITIALIZER_UINT(0xc01dc0feU);
    386389  static Atomic_Ulong static_ulong =
    387390    ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL);
     
    390393  static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG;
    391394
     395  Atomic_Uint stack_uint;
    392396  Atomic_Ulong stack_ulong;
    393397  Atomic_Pointer stack_ptr;
     
    396400  puts("=== static and dynamic initialization test case ===");
    397401
     402  _Atomic_Init_uint(&stack_uint, 0xc01dc0feU);
    398403  _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL);
    399404  _Atomic_Init_ptr(&stack_ptr, &static_ptr);
     
    401406
    402407  rtems_test_assert(
     408    memcmp(&stack_uint, &static_uint, sizeof(stack_uint)) == 0
     409  );
     410  rtems_test_assert(
    403411    memcmp(&stack_ulong, &static_ulong, sizeof(stack_ulong)) == 0
    404412  );
     
    410418  );
    411419
     420  rtems_test_assert(
     421    _Atomic_Load_uint(&stack_uint, ATOMIC_ORDER_RELAXED) == 0xc01dc0feU
     422  );
    412423  rtems_test_assert(
    413424    _Atomic_Load_ulong(&stack_ulong, ATOMIC_ORDER_RELAXED) == 0xdeadbeefUL
     
    461472static void test_simple_atomic_add_body(test_context *ctx)
    462473{
     474  unsigned int ia = 8, ib = 4;
     475  unsigned int ic;
    463476  unsigned long a = 2, b = 1;
    464477  unsigned long c;
    465478
    466479  puts("=== atomic simple add test case ==\n");
     480
     481  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
     482  _Atomic_Fetch_add_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
     483  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
     484  rtems_test_assert(ic == (ia + ib));
    467485
    468486  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
     
    474492static void test_simple_atomic_sub_body(test_context *ctx)
    475493{
     494  unsigned int ia = 8, ib = 4;
     495  unsigned int ic;
    476496  unsigned long a = 2, b = 1;
    477497  unsigned long c;
    478498
    479499  puts("=== atomic simple sub test case ==\n");
     500
     501  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
     502  _Atomic_Fetch_sub_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
     503  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
     504  rtems_test_assert(ic == (ia - ib));
    480505
    481506  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
     
    487512static void test_simple_atomic_or_body(test_context *ctx)
    488513{
     514  unsigned int ia = 8, ib = 4;
     515  unsigned int ic;
    489516  unsigned long a = 2, b = 1;
    490517  unsigned long c;
    491518
    492519  puts("=== atomic simple or test case ==\n");
     520
     521  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
     522  _Atomic_Fetch_or_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
     523  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
     524  rtems_test_assert(ic == (ia | ib));
    493525
    494526  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
     
    500532static void test_simple_atomic_and_body(test_context *ctx)
    501533{
     534  unsigned int ia = 8, ib = 4;
     535  unsigned int ic;
    502536  unsigned long a = 2, b = 1;
    503537  unsigned long c;
    504538
    505539  puts("=== atomic simple and test case ==\n");
     540
     541  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
     542  _Atomic_Fetch_and_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
     543  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
     544  rtems_test_assert(ic == (ia & ib));
    506545
    507546  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
     
    513552static void test_simple_atomic_exchange_body(test_context *ctx)
    514553{
     554  unsigned int ia = 8, ib = 4;
     555  unsigned int ic;
    515556  unsigned long a = 2, b = 1;
    516557  unsigned long c;
    517558
    518559  puts("=== atomic simple exchange test case ==\n");
     560
     561  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
     562  _Atomic_Exchange_uint(&ctx->atomic_int_value, ib, ATOMIC_ORDER_RELAXED);
     563  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
     564  rtems_test_assert(ic == ib);
    519565
    520566  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
     
    526572static void test_simple_atomic_compare_exchange_body(test_context *ctx)
    527573{
     574  unsigned int ia = 8, ib = 4;
     575  unsigned int ic;
    528576  unsigned long a = 2, b = 1;
    529577  unsigned long c;
    530578
    531579  puts("=== atomic simple compare exchange test case ==\n");
     580
     581  _Atomic_Store_uint(&ctx->atomic_int_value, ia, ATOMIC_ORDER_RELAXED);
     582  _Atomic_Compare_exchange_uint(&ctx->atomic_int_value, &ia, ib,
     583    ATOMIC_ORDER_RELAXED, ATOMIC_ORDER_RELAXED);
     584  ic = _Atomic_Load_uint(&ctx->atomic_int_value, ATOMIC_ORDER_RELAXED);
     585  rtems_test_assert(ic == ib);
    532586
    533587  _Atomic_Store_ulong(&ctx->atomic_value, a, ATOMIC_ORDER_RELAXED);
Note: See TracChangeset for help on using the changeset viewer.