Skip to content

Commit 8f4ef2f

Browse files
committed
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 <[email protected]>
1 parent 5a1553e commit 8f4ef2f

2 files changed

Lines changed: 17 additions & 3 deletions

File tree

meson.build

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ conf.set10(
176176
),
177177
description: 'Does struct opal_key have a key_type field?'
178178
)
179+
conf.set(
180+
'HAVE_TM_GMTOFF',
181+
cc.compiles(
182+
'''
183+
#include <time.h>
184+
int main(void) {
185+
struct tm tm;
186+
tm.tm_gmtoff = 1;
187+
}
188+
''',
189+
name: 'tm_gmtoff'
190+
),
191+
description: 'Does struct tm have a tm_gmtoff field?'
192+
)
179193

180194
if cc.has_function_attribute('fallthrough')
181195
conf.set('fallthrough', '__attribute__((__fallthrough__))')

plugins/wdc/wdc-utils.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ int wdc_UtilsGetTime(PUtilsTimeInfo timeInfo)
8181
timeInfo->second = currTimeInfo.tm_sec;
8282
timeInfo->msecs = 0;
8383
timeInfo->isDST = currTimeInfo.tm_isdst;
84-
#if (defined(__GLIBC__) && !defined(__UCLIBC__) && !defined(__MUSL__)) || defined(__FreeBSD__)
84+
#ifdef HAVE_TM_GMTOFF
8585
timeInfo->zone = -currTimeInfo.tm_gmtoff / 60;
86-
#else
86+
#else /* HAVE_TM_GMTOFF */
8787
timeInfo->zone = -1 * (timezone / SECONDS_IN_MIN);
88-
#endif
88+
#endif /* HAVE_TM_GMTOFF */
8989

9090
return WDC_STATUS_SUCCESS;
9191
}

0 commit comments

Comments
 (0)