#include "lookup_table.h"
#include "security.h"
#include "endianness.h"
+#include <pthread.h>
#include <errno.h>
return -1;
}
+
+/* This really could be replaced with _wcserror_s, but this doesn't seem to
+ * actually be available in MSVCRT.DLL on Windows XP (perhaps it's statically
+ * linked in by Visual Studio...?). */
+extern int
+win32_strerror_r_replacement(int errnum, wchar_t *buf, size_t buflen)
+{
+ static pthread_mutex_t strerror_lock = PTHREAD_MUTEX_INITIALIZER;
+
+ pthread_mutex_lock(&strerror_lock);
+ mbstowcs(buf, strerror(errnum), buflen);
+ buf[buflen - 1] = '\0';
+ pthread_mutex_unlock(&strerror_lock);
+ return 0;
+}
+
#endif /* __WIN32__ */
extern void
win32_global_cleanup();
+extern int
+win32_strerror_r_replacement(int errnum, tchar *buf, size_t buflen);
+
#endif /* _WIMLIB_WIN32_H */
* function defined ourselves. */
# define TSTRDUP WSTRDUP
# define tmkdir(path, mode) _wmkdir(path)
-# define tstrerror_r(errnum, buf, bufsize) _wcserror_s(buf, bufsize, errnum)
+# define tstrerror_r win32_strerror_r_replacement
# define trename win32_rename_replacement
# define ttruncate win32_truncate_replacement
#else /* __WIN32__ */