BUILD: cfgparse: always defined _GNU_SOURCE for sched.h and crypt.h

_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.
This commit is contained in:
Willy Tarreau 2022-08-07 16:55:07 +02:00
parent b6189bc268
commit 2e64472d16

View File

@ -10,10 +10,10 @@
*
*/
#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>