winpthreads: use `mbsrtowcs` instead of `mbstowcs`

`pthread_setname_np` function defined in thread.c uses `mbstowcs` function
which is not thread-safe. Use `mbsrtowcs` instead.

Signed-off-by: Kirill Makurin <maiddaisuki@outlook.com>
Signed-off-by: LIU Hao <lh_mouse@126.com>
diff --git a/mingw-w64-libraries/winpthreads/src/thread.c b/mingw-w64-libraries/winpthreads/src/thread.c
index 427f6a4..6a86472 100644
--- a/mingw-w64-libraries/winpthreads/src/thread.c
+++ b/mingw-w64-libraries/winpthreads/src/thread.c
@@ -28,6 +28,7 @@
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <wchar.h>
 
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
@@ -1862,13 +1863,14 @@
 
   if (_pthread_set_thread_description != NULL)
     {
-      size_t required_size = mbstowcs(NULL, name, 0);
+      mbstate_t mbs = {0};
+      size_t required_size = mbsrtowcs(NULL, &name, 0, &mbs);
       if (required_size != (size_t)-1)
         {
           wchar_t *wname = malloc((required_size + 1) * sizeof(wchar_t));
           if (wname != NULL)
             {
-              mbstowcs(wname, name, required_size + 1);
+              mbsrtowcs(wname, &name, required_size + 1, &mbs);
               _pthread_set_thread_description(tv->h, wname);
               free(wname);
             }