Summary:
This diff strengthens the preconditions for attempting to use
optimize by madvising away idle stacks, because it seemed to be causing
problems on OS X (https://github.com/facebook/proxygen/issues/3).
Test Plan: unit tests
Reviewed By: ldbrandy@fb.com
Subscribers: folly-diffs@, yfeldblum, chalfant
FB internal diff:
D2129100
Signature: t1:
2129100:
1433458268:
0b6b3696dde6c2bd13b89bc7ec58f0b1898be458
}
-#if FOLLY_X64
+// Stack madvise isn't Linux or glibc specific, but the system calls
+// and arithmetic (and bug compatibility) are not portable. The set of
+// platforms could be increased if it was useful.
+#if FOLLY_X64 && defined(_GNU_SOURCE) && defined(__linux__)
static const size_t s_pageSize = sysconf(_SC_PAGESIZE);
static FOLLY_TLS uintptr_t tls_stackLimit;
static void fetchStackLimits() {
pthread_attr_t attr;
-#if defined(_GNU_SOURCE) && defined(__linux__) // Linux+GNU extension
pthread_getattr_np(pthread_self(), &attr);
-#else
- pthread_attr_init(&attr);
-#endif
SCOPE_EXIT { pthread_attr_destroy(&attr); };
void* addr;