crt: Provide _aligned_* functions
Functions _aligned_free(), _aligned_malloc(), _aligned_offset_malloc(),
_aligned_offset_realloc() and _aligned_realloc() are available since
msvcr70.dll. For older CRT import libraries provide emulation via
mingw functions __mingw_aligned_free(), __mingw_aligned_malloc(),
__mingw_aligned_offset_malloc(), __mingw_aligned_offset_realloc() and
__mingw_aligned_realloc(). msvcrt.dll will use system implementation if
available, otherwise transparently fallback to mingw version.
Signed-off-by: Martin Storsjö <martin@martin.st>
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index f00e701..5850e55 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -513,6 +513,11 @@
misc/__p__osplatform.c \
misc/__pctype_func.c \
misc/__pwctype_func.c \
+ misc/_aligned_free.c \
+ misc/_aligned_malloc.c \
+ misc/_aligned_offset_malloc.c \
+ misc/_aligned_offset_realloc.c \
+ misc/_aligned_realloc.c \
misc/_create_locale.c \
misc/_free_locale.c \
misc/_get_current_locale.c \
@@ -783,6 +788,11 @@
misc/___mb_cur_max_func.c \
misc/__pctype_func.c \
misc/__pwctype_func.c \
+ misc/_aligned_free.c \
+ misc/_aligned_malloc.c \
+ misc/_aligned_offset_malloc.c \
+ misc/_aligned_offset_realloc.c \
+ misc/_aligned_realloc.c \
misc/lc_locale_func.c \
misc/strtoimax.c \
misc/strtoumax.c \
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in b/mingw-w64-crt/lib-common/msvcrt.def.in
index 7a029b8..681b491 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1202,11 +1202,11 @@
F_NON_I386(__iob_func) ; i386 __iob_func replaced by alias
F_NON_I386(__pctype_func) ; i386 __pctype_func replaced by emu
__wcserror
-_aligned_free
-_aligned_malloc
-_aligned_offset_malloc
-_aligned_offset_realloc
-_aligned_realloc
+F_NON_I386(_aligned_free) ; i386 _aligned_free replaced by emu
+F_NON_I386(_aligned_malloc) ; i386 _aligned_malloc replaced by emu
+F_NON_I386(_aligned_offset_malloc) ; i386 _aligned_offset_malloc replaced by emu
+F_NON_I386(_aligned_offset_realloc) ; i386 _aligned_offset_realloc replaced by emu
+F_NON_I386(_aligned_realloc) ; i386 _aligned_realloc replaced by emu
_cgetws
_cputws
_cwprintf
diff --git a/mingw-w64-crt/misc/_aligned_free.c b/mingw-w64-crt/misc/_aligned_free.c
new file mode 100644
index 0000000..eb4c36d
--- /dev/null
+++ b/mingw-w64-crt/misc/_aligned_free.c
@@ -0,0 +1,18 @@
+/**
+ * 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>
+
+static void __cdecl emu__aligned_free(void *memory)
+{
+ __mingw_aligned_free(memory);
+}
+
+#define RETT void
+#define FUNC _aligned_free
+#define ARGS void *memory
+#define CALL memory
+#include "msvcrt_or_emu_glue.h"
diff --git a/mingw-w64-crt/misc/_aligned_malloc.c b/mingw-w64-crt/misc/_aligned_malloc.c
new file mode 100644
index 0000000..51fca07
--- /dev/null
+++ b/mingw-w64-crt/misc/_aligned_malloc.c
@@ -0,0 +1,18 @@
+/**
+ * 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>
+
+static void * __cdecl emu__aligned_malloc(size_t size, size_t alignment)
+{
+ return __mingw_aligned_malloc(size, alignment);
+}
+
+#define RETT void *
+#define FUNC _aligned_malloc
+#define ARGS size_t size, size_t alignment
+#define CALL size, alignment
+#include "msvcrt_or_emu_glue.h"
diff --git a/mingw-w64-crt/misc/_aligned_offset_malloc.c b/mingw-w64-crt/misc/_aligned_offset_malloc.c
new file mode 100644
index 0000000..9a0dfd0
--- /dev/null
+++ b/mingw-w64-crt/misc/_aligned_offset_malloc.c
@@ -0,0 +1,18 @@
+/**
+ * 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>
+
+static void * __cdecl emu__aligned_offset_malloc(size_t size, size_t alignment, size_t offset)
+{
+ return __mingw_aligned_offset_malloc(size, alignment, offset);
+}
+
+#define RETT void *
+#define FUNC _aligned_offset_malloc
+#define ARGS size_t size, size_t alignment, size_t offset
+#define CALL size, alignment, offset
+#include "msvcrt_or_emu_glue.h"
diff --git a/mingw-w64-crt/misc/_aligned_offset_realloc.c b/mingw-w64-crt/misc/_aligned_offset_realloc.c
new file mode 100644
index 0000000..89c445a
--- /dev/null
+++ b/mingw-w64-crt/misc/_aligned_offset_realloc.c
@@ -0,0 +1,18 @@
+/**
+ * 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>
+
+static void * __cdecl emu__aligned_offset_realloc(void *memory, size_t size, size_t alignment, size_t offset)
+{
+ return __mingw_aligned_offset_realloc(memory, size, alignment, offset);
+}
+
+#define RETT void *
+#define FUNC _aligned_offset_realloc
+#define ARGS void *memory, size_t size, size_t alignment, size_t offset
+#define CALL memory, size, alignment, offset
+#include "msvcrt_or_emu_glue.h"
diff --git a/mingw-w64-crt/misc/_aligned_realloc.c b/mingw-w64-crt/misc/_aligned_realloc.c
new file mode 100644
index 0000000..7882bea
--- /dev/null
+++ b/mingw-w64-crt/misc/_aligned_realloc.c
@@ -0,0 +1,18 @@
+/**
+ * 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>
+
+static void * __cdecl emu__aligned_realloc(void *memory, size_t size, size_t alignment)
+{
+ return __mingw_aligned_realloc(memory, size, alignment);
+}
+
+#define RETT void *
+#define FUNC _aligned_realloc
+#define ARGS void *memory, size_t size, size_t alignment
+#define CALL memory, size, alignment
+#include "msvcrt_or_emu_glue.h"