Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow compilation of ldlt tests if targeting Windows #117

Merged
merged 1 commit into from
Jun 19, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion tests/ssids/kernels/AlignedAllocator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#include <cstddef>
#include <cstdlib>
#ifdef _WIN32
# include <malloc.h> // _aligned_malloc, _aligned_free
#endif
#include <new>

namespace spral { namespace test {
Expand All @@ -32,7 +35,9 @@ public:
T* allocate(size_t n) {
// NB: size allocated must be multiple of alignment
size_t sz = alignment*( ( n*sizeof(T)-1 )/alignment + 1);
#ifdef _ISOC11_SOURCE /* FIXME: is this ever true in C++? */
#ifdef _WIN32
auto ptr = _aligned_malloc(sz, alignment);
#elif defined(_ISOC11_SOURCE) /* FIXME: is this ever true in C++? */
auto ptr = aligned_alloc(alignment, sz);
#else /* _POSIX_C_SOURCE > 200112L || _XOPEN_SOURCE >= 600 */
void *ptr;
Expand All @@ -44,7 +49,11 @@ public:
}

void deallocate(T *p, size_t n) {
#ifdef _WIN32
_aligned_free(p);
#else
free(p);
#endif
}
};

Expand Down