diff options
author | Thomas Haller <thaller@redhat.com> | 2023-07-28 15:11:28 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-07-31 13:15:56 (GMT) |
commit | d3e9b5134663c08165f33ea38d2de7143eeb570d (patch) | |
tree | 8245ba602445f550ed8b35ee33c06837c0e58a7c | |
parent | 543b9f8f1ed3a7ba67e2f9da77ae92d72aef211d (diff) | |
download | libnl-d3e9b5134663c08165f33ea38d2de7143eeb570d.zip libnl-d3e9b5134663c08165f33ea38d2de7143eeb570d.tar.gz libnl-d3e9b5134663c08165f33ea38d2de7143eeb570d.tar.bz2 |
include/utils: move nl-auto base defines to "utils.h"
"utils.h" will become the internal helper "library" at the lowest
level. While "nl-auto.h" contains libnl3 specific functions, "utils.h"
does not.
Move libnl3 specific helpers from "nl-auto.h" to "utils.h".
-rw-r--r-- | include/netlink-private/netlink.h | 1 | ||||
-rw-r--r-- | include/netlink-private/nl-auto.h | 29 | ||||
-rw-r--r-- | include/netlink-private/utils.h | 32 |
3 files changed, 32 insertions, 30 deletions
diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h index 60af091..6ab141b 100644 --- a/include/netlink-private/netlink.h +++ b/include/netlink-private/netlink.h @@ -60,6 +60,7 @@ #include <netlink-private/cache-api.h> #include <netlink-private/types.h> #include <netlink-private/utils.h> +#include <netlink-private/nl-auto.h> #define NSEC_PER_SEC 1000000000L diff --git a/include/netlink-private/nl-auto.h b/include/netlink-private/nl-auto.h index f4c75d3..887f627 100644 --- a/include/netlink-private/nl-auto.h +++ b/include/netlink-private/nl-auto.h @@ -5,34 +5,7 @@ #include <stdlib.h> -#define _nl_auto(fcn) __attribute__((__cleanup__(fcn))) - -#define _NL_AUTO_DEFINE_FCN_VOID0(CastType, name, func) \ - static inline void name(void *v) \ - { \ - if (*((CastType *)v)) \ - func(*((CastType *)v)); \ - } \ - struct _nl_dummy_for_tailing_semicolon - -#define _NL_AUTO_DEFINE_FCN_STRUCT(CastType, name, func) \ - static inline void name(CastType *v) \ - { \ - if (v) \ - func(v); \ - } \ - struct _nl_dummy_for_tailing_semicolon - -#define _NL_AUTO_DEFINE_FCN_TYPED0(CastType, name, func) \ - static inline void name(CastType *v) \ - { \ - if (*v) \ - func(*v); \ - } \ - struct _nl_dummy_for_tailing_semicolon - -#define _nl_auto_free _nl_auto(_nl_auto_free_fcn) -_NL_AUTO_DEFINE_FCN_VOID0(void *, _nl_auto_free_fcn, free); +#include "netlink-private/utils.h" struct nl_addr; void nl_addr_put(struct nl_addr *); diff --git a/include/netlink-private/utils.h b/include/netlink-private/utils.h index b2d8b46..6c27ce5 100644 --- a/include/netlink-private/utils.h +++ b/include/netlink-private/utils.h @@ -86,6 +86,7 @@ #define _nl_deprecated(msg) __attribute__((__deprecated__(msg))) #define _nl_init __attribute__((constructor)) #define _nl_exit __attribute__((destructor)) +#define _nl_auto(fcn) __attribute__((__cleanup__(fcn))) /*****************************************************************************/ @@ -574,8 +575,6 @@ static inline char *_nl_strncpy_assert(char *dst, const char *src, size_t len) return dst; } -#include "nl-auto.h" - #define _NL_RETURN_ON_ERR(cmd) \ do { \ int _err; \ @@ -684,4 +683,33 @@ static inline char *_nl_inet_ntop_dup(int addr_family, const void *addr) INET6_ADDRSTRLEN)); } +/*****************************************************************************/ + +#define _NL_AUTO_DEFINE_FCN_VOID0(CastType, name, func) \ + static inline void name(void *v) \ + { \ + if (*((CastType *)v)) \ + func(*((CastType *)v)); \ + } \ + struct _nl_dummy_for_tailing_semicolon + +#define _NL_AUTO_DEFINE_FCN_STRUCT(CastType, name, func) \ + static inline void name(CastType *v) \ + { \ + if (v) \ + func(v); \ + } \ + struct _nl_dummy_for_tailing_semicolon + +#define _NL_AUTO_DEFINE_FCN_TYPED0(CastType, name, func) \ + static inline void name(CastType *v) \ + { \ + if (*v) \ + func(*v); \ + } \ + struct _nl_dummy_for_tailing_semicolon + +#define _nl_auto_free _nl_auto(_nl_auto_free_fcn) +_NL_AUTO_DEFINE_FCN_VOID0(void *, _nl_auto_free_fcn, free); + #endif |