[Piglit] [PATCH 1/2] util: add piglit_get_page_size(), piglit_align_alloc/free()
Brian Paul
brianp at vmware.com
Fri Feb 20 14:46:45 PST 2015
---
tests/util/piglit-util.c | 35 +++++++++++++++++++++++++++++++++++
tests/util/piglit-util.h | 10 ++++++++++
2 files changed, 45 insertions(+)
diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index f18560e..668f362 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -809,3 +809,38 @@ piglit_gettid(void)
return 0;
#endif
}
+
+
+unsigned
+piglit_get_page_size(void)
+{
+#if defined(_WIN32)
+ SYSTEM_INFO system_info;
+ GetSystemInfo (&system_info);
+ return system_info.dwPageSize;
+#else
+ return sysconf(_SC_PAGESIZE);
+#endif
+}
+
+
+void *
+piglit_alloc_aligned(size_t size, size_t alignment)
+{
+#if defined(_WIN32)
+ return _aligned_malloc(size, alignment);
+#else
+ return aligned_alloc(alignment, size);
+#endif
+}
+
+
+void
+piglit_free_aligned(void *p)
+{
+#if defined(_WIN32)
+ _aligned_free(p);
+#else
+ free(p);
+#endif
+}
diff --git a/tests/util/piglit-util.h b/tests/util/piglit-util.h
index dd618d2..caf79a0 100755
--- a/tests/util/piglit-util.h
+++ b/tests/util/piglit-util.h
@@ -345,6 +345,16 @@ piglit_parse_subtest_args(int *argc, char *argv[],
uint64_t
piglit_gettid(void);
+unsigned
+piglit_get_page_size(void);
+
+void *
+piglit_alloc_aligned(size_t size, size_t alignment);
+
+void
+piglit_free_aligned(void *p);
+
+
#ifdef __cplusplus
} /* end extern "C" */
#endif
--
1.9.1
More information about the Piglit
mailing list