mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-02 22:17:08 +08:00
Merge pull request #1333 from kyz/remove-iomainport
Replace IOMainPort/IOMasterPort() and kIOMainPortDefault/kIOMasterPortDefault with NULL
This commit is contained in:
commit
360136f405
@ -18,17 +18,15 @@ static int fillstat(io_registry_entry_t d, DriveStats *stat);
|
|||||||
int
|
int
|
||||||
gopsutil_v3_readdrivestat(DriveStats a[], int n)
|
gopsutil_v3_readdrivestat(DriveStats a[], int n)
|
||||||
{
|
{
|
||||||
mach_port_t port;
|
|
||||||
CFMutableDictionaryRef match;
|
CFMutableDictionaryRef match;
|
||||||
io_iterator_t drives;
|
io_iterator_t drives;
|
||||||
io_registry_entry_t d;
|
io_registry_entry_t d;
|
||||||
kern_return_t status;
|
kern_return_t status;
|
||||||
int na, rv;
|
int na, rv;
|
||||||
|
|
||||||
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(0, match, &drives);
|
||||||
if(status != KERN_SUCCESS)
|
if(status != KERN_SUCCESS)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
@ -30,7 +30,3 @@ 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,8 +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(kIOMainPortDefault,
|
service = IOServiceGetMatchingService(0, IOServiceMatching(IOSERVICE_SMC));
|
||||||
IOServiceMatching(IOSERVICE_SMC));
|
|
||||||
if (service == 0) {
|
if (service == 0) {
|
||||||
// Note: IOServiceMatching documents 0 on failure
|
// Note: IOServiceMatching documents 0 on failure
|
||||||
printf("ERROR: %s NOT FOUND\n", IOSERVICE_SMC);
|
printf("ERROR: %s NOT FOUND\n", IOSERVICE_SMC);
|
||||||
|
@ -29,9 +29,4 @@ 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