summaryrefslogtreecommitdiffstats
path: root/cpukit/score/include/rtems/score/cpustdatomic.h
diff options
context:
space:
mode:
authorWeiY <wei.a.yang@gmail.com>2013-08-25 21:45:41 +0800
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-08-28 14:58:50 +0200
commit697d31e660599bc8c93fba27b9d8725729a697b7 (patch)
tree033421331b9d11a75caa32847a8e82b96b962d0d /cpukit/score/include/rtems/score/cpustdatomic.h
parentposix: Avoid NULL pointer access (diff)
downloadrtems-697d31e660599bc8c93fba27b9d8725729a697b7.tar.bz2
add atomic init function
Diffstat (limited to 'cpukit/score/include/rtems/score/cpustdatomic.h')
-rw-r--r--cpukit/score/include/rtems/score/cpustdatomic.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/cpukit/score/include/rtems/score/cpustdatomic.h b/cpukit/score/include/rtems/score/cpustdatomic.h
index 243a8349dd..5e4f910434 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.
*