[PATCH] D39490: [scudo] Make getNumberOfCPUs Fuchsia compliant

Kostya Kortchinsky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 3 09:47:27 PDT 2017


cryptoad added a comment.

Except for the rebase, and the inline comment, maybe the API should return a u32 instead of uptr:

- CPU_COUNT returns an int;
- zx_system_get_num_cpus returns a uint32_t;
- HW_NCPU seems to be an int as well;
- NumberOfTSDs is a u32.

That could probably avoid some 32 -> 64 -> 32 conversions on 64-bit platforms. Opinions?



================
Comment at: lib/sanitizer_common/sanitizer_linux.cc:1845
+  req[1] = HW_NCPU;
+  if (sysctl(req, 2, &ncpu, &len, NULL, 0) == -1) {
+    Printf("sysctl hw.ncpu failed\n");
----------------
Maybe a CHECK_EQ(..., 0) here (or _NE -1). More concise, benefits of UNLIKELY.


Repository:
  rL LLVM

https://reviews.llvm.org/D39490





More information about the llvm-commits mailing list