aboutsummaryrefslogtreecommitdiffstats
path: root/src/wayland-util.c
diff options
context:
space:
mode:
authorSimon Ser <contact@emersion.fr>2024-03-28 15:33:41 +0100
committerSimon Ser <contact@emersion.fr>2024-03-28 17:56:34 +0100
commit36cef8653fe57eff7d38fc0f4877bb900b1a21ea (patch)
tree1d1c9eecc67cc6a39b9dbf64f9ec3449ab898412 /src/wayland-util.c
parentwl_touch.cancel: document lack of frame event (diff)
downloadwayland-36cef8653fe57eff7d38fc0f4877bb900b1a21ea.tar
wayland-36cef8653fe57eff7d38fc0f4877bb900b1a21ea.tar.gz
wayland-36cef8653fe57eff7d38fc0f4877bb900b1a21ea.tar.bz2
wayland-36cef8653fe57eff7d38fc0f4877bb900b1a21ea.tar.lz
wayland-36cef8653fe57eff7d38fc0f4877bb900b1a21ea.tar.xz
wayland-36cef8653fe57eff7d38fc0f4877bb900b1a21ea.tar.zst
wayland-36cef8653fe57eff7d38fc0f4877bb900b1a21ea.zip
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>
Diffstat (limited to 'src/wayland-util.c')
-rw-r--r--src/wayland-util.c20
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)