From: Sara Golemon Date: Fri, 15 Aug 2014 05:30:58 +0000 (-0700) Subject: don't use readFromSysfs on non-linux X-Git-Tag: v0.22.0~400 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=37ac741361ee8245da19ad8a63efff6fbe6d71eb;p=folly.git don't use readFromSysfs on non-linux 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 --- diff --git a/folly/detail/CacheLocality.cpp b/folly/detail/CacheLocality.cpp index adb4561a..e7d992ae 100644 --- a/folly/detail/CacheLocality.cpp +++ b/folly/detail/CacheLocality.cpp @@ -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) {