From: Paul Gofman pgofman@codeweavers.com
--- dlls/msvcp140_atomic_wait/main.c | 53 +++++++++++++++++++ .../msvcp140_atomic_wait.spec | 4 +- .../tests/msvcp140_atomic_wait.c | 47 ++++++++++++++++ 3 files changed, 102 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcp140_atomic_wait/main.c b/dlls/msvcp140_atomic_wait/main.c index 9c61b158b97..b79241571cc 100644 --- a/dlls/msvcp140_atomic_wait/main.c +++ b/dlls/msvcp140_atomic_wait/main.c @@ -187,3 +187,56 @@ void __stdcall __std_free_crt(void *ptr) { free(ptr); } + +struct tzdb_time_zones +{ + ULONG_PTR unk; + char *ver; + unsigned int count; + char **names; + char **links; +}; + +struct tzdb_time_zones * __stdcall __std_tzdb_get_time_zones(void) +{ + DYNAMIC_TIME_ZONE_INFORMATION tzd; + static char ver[] = "2022g"; + struct tzdb_time_zones *z; + unsigned int i, j; + + FIXME("returning Windows time zone names.\n"); + + z = calloc(1, sizeof(*z)); + while (!EnumDynamicTimeZoneInformation(z->count, &tzd)) + ++z->count; + + z->ver = ver; + z->names = calloc(z->count, sizeof(*z->names)); + z->links = calloc(z->count, sizeof(*z->links)); + + for (i = 0; i < z->count; ++i) + { + if (EnumDynamicTimeZoneInformation(i, &tzd)) + break; + z->names[i] = malloc(wcslen(tzd.StandardName) + 1); + j = 0; + while ((z->names[i][j] = tzd.StandardName[j])) + ++j; + } + z->count = i; + return z; +} + +void __stdcall __std_tzdb_delete_time_zones(struct tzdb_time_zones *z) +{ + unsigned int i; + + TRACE("(%p)\n", z); + + for (i = 0; i < z->count; ++i) + { + free(z->names[i]); + free(z->links[i]); + } + free(z); +} diff --git a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec index d335828d35c..9cad0f9d0fb 100644 --- a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec +++ b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec @@ -24,9 +24,9 @@ @ stub __std_tzdb_delete_current_zone @ stub __std_tzdb_delete_leap_seconds @ stub __std_tzdb_delete_sys_info -@ stub __std_tzdb_delete_time_zones +@ stdcall __std_tzdb_delete_time_zones(ptr) @ stub __std_tzdb_get_current_zone @ stub __std_tzdb_get_leap_seconds @ stub __std_tzdb_get_sys_info -@ stub __std_tzdb_get_time_zones +@ stdcall __std_tzdb_get_time_zones() @ stdcall __std_wait_for_threadpool_work_callbacks(ptr long) diff --git a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c index 1e99145ac4b..6c0f0eafec4 100644 --- a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c +++ b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c @@ -28,6 +28,15 @@ typedef struct SRWLOCK srwlock; } shared_mutex;
+struct tzdb_time_zones +{ + ULONG_PTR unk; + char *ver; + unsigned int count; + char **names; + char **links; +}; + static unsigned int (__stdcall *p___std_parallel_algorithms_hw_threads)(void);
static void (__stdcall *p___std_bulk_submit_threadpool_work)(PTP_WORK, size_t); @@ -41,6 +50,8 @@ static void (__stdcall *p___std_execution_wait_on_uchar)(void *, unsigned char); static void (__stdcall *p___std_execution_wake_by_address_all)(void *); static shared_mutex* (__stdcall *p___std_acquire_shared_mutex_for_instance)(void*); static void (__stdcall *p___std_release_shared_mutex_for_instance)(void*); +static struct tzdb_time_zones * (__stdcall *p___std_tzdb_get_time_zones)(void); +static void (__stdcall *p___std_tzdb_delete_time_zones)(struct tzdb_time_zones *);
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y) #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0) @@ -64,6 +75,8 @@ static HMODULE init(void) SET(p___std_execution_wake_by_address_all, "__std_execution_wake_by_address_all"); SET(p___std_acquire_shared_mutex_for_instance, "__std_acquire_shared_mutex_for_instance"); SET(p___std_release_shared_mutex_for_instance, "__std_release_shared_mutex_for_instance"); + SET(p___std_tzdb_get_time_zones, "__std_tzdb_get_time_zones"); + SET(p___std_tzdb_delete_time_zones, "__std_tzdb_delete_time_zones"); return msvcp; }
@@ -325,6 +338,39 @@ static void test___std_acquire_shared_mutex_for_instance(void) p___std_release_shared_mutex_for_instance(NULL); }
+static void test___std_tzdb(void) +{ + struct tzdb_time_zones *z; + unsigned int i; + + if (!p___std_tzdb_get_time_zones) + { + win_skip("__std_tzdb_get_time_zones is not available, skipping tests.\n"); + return; + } + + z = p___std_tzdb_get_time_zones(); + ok(!!z, "got NULL.\n"); + ok(!z->unk || broken(z->unk == 1 && !z->ver && !z->count), "got %#Ix.\n", z->unk); + if (z->unk) + { + win_skip("__std_tzdb_get_time_zones empty result, skipping remaining tests.\n"); + p___std_tzdb_delete_time_zones(z); + return; + } + ok(!!z->ver, "got NULL.\n"); + ok(z->count, "got 0.\n"); + *(volatile char *)z->ver |= 0; + + trace("ver %s.\n", debugstr_a(z->ver)); + for (i = 0; i < z->count; ++i) + { + ok(!!z->names[i], "got NULL.\n"); + } + + p___std_tzdb_delete_time_zones(z); +} + START_TEST(msvcp140_atomic_wait) { HMODULE msvcp; @@ -338,5 +384,6 @@ START_TEST(msvcp140_atomic_wait) test___std_atomic_wait_direct(); test___std_execution(); test___std_acquire_shared_mutex_for_instance(); + test___std_tzdb(); FreeLibrary(msvcp); }
From: Paul Gofman pgofman@codeweavers.com
--- dlls/msvcp140_atomic_wait/main.c | 33 +++++++++++++++++++ .../msvcp140_atomic_wait.spec | 4 +-- .../tests/msvcp140_atomic_wait.c | 20 ++++++++++- 3 files changed, 54 insertions(+), 3 deletions(-)
diff --git a/dlls/msvcp140_atomic_wait/main.c b/dlls/msvcp140_atomic_wait/main.c index b79241571cc..76d83d03e7f 100644 --- a/dlls/msvcp140_atomic_wait/main.c +++ b/dlls/msvcp140_atomic_wait/main.c @@ -197,6 +197,12 @@ struct tzdb_time_zones char **links; };
+struct tzdb_current_zone +{ + ULONG_PTR unk; + char *name; +}; + struct tzdb_time_zones * __stdcall __std_tzdb_get_time_zones(void) { DYNAMIC_TIME_ZONE_INFORMATION tzd; @@ -240,3 +246,30 @@ void __stdcall __std_tzdb_delete_time_zones(struct tzdb_time_zones *z) } free(z); } + +struct tzdb_current_zone * __stdcall __std_tzdb_get_current_zone(void) +{ + DYNAMIC_TIME_ZONE_INFORMATION tzd; + struct tzdb_current_zone *c; + unsigned int i; + + FIXME("returning Windows time zone name.\n"); + + if (GetDynamicTimeZoneInformation(&tzd) == TIME_ZONE_ID_INVALID) + return NULL; + + c = calloc(1, sizeof(*c)); + c->name = malloc(wcslen(tzd.StandardName) + 1); + i = 0; + while ((c->name[i] = tzd.StandardName[i])) + ++i; + return c; +} + +void __stdcall __std_tzdb_delete_current_zone(struct tzdb_current_zone *c) +{ + TRACE("(%p)\n", c); + + free(c->name); + free(c); +} diff --git a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec index 9cad0f9d0fb..164e562baa8 100644 --- a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec +++ b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec @@ -21,11 +21,11 @@ @ stdcall __std_parallel_algorithms_hw_threads() @ stdcall __std_release_shared_mutex_for_instance(ptr) @ stdcall __std_submit_threadpool_work(ptr) -@ stub __std_tzdb_delete_current_zone +@ stdcall __std_tzdb_delete_current_zone(ptr) @ stub __std_tzdb_delete_leap_seconds @ stub __std_tzdb_delete_sys_info @ stdcall __std_tzdb_delete_time_zones(ptr) -@ stub __std_tzdb_get_current_zone +@ stdcall __std_tzdb_get_current_zone() @ stub __std_tzdb_get_leap_seconds @ stub __std_tzdb_get_sys_info @ stdcall __std_tzdb_get_time_zones() diff --git a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c index 6c0f0eafec4..70615e78843 100644 --- a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c +++ b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c @@ -37,6 +37,12 @@ struct tzdb_time_zones char **links; };
+struct tzdb_current_zone +{ + ULONG_PTR unk; + char *name; +}; + static unsigned int (__stdcall *p___std_parallel_algorithms_hw_threads)(void);
static void (__stdcall *p___std_bulk_submit_threadpool_work)(PTP_WORK, size_t); @@ -52,6 +58,8 @@ static shared_mutex* (__stdcall *p___std_acquire_shared_mutex_for_instance)(void static void (__stdcall *p___std_release_shared_mutex_for_instance)(void*); static struct tzdb_time_zones * (__stdcall *p___std_tzdb_get_time_zones)(void); static void (__stdcall *p___std_tzdb_delete_time_zones)(struct tzdb_time_zones *); +static struct tzdb_current_zone * (__stdcall *p___std_tzdb_get_current_zone)(void); +static void (__stdcall *p___std_tzdb_delete_current_zone)(struct tzdb_current_zone *);
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y) #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0) @@ -77,6 +85,8 @@ static HMODULE init(void) SET(p___std_release_shared_mutex_for_instance, "__std_release_shared_mutex_for_instance"); SET(p___std_tzdb_get_time_zones, "__std_tzdb_get_time_zones"); SET(p___std_tzdb_delete_time_zones, "__std_tzdb_delete_time_zones"); + SET(p___std_tzdb_get_current_zone, "__std_tzdb_get_current_zone"); + SET(p___std_tzdb_delete_current_zone, "__std_tzdb_delete_current_zone"); return msvcp; }
@@ -340,6 +350,7 @@ static void test___std_acquire_shared_mutex_for_instance(void)
static void test___std_tzdb(void) { + struct tzdb_current_zone *c; struct tzdb_time_zones *z; unsigned int i;
@@ -363,11 +374,18 @@ static void test___std_tzdb(void) *(volatile char *)z->ver |= 0;
trace("ver %s.\n", debugstr_a(z->ver)); + c = p___std_tzdb_get_current_zone(); + ok(!!c, "got NULL.\n"); + ok(!!c->name, "got NULL.\n"); + ok(!c->unk, "got %#Ix.\n", c->unk); for (i = 0; i < z->count; ++i) { - ok(!!z->names[i], "got NULL.\n"); + if (!strcmp(c->name, z->names[i])) + break; } + ok(i < z->count, "current zone %s not found.\n", c->name);
+ p___std_tzdb_delete_current_zone(c); p___std_tzdb_delete_time_zones(z); }
From: Paul Gofman pgofman@codeweavers.com
--- dlls/msvcp140_atomic_wait/main.c | 15 +++++++++++++++ .../msvcp140_atomic_wait.spec | 4 ++-- .../tests/msvcp140_atomic_wait.c | 12 ++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/dlls/msvcp140_atomic_wait/main.c b/dlls/msvcp140_atomic_wait/main.c index 76d83d03e7f..30b76522b2c 100644 --- a/dlls/msvcp140_atomic_wait/main.c +++ b/dlls/msvcp140_atomic_wait/main.c @@ -273,3 +273,18 @@ void __stdcall __std_tzdb_delete_current_zone(struct tzdb_current_zone *c) free(c->name); free(c); } + +void * __stdcall __std_tzdb_get_leap_seconds(ULONG_PTR arg1, ULONG_PTR *arg2) +{ + FIXME("(%#Ix %p) stub\n", arg1, arg2); + + *arg2 = 0; + return NULL; +} + +void __stdcall __std_tzdb_delete_leap_seconds(void *l) +{ + TRACE("(%p)\n", l); + + free(l); +} diff --git a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec index 164e562baa8..5d23b217b72 100644 --- a/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec +++ b/dlls/msvcp140_atomic_wait/msvcp140_atomic_wait.spec @@ -22,11 +22,11 @@ @ stdcall __std_release_shared_mutex_for_instance(ptr) @ stdcall __std_submit_threadpool_work(ptr) @ stdcall __std_tzdb_delete_current_zone(ptr) -@ stub __std_tzdb_delete_leap_seconds +@ stdcall __std_tzdb_delete_leap_seconds(ptr) @ stub __std_tzdb_delete_sys_info @ stdcall __std_tzdb_delete_time_zones(ptr) @ stdcall __std_tzdb_get_current_zone() -@ stub __std_tzdb_get_leap_seconds +@ stdcall __std_tzdb_get_leap_seconds(ptr ptr) @ stub __std_tzdb_get_sys_info @ stdcall __std_tzdb_get_time_zones() @ stdcall __std_wait_for_threadpool_work_callbacks(ptr long) diff --git a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c index 70615e78843..2fa23107674 100644 --- a/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c +++ b/dlls/msvcp140_atomic_wait/tests/msvcp140_atomic_wait.c @@ -60,6 +60,8 @@ static struct tzdb_time_zones * (__stdcall *p___std_tzdb_get_time_zones)(void); static void (__stdcall *p___std_tzdb_delete_time_zones)(struct tzdb_time_zones *); static struct tzdb_current_zone * (__stdcall *p___std_tzdb_get_current_zone)(void); static void (__stdcall *p___std_tzdb_delete_current_zone)(struct tzdb_current_zone *); +static void * (__stdcall *p___std_tzdb_get_leap_seconds)(ULONG_PTR arg1, ULONG_PTR *); +static void (__stdcall *p___std_tzdb_delete_leap_seconds)(void *);
#define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y) #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0) @@ -87,6 +89,8 @@ static HMODULE init(void) SET(p___std_tzdb_delete_time_zones, "__std_tzdb_delete_time_zones"); SET(p___std_tzdb_get_current_zone, "__std_tzdb_get_current_zone"); SET(p___std_tzdb_delete_current_zone, "__std_tzdb_delete_current_zone"); + SET(p___std_tzdb_get_leap_seconds, "__std_tzdb_get_leap_seconds"); + SET(p___std_tzdb_delete_leap_seconds, "__std_tzdb_delete_leap_seconds"); return msvcp; }
@@ -352,7 +356,9 @@ static void test___std_tzdb(void) { struct tzdb_current_zone *c; struct tzdb_time_zones *z; + void *leap_seconds; unsigned int i; + ULONG_PTR arg2;
if (!p___std_tzdb_get_time_zones) { @@ -387,6 +393,12 @@ static void test___std_tzdb(void)
p___std_tzdb_delete_current_zone(c); p___std_tzdb_delete_time_zones(z); + + arg2 = 0xdeadbeef; + leap_seconds = p___std_tzdb_get_leap_seconds(100, &arg2); + ok(!leap_seconds, "got %p.\n", leap_seconds); + ok(!arg2, "got %#Ix.\n", arg2); + p___std_tzdb_delete_leap_seconds(leap_seconds); }
START_TEST(msvcp140_atomic_wait)
This allows Predecessor work with builtin msvcp140_atomic_wait.
The real information returned there should be not Windows time zones but instead IANA time zones. Windows probably gets that from icu.dll which we currently don't have.
Separately, __std_tzdb_get_leap_seconds() always returns NULL for me for some reason on Windows, even with the parameters the game is using (both locally and across Testbot), so the stub does the same.