On Fri, 16 Jan 2026, LIU Hao wrote:
在 2025-12-20 00:24, Pali Rohár 写道:
POSIX mkdtemp() function creates a unique temporary directory from input
template string.
Implementation is copied from mingw-w64-crt/misc/mkstemp.c file with
replaced _sopen() call by the _mkdir() call.
---
mingw-w64-crt/Makefile.am | 3 +-
mingw-w64-crt/misc/mkdtemp.c | 83 ++++++++++++++++++++++++++++++++++
mingw-w64-headers/crt/stdlib.h | 1 +
3 files changed, 86 insertions(+), 1 deletion(-)
create mode 100644 mingw-w64-crt/misc/mkdtemp.c
diff --git a/mingw-w64-headers/crt/stdlib.h
b/mingw-w64-headers/crt/stdlib.h
index a53c2ecb1c51..23c653d186f6 100644
--- a/mingw-w64-headers/crt/stdlib.h
+++ b/mingw-w64-headers/crt/stdlib.h
@@ -355,6 +355,7 @@ _CRTIMP int __cdecl ___mb_cur_max_func(void);
size_t __cdecl mbstowcs(wchar_t * __restrict__ _Dest,const char *
__restrict__ _Source,size_t _MaxCount);
_CRTIMP size_t __cdecl _mbstowcs_l(wchar_t * __restrict__ _Dest,const
char * __restrict__ _Source,size_t _MaxCount,_locale_t _Locale);
int __cdecl mkstemp(char *template_name);
+ char *__cdecl mkdtemp(char *template_name);
The name of this parameter has to be uglified. I will do that in a separate
commit.
Other than that, this patch looks good to me. Pushed now.
FYI, this patch broken compilation of busybox-w32 - with error messages
like this:
In file included from
/home/runner/work/llvm-mingw/llvm-mingw/busybox-w32/applets/applets.c:9:
In file included from
/home/runner/work/llvm-mingw/llvm-mingw/busybox-w32/include/busybox.h:8:
In file included from
/home/runner/work/llvm-mingw/llvm-mingw/busybox-w32/include/libbb.h:38:
/opt/llvm-mingw/i686-w64-mingw32/include/stdlib.h:358:17: error: function
declared 'cdecl' here was previously declared 'stdcall'
358 | char *__cdecl mkdtemp(char *_TemplateName);
| ^
/home/runner/work/llvm-mingw/llvm-mingw/busybox-w32/include/platform.h:615:14:
note: previous declaration is here
615 | extern char *mkdtemp(char *template) FAST_FUNC;
| ^
1 error generated.
I ran into this in my nightly build of llvm-mingw, where I recently
included busybox-w32 among the tools I build and bundle:
https://github.com/mstorsjo/llvm-mingw/actions/runs/21085840201/job/60657330345
I reported this issue to busybox-w32 at
https://github.com/rmyorston/busybox-w32/issues/555.
This looks mostly like an issue that should be fixed on the busybox-w32
side, but ideally we should coordinate with them around a fix for the
issue. (In the worst case, we could consider temporarily reverting this
addition here until it is sorted out on the busybox-w32 side. I'm unable
to include newer versions of mingw-w64 in releases of llvm-mingw until
this is sorted out...)
// Martin
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public