don't use readFromSysfs on non-linux
authorSara Golemon <sgolemon@fb.com>
Fri, 15 Aug 2014 05:30:58 +0000 (22:30 -0700)
committerSara Golemon <sgolemon@fb.com>
Fri, 15 Aug 2014 05:38:01 +0000 (22:38 -0700)
Summary:
It eventually tries to read from /sys/devices which is not portable.
Let's just fall back to sysconf/CacheLocality::uniform.

This fixes a runtime crash on OSX, but CYGWIN/BSD were probably also
affected.
Closes #80

@override-unit-failures

Test Plan: author tested, contbuild, flib

Reviewed By: joelm@fb.com

FB internal diff: D1498567

folly/detail/CacheLocality.cpp

index adb4561a61f76f85ff4ab8a1cbd1c93b371b2235..e7d992aedab741a82b479c7289056a45d2e5b226 100644 (file)
@@ -32,11 +32,13 @@ namespace folly { namespace detail {
 
 /// Returns the best real CacheLocality information available
 static CacheLocality getSystemLocalityInfo() {
+#ifdef __linux__
   try {
     return CacheLocality::readFromSysfs();
   } catch (...) {
     // keep trying
   }
+#endif
 
   long numCpus = sysconf(_SC_NPROCESSORS_CONF);
   if (numCpus <= 0) {