summaryrefslogtreecommitdiffstats
path: root/libcutils
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2015-04-16 18:35:38 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-04-16 18:35:43 +0000
commit51e32b52a3d087aec0e80df93129d598221bf312 (patch)
tree8c6121798d7efda991783418926789f0a421d9fc /libcutils
parentbb643ccb5d6b1f9a7809e9def30a498b42bd9ed0 (diff)
parenta8ac32c7815569add9ed3d729864d3b9cdbb5fce (diff)
downloadsystem_core-51e32b52a3d087aec0e80df93129d598221bf312.zip
system_core-51e32b52a3d087aec0e80df93129d598221bf312.tar.gz
system_core-51e32b52a3d087aec0e80df93129d598221bf312.tar.bz2
Merge "Move trace.h to stdatomic."
Diffstat (limited to 'libcutils')
-rw-r--r--libcutils/trace-dev.c14
-rw-r--r--libcutils/trace-host.c2
2 files changed, 8 insertions, 8 deletions
diff --git a/libcutils/trace-dev.c b/libcutils/trace-dev.c
index 4396625..a06987e 100644
--- a/libcutils/trace-dev.c
+++ b/libcutils/trace-dev.c
@@ -18,11 +18,11 @@
#include <fcntl.h>
#include <limits.h>
#include <pthread.h>
+#include <stdatomic.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
-#include <cutils/atomic.h>
#include <cutils/compiler.h>
#include <cutils/properties.h>
#include <cutils/trace.h>
@@ -37,11 +37,11 @@
*/
#define ATRACE_MESSAGE_LENGTH 1024
-volatile int32_t atrace_is_ready = 0;
+atomic_bool atrace_is_ready = ATOMIC_VAR_INIT(false);
int atrace_marker_fd = -1;
uint64_t atrace_enabled_tags = ATRACE_TAG_NOT_READY;
static bool atrace_is_debuggable = false;
-static volatile int32_t atrace_is_enabled = 1;
+static atomic_bool atrace_is_enabled = ATOMIC_VAR_INIT(true);
static pthread_once_t atrace_once_control = PTHREAD_ONCE_INIT;
static pthread_mutex_t atrace_tags_mutex = PTHREAD_MUTEX_INITIALIZER;
@@ -58,7 +58,7 @@ void atrace_set_debuggable(bool debuggable)
// the Zygote process from tracing.
void atrace_set_tracing_enabled(bool enabled)
{
- android_atomic_release_store(enabled ? 1 : 0, &atrace_is_enabled);
+ atomic_store_explicit(&atrace_is_enabled, enabled, memory_order_release);
atrace_update_tags();
}
@@ -155,8 +155,8 @@ static uint64_t atrace_get_property()
void atrace_update_tags()
{
uint64_t tags;
- if (CC_UNLIKELY(android_atomic_acquire_load(&atrace_is_ready))) {
- if (android_atomic_acquire_load(&atrace_is_enabled)) {
+ if (CC_UNLIKELY(atomic_load_explicit(&atrace_is_ready, memory_order_acquire))) {
+ if (atomic_load_explicit(&atrace_is_enabled, memory_order_acquire)) {
tags = atrace_get_property();
pthread_mutex_lock(&atrace_tags_mutex);
atrace_enabled_tags = tags;
@@ -183,7 +183,7 @@ static void atrace_init_once()
atrace_enabled_tags = atrace_get_property();
done:
- android_atomic_release_store(1, &atrace_is_ready);
+ atomic_store_explicit(&atrace_is_ready, true, memory_order_release);
}
void atrace_setup()
diff --git a/libcutils/trace-host.c b/libcutils/trace-host.c
index b87e543..6478e3e 100644
--- a/libcutils/trace-host.c
+++ b/libcutils/trace-host.c
@@ -20,7 +20,7 @@
#define __unused __attribute__((__unused__))
#endif
-volatile int32_t atrace_is_ready = 1;
+atomic_bool atrace_is_ready = ATOMIC_VAR_INIT(true);
int atrace_marker_fd = -1;
uint64_t atrace_enabled_tags = 0;