[Piglit] [PATCH] util: Add check for aligned_alloc.

Marek Olšák maraeo at gmail.com
Mon Feb 23 05:26:49 PST 2015


Yes, that's correct.

Marek

On Mon, Feb 23, 2015 at 12:56 PM, Jose Fonseca <jfonseca at vmware.com> wrote:
> I wonder if it wouldn't be easier to just use posix_memalign for all posix
> (non-Windows platform.)
>
> Marek can correct me if I'm wrong, but I don't think there's anything
> particularly special about aligned_alloc that justifies we go so out of our
> way to use it instead of posix_memalign.
>
> (Of course, aligned_alloc's prototype is much easier to use than
> posix_memalign, but now that this detail is hidden away, there's really not
> much difference.)
>
>
> Jose
>
>
> On 23/02/15 01:15, Vinson Lee wrote:
>>
>> 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
>>   }
>>
>>
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list