Skip to content

Commit 08b32c9

Browse files
committed
fix osx compile
1 parent b6bf1f6 commit 08b32c9

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[submodule "benchmark/vendor/benchmark"]
22
path = third_party/benchmark
3-
url = https://github.com/Matazure/benchmark.git
3+
url = https://github.com/matazure/benchmark.git
44
[submodule "test/vendor/googletest"]
55
path = third_party/googletest
6-
url = https://github.com/Matazure/googletest.git
6+
url = https://github.com/matazure/googletest.git
77
[submodule "third_party/stb"]
88
path = third_party/stb
99
url = https://github.com/nothings/stb.git

include/matazure/allocator.hpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#pragma once
22

3+
#ifdef __APPLE__
34
#include <stdlib.h>
5+
#else
6+
#include <malloc.h>
7+
#endif
8+
49
#include <matazure/config.hpp>
510

611
namespace matazure {
@@ -13,11 +18,13 @@ class aligned_allocator : public std::allocator<_Type> {
1318
aligned_allocator& operator=(const aligned_allocator& rhs) { return *this; }
1419

1520
_Type* allocate(size_t size) {
21+
#ifdef __GNUC__
1622
_Type* data = nullptr;
17-
#ifdef __WIN32
18-
data = reinterpret_cast<_Type*>(_aligned_malloc(size * sizeof(_Type), _Alignment));
23+
posix_memalign(reinterpret_cast<void**>(&data), _Alignment, size * sizeof(_Type));
24+
MATAZURE_ASSERT(data != nullptr, "Failed to alloc align memory");
25+
// _Type* data = reinterpret_cast<_Type*>(memalign(_Alignment, size * sizeof(_Type)));
1926
#else
20-
posix_memalign(reinterpret_cast<void **>(&data), _Alignment, size * sizeof(_Type));
27+
posix_memalign(reinterpret_cast<void**>(&data), _Alignment, size * sizeof(_Type));
2128
#endif
2229
return data;
2330
}

script/build_native.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
mkdir -p build
2+
cd build
3+
cmake .. $@
4+
5+
starttime=`date +'%Y-%m-%d %H:%M:%S'`
6+
7+
cmake --build . -- -j|| exit 1

0 commit comments

Comments
 (0)