1 /****************************************************************************/
2 #if( defined _WIN32 && !defined KERNEL_MODE && NTDDI_VERSION >= NTDDI_WINXP )
4 #ifdef LIBBENCHMARK_PAL_OPERATING_SYSTEM
5 #error More than one porting abstraction layer matches current platform. in "libbenchmark_porting_abstraction_layer_operating_system.h".
8 #define LIBBENCHMARK_PAL_OPERATING_SYSTEM
10 #define LIBBENCHMARK_PAL_OS_STRING "Windows"
14 #define LIBBENCHMARK_PAL_TIME_UNITS_PER_SECOND( pointer_to_time_units_per_second ) QueryPerformanceFrequency( (LARGE_INTEGER *)(pointer_to_time_units_per_second) )
16 #define LIBBENCHMARK_PAL_GET_HIGHRES_TIME( pointer_to_time ) QueryPerformanceCounter( (LARGE_INTEGER *)(pointer_to_time) );
24 /****************************************************************************/
25 #if( defined _WIN32 && defined KERNEL_MODE && NTDDI_VERSION >= NTDDI_WINXP )
27 #ifdef LIBBENCHMARK_PAL_OPERATING_SYSTEM
28 #error More than one porting abstraction layer matches current platform. in "libbenchmark_porting_abstraction_layer_operating_system.h".
31 #define LIBBENCHMARK_PAL_OPERATING_SYSTEM
33 #define LIBBENCHMARK_PAL_OS_STRING "Windows"
37 #define LIBBENCHMARK_PAL_TIME_UNITS_PER_SECOND( pointer_to_time_units_per_second ) KeQueryPerformanceCounter( (LARGE_INTEGER *)(pointer_to_time_units_per_second) )
39 #define LIBBENCHMARK_PAL_GET_HIGHRES_TIME( pointer_to_time ) *( (LARGE_INTEGER *) pointer_to_time ) = KeQueryPerformanceCounter( NULL );
47 /****************************************************************************/
48 #if( defined __linux__ && !defined KERNEL_MODE )
50 #ifdef LIBBENCHMARK_PAL_OPERATING_SYSTEM
51 #error More than one porting abstraction layer matches current platform. in "libbenchmark_porting_abstraction_layer_operating_system.h".
54 #define LIBBENCHMARK_PAL_OPERATING_SYSTEM
56 #define LIBBENCHMARK_PAL_OS_STRING "Linux"
64 #if( defined _POSIX_THREADS && _POSIX_TIMERS >= 0 && _POSIX_MONOTONIC_CLOCK >= 0 )
65 #define LIBBENCHMARK_PAL_TIME_UNITS_PER_SECOND( pointer_to_time_units_per_second ) *(pointer_to_time_units_per_second) = NUMBER_OF_NANOSECONDS_IN_ONE_SECOND
67 #define LIBBENCHMARK_PAL_GET_HIGHRES_TIME( pointer_to_time ) \
70 clock_gettime( CLOCK_MONOTONIC_RAW, &tp ); \
71 *(pointer_to_time) = tp.tv_sec * NUMBER_OF_NANOSECONDS_IN_ONE_SECOND + tp.tv_nsec; \
74 #error Linux without high resolution timers.
83 /****************************************************************************/
84 #if( defined __linux__ && defined KERNEL_MODE )
86 #ifdef LIBBENCHMARK_PAL_OPERATING_SYSTEM
87 #error More than one porting abstraction layer matches current platform. in "libbenchmark_porting_abstraction_layer_operating_system.h".
90 #define LIBBENCHMARK_PAL_OPERATING_SYSTEM
92 #define LIBBENCHMARK_PAL_OS_STRING "Linux"
96 #include <linux/module.h>
98 /* TRD : not clear to me how to obtain high res freq and current count, in Linux kernel
99 it doesn't matter right now because it becamse clear earlier there's no wait-for-thread-to-complete
100 function either, which breaks the lfds thread abstraction, and until I sort that out, benchmark
104 #error No high resolution time abstraction for the Linux kernel.
112 /****************************************************************************/
113 #if( !defined LIBBENCHMARK_PAL_OPERATING_SYSTEM )
115 #error No matching porting abstraction layer in "libbenchmark_porting_abstraction_layer_operating_system.h".