summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmair Majid <omajid@redhat.com>2019-10-16 05:25:29 -0400
committerHyungju Lee <leee.lee@samsung.com>2020-10-30 18:17:20 +0900
commitd0aeccc55a5803b95af74dd326ca7458d99a16e5 (patch)
treea8b15f1dbef696309937da5457b4f5e79745f4dc
parent2a8e481e2a22a38e3a231302885c306ce1c90668 (diff)
downloadcoreclr-d0aeccc55a5803b95af74dd326ca7458d99a16e5.tar.gz
coreclr-d0aeccc55a5803b95af74dd326ca7458d99a16e5.tar.bz2
coreclr-d0aeccc55a5803b95af74dd326ca7458d99a16e5.zip
Handle glibc sys/sysctl.h deprecation (#27048)
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
-rw-r--r--src/pal/src/misc/sysinfo.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/pal/src/misc/sysinfo.cpp b/src/pal/src/misc/sysinfo.cpp
index e3d001b544..56c72878be 100644
--- a/src/pal/src/misc/sysinfo.cpp
+++ b/src/pal/src/misc/sysinfo.cpp
@@ -26,9 +26,12 @@ Revision History:
#include <errno.h>
#include <unistd.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