OSDN Git Service

Enable clang compilation, use stdatomic.h.
authorChih-Hung Hsieh <chh@google.com>
Thu, 13 Aug 2015 19:27:32 +0000 (12:27 -0700)
committerChih-Hung Hsieh <chh@google.com>
Fri, 21 Aug 2015 19:24:03 +0000 (12:24 -0700)
* Remove old atomic.h and atomic_test.cpp.
  Use stdatomi.h in counter.c.
* Suppress warnings on unused variables/parameters.
* Suppress warnings on redefined typedef.

Change-Id: Ic7ec652608f2c9423984a3631fb58efea5a835e7

btcore/Android.mk
btcore/src/counter.c
osi/Android.mk
osi/BUILD.gn
osi/include/atomic.h [deleted file]
osi/src/allocation_tracker.c
osi/src/hash_map.c
osi/test/atomic_test.cpp [deleted file]

index 4120132..aa07cbe 100644 (file)
@@ -46,8 +46,7 @@ btcoreCommonIncludes := \
 # libbtcore static library for target
 # ========================================================
 include $(CLEAR_VARS)
-# osi/include/atomic.h depends on gcc atomic functions
-LOCAL_CLANG := false
+LOCAL_CLANG_CFLAGS += -Wno-error=typedef-redefinition
 LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
 LOCAL_SRC_FILES := $(btcoreCommonSrc)
 LOCAL_CFLAGS := -std=c99 $(bdroid_CFLAGS)
@@ -61,8 +60,7 @@ include $(BUILD_STATIC_LIBRARY)
 # ========================================================
 ifeq ($(HOST_OS),linux)
 include $(CLEAR_VARS)
-# osi/include/atomic.h depends on gcc atomic functions
-LOCAL_CLANG := false
+LOCAL_CLANG_CFLAGS += -Wno-error=typedef-redefinition
 LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
 LOCAL_SRC_FILES := $(btcoreCommonSrc)
 # TODO(armansito): Setting _GNU_SOURCE isn't very platform-independent but
@@ -82,8 +80,7 @@ endif
 # libbtcore unit tests for target
 # ========================================================
 include $(CLEAR_VARS)
-# osi/include/atomic.h depends on gcc atomic functions
-LOCAL_CLANG := false
+LOCAL_CLANG_CFLAGS += -Wno-error=typedef-redefinition
 LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
 LOCAL_SRC_FILES := $(btcoreCommonTestSrc)
 LOCAL_CFLAGS := -Wall -Werror -Werror=unused-variable
@@ -97,8 +94,7 @@ include $(BUILD_NATIVE_TEST)
 # ========================================================
 ifeq ($(HOST_OS),linux)
 include $(CLEAR_VARS)
-# osi/include/atomic.h depends on gcc atomic functions
-LOCAL_CLANG := false
+LOCAL_CLANG_CFLAGS += -Wno-error=typedef-redefinition
 LOCAL_C_INCLUDES := $(btcoreCommonIncludes)
 LOCAL_SRC_FILES := $(btcoreCommonTestSrc)
 LOCAL_CFLAGS := -Wall -Werror -Werror=unused-variable
index 13272cb..e1f3da4 100644 (file)
 #include <fcntl.h>
 #include <pthread.h>
 #include <stdarg.h>
+#include <stdatomic.h>
 #include <string.h>
 #include <sys/eventfd.h>
 
 #include "btcore/include/counter.h"
 #include "btcore/include/module.h"
 #include "osi/include/allocator.h"
-#include "osi/include/atomic.h"
 #include "osi/include/hash_functions.h"
 #include "osi/include/hash_map.h"
 #include "osi/include/list.h"
