Re: [Piglit] [PATCH] cmake: Detect if system has POSIX clocks

2013-10-16 Thread Ian Romanick
On 10/14/2013 04:37 PM, Jordan Justen wrote:
 Chad,
 
 I wanted a similar feature, but I was also thinking of adding a
 piglit-util function (piglit_get_microseconds). I think it should be
 easy to port this function to windows.
 
 I also had the cmake parts a little different, but I don't really have
 a preference on that.
 
 http://cgit.freedesktop.org/~jljusten/piglit/commit/?id=d1a9c3fb

I'd rather use a POSIX function and provide an implementation of that
function on platforms that don't already support it.  We already do that
for a number of C99 functions.

See also:

http://stackoverflow.com/questions/5404277/porting-clock-gettime-to-windows

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cmake: Detect if system has POSIX clocks

2013-10-16 Thread Chad Versace

On 10/16/2013 09:55 AM, Jordan Justen wrote:

On Wed, Oct 16, 2013 at 9:24 AM, Ian Romanick i...@freedesktop.org wrote:

On 10/14/2013 04:37 PM, Jordan Justen wrote:

Chad,

I wanted a similar feature, but I was also thinking of adding a
piglit-util function (piglit_get_microseconds). I think it should be
easy to port this function to windows.

I also had the cmake parts a little different, but I don't really have
a preference on that.

http://cgit.freedesktop.org/~jljusten/piglit/commit/?id=d1a9c3fb


I'd rather use a POSIX function and provide an implementation of that
function on platforms that don't already support it.  We already do that
for a number of C99 functions.


Would you consider clock_gettime a POSIX function?


It *is* a POSIX function, defined by SUSv2 and POSIX.1-2001.


My proposed piglit_get_microseconds function uses that. (I posted this
patch yesterday as
03/10 piglit-util: add piglit_get_microseconds.)

Although, according to:
http://www.tin.org/bin/man.cgi?section=3topic=clock_gettime
perhaps I should be making sure _POSIX_TIMERS and
_POSIX_MONOTONIC_CLOCK are defined.

Or, is your feedback that we should use the clock_gettime function as
the interface rather than adding piglit_get_microseconds? In that
case, my thought is that the simple wrapper function would make it
somewhat less cumbersome than dealing with the struct. (simple
uint64_t vs. 2 fields in a struct)


I'm not opposed to a simple wrapper around clock_gettime(). However, I'd
like to see such a wrapper implemented on top of this patch.
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cmake: Detect if system has POSIX clocks

2013-10-16 Thread Ian Romanick
On 10/16/2013 09:55 AM, Jordan Justen wrote:
 On Wed, Oct 16, 2013 at 9:24 AM, Ian Romanick i...@freedesktop.org wrote:
 On 10/14/2013 04:37 PM, Jordan Justen wrote:
 Chad,

 I wanted a similar feature, but I was also thinking of adding a
 piglit-util function (piglit_get_microseconds). I think it should be
 easy to port this function to windows.

 I also had the cmake parts a little different, but I don't really have
 a preference on that.

 http://cgit.freedesktop.org/~jljusten/piglit/commit/?id=d1a9c3fb

 I'd rather use a POSIX function and provide an implementation of that
 function on platforms that don't already support it.  We already do that
 for a number of C99 functions.
 
 Would you consider clock_gettime a POSIX function?
 
 My proposed piglit_get_microseconds function uses that. (I posted this
 patch yesterday as
 03/10 piglit-util: add piglit_get_microseconds.)
 
 Although, according to:
 http://www.tin.org/bin/man.cgi?section=3topic=clock_gettime
 perhaps I should be making sure _POSIX_TIMERS and
 _POSIX_MONOTONIC_CLOCK are defined.
 
 Or, is your feedback that we should use the clock_gettime function as
 the interface rather than adding piglit_get_microseconds? In that
 case, my thought is that the simple wrapper function would make it
 somewhat less cumbersome than dealing with the struct. (simple
 uint64_t vs. 2 fields in a struct)

Rght.  I always forget how annoying the interfaces are in the POSIX
time functions.  piglit_get_microseconds isn't just a portability
wrapper around clock_gettime, it provides a different interface.
Correct?  I'm fine with that.

I do agree with Chad's comment about the implementation of
piglit_get_microseconds.  I'll reply there too.

 -Jordan

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cmake: Detect if system has POSIX clocks

2013-10-14 Thread Jordan Justen
Chad,

I wanted a similar feature, but I was also thinking of adding a
piglit-util function (piglit_get_microseconds). I think it should be
easy to port this function to windows.

I also had the cmake parts a little different, but I don't really have
a preference on that.

http://cgit.freedesktop.org/~jljusten/piglit/commit/?id=d1a9c3fb

-Jordan


On Mon, Oct 14, 2013 at 11:06 AM, Chad Versace
chad.vers...@linux.intel.com wrote:
 Set CMake cache var PIGLIT_HAS_POSIX_CLOCKS if if clock_gettime() is
 available.

 Tests that need to measure time, such as GL_ARB_sync tests, will use
 Posix clocks.

 CC: Nicholas Mack nichm...@gmail.com
 Signed-off-by: Chad Versace chad.vers...@linux.intel.com
 ---
  CMakeLists.txt | 11 +++
  1 file changed, 11 insertions(+)

 diff --git a/CMakeLists.txt b/CMakeLists.txt
 index 4ec5ddf..ac66152 100644
 --- a/CMakeLists.txt
 +++ b/CMakeLists.txt
 @@ -3,6 +3,7 @@ cmake_minimum_required(VERSION 2.6)
  list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)

  INCLUDE (CheckCCompilerFlag)
 +INCLUDE (CheckCSourceCompiles)
  INCLUDE (CheckCXXCompilerFlag)
  INCLUDE (CheckFunctionExists)
  INCLUDE (CheckIncludeFile)
 @@ -266,6 +267,16 @@ else (APPLE)
 )
  endif (APPLE)

 +check_c_source_compiles(
 +   
 +   #define POSIX_C_SOURCE = 199309L
 +   #include time.h
 +   int main() { return clock_gettime(CLOCK_MONOTONIC, NULL); }
 +   
 +
 +   PIGLIT_HAS_POSIX_CLOCKS
 +)
 +
  FIND_LIBRARY(OPENGL_egl_LIBRARY
NAMES EGL
PATHS /usr/lib
 --
 1.8.3.1

 ___
 Piglit mailing list
 Piglit@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/piglit
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit