From 8f4ef2f55c5dcf5049db90d23d955fcf951f51af Mon Sep 17 00:00:00 2001 From: Tokunori Ikegami Date: Wed, 21 May 2025 01:33:03 +0900 Subject: [PATCH] wdc: use HAVE_TM_GMTOFF meson configuration variable Set the variable if the struct tm have a tm_gmtoff field. Signed-off-by: Tokunori Ikegami --- meson.build | 14 ++++++++++++++ plugins/wdc/wdc-utils.c | 6 +++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/meson.build b/meson.build index b4192495a6..02f6050604 100644 --- a/meson.build +++ b/meson.build @@ -176,6 +176,20 @@ conf.set10( ), description: 'Does struct opal_key have a key_type field?' ) +conf.set( + 'HAVE_TM_GMTOFF', + cc.compiles( + ''' + #include + int main(void) { + struct tm tm; + tm.tm_gmtoff = 1; + } + ''', + name: 'tm_gmtoff' + ), + description: 'Does struct tm have a tm_gmtoff field?' +) if cc.has_function_attribute('fallthrough') conf.set('fallthrough', '__attribute__((__fallthrough__))') diff --git a/plugins/wdc/wdc-utils.c b/plugins/wdc/wdc-utils.c index 31884990b7..9988ff1d12 100644 --- a/plugins/wdc/wdc-utils.c +++ b/plugins/wdc/wdc-utils.c @@ -81,11 +81,11 @@ int wdc_UtilsGetTime(PUtilsTimeInfo timeInfo) timeInfo->second = currTimeInfo.tm_sec; timeInfo->msecs = 0; timeInfo->isDST = currTimeInfo.tm_isdst; -#if (defined(__GLIBC__) && !defined(__UCLIBC__) && !defined(__MUSL__)) || defined(__FreeBSD__) +#ifdef HAVE_TM_GMTOFF timeInfo->zone = -currTimeInfo.tm_gmtoff / 60; -#else +#else /* HAVE_TM_GMTOFF */ timeInfo->zone = -1 * (timezone / SECONDS_IN_MIN); -#endif +#endif /* HAVE_TM_GMTOFF */ return WDC_STATUS_SUCCESS; }