mirror of
https://github.com/shirou/gopsutil.git
synced 2025-04-28 13:48:49 +08:00
Merge pull request #1191 from shirou/feature/update_mac_cgo
[disk][host][mac] fix deprecated code in macOS Monterey
This commit is contained in:
commit
b1186a68ed
@ -25,7 +25,7 @@ gopsutil_v3_readdrivestat(DriveStats a[], int n)
|
|||||||
kern_return_t status;
|
kern_return_t status;
|
||||||
int na, rv;
|
int na, rv;
|
||||||
|
|
||||||
IOMasterPort(bootstrap_port, &port);
|
IOMainPort(bootstrap_port, &port);
|
||||||
match = IOServiceMatching("IOMedia");
|
match = IOServiceMatching("IOMedia");
|
||||||
CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
|
CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue);
|
||||||
status = IOServiceGetMatchingServices(port, match, &drives);
|
status = IOServiceGetMatchingServices(port, match, &drives);
|
||||||
|
@ -30,3 +30,7 @@ struct CPUStats {
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern int gopsutil_v3_readdrivestat(DriveStats a[], int n);
|
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
|
||||||
|
@ -72,7 +72,7 @@ kern_return_t gopsutil_v3_open_smc(void) {
|
|||||||
kern_return_t result;
|
kern_return_t result;
|
||||||
io_service_t service;
|
io_service_t service;
|
||||||
|
|
||||||
service = IOServiceGetMatchingService(kIOMasterPortDefault,
|
service = IOServiceGetMatchingService(kIOMainPortDefault,
|
||||||
IOServiceMatching(IOSERVICE_SMC));
|
IOServiceMatching(IOSERVICE_SMC));
|
||||||
if (service == 0) {
|
if (service == 0) {
|
||||||
// Note: IOServiceMatching documents 0 on failure
|
// Note: IOServiceMatching documents 0 on failure
|
||||||
|
@ -29,4 +29,9 @@ kern_return_t gopsutil_v3_open_smc(void);
|
|||||||
kern_return_t gopsutil_v3_close_smc(void);
|
kern_return_t gopsutil_v3_close_smc(void);
|
||||||
double gopsutil_v3_get_temperature(char *);
|
double gopsutil_v3_get_temperature(char *);
|
||||||
|
|
||||||
|
#if (MAC_OS_X_VERSION_MIN_REQUIRED < 120000) // Before macOS 12 Monterey
|
||||||
|
#define kIOMainPortDefault kIOMasterPortDefault
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // __SMC_H__
|
#endif // __SMC_H__
|
||||||
|
Loading…
x
Reference in New Issue
Block a user