| 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ |
| 6 | |
| 7 | #undef __MSVCRT_VERSION__ |
| 8 | #define _UCRT |
| 9 | |
| 10 | #include <time.h> |
| 11 | |
| 12 | // These are required to provide the unrepfixed data symbols "timezone" |
| 13 | // and "tzname"; we can't remap "timezone" via a define due to clashes |
| 14 | // with e.g. "struct timezone". |
| 15 | typedef void __cdecl (*_tzset_func)(void); |
| 16 | extern _tzset_func __MINGW_IMP_SYMBOL(_tzset); |
| 17 | |
| 18 | // Default initial values until _tzset has been called; these are the same |
| 19 | // as the initial values in msvcrt/ucrtbase. |
| 20 | static char initial_tzname0[] = "PST"; |
| 21 | static char initial_tzname1[] = "PDT"; |
| 22 | static char *initial_tznames[] = { initial_tzname0, initial_tzname1 }; |
| 23 | static long initial_timezone = 28800; |
| 24 | static int initial_daylight = 1; |
| 25 | char** __MINGW_IMP_SYMBOL(tzname) = initial_tznames; |
| 26 | long * __MINGW_IMP_SYMBOL(timezone) = &initial_timezone; |
| 27 | int * __MINGW_IMP_SYMBOL(daylight) = &initial_daylight; |
| 28 | |
| 29 | void __cdecl _tzset(void) |
| 30 | { |
| 31 | __MINGW_IMP_SYMBOL(_tzset)(); |
| 32 | // Redirect the __imp_ pointers to the actual data provided by the UCRT. |
| 33 | // From this point, the exposed values should stay in sync. |
| 34 | __MINGW_IMP_SYMBOL(tzname) = _tzname; |
| 35 | __MINGW_IMP_SYMBOL(timezone) = __timezone(); |
| 36 | __MINGW_IMP_SYMBOL(daylight) = __daylight(); |
| 37 | } |
| 38 | |
| 39 | void __cdecl tzset(void) |
| 40 | { |
| 41 | _tzset(); |
| 42 | } |