From 842093bb843ae6c719c2b1cf32eb749cab9e46ca Mon Sep 17 00:00:00 2001 From: Simon Ser <contact@emersion.fr> 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 <sys/sysmacros.h> and ensure that apart from symbols defined there the file only uses POSIX toys. --- render/allocator/allocator.c | 1 - render/allocator/drm_dumb.c | 1 - render/allocator/gbm.c | 1 - 3 files changed, 3 deletions(-) (limited to 'render/allocator') diff --git a/render/allocator/allocator.c b/render/allocator/allocator.c index e0620a1b..639b52be 100644 --- a/render/allocator/allocator.c +++ b/render/allocator/allocator.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include <assert.h> #include <fcntl.h> #include <stdlib.h> diff --git a/render/allocator/drm_dumb.c b/render/allocator/drm_dumb.c index 6de44f40..eb4ce99f 100644 --- a/render/allocator/drm_dumb.c +++ b/render/allocator/drm_dumb.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include <assert.h> #include <drm_fourcc.h> diff --git a/render/allocator/gbm.c b/render/allocator/gbm.c index 25ddbbae..baa0fb6e 100644 --- a/render/allocator/gbm.c +++ b/render/allocator/gbm.c @@ -1,4 +1,3 @@ -#define _POSIX_C_SOURCE 200809L #include <assert.h> #include <drm_fourcc.h> #include <fcntl.h> -- cgit v1.2.3