From 842093bb843ae6c719c2b1cf32eb749cab9e46ca Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 15 Feb 2024 15:34:49 +0100 Subject: Define _POSIX_C_SOURCE globally Stop trying to maintain a per-file _POSIX_C_SOURCE. Instead, require POSIX.1-2008 globally. A lot of core source files depend on that already. Some care must be taken on a few select files where we need a bit more than POSIX. Some files need XSI extensions (_XOPEN_SOURCE) and some files need BSD extensions (_DEFAULT_SOURCE). In both cases, these feature test macros imply _POSIX_C_SOURCE. Make sure to not define both these macros and _POSIX_C_SOURCE explicitly to avoid POSIX requirement conflicts (e.g. _POSIX_C_SOURCE says POSIX.1-2001 but _XOPEN_SOURCE says POSIX.1-2008). Additionally, there is one special case in render/vulkan/vulkan.c. That file needs major()/minor(), and these are system-specific. On FreeBSD, _POSIX_C_SOURCE hides system-specific symbols so we need to make sure it's not defined for this file. On Linux, we can explicitly include and ensure that apart from symbols defined there the file only uses POSIX toys. --- xwayland/selection/incoming.c | 1 - xwayland/selection/selection.c | 1 - xwayland/server.c | 1 - xwayland/sockets.c | 3 ++- xwayland/xwayland.c | 1 - xwayland/xwm.c | 3 --- 6 files changed, 2 insertions(+), 8 deletions(-) (limited to 'xwayland') diff --git a/xwayland/selection/incoming.c b/xwayland/selection/incoming.c index c2e1e712..4a0b450c 100644 --- a/xwayland/selection/incoming.c +++ b/xwayland/selection/incoming.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/xwayland/selection/selection.c b/xwayland/selection/selection.c index 0079df2f..4d1e366e 100644 --- a/xwayland/selection/selection.c +++ b/xwayland/selection/selection.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/xwayland/server.c b/xwayland/server.c index 6dd42246..4f92879d 100644 --- a/xwayland/server.c +++ b/xwayland/server.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/xwayland/sockets.c b/xwayland/sockets.c index 873fde8d..9e287f36 100644 --- a/xwayland/sockets.c +++ b/xwayland/sockets.c @@ -1,4 +1,5 @@ -#define _XOPEN_SOURCE 700 +#undef _POSIX_C_SOURCE +#define _XOPEN_SOURCE 700 // for S_ISVTX #include #include #include diff --git a/xwayland/xwayland.c b/xwayland/xwayland.c index 0ffc1fef..c4ca9ae4 100644 --- a/xwayland/xwayland.c +++ b/xwayland/xwayland.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include #include #include diff --git a/xwayland/xwm.c b/xwayland/xwm.c index 9a6cf771..c75f2be7 100644 --- a/xwayland/xwm.c +++ b/xwayland/xwm.c @@ -1,6 +1,3 @@ -#ifndef _POSIX_C_SOURCE -#define _POSIX_C_SOURCE 200809L -#endif #include #include #include -- cgit v1.2.3