netdev-dpdk: fix mbuf leaks
[cascardo/ovs.git] / lib / ovs-atomic-gcc4.7+.h
index 07bef2a..4c197eb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
 #error "This header should only be included indirectly via ovs-atomic.h."
 #endif
 
-/* C11 standardized atomic type. */
-typedef bool               atomic_bool;
-
-typedef char               atomic_char;
-typedef signed char        atomic_schar;
-typedef unsigned char      atomic_uchar;
-
-typedef short              atomic_short;
-typedef unsigned short     atomic_ushort;
-
-typedef int                atomic_int;
-typedef unsigned int       atomic_uint;
-
-typedef long               atomic_long;
-typedef unsigned long      atomic_ulong;
-
-typedef long long          atomic_llong;
-typedef unsigned long long atomic_ullong;
-
-typedef size_t             atomic_size_t;
-typedef ptrdiff_t          atomic_ptrdiff_t;
-
-typedef intmax_t           atomic_intmax_t;
-typedef uintmax_t          atomic_uintmax_t;
-
-typedef intptr_t           atomic_intptr_t;
-typedef uintptr_t          atomic_uintptr_t;
-
-/* Nonstandard atomic types. */
-typedef int8_t             atomic_int8_t;
-typedef uint8_t            atomic_uint8_t;
-
-typedef int16_t            atomic_int16_t;
-typedef uint16_t           atomic_uint16_t;
-
-typedef int32_t            atomic_int32_t;
-typedef uint32_t           atomic_uint32_t;
-
-typedef int64_t            atomic_int64_t;
-typedef uint64_t           atomic_uint64_t;
+#define ATOMIC(TYPE) TYPE
 
 typedef enum {
     memory_order_relaxed = __ATOMIC_RELAXED,
@@ -86,6 +47,20 @@ typedef enum {
     (*(DST) = __atomic_load_n(SRC, ORDER),      \
      (void) 0)
 
+#define atomic_compare_exchange_strong(DST, EXP, SRC)              \
+    atomic_compare_exchange_strong_explicit(DST, EXP, SRC,         \
+                                            memory_order_seq_cst,  \
+                                            memory_order_seq_cst)
+#define atomic_compare_exchange_strong_explicit(DST, EXP, SRC, ORD1, ORD2) \
+    __atomic_compare_exchange_n(DST, EXP, SRC, false, ORD1, ORD2)
+
+#define atomic_compare_exchange_weak(DST, EXP, SRC)              \
+    atomic_compare_exchange_weak_explicit(DST, EXP, SRC,         \
+                                          memory_order_seq_cst,  \
+                                          memory_order_seq_cst)
+#define atomic_compare_exchange_weak_explicit(DST, EXP, SRC, ORD1, ORD2) \
+    __atomic_compare_exchange_n(DST, EXP, SRC, true, ORD1, ORD2)
+
 #define atomic_add(RMW, OPERAND, ORIG) \
         atomic_add_explicit(RMW, OPERAND, ORIG, memory_order_seq_cst)
 #define atomic_sub(RMW, OPERAND, ORIG) \
@@ -107,35 +82,5 @@ typedef enum {
     (*(ORIG) = __atomic_fetch_xor(RMW, OPERAND, ORDER), (void) 0)
 #define atomic_and_explicit(RMW, OPERAND, ORIG, ORDER)  \
     (*(ORIG) = __atomic_fetch_and(RMW, OPERAND, ORDER), (void) 0)
-\f
-/* atomic_flag */
-
-typedef struct {
-    unsigned char b;
-} atomic_flag;
-#define ATOMIC_FLAG_INIT { .b = false }
-
-static inline bool
-atomic_flag_test_and_set_explicit(volatile atomic_flag *object,
-                                  memory_order order)
-{
-    return __atomic_test_and_set(&object->b, order);
-}
-
-static inline bool
-atomic_flag_test_and_set(volatile atomic_flag *object)
-{
-    return atomic_flag_test_and_set_explicit(object, memory_order_seq_cst);
-}
-
-static inline void
-atomic_flag_clear_explicit(volatile atomic_flag *object, memory_order order)
-{
-    __atomic_clear(object, order);
-}
 
-static inline void
-atomic_flag_clear(volatile atomic_flag *object)
-{
-    atomic_flag_clear_explicit(object, memory_order_seq_cst);
-}
+#include "ovs-atomic-flag-gcc4.7+.h"