File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change 23
23
24
24
namespace swift {
25
25
26
- // FIXME: Use C11 aligned_alloc or Windows _aligned_malloc if available.
26
+ // FIXME: Use C11 aligned_alloc if available.
27
27
inline void *AlignedAlloc (size_t size, size_t align) {
28
28
// posix_memalign only accepts alignments greater than sizeof(void*).
29
29
//
30
30
if (align < sizeof (void *))
31
31
align = sizeof (void *);
32
32
33
33
void *r;
34
+ #if defined(_WIN32)
35
+ r = _aligned_malloc (size, align);
36
+ assert (r && " _aligned_malloc failed" );
37
+ #else
34
38
int res = posix_memalign (&r, align, size);
35
39
assert (res == 0 && " posix_memalign failed" );
36
40
(void )res; // Silence the unused variable warning.
41
+ #endif
37
42
return r;
38
43
}
39
-
40
- // FIXME: Use Windows _aligned_free if available.
44
+
41
45
inline void AlignedFree (void *p) {
46
+ #if defined(_WIN32)
47
+ _aligned_free (p);
48
+ #else
42
49
free (p);
50
+ #endif
43
51
}
44
-
52
+
45
53
} // end namespace swift
46
54
47
55
#endif // SWIFT_BASIC_MALLOC_H
You can’t perform that action at this time.
0 commit comments