add system-specific AllocateAligned call (because _mm_malloc isnt as portable as hoped)
("RTL" directly has been added to sysdep - requires update of workspace) This was SVN commit r6156.
This commit is contained in:
parent
84f5428b9f
commit
2382899a87
@ -431,6 +431,8 @@ function setup_all_libs ()
|
||||
"cryptopp",
|
||||
"valgrind"
|
||||
}
|
||||
|
||||
-- OS-specific
|
||||
sysdep_dirs = {
|
||||
linux = { "lib/sysdep/linux", "lib/sysdep/unix", "lib/sysdep/unix/x" },
|
||||
-- note: RC file must be added to main_exe package.
|
||||
@ -441,7 +443,14 @@ function setup_all_libs ()
|
||||
for i,v in sysdep_dirs[OS] do
|
||||
tinsert(source_dirs, v);
|
||||
end
|
||||
-- tinsert(source_dirs, sysdep_dirs[OS]);
|
||||
|
||||
-- runtime-library-specific
|
||||
if target == "gnu" then
|
||||
tinsert(source_dirs, "lib/sysdep/rtl/gcc");
|
||||
else
|
||||
tinsert(source_dirs, "lib/sysdep/rtl/msc");
|
||||
end
|
||||
|
||||
setup_static_lib_package("lowlevel", source_dirs, extern_libs, {})
|
||||
end
|
||||
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include "lib/bits.h" // round_up
|
||||
#include "lib/sysdep/x86_x64/x86_x64.h" // x86_x64_L1CacheLineSize
|
||||
#include "lib/sysdep/rtl.h" // rtl_AllocateAligned
|
||||
|
||||
|
||||
/**
|
||||
@ -93,7 +94,7 @@ public:
|
||||
const size_type alignment = x86_x64_L1CacheLineSize();
|
||||
const size_type elementSize = round_up(sizeof(T), alignment);
|
||||
const size_type size = numElements * elementSize;
|
||||
pointer p = (pointer)_mm_malloc(size, alignment);
|
||||
pointer p = (pointer)rtl_AllocateAligned(size, alignment);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
17
source/lib/sysdep/rtl.h
Normal file
17
source/lib/sysdep/rtl.h
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* =========================================================================
|
||||
* File : rtl.h
|
||||
* Project : 0 A.D.
|
||||
* Description : functions specific to the toolset's runtime library
|
||||
* =========================================================================
|
||||
*/
|
||||
|
||||
// license: GPL; see lib/license.txt
|
||||
|
||||
#ifndef INCLUDED_RTL
|
||||
#define INCLUDED_RTL
|
||||
|
||||
LIB_API void* rtl_AllocateAligned(size_t size, size_t alignment);
|
||||
LIB_API void rtl_FreeAligned(void* alignedPointer);
|
||||
|
||||
#endif // #ifndef INCLUDED_RTL
|
0
source/lib/sysdep/rtl/gcc/gcc.cpp
Normal file
0
source/lib/sysdep/rtl/gcc/gcc.cpp
Normal file
12
source/lib/sysdep/rtl/msc/msc.cpp
Normal file
12
source/lib/sysdep/rtl/msc/msc.cpp
Normal file
@ -0,0 +1,12 @@
|
||||
#include "precompiled.h"
|
||||
#include "lib/sysdep/rtl.h"
|
||||
|
||||
void* rtl_AllocateAligned(size_t size, size_t alignment)
|
||||
{
|
||||
return _aligned_malloc(size, alignment);
|
||||
}
|
||||
|
||||
void rtl_FreeAligned(void* alignedPointer)
|
||||
{
|
||||
_aligned_free(alignedPointer);
|
||||
}
|
Loading…
Reference in New Issue
Block a user