[Piglit] [PATCH] util: Include time.h on all platforms.

Vinson Lee vlee at freedesktop.org
Fri Nov 4 21:09:16 UTC 2016


On Fri, Nov 4, 2016 at 8:45 AM, Brian Paul <brianp at vmware.com> wrote:
> On 11/03/2016 03:36 PM, Vinson Lee wrote:
>>
>> Fix MinGW build error.
>>
>> piglit-util.c: In function 'piglit_time_is_monotonic':
>> piglit-util.c:583:18: error: storage size of 't' isn't known
>>    struct timespec t;
>>                    ^
>>
>> Fixes: e0048f4940f7 ("util: Add piglit_delay_ns() api")
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=98486
>> Signed-off-by: Vinson Lee <vlee at freedesktop.org>
>> ---
>>   tests/util/piglit-util.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
>> index ef955b97dd26..6becfa664490 100644
>> --- a/tests/util/piglit-util.c
>> +++ b/tests/util/piglit-util.c
>> @@ -32,7 +32,6 @@
>>   #include <unistd.h>
>>   #include <sys/types.h>
>>   #include <sys/syscall.h>
>> -#include <time.h>
>>   #endif
>>
>>   #include <assert.h>
>> @@ -42,6 +41,7 @@
>>   #include <string.h>
>>   #include <errno.h>
>>   #include <inttypes.h>
>> +#include <time.h>
>>
>>   #if defined(PIGLIT_HAS_POSIX_CLOCK_MONOTONIC) &&
>> defined(PIGLIT_HAS_POSIX_TIMER_NOTIFY_THREAD)
>>   #include <pthread.h>
>>
>
> Hmm, I'm not seeing this problem with my MinGW setup here (version 4.6.3)
> but your patch does no harm either.
>
> Reviewed-by: Brian Paul <brianp at vmware.com>
> Tested-by: Brian Paul <brianp at vmware.com>
>
>
> BTW, do you see this warning:
>
> piglit/tests/util/piglit-util.c: In function ‘piglit_delay_ns’:
> piglit/tests/util/piglit-util.c:634:2: warning: implicit declaration of
> function ‘usleep’ [-Wimplicit-function-declaration]
>
> Using Sleep(time_ns / 1000000) instead of usleep(time_ns / 1000) seems to
> work.  There's only caller of piglit_delay_ns() and it passes in 1 second so
> this change would be OK for the time being.  I'm wondering how practical ns
> sleeping is in any case.
>
> -Brian
>

I also see the usleep warning with or without this time.h patch.

Vinson


More information about the Piglit mailing list