They are natively available since msvcr80.dll, they are not available in
msvcrt.dll. Provide compatibility emulation into all import libraries where
they are not available.
Adjust check for _aligned_msize() which is also available since
msvcr80.dll.
---
mingw-w64-crt/Makefile.am | 6 ++++++
mingw-w64-crt/misc/_aligned_offset_recalloc.c | 16 ++++++++++++++++
mingw-w64-crt/misc/_aligned_recalloc.c | 16 ++++++++++++++++
mingw-w64-crt/misc/_recalloc.c | 16 ++++++++++++++++
mingw-w64-headers/crt/crtdbg.h | 2 +-
mingw-w64-headers/crt/malloc.h | 2 +-
mingw-w64-headers/crt/stdlib.h | 2 +-
7 files changed, 57 insertions(+), 3 deletions(-)
create mode 100644 mingw-w64-crt/misc/_aligned_offset_recalloc.c
create mode 100644 mingw-w64-crt/misc/_aligned_recalloc.c
create mode 100644 mingw-w64-crt/misc/_recalloc.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 71368648cca3..b90920e468fe 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -333,7 +333,10 @@ src_msvcrt=\
misc/__iswcsymf.c \
misc/__sys_errlist.c \
misc/__sys_nerr.c \
+ misc/_aligned_offset_recalloc.c \
+ misc/_aligned_recalloc.c \
misc/_configthreadlocale.c \
+ misc/_recalloc.c \
misc/_set_purecall_handler.c \
misc/imaxdiv.c \
misc/invalid_parameter_handler.c \
@@ -820,9 +823,12 @@ src_pre_msvcr80=\
misc/__iswcsymf.c \
misc/__sys_errlist.c \
misc/__sys_nerr.c \
+ misc/_aligned_offset_recalloc.c \
+ misc/_aligned_recalloc.c \
misc/_configthreadlocale.c \
misc/_get_errno.c \
misc/_initterm_e.c \
+ misc/_recalloc.c \
misc/_set_errno.c \
misc/btowc.c \
misc/imaxabs.c \
diff --git a/mingw-w64-crt/misc/_aligned_offset_recalloc.c
b/mingw-w64-crt/misc/_aligned_offset_recalloc.c
new file mode 100644
index 000000000000..caccc29f2360
--- /dev/null
+++ b/mingw-w64-crt/misc/_aligned_offset_recalloc.c
@@ -0,0 +1,16 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <malloc.h>
+
+void * __cdecl _aligned_offset_recalloc(void *memory, size_t count, size_t
size, size_t alignment, size_t offset)
+{
+ size_t total_size;
+ if (__builtin_mul_overflow(count, size, &total_size))
+ return NULL;
+ return _aligned_offset_realloc(memory, total_size, alignment, offset);
+}
+void * (__cdecl *__MINGW_IMP_SYMBOL(_aligned_offset_recalloc))(void *, size_t,
size_t, size_t, size_t) = _aligned_offset_recalloc;
diff --git a/mingw-w64-crt/misc/_aligned_recalloc.c
b/mingw-w64-crt/misc/_aligned_recalloc.c
new file mode 100644
index 000000000000..b5ba8ed807ef
--- /dev/null
+++ b/mingw-w64-crt/misc/_aligned_recalloc.c
@@ -0,0 +1,16 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <malloc.h>
+
+void * __cdecl _aligned_recalloc(void *memory, size_t count, size_t size,
size_t alignment)
+{
+ size_t total_size;
+ if (__builtin_mul_overflow(count, size, &total_size))
+ return NULL;
+ return _aligned_realloc(memory, total_size, alignment);
+}
+void * (__cdecl *__MINGW_IMP_SYMBOL(_aligned_recalloc))(void *, size_t,
size_t, size_t) = _aligned_recalloc;
diff --git a/mingw-w64-crt/misc/_recalloc.c b/mingw-w64-crt/misc/_recalloc.c
new file mode 100644
index 000000000000..5eaecccf1306
--- /dev/null
+++ b/mingw-w64-crt/misc/_recalloc.c
@@ -0,0 +1,16 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <malloc.h>
+
+void * __cdecl _recalloc(void *memory, size_t count, size_t size)
+{
+ size_t total_size;
+ if (__builtin_mul_overflow(count, size, &total_size))
+ return NULL;
+ return realloc(memory, total_size);
+}
+void * (__cdecl *__MINGW_IMP_SYMBOL(_recalloc))(void *, size_t, size_t) =
_recalloc;
diff --git a/mingw-w64-headers/crt/crtdbg.h b/mingw-w64-headers/crt/crtdbg.h
index c498bcfa63f0..2da0cdbe72a5 100644
--- a/mingw-w64-headers/crt/crtdbg.h
+++ b/mingw-w64-headers/crt/crtdbg.h
@@ -161,10 +161,10 @@ extern "C" {
#define _aligned_offset_malloc_dbg(s,a,o,f,l) _aligned_offset_malloc(s,a,o)
#define _aligned_offset_realloc_dbg(p,s,a,o,f,l)
_aligned_offset_realloc(p,s,a,o)
-#if __MSVCRT_VERSION__ >= 0x900
#define _recalloc_dbg(p,c,s,t,f,l) _recalloc(p,c,s)
#define _aligned_recalloc_dbg(p,c,s,a,f,l) _aligned_realloc(p,c,s,a)
#define _aligned_offset_recalloc_dbg(p,c,s,a,o,f,l)
_aligned_offset_recalloc(p,c,s,a,o)
+#if __MSVCRT_VERSION__ >= 0x800
#define _aligned_msize_dbg(p,a,o) _aligned_msize(p,a,o)
#endif
diff --git a/mingw-w64-headers/crt/malloc.h b/mingw-w64-headers/crt/malloc.h
index cc72d4cac909..78d67dd2eeb4 100644
--- a/mingw-w64-headers/crt/malloc.h
+++ b/mingw-w64-headers/crt/malloc.h
@@ -102,10 +102,10 @@ extern "C" {
_CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t
_Alignment,size_t _Offset);
_CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t
_Alignment);
_CRTIMP void *__cdecl _aligned_offset_realloc(void *_Memory,size_t
_Size,size_t _Alignment,size_t _Offset);
-# if __MSVCRT_VERSION__ >= 0x900
_CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size);
_CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t
_Size,size_t _Alignment);
_CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t
_Count,size_t _Size,size_t _Alignment,size_t _Offset);
+# if __MSVCRT_VERSION__ >= 0x800
_CRTIMP size_t __cdecl _aligned_msize(void *_Memory,size_t _Alignment,size_t
_Offset);
# endif
diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
index d43fa33b7f2c..998eb4362cac 100644
--- a/mingw-w64-headers/crt/stdlib.h
+++ b/mingw-w64-headers/crt/stdlib.h
@@ -458,10 +458,10 @@ float __cdecl __MINGW_NOTHROW strtof(const char *
__restrict__ _Str,char ** __re
_CRTIMP void *__cdecl _aligned_offset_malloc(size_t _Size,size_t
_Alignment,size_t _Offset);
_CRTIMP void *__cdecl _aligned_realloc(void *_Memory,size_t _Size,size_t
_Alignment);
_CRTIMP void *__cdecl _aligned_offset_realloc(void *_Memory,size_t
_Size,size_t _Alignment,size_t _Offset);
-# if __MSVCRT_VERSION__ >= 0x900
_CRTIMP void *__cdecl _recalloc(void *_Memory,size_t _Count,size_t _Size);
_CRTIMP void *__cdecl _aligned_recalloc(void *_Memory,size_t _Count,size_t
_Size,size_t _Alignment);
_CRTIMP void *__cdecl _aligned_offset_recalloc(void *_Memory,size_t
_Count,size_t _Size,size_t _Alignment,size_t _Offset);
+# if __MSVCRT_VERSION__ >= 0x800
_CRTIMP size_t __cdecl _aligned_msize(void *_Memory,size_t _Alignment,size_t
_Offset);
# endif
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public