This repository was archived by the owner on Jan 23, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Expand file tree Collapse file tree 2 files changed +17
-3
lines changed Original file line number Diff line number Diff line change 40
40
#include < unistd.h> // sysconf
41
41
#include " globals.h"
42
42
43
+ #if defined(_ARM_) || defined(_ARM64_)
44
+ #define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
45
+ #else
46
+ #define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
47
+ #endif
48
+
43
49
// The cachced number of logical CPUs observed.
44
50
static uint32_t g_logicalCpuCount = 0 ;
45
51
@@ -67,7 +73,7 @@ bool GCToOSInterface::Initialize()
67
73
g_pageSizeUnixInl = uint32_t ((pageSize > 0 ) ? pageSize : 0x1000 );
68
74
69
75
// Calculate and cache the number of processors on this machine
70
- int cpuCount = sysconf (_SC_NPROCESSORS_ONLN );
76
+ int cpuCount = sysconf (SYSCONF_GET_NUMPROCS );
71
77
if (cpuCount == -1 )
72
78
{
73
79
return false ;
Original file line number Diff line number Diff line change @@ -103,10 +103,18 @@ PAL_GetLogicalCpuCountFromOS()
103
103
int nrcpus = 0 ;
104
104
105
105
#if HAVE_SYSCONF
106
- nrcpus = sysconf (_SC_NPROCESSORS_ONLN);
106
+
107
+ #if defined(_ARM_) || defined(_ARM64_)
108
+ #define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_CONF
109
+ #define SYSCONF_GET_NUMPROCS_NAME " _SC_NPROCESSORS_CONF"
110
+ #else
111
+ #define SYSCONF_GET_NUMPROCS _SC_NPROCESSORS_ONLN
112
+ #define SYSCONF_GET_NUMPROCS_NAME " _SC_NPROCESSORS_ONLN"
113
+ #endif
114
+ nrcpus = sysconf (SYSCONF_GET_NUMPROCS);
107
115
if (nrcpus < 1 )
108
116
{
109
- ASSERT (" sysconf failed for _SC_NPROCESSORS_ONLN (%d)\n " , errno);
117
+ ASSERT (" sysconf failed for %s (%d)\n " , SYSCONF_GET_NUMPROCS_NAME , errno);
110
118
}
111
119
#elif HAVE_SYSCTL
112
120
int rc;
You can’t perform that action at this time.
0 commit comments