]> git.proxmox.com Git - mirror_ovs.git/blame - lib/ovs-atomic-flag-gcc4.7+.h
dpctl: Add the option 'pmd' for dump-flows.
[mirror_ovs.git] / lib / ovs-atomic-flag-gcc4.7+.h
CommitLineData
29ab0cf7 1/*
8917f72c 2 * Copyright (c) 2013, 2014 Nicira, Inc.
29ab0cf7
BP
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at:
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/* This header implements atomic_flag on Clang and on GCC 4.7 and later. */
18#ifndef IN_OVS_ATOMIC_H
19#error "This header should only be included indirectly via ovs-atomic.h."
20#endif
21
22/* atomic_flag */
23
24typedef struct {
25 unsigned char b;
26} atomic_flag;
27#define ATOMIC_FLAG_INIT { .b = false }
28
29static inline bool
30atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
31 memory_order order)
32{
33 return __atomic_test_and_set(&object->b, order);
34}
35
36static inline bool
37atomic_flag_test_and_set(volatile atomic_flag *object)
38{
39 return atomic_flag_test_and_set_explicit(object, memory_order_seq_cst);
40}
41
42static inline void
43atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order)
44{
45 __atomic_clear(object, order);
46}
47
48static inline void
49atomic_flag_clear(volatile atomic_flag *object)
50{
51 atomic_flag_clear_explicit(object, memory_order_seq_cst);
52}