util: Add piglit_alloc_aligned support for Mac OS X.

Submitted by Vinson Lee on Feb. 21, 2015, 9:04 a.m.

Details

Message ID 1424509443-30140-1-git-send-email-vlee@freedesktop.org
State New
Headers show

Not browsing as part of any series.

Commit Message

Vinson Lee Feb. 21, 2015, 9:04 a.m.
Mac OS X does not have aligned_alloc or memalign.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89259
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
---
 tests/util/piglit-util.c | 4 ++++
 1 file changed, 4 insertions(+)

Patch hide | download patch | download mbox

diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
index 76a13ac..ec1db49 100644
--- a/tests/util/piglit-util.c
+++ b/tests/util/piglit-util.c
@@ -829,6 +829,10 @@  piglit_alloc_aligned(size_t size, size_t alignment)
 {
 #if defined(_WIN32)
    return _aligned_malloc(size, alignment);
+#elif defined(__APPLE__)
+   void *memptr;
+   posix_memalign(&memptr, alignment, size);
+   return memptr;
 #else
    return aligned_alloc(alignment, size);
 #endif

Comments

Sorry Vinson, I just pushed a similar patch without realizing you had 
already posted this for review.

Note that posix_memalign indicates failure via return value.

Jose

On 21/02/15 09:04, Vinson Lee wrote:
> Mac OS X does not have aligned_alloc or memalign.
>
> Bugzilla: https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.freedesktop.org_show-5Fbug.cgi-3Fid-3D89259&d=AwIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=zfmBZnnVGHeYde45pMKNnVyzeaZbdIqVLprmZCM2zzE&m=FoQ44zSGSEY8lI2-dPJESnX2FsJvThPqtap_Q8NsSAo&s=4_gTbLDKlpt3wsybEBrnc_Z0QRNLONYBEGciQvvbVBY&e=
> Signed-off-by: Vinson Lee <vlee@freedesktop.org>
> ---
>   tests/util/piglit-util.c | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
> index 76a13ac..ec1db49 100644
> --- a/tests/util/piglit-util.c
> +++ b/tests/util/piglit-util.c
> @@ -829,6 +829,10 @@ piglit_alloc_aligned(size_t size, size_t alignment)
>   {
>   #if defined(_WIN32)
>      return _aligned_malloc(size, alignment);
> +#elif defined(__APPLE__)
> +   void *memptr;
> +   posix_memalign(&memptr, alignment, size);
> +   return memptr;
>   #else
>      return aligned_alloc(alignment, size);
>   #endif
>