[cfe-dev] [libcxx] Why is <sys/sysctl.h> included by default?
Craig, Ben via cfe-dev
cfe-dev at lists.llvm.org
Mon Jan 25 13:13:03 PST 2016
Summary:
I want to switch some code from black-listing platforms to white-listing
platforms instead.
Does anyone know what OSes / platforms want to use sys/sysctl.h in
thread.cpp?
Longer post:
I suspect that this is rapidly going to turn into a discussion on how
libcxx does preprocessor platform detection, but that's kind of what I
want to talk about anyway.
Libcxx's thread.cpp has this chunk of code:
#if !defined(_WIN32)
# if !defined(__sun__) && !defined(__linux__) && !defined(_AIX) &&
!defined(__native_client__) && !defined(__CloudABI__)
# include <sys/sysctl.h>
# endif // !defined(__sun__) && !defined(__linux__) && !defined(_AIX)
&& !defined(__native_client__) && !defined(__CloudABI__)
# include <unistd.h>
#endif // !_WIN32
So if your OS is not one of the six listed (_WIN21, __sun__, __linux__,
AIX, __native_client__, __CloudABI__), then you get to include
sys/sysctl.h. sysctl.h isn't defined by the standard C library, and
isn't part of POSIX.
I'm trying to add some new embedded OS and C library support to libcxx,
and I don't have a sys/sysctl.h. I think the correct and maintainable
thing to do here is to switch away from black-listing certain OSes, and
instead white-list the OSes that want to use sys/sysctl.h here. I don't
know what that list is though.
I'm a little more forgiving of unistd.h, as POSIX at least partially
defines that header.
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
More information about the cfe-dev
mailing list