summaryrefslogtreecommitdiff
path: root/system_wrappers/source/atomic32_mac.cc
diff options
context:
space:
mode:
authorandrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2012-10-22 18:19:23 +0000
committerandrew@webrtc.org <andrew@webrtc.org@4adac7df-926f-26a2-2b94-8c16560cd09d>2012-10-22 18:19:23 +0000
commitb015cbede88899f67a53fbbe581b02ce8e327949 (patch)
tree530a64a3cfdbbabacab974c183326517d49e761e /system_wrappers/source/atomic32_mac.cc
downloadwebrtc-b015cbede88899f67a53fbbe581b02ce8e327949.tar.gz
Move src/ -> webrtc/
TBR=niklas.enbom@webrtc.org Review URL: https://webrtc-codereview.appspot.com/915006 git-svn-id: http://webrtc.googlecode.com/svn/trunk/webrtc@2963 4adac7df-926f-26a2-2b94-8c16560cd09d
Diffstat (limited to 'system_wrappers/source/atomic32_mac.cc')
-rw-r--r--system_wrappers/source/atomic32_mac.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/system_wrappers/source/atomic32_mac.cc b/system_wrappers/source/atomic32_mac.cc
new file mode 100644
index 00000000..9a493b58
--- /dev/null
+++ b/system_wrappers/source/atomic32_mac.cc
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
+ *
+ * Use of this source code is governed by a BSD-style license
+ * that can be found in the LICENSE file in the root of the source
+ * tree. An additional intellectual property rights grant can be found
+ * in the file PATENTS. All contributing project authors may
+ * be found in the AUTHORS file in the root of the source tree.
+ */
+
+#include "atomic32.h"
+
+#include <assert.h>
+#include <libkern/OSAtomic.h>
+#include <stdlib.h>
+
+#include "common_types.h"
+
+namespace webrtc {
+
+Atomic32::Atomic32(WebRtc_Word32 initialValue) : _value(initialValue)
+{
+ assert(Is32bitAligned());
+}
+
+Atomic32::~Atomic32()
+{
+}
+
+WebRtc_Word32 Atomic32::operator++()
+{
+ return OSAtomicIncrement32Barrier(&_value);
+}
+
+WebRtc_Word32 Atomic32::operator--()
+{
+ return OSAtomicDecrement32Barrier(&_value);
+}
+
+WebRtc_Word32 Atomic32::operator+=(WebRtc_Word32 value)
+{
+ return OSAtomicAdd32Barrier(value, &_value);
+}
+
+WebRtc_Word32 Atomic32::operator-=(WebRtc_Word32 value)
+{
+ return OSAtomicAdd32Barrier(-value, &_value);
+}
+
+bool Atomic32::CompareExchange(WebRtc_Word32 newValue,
+ WebRtc_Word32 compareValue)
+{
+ return OSAtomicCompareAndSwap32Barrier(compareValue, newValue, &_value);
+}
+
+WebRtc_Word32 Atomic32::Value() const
+{
+ return _value;
+}
+} // namespace webrtc