aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys/win32
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2013-09-25 16:26:42 +0200
committerRickard Green <[email protected]>2013-09-25 16:26:42 +0200
commit3eff4c3108492366c8bde3e007f648fd99bd04a4 (patch)
treef6e3501ad0fb687c0a7e7cba377b3e2adc9de1c4 /erts/emulator/sys/win32
parent20641fe0f2ea745873fc7557448d3a7deb1bd639 (diff)
parentcabfe2cdc0b8d879431f81233addd2a43ff1f742 (diff)
downloadotp-3eff4c3108492366c8bde3e007f648fd99bd04a4.tar.gz
otp-3eff4c3108492366c8bde3e007f648fd99bd04a4.tar.bz2
otp-3eff4c3108492366c8bde3e007f648fd99bd04a4.zip
Merge branch 'rickard/aligned-sys_alloc-carriers/OTP-11318' into rickard/aligned-sys_alloc-carriers_maint/OTP-11318
Conflicts: erts/emulator/beam/erl_alloc.c erts/emulator/beam/erl_alloc_util.c erts/emulator/beam/erl_alloc_util.h
Diffstat (limited to 'erts/emulator/sys/win32')
-rw-r--r--erts/emulator/sys/win32/erl_win_sys.h2
-rwxr-xr-xerts/emulator/sys/win32/sys.c26
2 files changed, 27 insertions, 1 deletions
diff --git a/erts/emulator/sys/win32/erl_win_sys.h b/erts/emulator/sys/win32/erl_win_sys.h
index 5ce1a61303..c44c5d9492 100644
--- a/erts/emulator/sys/win32/erl_win_sys.h
+++ b/erts/emulator/sys/win32/erl_win_sys.h
@@ -95,6 +95,8 @@
# define ERTS_I64_LITERAL(X) X##i64
#endif
+#define ERTS_HAVE_ERTS_SYS_ALIGNED_ALLOC 1
+
/*
* Practial Windows specific macros.
*/
diff --git a/erts/emulator/sys/win32/sys.c b/erts/emulator/sys/win32/sys.c
index 922967c698..6a1d6b08f4 100755
--- a/erts/emulator/sys/win32/sys.c
+++ b/erts/emulator/sys/win32/sys.c
@@ -32,7 +32,7 @@
#include "erl_threads.h"
#include "../../drivers/win32/win_con.h"
#include "erl_cpu_topology.h"
-
+#include <malloc.h>
void erts_sys_init_float(void);
@@ -2912,6 +2912,30 @@ void erts_sys_free(ErtsAlcType_t t, void *x, void *p)
free(p);
}
+void *erts_sys_aligned_alloc(UWord alignment, UWord size)
+{
+ void *ptr;
+ ASSERT(alignment && (alignment & ~alignment) == 0); /* power of 2 */
+ ptr = _aligned_malloc((size_t) size, (size_t) alignment);
+ ASSERT(!ptr || (((UWord) ptr) & (alignment - 1)) == 0);
+ return ptr;
+}
+
+void erts_sys_aligned_free(UWord alignment, void *ptr)
+{
+ ASSERT(alignment && (alignment & ~alignment) == 0); /* power of 2 */
+ _aligned_free(ptr);
+}
+
+void *erts_sys_aligned_realloc(UWord alignment, void *ptr, UWord size, UWord old_size)
+{
+ void *new_ptr;
+ ASSERT(alignment && (alignment & ~alignment) == 0); /* power of 2 */
+ new_ptr = _aligned_realloc(ptr, (size_t) size, (size_t) alignment);
+ ASSERT(!new_ptr || (((UWord) new_ptr) & (alignment - 1)) == 0);
+ return new_ptr;
+}
+
static Preload* preloaded = NULL;
static unsigned* res_name = NULL;
static int num_preloaded = 0;