diff options
author | Rickard Green <[email protected]> | 2013-09-25 16:26:42 +0200 |
---|---|---|
committer | Rickard Green <[email protected]> | 2013-09-25 16:26:42 +0200 |
commit | 3eff4c3108492366c8bde3e007f648fd99bd04a4 (patch) | |
tree | f6e3501ad0fb687c0a7e7cba377b3e2adc9de1c4 /erts/emulator/sys/win32/sys.c | |
parent | 20641fe0f2ea745873fc7557448d3a7deb1bd639 (diff) | |
parent | cabfe2cdc0b8d879431f81233addd2a43ff1f742 (diff) | |
download | otp-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/sys.c')
-rwxr-xr-x | erts/emulator/sys/win32/sys.c | 26 |
1 files changed, 25 insertions, 1 deletions
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; |