@@ -41,7 +41,7 @@
 typedef int (*handler_t)(socket_t * socket);
 
 typedef struct counter_t {
-  atomic_s64_t val;
+  _Atomic(int64_t) val;
 } counter_t;
 
 typedef struct hash_element_t {
@@ -157,17 +157,14 @@ void counter_set(const char *name, counter_data_t val) {
   assert(name != NULL);
   counter_t *counter = name_to_counter_(name);
   if (counter)
-    atomic_store_s64(&counter->val, val);
+    atomic_store(&counter->val, val);
 }
 
 void counter_add(const char *name, counter_data_t val) {
   assert(name != NULL);
   counter_t *counter = name_to_counter_(name);
   if (counter) {
-    if (val == 1)
-      atomic_inc_prefix_s64(&counter->val);
-    else
-      atomic_add_s64(&counter->val, val);
+    atomic_fetch_add(&counter->val, val);
   }
 }
 
@@ -187,7 +184,7 @@ static counter_t *counter_new_(counter_data_t initial_val) {
   if (!counter) {
     return NULL;
   }
-  atomic_store_s64(&counter->val, initial_val);
+  atomic_store(&counter->val, initial_val);
   return counter;
 }
 
index 867d48f..473c3fb 100644 (file)
@@ -55,7 +55,6 @@ btosiCommonTestSrc := \
     ./test/allocation_tracker_test.cpp \
     ./test/allocator_test.cpp \
     ./test/array_test.cpp \
-    ./test/atomic_test.cpp \
     ./test/config_test.cpp \
     ./test/data_dispatcher_test.cpp \
     ./test/eager_reader_test.cpp \
@@ -77,7 +76,6 @@ btosiCommonCFlags := -std=c99 -Wall -Werror -fvisibility=hidden
 # libosi static library for target
 # ========================================================
 include $(CLEAR_VARS)
-LOCAL_CLANG := false  # osi/include/atomic.h depends on gcc atomic functions
 LOCAL_C_INCLUDES := $(btosiCommonIncludes)
 LOCAL_SRC_FILES := $(btosiCommonSrc)
 LOCAL_CFLAGS := $(btosiCommonCFlags)
@@ -93,7 +91,6 @@ include $(BUILD_STATIC_LIBRARY)
 # ========================================================
 ifeq ($(HOST_OS),linux)
 include $(CLEAR_VARS)
-LOCAL_CLANG := false  # osi/include/atomic.h depends on gcc atomic functions
 LOCAL_C_INCLUDES := $(btosiCommonIncludes)
 LOCAL_SRC_FILES := $(btosiCommonSrc)
 # TODO(armansito): Setting _GNU_SOURCE isn't very platform-independent but
@@ -117,7 +114,6 @@ endif
 # libosi unit tests for target
 # ========================================================
 include $(CLEAR_VARS)
-LOCAL_CLANG := false  # osi/include/atomic.h depends on gcc atomic functions
 LOCAL_C_INCLUDES := $(btosiCommonIncludes)
 LOCAL_SRC_FILES := $(btosiCommonTestSrc)
 LOCAL_CFLAGS := -Wall
@@ -131,7 +127,6 @@ include $(BUILD_NATIVE_TEST)
 # ========================================================
 ifeq ($(HOST_OS),linux)
 include $(CLEAR_VARS)
-LOCAL_CLANG := false  # osi/include/atomic.h depends on gcc atomic functions
 LOCAL_C_INCLUDES := $(btosiCommonIncludes)
 LOCAL_SRC_FILES := $(btosiCommonTestSrc)
 LOCAL_CFLAGS := -Wall
index 3691e45..af72693 100644 (file)
@@ -61,7 +61,6 @@ executable("net_test_osi") {
     "test/allocation_tracker_test.cpp",
     "test/allocator_test.cpp",
     "test/array_test.cpp",
-    "test/atomic_test.cpp",
     "test/config_test.cpp",
     "test/data_dispatcher_test.cpp",
     "test/eager_reader_test.cpp",
diff --git a/osi/include/atomic.h b/osi/include/atomic.h
deleted file mode 100644 (file)
index a38c9c4..0000000
+++ /dev/null
@@ -1,115 +0,0 @@
-/******************************************************************************
- *
- *  Copyright (C) 2014 Google, Inc.
- *
- *  Licensed under the Apache License, Version 2.0 (the "License");
- *  you may not use this file except in compliance with the License.
- *  You may obtain a copy of the License at:
- *
- *  http://www.apache.org/licenses/LICENSE-2.0
- *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
- *
- ******************************************************************************/
-
-#pragma once
-
-#include <stdbool.h>
-#include <stdint.h>
-
-// Set of atomic operations to work on data structures.
-// The atomic type data should only be manipulated by these functions.
-// This uses the gcc built in functions.
-//  gcc doc section 6.50 "Built-in functions for memory model aware atomic operations"
-//
-// Data types:
-// atomic_<name>_t
-//
-// e.g.
-//  atomic_s32_t for a signed 32 bit integer.
-//  atomic_u32_t for an unsigned 32 bit integer.
-//
-// Functions:
-// atomic_<operation>_<name>(atomic_t *, ...)
-//
-// e.g.
-//  uint32_t atomic_dec_prefix_u32(volatile atomic_u32_t *atomic)
-//
-// The prefix/postfix classification corresponds which value is returned
-// from the function call, the old or the new one.
-
-#if defined(GCC_VERSION) && GCC_VERSION < 40700
-#warning "Atomics not supported"
-#endif
-
-#define ATOMIC_TYPE(name, type) \
-  struct atomic_##name { \
-    type _val; \
-}; \
-typedef struct atomic_##name atomic_##name##_t;
-
-#define ATOMIC_STORE(name, type, sz) \
-static inline void atomic_store_##name(volatile atomic_##name##_t *atomic, type val) { \
-  __atomic_store_##sz(&atomic->_val, val, __ATOMIC_SEQ_CST); \
-}
-
-#define ATOMIC_LOAD(name, type, sz) \
-static inline type atomic_load_##name(volatile atomic_##name##_t *atomic) { \
-  return __atomic_load_##sz(&atomic->_val, __ATOMIC_SEQ_CST); \
-}
-
-// Returns value after operation, e.g. new value
-#define ATOMIC_INC_PREFIX(name, type, sz) \
-static inline type atomic_inc_prefix_##name(volatile atomic_##name##_t *atomic) { \
-  return __atomic_add_fetch_##sz(atomic, 1, __ATOMIC_SEQ_CST); \
-}
-
-// Returns value after operation, e.g. new value
-#define ATOMIC_DEC_PREFIX(name, type, sz) \
-static inline type atomic_dec_prefix_##name(volatile atomic_##name##_t *atomic) { \
-  return __atomic_sub_fetch_##sz(atomic, 1, __ATOMIC_SEQ_CST); \
-}
-
-// Returns value before operation, e.g. old value
-#define ATOMIC_INC_POSTFIX(name, type, sz) \
-static inline type atomic_inc_postfix_##name(volatile atomic_##name##_t *atomic) { \
-  return __atomic_fetch_add_##sz(atomic, 1, __ATOMIC_SEQ_CST); \
-}
-
-// Returns value before operation, e.g. old value
-#define ATOMIC_DEC_POSTFIX(name, type, sz) \
-static inline type atomic_dec_postfix_##name(volatile atomic_##name##_t *atomic) { \
-  return __atomic_fetch_sub_##sz(atomic, 1, __ATOMIC_SEQ_CST); \
-}
-
-// Returns value after operation, e.g. new value
-#define ATOMIC_ADD(name, type, sz) \
-static inline type atomic_add_##name(volatile atomic_##name##_t *atomic, type val) { \
-  return __atomic_add_fetch_##sz(atomic, val, __ATOMIC_SEQ_CST); \
-}
-
-// Returns value after operation, e.g. new value
-#define ATOMIC_SUB(name, type, sz) \
-static inline type atomic_sub_##name(volatile atomic_##name##_t *atomic, type val) { \
-  return __atomic_sub_fetch_##sz(atomic, val, __ATOMIC_SEQ_CST); \
-}
-
-#define ATOMIC_MAKE(name, type, sz) \
-  ATOMIC_TYPE(name, type) \
-  ATOMIC_STORE(name, type, sz) \
-  ATOMIC_LOAD(name, type, sz) \
-  ATOMIC_INC_PREFIX(name, type, sz) \
-  ATOMIC_DEC_PREFIX(name, type, sz) \
-  ATOMIC_INC_POSTFIX(name, type, sz) \
-  ATOMIC_DEC_POSTFIX(name, type, sz) \
-  ATOMIC_ADD(name, type, sz) \
-  ATOMIC_SUB(name, type, sz)
-
-ATOMIC_MAKE(s32, int32_t, 4)
-ATOMIC_MAKE(u32, uint32_t, 4)
-ATOMIC_MAKE(s64, int64_t, 8)
-ATOMIC_MAKE(u64, uint64_t, 8)
index bb0b219..1815be9 100644 (file)
@@ -147,7 +147,7 @@ void *allocation_tracker_notify_alloc(uint8_t allocator_id, void *ptr, size_t re
   return return_ptr;
 }
 
