--- src/util.cc.orig	2022-05-15 10:08:10.000000000 -0500
+++ src/util.cc	2022-05-18 04:31:14.000000000 -0500
@@ -62,6 +62,47 @@
 
 using namespace std;
 
+#ifdef __APPLE__
+#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050
+#include <Availability.h>
+#else
+#include <AvailabilityMacros.h>
+#endif
+#endif //#ifndef __MAC_OS_X_VERSION_MIN_REQUIRED
+
+
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+//#include <sys/types.h>
+//#include <sys/sysctl.h>
+#define _SC_NPROCESSORS_ONLN 58
+
+long tigersysconf(int name){
+
+    if (name == _SC_NPROCESSORS_ONLN) {
+		int nm[2];
+		size_t len = 4;
+		uint32_t count;
+		
+		nm[0] = CTL_HW; nm[1] = HW_AVAILCPU;
+		sysctl(nm, 2, &count, &len, NULL, 0);
+		
+		if (count < 1) {
+			nm[1] = HW_NCPU;
+			sysctl(nm, 2, &count, &len, NULL, 0);
+			if (count < 1) { count = 1; }
+			}
+			
+		return (long)count;
+    }
+    return -1;
+}
+#endif //#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+#endif //#ifdef __APPLE__
+
+
+
+
 void Fatal(const char* msg, ...) {
   va_list ap;
   fprintf(stderr, "ninja: fatal: ");
@@ -720,7 +761,12 @@
   }
 #endif
   if (cgroupCount >= 0 && schedCount >= 0) return std::min(cgroupCount, schedCount);
-  if (cgroupCount < 0 && schedCount < 0) return sysconf(_SC_NPROCESSORS_ONLN);
+  if (cgroupCount < 0 && schedCount < 0)
+#if __MAC_OS_X_VERSION_MIN_REQUIRED < 1050
+    return tigersysconf(_SC_NPROCESSORS_ONLN);
+#else
+    return sysconf(_SC_NPROCESSORS_ONLN);
+#endif
   return std::max(cgroupCount, schedCount);
 #endif
 }
