1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license.
3
4#pragma once
5
6#include <cstdlib>
7
8#ifdef _WIN32
9#include <malloc.h>
10#endif
11
12namespace FASTER {
13namespace core {
14
15/// Windows and standard C++/Linux have incompatible implementations of aligned malloc(). (Windows
16/// defines a corresponding aligned free(), while Linux relies on the ordinary free().)
17inline void* aligned_alloc(size_t alignment, size_t size) {
18#ifdef _WIN32
19 return _aligned_malloc(size, alignment);
20#else
21 return ::aligned_alloc(alignment, size);
22#endif
23}
24
25inline void aligned_free(void* ptr) {
26#ifdef _WIN32
27 _aligned_free(ptr);
28#else
29 ::free(ptr);
30#endif
31}
32
33}
34} // namespace FASTER::core
35
36