Use sysconf(_SC_PAGE_SIZE) instead of PAGE_SIZE
The PAGE_SIZE definition isn't available for some reason on the MacOS 11
SDK, but sysconf(_SC_PAGE_SIZE) is more portable anyways, so use that.
Test: build with xcode 12 beta 2 macos 11 sdk
Change-Id: I3464863e0e271f0de67d1cbae6cb7b3f17991b32
diff --git a/cmsg.cpp b/cmsg.cpp
index 1fa873c..95db303 100644
--- a/cmsg.cpp
+++ b/cmsg.cpp
@@ -31,9 +31,10 @@
ssize_t SendFileDescriptorVector(borrowed_fd sockfd, const void* data, size_t len,
const std::vector<int>& fds) {
+ static const size_t page_size = sysconf(_SC_PAGE_SIZE);
size_t cmsg_space = CMSG_SPACE(sizeof(int) * fds.size());
size_t cmsg_len = CMSG_LEN(sizeof(int) * fds.size());
- if (cmsg_space >= PAGE_SIZE) {
+ if (cmsg_space >= page_size) {
errno = ENOMEM;
return -1;
}
@@ -74,8 +75,9 @@
std::vector<unique_fd>* fds) {
fds->clear();
+ static const size_t page_size = sysconf(_SC_PAGE_SIZE);
size_t cmsg_space = CMSG_SPACE(sizeof(int) * max_fds);
- if (cmsg_space >= PAGE_SIZE) {
+ if (cmsg_space >= page_size) {
errno = ENOMEM;
return -1;
}