-void *allocation_tracker_notify_free(uint8_t allocator_id, void *ptr) {
+void *allocation_tracker_notify_free(UNUSED_ATTR uint8_t allocator_id, void *ptr) {
   if (!allocations || !ptr)
     return ptr;
 
@@ -159,8 +159,8 @@ void *allocation_tracker_notify_free(uint8_t allocator_id, void *ptr) {
   assert(allocation->allocator_id == allocator_id); // Must be from the same allocator
   allocation->freed = true;
 
-  const char *beginning_canary = ((char *)ptr) - canary_size;
-  const char *end_canary = ((char *)ptr) + allocation->size;
+  UNUSED_ATTR const char *beginning_canary = ((char *)ptr) - canary_size;
+  UNUSED_ATTR const char *end_canary = ((char *)ptr) + allocation->size;
 
   for (size_t i = 0; i < canary_size; i++) {
     assert(beginning_canary[i] == canary[i]);
index 6d36ec3..c483948 100644 (file)
@@ -21,6 +21,7 @@
 #include <hash_map.h>
 
 #include "osi/include/allocator.h"
+#include "osi/include/osi.h"
 
 struct hash_map_t;
 
@@ -138,7 +139,7 @@ bool hash_map_set(hash_map_t *hash_map, const void *key, void *data) {
 
   if (hash_map_entry) {
     // Calls hash_map callback to delete the hash_map_entry.
-    bool rc = list_remove(hash_bucket_list, hash_map_entry);
+    UNUSED_ATTR bool rc = list_remove(hash_bucket_list, hash_map_entry);
     assert(rc == true);
   } else {
     hash_map->hash_size++;
diff --git a/osi/test/atomic_test.cpp b/osi/test/atomic_test.cpp
deleted file mode 100644 (file)
index b0039ab..0000000
+++ /dev/null
@@ -1,278 +0,0 @@
-#include <gtest/gtest.h>
-
-extern "C" {
-#include "atomic.h"
-}
-
-const static size_t ATOMIC_DATA_MAX = 2;
-const static int ATOMIC_MAX_THREADS = 20;
-
-struct atomic_test_s32_s {
-  pthread_t pthread_id;
-  int thread_num;
-  int max_val;
-  atomic_s32_t *data;
-};
-
-void *atomic_thread(void *context) {
-  struct atomic_test_s32_s *at = (struct atomic_test_s32_s *)context;
-  for (int i = 0; i < at->max_val; i++) {
-    usleep(1);
-    atomic_inc_prefix_s32(&at->data[i]);
-  }
-  return NULL;
-}
-
-void *atomic_thread_inc_dec(void *context) {
-  struct atomic_test_s32_s *at = (struct atomic_test_s32_s *)context;
-  for (int i = 0; i < at->max_val; i++) {
-    usleep(1);
-    atomic_inc_prefix_s32(&at->data[i]);
-    usleep(1);
-    atomic_dec_prefix_s32(&at->data[i]);
-  }
-  return NULL;
-}
-
-TEST(AtomicTest, test_store_load_s32) {
-  atomic_s32_t data;
-
-  atomic_store_s32(&data, -1);
-  EXPECT_EQ(-1, atomic_load_s32(&data));
-
-  atomic_store_s32(&data, 0);
-  EXPECT_EQ(0, atomic_load_s32(&data));
-
-  atomic_store_s32(&data, 1);
-  EXPECT_EQ(1, atomic_load_s32(&data));
-
-  atomic_store_s32(&data, 2);
-  EXPECT_EQ(2, atomic_load_s32(&data));
-}
-
-TEST(AtomicTest, test_store_load_u32) {
-  atomic_u32_t data;
-
-  atomic_store_u32(&data, -1);
-  EXPECT_EQ((uint32_t)-1, atomic_load_u32(&data));
-
-  atomic_store_u32(&data, 0);
-  EXPECT_EQ((uint32_t)0, atomic_load_u32(&data));
-
-  atomic_store_u32(&data, 1);
-  EXPECT_EQ((uint32_t)1, atomic_load_u32(&data));
-
-  atomic_store_u32(&data, 2);
-  EXPECT_EQ((uint32_t)2, atomic_load_u32(&data));
-}
-
-TEST(AtomicTest, test_inc_dec_s32) {
-  atomic_s32_t data;
-
-  atomic_store_s32(&data, 0);
-  EXPECT_EQ(0, atomic_load_s32(&data));
-
-  int32_t val = atomic_inc_prefix_s32(&data);
-  EXPECT_EQ(1, atomic_load_s32(&data));
-  EXPECT_EQ(1, val);
-
-  val = atomic_inc_prefix_s32(&data);
-  EXPECT_EQ(2, atomic_load_s32(&data));
-  EXPECT_EQ(2, val);
-
-  val = atomic_inc_prefix_s32(&data);
-  EXPECT_EQ(3, atomic_load_s32(&data));
-  EXPECT_EQ(3, val);
-
-  val = atomic_dec_prefix_s32(&data);
-  EXPECT_EQ(2, val);
-
-  val = atomic_dec_prefix_s32(&data);
-  EXPECT_EQ(1, val);
-  val = atomic_dec_prefix_s32(&data);
-  EXPECT_EQ(0, val);
-  val = atomic_dec_prefix_s32(&data);
-  EXPECT_EQ(-1, val);
-}
-
-TEST(AtomicTest, test_inc_dec_u32) {
-  atomic_u32_t data;
-
-  atomic_store_u32(&data, 0);
-  EXPECT_EQ((unsigned)0, atomic_load_u32(&data));
-
-  uint32_t val = atomic_inc_prefix_u32(&data);
-  EXPECT_EQ((unsigned)1, atomic_load_u32(&data));
-  EXPECT_EQ((unsigned)1, val);
-
-  val = atomic_inc_prefix_u32(&data);
-  EXPECT_EQ((unsigned)2, atomic_load_u32(&data));
-  EXPECT_EQ((unsigned)2, val);
-
-  val = atomic_inc_prefix_u32(&data);
-  EXPECT_EQ((unsigned)3, atomic_load_u32(&data));
-  EXPECT_EQ((unsigned)3, val);
-
-  val = atomic_dec_prefix_u32(&data);
-  EXPECT_EQ((unsigned)2, val);
-
-  val = atomic_dec_prefix_u32(&data);
-  EXPECT_EQ((unsigned)1, val);
-  val = atomic_dec_prefix_u32(&data);
-  EXPECT_EQ((unsigned)0, val);
-  val = atomic_dec_prefix_u32(&data);
-  EXPECT_EQ((unsigned)-1, val);
-}
-
-TEST(AtomicTest, test_atomic_inc_thread) {
-  struct atomic_test_s32_s atomic_test[ATOMIC_MAX_THREADS];
-  atomic_s32_t data[ATOMIC_DATA_MAX];
-
-  memset(&atomic_test, 0, sizeof(atomic_test));
-  memset(data, 0, sizeof(data));
-
-  for (unsigned int i = 0; i < ATOMIC_DATA_MAX; i++) {
-    EXPECT_EQ(0, data[i]._val);
-  }
-
-  for (int i = 0; i < ATOMIC_MAX_THREADS; i++) {
-    atomic_test[i].thread_num = i;
-    atomic_test[i].max_val = ATOMIC_DATA_MAX;
-    atomic_test[i].data = data;
-    pthread_create(&atomic_test[i].pthread_id, NULL, atomic_thread, &atomic_test[i]);
-  }
-
-  for (int i = 0; i < ATOMIC_MAX_THREADS; i++) {
-    int rc = pthread_join(atomic_test[i].pthread_id, NULL);
-    EXPECT_EQ(0, rc);
-  }
-
-  for (unsigned int i = 0; i < ATOMIC_DATA_MAX; i++) {
-    EXPECT_EQ(1 * ATOMIC_MAX_THREADS, data[i]._val);
-  }
-}
-
-TEST(AtomicTest, test_atomic_inc_thread_single) {
-  struct atomic_test_s32_s atomic_test[ATOMIC_MAX_THREADS];
-  atomic_s32_t data;
-
-  memset(&atomic_test, 0, sizeof(atomic_test));
-  memset(&data, 0, sizeof(data));
-
-  EXPECT_EQ(0, data._val);
-
-  for (int i = 0; i < ATOMIC_MAX_THREADS; i++) {
-    atomic_test[i].thread_num = i;
-    atomic_test[i].max_val = 1;
-    atomic_test[i].data = &data;
-    pthread_create(&atomic_test[i].pthread_id, NULL, atomic_thread_inc_dec, &atomic_test[i]);
-  }
-
-  for (int i = 0; i < ATOMIC_MAX_THREADS; i++) {
-    int rc = pthread_join(atomic_test[i].pthread_id, NULL);
-    EXPECT_EQ(0, rc);
-  }
-  EXPECT_EQ(0, data._val);
-}
-
-TEST(AtomicTest, test_store_load_s64) {
-  atomic_s64_t data;
-
-  atomic_store_s64(&data, -1);
-  EXPECT_EQ(-1, atomic_load_s64(&data));
-
-  atomic_store_s64(&data, 0);
-  EXPECT_EQ(0, atomic_load_s64(&data));
-
-  atomic_store_s64(&data, 1);
-  EXPECT_EQ(1, atomic_load_s64(&data));
-
-  atomic_store_s64(&data, 2);
-  EXPECT_EQ(2, atomic_load_s64(&data));
-}
-
-TEST(AtomicTest, test_inc_dec_s64) {
-  atomic_s64_t data;
-
-  atomic_store_s64(&data, 0);
-  EXPECT_EQ(0, atomic_load_s64(&data));
-
-  int64_t val = atomic_inc_prefix_s64(&data);
-  EXPECT_EQ(1, atomic_load_s64(&data));
-  EXPECT_EQ(1, val);
-
-  val = atomic_inc_prefix_s64(&data);
-  EXPECT_EQ(2, atomic_load_s64(&data));
-  EXPECT_EQ(2, val);
-
-  val = atomic_inc_prefix_s64(&data);
-  EXPECT_EQ(3, atomic_load_s64(&data));
-  EXPECT_EQ(3, val);
-
-  val = atomic_dec_prefix_s64(&data);
-  EXPECT_EQ(2, val);
-
-  val = atomic_dec_prefix_s64(&data);
-  EXPECT_EQ(1, val);
-  val = atomic_dec_prefix_s64(&data);
-  EXPECT_EQ(0, val);
-  val = atomic_dec_prefix_s64(&data);
-  EXPECT_EQ(-1, val);
-
-  // Mutating using postfix.
-  val = atomic_inc_postfix_s64(&data);
-  EXPECT_EQ(0, atomic_load_s64(&data));
-  EXPECT_EQ(-1, val);
-
-  val = atomic_inc_postfix_s64(&data);
-  EXPECT_EQ(1, atomic_load_s64(&data));
-  EXPECT_EQ(0, val);
-
-  val = atomic_inc_postfix_s64(&data);
-  EXPECT_EQ(2, atomic_load_s64(&data));
-  EXPECT_EQ(1, val);
-
-  val = atomic_dec_postfix_s64(&data);
-  EXPECT_EQ(2, val);
-
-  val = atomic_dec_postfix_s64(&data);
-  EXPECT_EQ(1, val);
-  val = atomic_dec_postfix_s64(&data);
-  EXPECT_EQ(0, val);
-  val = atomic_dec_postfix_s64(&data);
-  EXPECT_EQ(-1, val);
-  EXPECT_EQ(-2, atomic_load_s64(&data));
-}
-
-TEST(AtomicTest, test_add_sub_u64) {
-  atomic_u64_t data;
-
-  atomic_store_u64(&data, 0);
-  EXPECT_EQ((unsigned)0, atomic_load_u64(&data));
-
-  uint64_t val = atomic_add_u64(&data, 0xffff);
-  EXPECT_EQ((unsigned)0xffff, atomic_load_u64(&data));
-  EXPECT_EQ((unsigned)0xffff, val);
-
-  val = atomic_add_u64(&data, 0xffff);
-  EXPECT_EQ((unsigned)(2 * 0xffff), atomic_load_u64(&data));
-  EXPECT_EQ((unsigned)(2 * 0xffff), val);
-
-  val = atomic_add_u64(&data, 0xffff);
-  EXPECT_EQ((unsigned)(3 * 0xffff), atomic_load_u64(&data));
-  EXPECT_EQ((unsigned)(3 * 0xffff), val);
-  EXPECT_NE((unsigned)(3 * 0xfff0), val);
-
-  val = atomic_sub_u64(&data, 0xffff);
-  EXPECT_EQ((unsigned)(2 * 0xffff), val);
-
-  val = atomic_sub_u64(&data, 0);
-  EXPECT_EQ((unsigned)(2 * 0xffff), val);
-  val = atomic_sub_u64(&data, 0xffff);
-  EXPECT_EQ((unsigned)(1 * 0xffff), val);
-
-  val = atomic_sub_u64(&data, 0xffff);
-  EXPECT_EQ((unsigned)0, val);
-}
-
-