This repository has been archived by the owner on Jan 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_rdtsc.c
115 lines (92 loc) · 2.37 KB
/
php_rdtsc.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* This code was generated by phptoc.c */
/* {{{ Includes */
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "php_rdtsc.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "zend.h"
#include "zend_API.h"
#include "zend_exceptions.h"
#include "zend_operators.h"
#include "zend_constants.h"
#include "zend_ini.h"
#include "zend_interfaces.h"
#ifndef HAVE_TICK_COUNTER
#error your platform is not supported
#endif
#define RDTSC_RETURN_LONG_LONG(__val) \
{ \
if ((__val) < LONG_MAX) { \
RETURN_LONG((long) (__val)); \
} else { \
char *ret; \
int l = spprintf(&ret, 0, "%llu", (__val)); \
RETURN_STRINGL(ret, l, 0); \
} \
}
/* }}} */
/* {{{ Class entry pointers */
PHPAPI zend_class_entry *rdtsc_Rdtsc_ptr;
/* }}} */
/* {{{ Methods for class Rdtsc */
// public static function ticks()
ZEND_METHOD(Rdtsc, ticks)
{
if (zend_parse_parameters_none() == FAILURE) {
return;
}
RDTSC_RETURN_LONG_LONG(getticks());
}
/* }}} */
/* {{{ Global functions */
/* }}} */
/* {{{ Method tables for classes */
ZEND_BEGIN_ARG_INFO_EX(arginfo_rdtsc_Rdtsc_ticks, 0, 0, 0)
ZEND_END_ARG_INFO()
static zend_function_entry rdtsc_Rdtsc_functions[] = {
ZEND_ME(Rdtsc, ticks, arginfo_rdtsc_Rdtsc_ticks, ZEND_ACC_STATIC|ZEND_ACC_PUBLIC)
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ Function table */
static zend_function_entry rdtsc_functions[] = {
{NULL, NULL, NULL}
};
/* }}} */
/* {{{ Init */
PHP_MINIT_FUNCTION(rdtsc)
{
zend_class_entry _ce;
INIT_CLASS_ENTRY(_ce, "Rdtsc", rdtsc_Rdtsc_functions);
rdtsc_Rdtsc_ptr = zend_register_internal_class(&_ce TSRMLS_CC);
return SUCCESS;
}
/* }}} */
/* {{{ Info */
PHP_MINFO_FUNCTION(rdtsc)
{
php_info_print_table_start();
php_info_print_table_header(2, "rdtsc", "enabled");
php_info_print_table_row(2, "Version", "0.1");
php_info_print_table_end();
}
/* }}} */
/* {{{ Module entry */
zend_module_entry rdtsc_module_entry = {
STANDARD_MODULE_HEADER,
"rdtsc",
rdtsc_functions,
PHP_MINIT(rdtsc),
NULL,
NULL,
NULL,
PHP_MINFO(rdtsc),
"0.1",
STANDARD_MODULE_PROPERTIES
};
#ifdef COMPILE_DL_RDTSC
ZEND_GET_MODULE(rdtsc)
#endif
/* }}} */