basic: Override glibc's sys/param.h header with an empty file

Instead of unconditionally including sys/param.h in
macro-fundamental.h which itself includes a bunch of other unnecessary
headers, let's override it with an empty file to avoid it from overriding
our MAX() macro. We can't make including it an error as it's included (
for seemingly no good reason) by <resolv.h>.
This commit is contained in:
Daan De Meyer
2025-05-09 11:23:14 +02:00
parent 8449d38d6f
commit 3b58245624
8 changed files with 15 additions and 22 deletions
+8
View File
@@ -0,0 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
/* sys/param.h from glibc unconditionally overrides the MIN() and MAX() macros which interferes with our own
* MAX() macro. It also includes a bunch of other headers transitively so we don't want to include
* sys/param.h in macro-fundamental.h unconditionally. We'd like to make including this file an error but
* unfortunately <resolv.h> includes it. However, <resolv.h> doesn't actually make use of anything from
* sys/param.h, so we override it with an empty file so it can't mess with our macros. */
-1
View File
@@ -5,7 +5,6 @@
#include <errno.h>
#include <inttypes.h>
#include <stdbool.h>
#include <sys/param.h>
#include <sys/sysmacros.h>
#include <sys/types.h>
+2
View File
@@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include <signal.h>
#include "macro.h"
#include "memory-util.h"
+2
View File
@@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <unistd.h>
#include "alloc-util.h"
#include "conf-files.h"
#include "copy.h"
-7
View File
@@ -7,13 +7,6 @@
#include <stddef.h>
#include <stdint.h>
/* This header unconditionally defines MAX() so include it here already so
* it won't override our own definition of MAX() that we define later in this
* file. */
#if !SD_BOOT
#include <sys/param.h>
#endif
/* Temporarily disable some warnings */
#define DISABLE_WARNING_DEPRECATED_DECLARATIONS \
_Pragma("GCC diagnostic push"); \
+1 -4
View File
@@ -47,13 +47,10 @@ on 1 byte), but shoehorning those bytes into integers efficiently is messy.
*/
/* #define SELF_TEST 1 */
#include <endian.h> /* attempt to define endianness */
#include <stdint.h> /* defines uint32_t etc */
#include <stdio.h> /* defines printf for tests */
#include <sys/param.h> /* attempt to define endianness */
#include <time.h> /* defines time_t for timings in the test */
#ifdef linux
# include <endian.h> /* attempt to define endianness */
#endif
_Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"")
-1
View File
@@ -1,7 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <arpa/inet.h>
#include <sys/param.h>
#include "sd-device.h"
+2 -9
View File
@@ -6,7 +6,7 @@
#pragma once
#include <sys/param.h>
#include <limits.h>
#if defined(__FreeBSD_kernel__)
# define INIT_FIFO "/etc/.initctl"
@@ -25,13 +25,6 @@
#define INIT_CMD_UNSETENV 7
#define INIT_CMD_CHANGECONS 12345
#ifdef MAXHOSTNAMELEN
# define INITRQ_HLEN MAXHOSTNAMELEN
#else
# define INITRQ_HLEN 64
#endif
/*
* This is what BSD 4.4 uses when talking to init.
* Linux doesn't use this right now.
@@ -39,7 +32,7 @@
struct init_request_bsd {
char gen_id[8]; /* Beats me.. telnetd uses "fe" */
char tty_id[16]; /* Tty name minus /dev/tty */
char host[INITRQ_HLEN]; /* Hostname */
char host[HOST_NAME_MAX]; /* Hostname */
char term_type[16]; /* Terminal type */
int signal; /* Signal to send */
int pid; /* Process to send to */