Commit graph

20 commits

Author SHA1 Message Date
Antonio Cardace
2e70391033
shared: extend NM_IN_STRSET and NM_IN_SET to support up to 20 args
https://bugzilla.redhat.com/show_bug.cgi?id=1847814
2020-08-06 11:21:45 +02:00
Thomas Haller
b16b42266d
shared: make implementation for NM_IN_STRSET() more reusable 2020-08-05 10:22:10 +02:00
Thomas Haller
62c1a1b5b2
shared: move nm_utils_is_power_of_two() to nm-stdaux and add nm_utils_is_power_of_two_or_zero() 2020-07-31 08:53:04 +02:00
Thomas Haller
8346870aa6
shared: add nm_assert_unreachable_val() macro 2020-07-24 16:03:15 +02:00
Thomas Haller
7ae8100d7a
shared: add NM_IS_IPv4() macro
This is of course trivial. However, we use this macro at several places
as and index into an array of length 2, to lookup either the IPv4 or
IPv6 element. As such, this MUST return 0 or 1. This promise is what the
macro should convey.
2020-07-23 15:29:23 +02:00
Thomas Haller
56a0aa06ac
shared: move addr-family helpers to "nm-std-aux.h"
Handling address families is something we do all over the place.
Move some simple helper code to "nm-std-aux.h".
2020-07-23 15:29:23 +02:00
Thomas Haller
b17e3cf707
all: add trailing semicolon to NM_AUTO_DEFINE_FCN_*() uses 2020-07-19 12:01:56 +02:00
Thomas Haller
8bd2673484
shared: add _NM_DUMMY_STRUCT_FOR_TRAILING_SEMICOLON define
Will be used next.
2020-07-19 11:37:23 +02:00
Thomas Haller
4168c19e04
shared: move nm_close(), nm_auto_close, nm_steal_fd(), nm_steal_int() to nm-std-aux 2020-07-12 13:05:13 +02:00
Thomas Haller
6feab75447
shared: add nm_steal_pointer()/nm_clear_free() to "nm-std-aux.h"
There is the team of nm_auto*, nm_clear_pointer() and nm_steal_pointer().
These goes nicely together so that an autovariable owns a resource,
to free it (clear) and to transfer ownership (steal).

We have these also in glib, but we certainly also need it if we don't
have glib because that very much goes together with nm_auto*. Add it.
2020-07-07 22:32:35 +02:00
Thomas Haller
1d6e208c12
shared: move NM_AUTO_DEFINE_FCN*(), nm_auto_free and nm_clear_pointer() to "nm-std-aux.h" 2020-07-07 22:25:42 +02:00
Thomas Haller
1b9001f867
shared: include <stdbool.h> in "nm-std-aux.h" and fix glib-ism
For a long time already we build with gnu11/C11. We thus rely on having
<stdbool.h> around, which is C99. Use it.

Also fix "nm-std-aux.h" to not use TRUE/FALSE glib defines.
2020-07-07 22:25:19 +02:00
Thomas Haller
3b80c6c28f
shared: make NM_BOOLEAN_EXPR() macro composable and use it for _G_BOOLEAN_EXPR()
We redefine _G_BOOLEAN_EXPR(), so let it use NM_BOOLEAN_EXPR().

Also, we use G_LIKELY() (and thus NM_BOOLEAN_EXPR()) inside nm_assert(),
and we use nm_assert() in some macros. To be able to nest nm_assert()
calls, we need to create unique variable names for NM_BOOLEAN_EXPR().
2020-07-07 21:52:22 +02:00
Thomas Haller
f0deb24249
shared: move various basic helpers from "nm-macros-internal.h" to "nm-std-aux.h"
These are generally useful and independent of glib. Move them to
nm-std-aux, which has no glib dependency.
2020-07-07 21:33:25 +02:00
Thomas Haller
b9e458b184
shared: add NM_N_ELEMENTS() macro 2020-07-06 14:11:23 +02:00
Thomas Haller
d407c1271c
shared: move NM_SET_OUT() to "nm-std-aux.h" 2020-07-06 14:11:22 +02:00
Thomas Haller
b109d63376
shared: add min/max macros to "nm-std-aux.h" 2020-07-06 11:45:37 +02:00
Thomas Haller
5361317f68
shared: add macros for declaration attribute to "nm-std-aux.h" 2020-07-06 11:45:37 +02:00
Thomas Haller
030d68aef7
shared: add nm_assert() to "nm-std-aux.h"
Having assertion macros that are disabled by default, is not
only useful for our glib code, but should also be available
for nm-std-aux. Move the macros.
2020-07-06 11:45:37 +02:00
Thomas Haller
5dd923cd86
shared: add "nm-std-aux/nm-std-aux.h" header
"nm-std-aux" is an utility library that has no glib depdencency. That
is the difference to "nm-glib-aux".
2020-07-06 11:10:43 +02:00