LCOV - code coverage report
Current view: top level - js/src/threading/posix - CpuCount.cpp (source / functions) Hit Total Coverage
Test: output.info Lines: 5 5 100.0 %
Date: 2017-07-14 16:53:18 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #include <unistd.h>
       7             : 
       8             : #include "threading/CpuCount.h"
       9             : 
      10             : uint32_t
      11           7 : js::GetCPUCount()
      12             : {
      13             :     static uint32_t ncpus = 0;
      14             : 
      15             :     // _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN are common, but not
      16             :     // standard.
      17           7 :     if (ncpus == 0) {
      18             : #if defined(_SC_NPROCESSORS_CONF)
      19           3 :         long n = sysconf(_SC_NPROCESSORS_CONF);
      20           3 :         ncpus = (n > 0) ? uint32_t(n) : 1;
      21             : #elif defined(_SC_NPROCESSORS_ONLN)
      22             :         long n = sysconf(_SC_NPROCESSORS_ONLN);
      23             :         ncpus = (n > 0) ? uint32_t(n) : 1;
      24             : #else
      25             :         ncpus = 1;
      26             : #endif
      27             :     }
      28             : 
      29           7 :     return ncpus;
      30             : }

Generated by: LCOV version 1.13