Solaris: add kstat lookup wrappers

The system interfaces kstat_lookup() and kstat_data_lookup() take a
non-constant string parameter, but passing string literals is valid.

Add wrapper functions to ignore all the const-discard warnings.
This commit is contained in:
Christian Göttsche
2021-05-19 19:00:44 +02:00
committed by cgzones
parent 4676e35f42
commit fdda291a0e
3 changed files with 36 additions and 23 deletions

View File

@ -11,6 +11,7 @@ in the source distribution for its full text.
#include "config.h" // IWYU pragma: keep
#include <kstat.h>
#include <libproc.h>
#include <signal.h>
#include <stdbool.h>
@ -109,4 +110,16 @@ static inline void Platform_gettime_monotonic(uint64_t* msec) {
Generic_gettime_monotonic(msec);
}
static inline void* kstat_data_lookup_wrapper(kstat_t* ksp, const char* name) {
IGNORE_WCASTQUAL_BEGIN
return kstat_data_lookup(ksp, (char*)name);
IGNORE_WCASTQUAL_END
}
static inline kstat_t* kstat_lookup_wrapper(kstat_ctl_t* kc, const char* ks_module, int ks_instance, const char* ks_name) {
IGNORE_WCASTQUAL_BEGIN
return kstat_lookup(kc, (char*)ks_module, ks_instance, (char*)ks_name);
IGNORE_WCASTQUAL_END
}
#endif