xref: /PHP-7.4/ext/standard/hrtime.h (revision 4a55794b)
1 /*
2    +----------------------------------------------------------------------+
3    | PHP Version 7                                                        |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 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 
20 #ifndef HRTIME_H
21 #define HRTIME_H
22 
23 #define PHP_HRTIME_PLATFORM_POSIX   0
24 #define PHP_HRTIME_PLATFORM_WINDOWS 0
25 #define PHP_HRTIME_PLATFORM_APPLE   0
26 #define PHP_HRTIME_PLATFORM_HPUX    0
27 #define PHP_HRTIME_PLATFORM_AIX     0
28 
29 #if defined(_POSIX_TIMERS) && ((_POSIX_TIMERS > 0) || defined(__OpenBSD__)) && defined(_POSIX_MONOTONIC_CLOCK) && defined(CLOCK_MONOTONIC)
30 # undef  PHP_HRTIME_PLATFORM_POSIX
31 # define PHP_HRTIME_PLATFORM_POSIX 1
32 #elif defined(_WIN32) || defined(_WIN64)
33 # undef  PHP_HRTIME_PLATFORM_WINDOWS
34 # define PHP_HRTIME_PLATFORM_WINDOWS 1
35 #elif defined(__APPLE__)
36 # undef  PHP_HRTIME_PLATFORM_APPLE
37 # define PHP_HRTIME_PLATFORM_APPLE 1
38 #elif (defined(__hpux) || defined(hpux)) || ((defined(__sun__) || defined(__sun) || defined(sun)) && (defined(__SVR4) || defined(__svr4__)))
39 # undef  PHP_HRTIME_PLATFORM_HPUX
40 # define PHP_HRTIME_PLATFORM_HPUX 1
41 #elif defined(_AIX)
42 # undef  PHP_HRTIME_PLATFORM_AIX
43 # define PHP_HRTIME_PLATFORM_AIX 1
44 #endif
45 
46 #define HRTIME_AVAILABLE (PHP_HRTIME_PLATFORM_POSIX || PHP_HRTIME_PLATFORM_WINDOWS || PHP_HRTIME_PLATFORM_APPLE || PHP_HRTIME_PLATFORM_HPUX || PHP_HRTIME_PLATFORM_AIX)
47 
48 BEGIN_EXTERN_C()
49 
50 typedef uint64_t php_hrtime_t;
51 
52 PHPAPI php_hrtime_t php_hrtime_current(void);
53 
54 PHP_MINIT_FUNCTION(hrtime);
55 
56 PHP_FUNCTION(hrtime);
57 
58 END_EXTERN_C()
59 
60 #endif /* HRTIME_H */
61