diff options
author | Simon McVittie <smcv@collabora.com> | 2023-05-31 16:26:26 +0100 |
---|---|---|
committer | Philip Withnall <philip@tecnocode.co.uk> | 2023-08-16 14:02:35 +0100 |
commit | 40508b35b9c74171560dc9e627a35be2d7fb1db5 (patch) | |
tree | 08f0c4f44bd168070485472dc1cec6af56dfd846 | |
parent | 4a60527f2e3f0224e7b7a6726893ec95a024ef1c (diff) | |
download | glib-40508b35b9c74171560dc9e627a35be2d7fb1db5.tar.gz |
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>
-rw-r--r-- | glib/glib-unix.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/glib/glib-unix.c b/glib/glib-unix.c index f671887c9..c25cd30f0 100644 --- a/glib/glib-unix.c +++ b/glib/glib-unix.c @@ -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 |