glib-unix: Assert that O_NONBLOCK and FD_CLOEXEC are numerically distinct

Since 5c65437d "glib-unix: Add O_NONBLOCK support to g_unix_open_pipe()"
we have effectively been assuming that these two flags are
distinguishable. If that's an assumption we want to make, we should make
it a static assertion, so that GLib will fail to compile on platforms
where it isn't true.

Signed-off-by: Simon McVittie <smcv@collabora.com>
This commit is contained in:
Simon McVittie 2023-05-31 16:26:26 +01:00 committed by Philip Withnall
parent 4a60527f2e
commit 40508b35b9

View File

@ -37,6 +37,12 @@ G_STATIC_ASSERT (G_ALIGNOF (gssize) == G_ALIGNOF (ssize_t));
G_STATIC_ASSERT (sizeof (GPid) == sizeof (pid_t));
G_STATIC_ASSERT (G_ALIGNOF (GPid) == G_ALIGNOF (pid_t));
/* If this assertion fails, then the ABI of g_unix_open_pipe() would be
* ambiguous on this platform.
* On Linux, usually O_NONBLOCK == 04000 and FD_CLOEXEC == 1, but the same
* might not be true everywhere. */
G_STATIC_ASSERT (O_NONBLOCK != FD_CLOEXEC);
/**
* SECTION:gunix
* @title: UNIX-specific utilities and integration