/*
- * Copyright (c) 2013 Nicira, Inc.
+ * Copyright (c) 2013, 2014 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "ovs-thread.h"
#if OVS_ATOMIC_PTHREADS_IMPL
+void
+atomic_flag_init(volatile atomic_flag *flag_)
+{
+ atomic_flag *flag = CONST_CAST(atomic_flag *, flag_);
+
+ pthread_mutex_init(&flag->mutex, NULL);
+ atomic_flag_clear(flag_);
+}
+
+void
+atomic_flag_destroy(volatile atomic_flag *flag_)
+{
+ atomic_flag *flag = CONST_CAST(atomic_flag *, flag_);
+
+ pthread_mutex_destroy(&flag->mutex);
+}
+
bool
atomic_flag_test_and_set(volatile atomic_flag *flag_)
{
atomic_flag *flag = CONST_CAST(atomic_flag *, flag_);
bool old_value;
- ovs_mutex_lock(&flag->mutex);
+ xpthread_mutex_lock(&flag->mutex);
old_value = flag->b;
flag->b = true;
- ovs_mutex_unlock(&flag->mutex);
+ xpthread_mutex_unlock(&flag->mutex);
return old_value;
}
{
atomic_flag *flag = CONST_CAST(atomic_flag *, flag_);
- ovs_mutex_lock(&flag->mutex);
+ xpthread_mutex_lock(&flag->mutex);
flag->b = false;
- ovs_mutex_unlock(&flag->mutex);
+ xpthread_mutex_unlock(&flag->mutex);
}
void