diff options
author | Simon Ser <contact@emersion.fr> | 2024-03-28 15:33:41 +0100 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2024-03-28 17:56:34 +0100 |
commit | 36cef8653fe57eff7d38fc0f4877bb900b1a21ea (patch) | |
tree | 1d1c9eecc67cc6a39b9dbf64f9ec3449ab898412 | |
parent | 4945f2664fced2cb7b6d836169cfe6e87ee19b90 (diff) |
util: convert macros to inline functions
Functionally equivalent except the usual macro footguns are avoided
and type safety is increased.
Signed-off-by: Simon Ser <contact@emersion.fr>
-rw-r--r-- | src/wayland-util.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/wayland-util.c b/src/wayland-util.c index bb2a183..7231346 100644 --- a/src/wayland-util.c +++ b/src/wayland-util.c @@ -174,9 +174,23 @@ union map_entry { void *data; }; -#define map_entry_is_free(entry) ((entry).next & 0x1) -#define map_entry_get_data(entry) ((void *)((entry).next & ~(uintptr_t)0x3)) -#define map_entry_get_flags(entry) (((entry).next >> 1) & 0x1) +static inline bool +map_entry_is_free(union map_entry entry) +{ + return entry.next & 0x1; +} + +static inline void * +map_entry_get_data(union map_entry entry) +{ + return (void *)(entry.next & ~(uintptr_t)0x3); +} + +static inline uint32_t +map_entry_get_flags(union map_entry entry) +{ + return (entry.next >> 1) & 0x1; +} void wl_map_init(struct wl_map *map, uint32_t side) |