osmo_io: Use bitfield for various boolean flags
Change-Id: Ic134e4c8d791c34778202fea98a70bc04007a113
diff --git a/src/core/osmo_io_internal.h b/src/core/osmo_io_internal.h
index cd620e7..d45b161 100644
--- a/src/core/osmo_io_internal.h
+++ b/src/core/osmo_io_internal.h
@@ -29,6 +29,19 @@
void (*read_disable)(struct osmo_io_fd *iofd);
};
+#define IOFD_FLAG_CLOSED (1<<0)
+#define IOFD_FLAG_IN_CALLBACK (1<<1)
+#define IOFD_FLAG_TO_FREE (1<<2)
+#define IOFD_FLAG_NOTIFY_CONNECTED (1<<3)
+
+#define IOFD_FLAG_SET(iofd, flag) \
+ (iofd)->flags |= (flag)
+
+#define IOFD_FLAG_UNSET(iofd, flag) \
+ (iofd)->flags &= ~(flag)
+
+#define IOFD_FLAG_ISSET(iofd, flag) ((iofd)->flags & (flag))
+
struct osmo_io_fd {
/*! linked list for internal management */
struct llist_head list;
@@ -38,10 +51,7 @@
enum osmo_io_fd_mode mode;
/*! flags to guard closing/freeing of iofd */
- /* TODO: Move to bitfield */
- bool closed;
- bool in_callback;
- bool to_free;
+ uint32_t flags;
/*! human-readable name to associte with fd */
char *name;