Changeset 945853b7 in rtems
 Timestamp:
 Feb 13, 2014, 2:38:52 PM (6 years ago)
 Branches:
 4.11, 5, master
 Children:
 ad56361
 Parents:
 cd2c655
 gitauthor:
 Sebastian Huber <sebastian.huber@…> (02/13/14 14:38:52)
 gitcommitter:
 Sebastian Huber <sebastian.huber@…> (02/14/14 09:28:30)
 Files:

 3 edited
Legend:
 Unmodified
 Added
 Removed

cpukit/score/include/rtems/score/atomic.h
rcd2c655 r945853b7 35 35 * @brief atomic data initializer for static initialization. 36 36 */ 37 #define ATOMIC_INITIALIZER_UINT(value) CPU_ATOMIC_INITIALIZER_UINT(value) 37 38 #define ATOMIC_INITIALIZER_ULONG(value) CPU_ATOMIC_INITIALIZER_ULONG(value) 38 39 #define ATOMIC_INITIALIZER_PTR(value) CPU_ATOMIC_INITIALIZER_PTR(value) … … 49 50 * @param pointer a pointer to be stored into object. 50 51 */ 52 static inline void _Atomic_Init_uint( 53 volatile Atomic_Uint *object, 54 unsigned int value 55 ) 56 { 57 _CPU_atomic_Init_uint(object, value); 58 } 59 51 60 static inline void _Atomic_Init_ulong( 52 61 volatile Atomic_Ulong *object, … … 73 82 * The order shall not be ATOMIC_ORDER_RELEASE. 74 83 */ 84 static inline unsigned int _Atomic_Load_uint( 85 volatile Atomic_Uint *object, 86 Atomic_Order order 87 ) 88 { 89 return _CPU_atomic_Load_uint( object, order ); 90 } 91 75 92 static inline unsigned long _Atomic_Load_ulong( 76 93 volatile Atomic_Ulong *object, … … 98 115 * The order shall not be ATOMIC_ORDER_ACQUIRE. 99 116 */ 117 static inline void _Atomic_Store_uint( 118 volatile Atomic_Uint *object, 119 unsigned int value, 120 Atomic_Order order 121 ) 122 { 123 _CPU_atomic_Store_uint( object, value, order ); 124 } 125 100 126 static inline void _Atomic_Store_ulong( 101 127 volatile Atomic_Ulong *object, … … 125 151 * @retval a result value before add ops. 126 152 */ 153 static inline unsigned int _Atomic_Fetch_add_uint( 154 volatile Atomic_Uint *object, 155 unsigned int value, 156 Atomic_Order order 157 ) 158 { 159 return _CPU_atomic_Fetch_add_uint( object, value, order ); 160 } 161 127 162 static inline unsigned long _Atomic_Fetch_add_ulong( 128 163 volatile Atomic_Ulong *object, … … 152 187 * @retval a result value before sub ops. 153 188 */ 189 static inline unsigned int _Atomic_Fetch_sub_uint( 190 volatile Atomic_Uint *object, 191 unsigned int value, 192 Atomic_Order order 193 ) 194 { 195 return _CPU_atomic_Fetch_sub_uint( object, value, order ); 196 } 197 154 198 static inline unsigned long _Atomic_Fetch_sub_ulong( 155 199 volatile Atomic_Ulong *object, … … 179 223 * @retval a result value before or ops. 180 224 */ 225 static inline unsigned int _Atomic_Fetch_or_uint( 226 volatile Atomic_Uint *object, 227 unsigned int value, 228 Atomic_Order order 229 ) 230 { 231 return _CPU_atomic_Fetch_or_uint( object, value, order ); 232 } 233 181 234 static inline unsigned long _Atomic_Fetch_or_ulong( 182 235 volatile Atomic_Ulong *object, … … 206 259 * @retval a result value before and ops. 207 260 */ 261 static inline unsigned int _Atomic_Fetch_and_uint( 262 volatile Atomic_Uint *object, 263 unsigned int value, 264 Atomic_Order order 265 ) 266 { 267 return _CPU_atomic_Fetch_and_uint( object, value, order ); 268 } 269 208 270 static inline unsigned long _Atomic_Fetch_and_ulong( 209 271 volatile Atomic_Ulong *object, … … 233 295 * @retval a result value before exchange ops. 234 296 */ 297 static inline unsigned int _Atomic_Exchange_uint( 298 volatile Atomic_Uint *object, 299 unsigned int value, 300 Atomic_Order order 301 ) 302 { 303 return _CPU_atomic_Exchange_uint( object, value, order ); 304 } 305 235 306 static inline unsigned long _Atomic_Exchange_ulong( 236 307 volatile Atomic_Ulong *object, … … 265 336 * @retval false if the compare exchange failed. 266 337 */ 338 static inline bool _Atomic_Compare_exchange_uint( 339 volatile Atomic_Uint *object, 340 unsigned int *old_value, 341 unsigned int new_value, 342 Atomic_Order order_succ, 343 Atomic_Order order_fail 344 ) 345 { 346 return _CPU_atomic_Compare_exchange_uint( object, old_value, new_value, 347 order_succ, order_fail ); 348 } 349 267 350 static inline bool _Atomic_Compare_exchange_ulong( 268 351 volatile Atomic_Ulong *object, 
cpukit/score/include/rtems/score/cpustdatomic.h
rcd2c655 r945853b7 35 35 /** 36 36 * @brief atomic operation unsigned integer type 37 */ 38 typedef atomic_uint Atomic_Uint; 39 40 /** 41 * @brief atomic operation unsigned long integer type 37 42 */ 38 43 typedef atomic_ulong Atomic_Ulong; … … 72 77 * @brief atomic data initializer for static initialization. 73 78 */ 79 #define CPU_ATOMIC_INITIALIZER_UINT(value) ATOMIC_VAR_INIT(value) 74 80 #define CPU_ATOMIC_INITIALIZER_ULONG(value) ATOMIC_VAR_INIT(value) 75 81 #define CPU_ATOMIC_INITIALIZER_PTR(pointer) \ … … 84 90 * @param value a value to be stored into object. 85 91 */ 92 static inline void _CPU_atomic_Init_uint( 93 volatile Atomic_Uint *object, 94 unsigned int value 95 ) 96 { 97 atomic_init( object, value ); 98 } 99 86 100 static inline void _CPU_atomic_Init_ulong( 87 101 volatile Atomic_Ulong *object, … … 108 122 * The order shall not be ATOMIC_ORDER_RELEASE. 109 123 */ 124 static inline unsigned int _CPU_atomic_Load_uint( 125 volatile Atomic_Uint *object, 126 Atomic_Order order 127 ) 128 { 129 return atomic_load_explicit( object, (memory_order) order ); 130 } 131 110 132 static inline unsigned long _CPU_atomic_Load_ulong( 111 133 volatile Atomic_Ulong *object, … … 133 155 * The order shall not be ATOMIC_ORDER_ACQUIRE. 134 156 */ 157 static inline void _CPU_atomic_Store_uint( 158 volatile Atomic_Uint *object, 159 unsigned int value, 160 Atomic_Order order 161 ) 162 { 163 atomic_store_explicit( object, value, (memory_order) order ); 164 } 165 135 166 static inline void _CPU_atomic_Store_ulong( 136 167 volatile Atomic_Ulong *object, … … 160 191 * @retval a result value before add ops. 161 192 */ 193 static inline unsigned int _CPU_atomic_Fetch_add_uint( 194 volatile Atomic_Uint *object, 195 unsigned int value, 196 Atomic_Order order 197 ) 198 { 199 return atomic_fetch_add_explicit( object, value, (memory_order) order ); 200 } 201 162 202 static inline unsigned long _CPU_atomic_Fetch_add_ulong( 163 203 volatile Atomic_Ulong *object, … … 187 227 * @retval a result value before sub ops. 188 228 */ 229 static inline unsigned int _CPU_atomic_Fetch_sub_uint( 230 volatile Atomic_Uint *object, 231 unsigned int value, 232 Atomic_Order order 233 ) 234 { 235 return atomic_fetch_sub_explicit( object, value, (memory_order) order ); 236 } 237 189 238 static inline unsigned long _CPU_atomic_Fetch_sub_ulong( 190 239 volatile Atomic_Ulong *object, … … 214 263 * @retval a result value before or ops. 215 264 */ 265 static inline unsigned int _CPU_atomic_Fetch_or_uint( 266 volatile Atomic_Uint *object, 267 unsigned int value, 268 Atomic_Order order 269 ) 270 { 271 return atomic_fetch_or_explicit( object, value, (memory_order) order ); 272 } 273 216 274 static inline unsigned long _CPU_atomic_Fetch_or_ulong( 217 275 volatile Atomic_Ulong *object, … … 241 299 * @retval a result value before and ops. 242 300 */ 301 static inline unsigned int _CPU_atomic_Fetch_and_uint( 302 volatile Atomic_Uint *object, 303 unsigned int value, 304 Atomic_Order order 305 ) 306 { 307 return atomic_fetch_and_explicit( object, value, (memory_order) order ); 308 } 309 243 310 static inline unsigned long _CPU_atomic_Fetch_and_ulong( 244 311 volatile Atomic_Ulong *object, … … 268 335 * @retval a result value before exchange ops. 269 336 */ 337 static inline unsigned int _CPU_atomic_Exchange_uint( 338 volatile Atomic_Uint *object, 339 unsigned int value, 340 Atomic_Order order 341 ) 342 { 343 return atomic_exchange_explicit( object, value, (memory_order) order ); 344 } 345 270 346 static inline unsigned long _CPU_atomic_Exchange_ulong( 271 347 volatile Atomic_Ulong *object, … … 304 380 * @retval false if the compare exchange failed. 305 381 */ 382 static inline bool _CPU_atomic_Compare_exchange_uint( 383 volatile Atomic_Uint *object, 384 unsigned int *old_value, 385 unsigned int new_value, 386 Atomic_Order order_succ, 387 Atomic_Order order_fail 388 ) 389 { 390 return atomic_compare_exchange_strong_explicit( object, old_value, 391 new_value, order_succ, order_fail ); 392 } 393 306 394 static inline bool _CPU_atomic_Compare_exchange_ulong( 307 395 volatile Atomic_Ulong *object, 
testsuites/smptests/smpatomic01/init.c
rcd2c655 r945853b7 81 81 size_t worker_count; 82 82 rtems_id stop_worker_timer_id; 83 Atomic_Uint atomic_int_value; 83 84 Atomic_Ulong atomic_value; 84 85 unsigned long per_worker_value[CPU_COUNT]; … … 384 385 static void test_static_and_dynamic_initialization(void) 385 386 { 387 static Atomic_Uint static_uint = 388 ATOMIC_INITIALIZER_UINT(0xc01dc0feU); 386 389 static Atomic_Ulong static_ulong = 387 390 ATOMIC_INITIALIZER_ULONG(0xdeadbeefUL); … … 390 393 static Atomic_Flag static_flag = ATOMIC_INITIALIZER_FLAG; 391 394 395 Atomic_Uint stack_uint; 392 396 Atomic_Ulong stack_ulong; 393 397 Atomic_Pointer stack_ptr; … … 396 400 puts("=== static and dynamic initialization test case ==="); 397 401 402 _Atomic_Init_uint(&stack_uint, 0xc01dc0feU); 398 403 _Atomic_Init_ulong(&stack_ulong, 0xdeadbeefUL); 399 404 _Atomic_Init_ptr(&stack_ptr, &static_ptr); … … 401 406 402 407 rtems_test_assert( 408 memcmp(&stack_uint, &static_uint, sizeof(stack_uint)) == 0 409 ); 410 rtems_test_assert( 403 411 memcmp(&stack_ulong, &static_ulong, sizeof(stack_ulong)) == 0 404 412 ); … … 410 418 ); 411 419 420 rtems_test_assert( 421 _Atomic_Load_uint(&stack_uint, ATOMIC_ORDER_RELAXED) == 0xc01dc0feU 422 ); 412 423 rtems_test_assert( 413 424 _Atomic_Load_ulong(&stack_ulong, ATOMIC_ORDER_RELAXED) == 0xdeadbeefUL … … 461 472 static void test_simple_atomic_add_body(test_context *ctx) 462 473 { 474 unsigned int ia = 8, ib = 4; 475 unsigned int ic; 463 476 unsigned long a = 2, b = 1; 464 477 unsigned long c; 465 478 466 479 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)); 467 485 468 486 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); … … 474 492 static void test_simple_atomic_sub_body(test_context *ctx) 475 493 { 494 unsigned int ia = 8, ib = 4; 495 unsigned int ic; 476 496 unsigned long a = 2, b = 1; 477 497 unsigned long c; 478 498 479 499 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)); 480 505 481 506 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); … … 487 512 static void test_simple_atomic_or_body(test_context *ctx) 488 513 { 514 unsigned int ia = 8, ib = 4; 515 unsigned int ic; 489 516 unsigned long a = 2, b = 1; 490 517 unsigned long c; 491 518 492 519 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)); 493 525 494 526 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); … … 500 532 static void test_simple_atomic_and_body(test_context *ctx) 501 533 { 534 unsigned int ia = 8, ib = 4; 535 unsigned int ic; 502 536 unsigned long a = 2, b = 1; 503 537 unsigned long c; 504 538 505 539 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)); 506 545 507 546 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); … … 513 552 static void test_simple_atomic_exchange_body(test_context *ctx) 514 553 { 554 unsigned int ia = 8, ib = 4; 555 unsigned int ic; 515 556 unsigned long a = 2, b = 1; 516 557 unsigned long c; 517 558 518 559 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); 519 565 520 566 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED); … … 526 572 static void test_simple_atomic_compare_exchange_body(test_context *ctx) 527 573 { 574 unsigned int ia = 8, ib = 4; 575 unsigned int ic; 528 576 unsigned long a = 2, b = 1; 529 577 unsigned long c; 530 578 531 579 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); 532 586 533 587 _Atomic_Store_ulong(&ctx>atomic_value, a, ATOMIC_ORDER_RELAXED);
Note: See TracChangeset
for help on using the changeset viewer.