[PATCH 1/6] add atomic init function
WeiY
wei.a.yang at gmail.com
Mon Aug 19 15:39:43 UTC 2013
---
cpukit/score/include/rtems/score/atomic.h | 27 ++++++++++++++++++++++
cpukit/score/include/rtems/score/cpustdatomic.h | 28 +++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/cpukit/score/include/rtems/score/atomic.h b/cpukit/score/include/rtems/score/atomic.h
index d94ac92..db70fe8 100644
--- a/cpukit/score/include/rtems/score/atomic.h
+++ b/cpukit/score/include/rtems/score/atomic.h
@@ -32,6 +32,33 @@ extern "C" {
/**@{*/
/**
+ * @brief atomic data initializer for static initialization.
+ */
+#define ATOMIC_VAR_INITIALIZER(value) CPU_ATOMIC_INITIALIZER(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);
+}
+
+/**
* @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..7de7ebb 100644
--- a/cpukit/score/include/rtems/score/cpustdatomic.h
+++ b/cpukit/score/include/rtems/score/cpustdatomic.h
@@ -67,6 +67,34 @@ typedef enum {
ATOMIC_ORDER_RELEASE = memory_order_release
} Atomic_Order;
+
+/**
+ * @brief atomic data initializer for static initialization.
+ */
+#define CPU_ATOMIC_INITIALIZER(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);
+}
+
/**
* @brief Atomically load an atomic type value from atomic object.
*
--
1.7.9.5
More information about the devel
mailing list