Last active
December 4, 2021 03:36
-
-
Save shirou/30d9e63b4f84c86967fa1c9f8971ec09 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/disk/iostat_darwin.c b/disk/iostat_darwin.c | |
index 9619c6f..04d9984 100644 | |
--- a/disk/iostat_darwin.c | |
+++ b/disk/iostat_darwin.c | |
@@ -25,7 +25,7 @@ readdrivestat(DriveStats a[], int n) | |
kern_return_t status; | |
int na, rv; | |
- IOMasterPort(bootstrap_port, &port); | |
+ IOMainPort(bootstrap_port, &port); | |
match = IOServiceMatching("IOMedia"); | |
CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue); | |
status = IOServiceGetMatchingServices(port, match, &drives); | |
diff --git a/disk/iostat_darwin.h b/disk/iostat_darwin.h | |
index c720849..d943fdf 100644 | |
--- a/disk/iostat_darwin.h | |
+++ b/disk/iostat_darwin.h | |
@@ -30,3 +30,7 @@ struct CPUStats { | |
}; | |
extern int gopsutil_v3_readdrivestat(DriveStats a[], int n); | |
+ | |
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < 120000) // Before macOS 12 Monterey | |
+ #define IOMainPort IOMasterPort | |
+#endif | |
diff --git a/host/smc_darwin.c b/host/smc_darwin.c | |
index aedea8b..7d4879c 100644 | |
--- a/host/smc_darwin.c | |
+++ b/host/smc_darwin.c | |
@@ -72,7 +72,7 @@ kern_return_t open_smc(void) { | |
kern_return_t result; | |
io_service_t service; | |
- service = IOServiceGetMatchingService(kIOMasterPortDefault, | |
+ service = IOServiceGetMatchingService(kIOMainPortDefault, | |
IOServiceMatching(IOSERVICE_SMC)); | |
if (service == 0) { | |
// Note: IOServiceMatching documents 0 on failure | |
diff --git a/host/smc_darwin.h b/host/smc_darwin.h | |
index ab51ed9..d479686 100644 | |
--- a/host/smc_darwin.h | |
+++ b/host/smc_darwin.h | |
@@ -29,4 +29,9 @@ kern_return_t open_smc(void); | |
kern_return_t close_smc(void); | |
double get_temperature(char *); | |
+#if (MAC_OS_X_VERSION_MIN_REQUIRED < 120000) // Before macOS 12 Monterey | |
+ #define kIOMainPortDefault kIOMasterPortDefault | |
+#endif | |
+ | |
+ | |
#endif // __SMC_H__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment