]> git.kaiwu.me - quickjs.git/commitdiff
keep more generic cpu_count() for non Linux systems
authorFabrice Bellard <fabrice@bellard.org>
Thu, 4 Jun 2026 09:08:15 +0000 (11:08 +0200)
committerFabrice Bellard <fabrice@bellard.org>
Thu, 4 Jun 2026 09:08:15 +0000 (11:08 +0200)
run-test262.c

index 8e2a7e7a539990038242085c0e0a1507187e8ee2..81811b58d1abcb3fcf212f483d5d57fd2bd03397 100644 (file)
@@ -151,7 +151,7 @@ static int cpu_count(void)
             count += 1 & (procmask >> i);
     return count;
 }
-#else
+#elif defined(__linux__)
 /* return the number of available physical cores or -1 if not available */
 static int get_cpu_info_physical_cores(void)
 {
@@ -215,7 +215,12 @@ static int cpu_count(void)
         n = 1;
     return n;
 }
-#endif /* !_WIN32 */
+#else /* __linux__ */
+static int cpu_count(void)
+{
+    return sysconf(_SC_NPROCESSORS_ONLN);
+}
+#endif /* !__linux__ */
 
 static void init_thread_local_storage(ThreadLocalStorage *tls)
 {