Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefix C function by gopsutil_v3_ #1176

Merged
merged 1 commit into from Nov 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion v3/disk/disk_darwin_cgo.go
Expand Up @@ -19,7 +19,7 @@ import (

func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOCountersStat, error) {
var buf [C.NDRIVE]C.DriveStats
n, err := C.v3readdrivestat(&buf[0], C.int(len(buf)))
n, err := C.gopsutil_v3_readdrivestat(&buf[0], C.int(len(buf)))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion v3/disk/iostat_darwin.c
Expand Up @@ -16,7 +16,7 @@ static int getdrivestat(io_registry_entry_t d, DriveStats *stat);
static int fillstat(io_registry_entry_t d, DriveStats *stat);

int
v3readdrivestat(DriveStats a[], int n)
gopsutil_v3_readdrivestat(DriveStats a[], int n)
{
mach_port_t port;
CFMutableDictionaryRef match;
Expand Down
2 changes: 1 addition & 1 deletion v3/disk/iostat_darwin.h
Expand Up @@ -29,4 +29,4 @@ struct CPUStats {
natural_t idle;
};

extern int v3readdrivestat(DriveStats a[], int n);
extern int gopsutil_v3_readdrivestat(DriveStats a[], int n);
6 changes: 3 additions & 3 deletions v3/host/host_darwin_cgo.go
Expand Up @@ -34,13 +34,13 @@ func SensorsTemperaturesWithContext(ctx context.Context) ([]TemperatureStat, err
}
var temperatures []TemperatureStat

C.open_smc()
defer C.close_smc()
C.gopsutil_v3_open_smc()
defer C.gopsutil_v3_close_smc()

for _, key := range temperatureKeys {
temperatures = append(temperatures, TemperatureStat{
SensorKey: key,
Temperature: float64(C.get_temperature(C.CString(key))),
Temperature: float64(C.gopsutil_v3_get_temperature(C.CString(key))),
})
}
return temperatures, nil
Expand Down
6 changes: 3 additions & 3 deletions v3/host/smc_darwin.c
Expand Up @@ -68,7 +68,7 @@ typedef struct {
static const int SMC_KEY_SIZE = 4; // number of characters in an SMC key.
static io_connect_t conn; // our connection to the SMC.

kern_return_t open_smc(void) {
kern_return_t gopsutil_v3_open_smc(void) {
kern_return_t result;
io_service_t service;

Expand All @@ -86,7 +86,7 @@ kern_return_t open_smc(void) {
return result;
}

kern_return_t close_smc(void) { return IOServiceClose(conn); }
kern_return_t gopsutil_v3_close_smc(void) { return IOServiceClose(conn); }

static uint32_t to_uint32(char *key) {
uint32_t ans = 0;
Expand Down Expand Up @@ -155,7 +155,7 @@ static kern_return_t read_smc(char *key, smc_return_t *result_smc) {
return result;
}

double get_temperature(char *key) {
double gopsutil_v3_get_temperature(char *key) {
kern_return_t result;
smc_return_t result_smc;

Expand Down
6 changes: 3 additions & 3 deletions v3/host/smc_darwin.h
Expand Up @@ -25,8 +25,8 @@
#define THUNDERBOLT_1 "TI1P"
#define WIRELESS_MODULE "TW0P"

kern_return_t open_smc(void);
kern_return_t close_smc(void);
double get_temperature(char *);
kern_return_t gopsutil_v3_open_smc(void);
kern_return_t gopsutil_v3_close_smc(void);
double gopsutil_v3_get_temperature(char *);

#endif // __SMC_H__