vppinfra: add CLIB_SWAP() 01/41601/2
authorDamjan Marion <damarion@cisco.com>
Wed, 25 Sep 2024 13:52:16 +0000 (15:52 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Wed, 25 Sep 2024 20:05:45 +0000 (20:05 +0000)
Type: improvement
Change-Id: I1911a9d6a0ca8e1d24ce7b95281886392081ffc6
Signed-off-by: Damjan Marion <damarion@cisco.com>
src/vppinfra/clib.h

index 75cebc6..5348738 100644 (file)
 #define CLIB_STRING_ARRAY(...)                                                \
   (char *[]) { __VA_ARGS__, 0 }
 
+#define CLIB_SWAP(a, b)                                                       \
+  {                                                                           \
+    typeof (a) __tmp = a;                                                     \
+    a = b;                                                                    \
+    b = __tmp;                                                                \
+  }
+
 /* sanitizers */
 #ifdef __has_feature
 #if __has_feature(address_sanitizer)