Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Handle glibc sys/sysctl.h deprecation (#27048)
Browse files Browse the repository at this point in the history
glibc has deprecated sys/sysctl.h:

    In file included from /coreclr/src/pal/src/misc/sysinfo.cpp:32:
    /usr/include/sys/sysctl.h:21:2: error: "The <sys/sysctl.h> header is deprecated and will be removed." [-Werror,-W#warnings]
    #warning "The <sys/sysctl.h> header is deprecated and will be removed."
     ^
    1 error generated.

Fix that by preferring sysconf and only including sys/sysctl.h if
HAVE_SYSCONF is not true. This mirrors the order of the implementation
code in this file (sysinfo.cpp) which checks for HAVE_SYSCONF
before HAVE_SYSCTL.

Fixes #27008
  • Loading branch information
omajid authored and janvorli committed Oct 16, 2019
1 parent c07ec4c commit 6ce179a
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/pal/src/misc/sysinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ Revision History:
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <sys/types.h>
#if HAVE_SYSCTL

#if HAVE_SYSCONF
// <unistd.h> already included above
#elif HAVE_SYSCTL
#include <sys/sysctl.h>
#elif !HAVE_SYSCONF
#else
#error Either sysctl or sysconf is required for GetSystemInfo.
#endif

Expand Down

0 comments on commit 6ce179a

Please sign in to comment.