[PATCH 1/4] modify the atomic API to be compatible with C11 stdatomic.h
Deng Hengyi
wei.a.yang at gmail.com
Mon Jun 24 15:22:58 UTC 2013
在 2013-6-24,下午9:20,Gedare Bloom <gedare at rtems.org> 写道:
> I have one specific comment below, and a couple small questions:
> * What are the new types from for example atomic_xxx
The new type is mainly from <stdatomic.h>
> * Why do we still keep the old types (Atomic_Xxx) in some cases but
> replaced in others by standard types? Would it be simpler to just use
> standard types?
>
Because we want to keep the freedom of our atomic API, as you know there are many architectures which are working under UP mode and some of which are not support atomic instructions. In order to keep the API unified we still keep the exist API and replace the SMP atomic implementation with <stdatomic.h>.
And now Sebastian is defining the new atomic requirement, it also will be modified later.
>> diff --git a/cpukit/score/include/rtems/score/genericcpuatomic.h b/cpukit/score/include/rtems/score/genericcpuatomic.h
>> index 2599d0d..ed5868a 100644
>> --- a/cpukit/score/include/rtems/score/genericcpuatomic.h
>> +++ b/cpukit/score/include/rtems/score/genericcpuatomic.h
>> @@ -16,6 +16,7 @@
>> #define _RTEMS_SCORE_GEMERAL_ATOMIC_CPU_H
>>
>> #include <stdint.h>
>> +#include <stdatomic.h>
>>
>> #ifdef __cplusplus
>> extern "C" {
>> @@ -31,27 +32,37 @@ extern "C" {
>> /**
>> * @brief atomic operation unsigned integer type
>> */
>> -typedef unsigned int Atomic_Int;
>> +//typedef unsigned int Atomic_Int;
>> +//typedef _Atomic(unsigned int) Atomic_Int;
>> +typedef atomic_uint Atomic_Int;
>>
> Is there a reason to keep the commented out lines here and below, or
> can they be deleted?
>
>> /**
>> * @brief atomic operation unsigned long integer type
>> */
>> -typedef unsigned long Atomic_Long;
>> +//typedef unsigned long Atomic_Long;
>> +//typedef _Atomic(unsigned long) Atomic_Long;
>> +typedef atomic_ulong Atomic_Long;
>>
>> /**
>> * @brief atomic operation unsigned 32-bit integer type
>> */
>> -typedef uint32_t Atomic_Int32;
>> +//typedef uint32_t Atomic_Int32;
>> +//typedef _Atomic(uint32_t) Atomic_Int32;
>> +typedef atomic_uint_least32_t Atomic_Int32;
>>
>> /**
>> * @brief atomic operation unsigned 64-bit integer type
>> */
>> -typedef uint64_t Atomic_Int64;
>> +//typedef uint64_t Atomic_Int64;
>> +//typedef _Atomic(uint64_t) Atomic_Int64;
>> +typedef atomic_uint_least64_t Atomic_Int64;
>>
>> /**
>> * @brief atomic operation unsigned integer the size of a pointer type
>> */
>> -typedef uintptr_t Atomic_Pointer;
>> +//typedef uintptr_t Atomic_Pointer;
>> +//typedef _Atomic(uintptr_t) Atomic_Pointer;
>> +typedef atomic_uintptr_t Atomic_Pointer;
>>
>> #ifdef __cplusplus
>> }
More information about the devel
mailing list