summaryrefslogtreecommitdiffstats
path: root/include/base
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2024-08-22 15:48:47 (GMT)
committerThomas Haller <thaller@redhat.com>2024-08-22 15:49:00 (GMT)
commit01f06b57620d0098777ce00951ce46dca9655ae3 (patch)
treea7a4c2a88869423ae0aaec2371a880041d66b167 /include/base
parent5b5702591c672391e5508e5e62ee1dfcead0176d (diff)
downloadlibnl-01f06b57620d0098777ce00951ce46dca9655ae3.zip
libnl-01f06b57620d0098777ce00951ce46dca9655ae3.tar.gz
libnl-01f06b57620d0098777ce00951ce46dca9655ae3.tar.bz2
base: add _nl_swap() helper macro
Diffstat (limited to 'include/base')
-rw-r--r--include/base/nl-base-utils.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/base/nl-base-utils.h b/include/base/nl-base-utils.h
index 287a122..a735134 100644
--- a/include/base/nl-base-utils.h
+++ b/include/base/nl-base-utils.h
@@ -769,6 +769,19 @@ _NL_AUTO_DEFINE_FCN_VOID0(void *, _nl_auto_free_fcn, free);
/*****************************************************************************/
+#define _nl_swap(p_a, p_b) \
+ do { \
+ typeof(*(p_a)) *const _p_a = (p_a); \
+ typeof(*(p_a)) *const _p_b = (p_b); \
+ typeof(*(p_a)) _tmp; \
+ \
+ _tmp = *_p_a; \
+ *_p_a = *_p_b; \
+ *_p_b = _tmp; \
+ } while (0)
+
+/*****************************************************************************/
+
#define NSEC_PER_SEC 1000000000L
struct trans_tbl {