hrtime.h 2.5 KB

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