[Piglit] [PATCH] util: Add check for aligned_alloc.
Vinson Lee
vlee at freedesktop.org
Sun Feb 22 17:15:46 PST 2015
glibc < 2.16 does not have aligned_alloc.
Signed-off-by: Vinson Lee <vlee at freedesktop.org>
---
CMakeLists.txt | 1 +
tests/util/config.h.in | 1 +
tests/util/piglit-util.c | 6 +++---
3 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index db5f718..dc5e92e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -400,6 +400,7 @@ if(NOT MINGW)
check_function_exists(fopen_s HAVE_FOPEN_S)
endif()
check_function_exists(setrlimit HAVE_SETRLIMIT)
+check_function_exists(aligned_alloc HAVE_ALIGNED_ALLOC)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
diff --git a/tests/util/config.h.in b/tests/util/config.h.in
index c6e23db..5fab0e6 100644
--- a/tests/util/config.h.in
+++ b/tests/util/config.h.in
@@ -4,6 +4,7 @@
#cmakedefine HAVE_FOPEN_S
#cmakedefine HAVE_SETRLIMIT
#cmakedefine HAVE_STRNDUP
+#cmakedefine HAVE_ALIGNED_ALLOC
#cmakedefine HAVE_FCNTL_H
#cmakedefine HAVE_SYS_STAT_H
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 4c5e389..4d8291d 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -829,14 +829,14 @@ piglit_alloc_aligned(size_t size, size_t alignment)
{
#if defined(_WIN32)
return _aligned_malloc(size, alignment);
-#elif defined(__APPLE__)
+#elif defined(HAVE_ALIGNED_ALLOC)
+ return aligned_alloc(alignment, size);
+#else
void *p;
if (posix_memalign(&p, alignment, size) != 0) {
return NULL;
}
return p;
-#else
- return aligned_alloc(alignment, size);
#endif
}
--
2.3.0
More information about the Piglit
mailing list