From 71d0d31e5d9edc68bdc42ae4d4df4ed50b4841e2 Mon Sep 17 00:00:00 2001 From: Pierre Fersing Date: Wed, 10 Nov 2021 20:08:15 +0100 Subject: [PATCH] Prefix C function by gopsutil_v3_ This should avoid conflict between both: * Version 2 of gopsutil * Other library in version 3 that define the same C function --- v3/disk/disk_darwin_cgo.go | 2 +- v3/disk/iostat_darwin.c | 2 +- v3/disk/iostat_darwin.h | 2 +- v3/host/host_darwin_cgo.go | 6 +++--- v3/host/smc_darwin.c | 6 +++--- v3/host/smc_darwin.h | 6 +++--- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/v3/disk/disk_darwin_cgo.go b/v3/disk/disk_darwin_cgo.go index fa3de37b7..8551c2f19 100644 --- a/v3/disk/disk_darwin_cgo.go +++ b/v3/disk/disk_darwin_cgo.go @@ -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 } diff --git a/v3/disk/iostat_darwin.c b/v3/disk/iostat_darwin.c index 9cd2f60b3..1ec698a21 100644 --- a/v3/disk/iostat_darwin.c +++ b/v3/disk/iostat_darwin.c @@ -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; diff --git a/v3/disk/iostat_darwin.h b/v3/disk/iostat_darwin.h index 7706c538c..cb9ec7a0a 100644 --- a/v3/disk/iostat_darwin.h +++ b/v3/disk/iostat_darwin.h @@ -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); diff --git a/v3/host/host_darwin_cgo.go b/v3/host/host_darwin_cgo.go index d5ba4cde3..5c06d9031 100644 --- a/v3/host/host_darwin_cgo.go +++ b/v3/host/host_darwin_cgo.go @@ -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 diff --git a/v3/host/smc_darwin.c b/v3/host/smc_darwin.c index aedea8be9..c029d0ab6 100644 --- a/v3/host/smc_darwin.c +++ b/v3/host/smc_darwin.c @@ -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; @@ -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; @@ -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; diff --git a/v3/host/smc_darwin.h b/v3/host/smc_darwin.h index ab51ed9f7..e3013abdb 100644 --- a/v3/host/smc_darwin.h +++ b/v3/host/smc_darwin.h @@ -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__