]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: cfgparse: always defined _GNU_SOURCE for sched.h and crypt.h
authorWilly Tarreau <w@1wt.eu>
Sun, 7 Aug 2022 14:55:07 +0000 (16:55 +0200)
committerWilly Tarreau <w@1wt.eu>
Sun, 7 Aug 2022 14:55:07 +0000 (16:55 +0200)
_GNU_SOURCE used to be defined only when USE_LIBCRYPT was set. It's also
needed for sched_setaffinity() to be exported. As a side effect, when
USE_LIBCRYPT is not set, a warning is emitted, as Ilya found and reported
in issue #1815. Let's just define _GNU_SOURCE regardless of USE_LIBCRYPT,
and also explicitly add sched.h, as right now it appears to be inherited
from one of the other includes.

This should be backported to 2.4.

src/cfgparse.c

index 52979390b58c21fa33a369badbf666397a3d1751..fc447d6eb5e2a45539fdcf696ae5454fab1efbca 100644 (file)
  *
  */
 
-#ifdef USE_LIBCRYPT
-/* This is to have crypt() defined on Linux */
+/* This is to have crypt() and sched_setaffinity() defined on Linux */
 #define _GNU_SOURCE
 
+#ifdef USE_LIBCRYPT
 #ifdef USE_CRYPT_H
 /* some platforms such as Solaris need this */
 #include <crypt.h>
@@ -29,6 +29,9 @@
 #include <pwd.h>
 #include <grp.h>
 #include <errno.h>
+#ifdef USE_CPU_AFFINITY
+#include <sched.h>
+#endif
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>