[PATCH 1/6] add atomic init function

WeiY wei.a.yang at gmail.com
Sun Aug 25 13:45:41 UTC 2013


---
 cpukit/score/include/rtems/score/atomic.h       |   37 ++++++++++++++++++++++
 cpukit/score/include/rtems/score/cpustdatomic.h |   38 +++++++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/cpukit/score/include/rtems/score/atomic.h b/cpukit/score/include/rtems/score/atomic.h
index d94ac92..d51e733 100644
--- a/cpukit/score/include/rtems/score/atomic.h
+++ b/cpukit/score/include/rtems/score/atomic.h
@@ -32,6 +32,43 @@ extern "C" {
 /**@{*/
 
 /**
+ * @brief atomic data initializer for static initialization.
+ */
+#define ATOMIC_INITIALIZER_UINT(value) CPU_ATOMIC_INITIALIZER_UINT(value)
+#define ATOMIC_INITIALIZER_PTR(value) CPU_ATOMIC_INITIALIZER_PTR(value)
+#define ATOMIC_INITIALIZER_FLAG(value) CPU_ATOMIC_INITIALIZER_FLAG(value)
+
+/**
+ * @brief Initializes an atomic type value into a atomic object.
+ *
+ * @param object an atomic type pointer of object.
+ * @param value a value to be stored into object.
+ */
+RTEMS_INLINE_ROUTINE void _Atomic_Init_uint(
+  volatile Atomic_Uint *object,
+  uint_fast32_t value
+)
+{
+  _CPU_atomic_Init_uint(object, value);
+}
+
+RTEMS_INLINE_ROUTINE void _Atomic_Init_ptr(
+  volatile Atomic_Pointer *object,
+  uintptr_t value
+)
+{
+  _CPU_atomic_Init_ptr(object, value);
+}
+
+RTEMS_INLINE_ROUTINE void _Atomic_Init_flag(
+  volatile Atomic_Flag *object,
+  _Bool value
+)
+{
+  _CPU_atomic_Init_flag(object, value);
+}
+
+/**
  * @brief Atomically load an atomic type value from atomic object.
  *
  * @param object an atomic type pointer of object.
diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h b/cpukit/score/include/rtems/score/cpustdatomic.h
index 243a834..5e4f910 100644
--- a/cpukit/score/include/rtems/score/cpustdatomic.h
+++ b/cpukit/score/include/rtems/score/cpustdatomic.h
@@ -67,6 +67,44 @@ typedef enum {
   ATOMIC_ORDER_RELEASE = memory_order_release
 } Atomic_Order;
 
+
+/**
+ * @brief atomic data initializer for static initialization.
+ */
+#define CPU_ATOMIC_INITIALIZER_UINT(value) ATOMIC_VAR_INIT(value)
+#define CPU_ATOMIC_INITIALIZER_PTR(value) ATOMIC_VAR_INIT(value)
+#define CPU_ATOMIC_INITIALIZER_FLAG(value) ATOMIC_VAR_INIT(value)
+
+/**
+ * @brief Initializes an atomic type value into a atomic object.
+ *
+ * @param object an atomic type pointer of object.
+ * @param value a value to be stored into object.
+ */
+RTEMS_INLINE_ROUTINE void _CPU_atomic_Init_uint(
+  volatile Atomic_Uint *object,
+  uint_fast32_t value
+)
+{
+  atomic_init(object, value);
+}
+
+RTEMS_INLINE_ROUTINE void _CPU_atomic_Init_ptr(
+  volatile Atomic_Pointer *object,
+  uintptr_t value
+)
+{
+  atomic_init(object, value);
+}
+
+RTEMS_INLINE_ROUTINE void _CPU_atomic_Init_flag(
+  volatile Atomic_Flag *object,
+  _Bool value
+)
+{
+  atomic_init(object, value);
+}
+
 /**
  * @brief Atomically load an atomic type value from atomic object.
  *
-- 
1.7.9.5




More information about the devel mailing list