hrtime.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. +----------------------------------------------------------------------+
  3. | Copyright (c) The PHP Group |
  4. +----------------------------------------------------------------------+
  5. | This source file is subject to version 3.01 of the PHP license, |
  6. | that is bundled with this package in the file LICENSE, and is |
  7. | available through the world-wide-web at the following url: |
  8. | https://www.php.net/license/3_01.txt |
  9. | If you did not receive a copy of the PHP license and are unable to |
  10. | obtain it through the world-wide-web, please send a note to |
  11. | license@php.net so we can mail you a copy immediately. |
  12. +----------------------------------------------------------------------+
  13. | Author: Niklas Keller <kelunik@php.net> |
  14. | Author: Anatol Belski <ab@php.net> |
  15. +----------------------------------------------------------------------+
  16. */
  17. #ifndef HRTIME_H
  18. #define HRTIME_H
  19. #define PHP_HRTIME_PLATFORM_POSIX 0
  20. #define PHP_HRTIME_PLATFORM_WINDOWS 0
  21. #define PHP_HRTIME_PLATFORM_APPLE 0
  22. #define PHP_HRTIME_PLATFORM_HPUX 0
  23. #define PHP_HRTIME_PLATFORM_AIX 0
  24. #if defined(_POSIX_TIMERS) && ((_POSIX_TIMERS > 0) || defined(__OpenBSD__)) && defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC)
  25. # undef PHP_HRTIME_PLATFORM_POSIX
  26. # define PHP_HRTIME_PLATFORM_POSIX 1
  27. #elif defined(_WIN32) || defined(_WIN64)
  28. # undef PHP_HRTIME_PLATFORM_WINDOWS
  29. # define PHP_HRTIME_PLATFORM_WINDOWS 1
  30. #elif defined(__APPLE__)
  31. # undef PHP_HRTIME_PLATFORM_APPLE
  32. # define PHP_HRTIME_PLATFORM_APPLE 1
  33. #elif (defined(__hpux) || defined(hpux)) || ((defined(__sun__) || defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__)))
  34. # undef PHP_HRTIME_PLATFORM_HPUX
  35. # define PHP_HRTIME_PLATFORM_HPUX 1
  36. #elif defined(_AIX)
  37. # undef PHP_HRTIME_PLATFORM_AIX
  38. # define PHP_HRTIME_PLATFORM_AIX 1
  39. #endif
  40. #define HRTIME_AVAILABLE (PHP_HRTIME_PLATFORM_POSIX || PHP_HRTIME_PLATFORM_WINDOWS || PHP_HRTIME_PLATFORM_APPLE || PHP_HRTIME_PLATFORM_HPUX || PHP_HRTIME_PLATFORM_AIX)
  41. BEGIN_EXTERN_C()
  42. typedef uint64_t php_hrtime_t;
  43. PHPAPI php_hrtime_t php_hrtime_current(void);
  44. PHP_MINIT_FUNCTION(hrtime);
  45. END_EXTERN_C()
  46. #endif /* HRTIME_H */