Skip to content

Commit

Permalink
Merge pull request #1176 from PierreF/cgo-conflict-names-v3
Browse files Browse the repository at this point in the history
Prefix C function by gopsutil_v3_
  • Loading branch information
shirou authored Nov 30, 2021
2 parents aa3378b + 71d0d31 commit 3b41707
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion v3/disk/disk_darwin_cgo.go
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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__

0 comments on commit 3b41707

Please sign in to comment.