-
Notifications
You must be signed in to change notification settings - Fork 0
/
php_perfidious.h
186 lines (155 loc) · 5.98 KB
/
php_perfidious.h
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
/**
* Copyright (c) anno Domini nostri Jesu Christi MMXXIV John Boehr & contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PHP_PERFIDIOUS_H
#define PHP_PERFIDIOUS_H
#include <sys/types.h>
#include "main/php.h"
#define PHP_PERFIDIOUS_NAME "perfidious"
#define PHP_PERFIDIOUS_VERSION "0.1.0"
#define PHP_PERFIDIOUS_RELEASE "2024-03-24"
#define PHP_PERFIDIOUS_AUTHORS "John Boehr <[email protected]> (lead)"
#define PHP_PERFIDIOUS_NAMESPACE "Perfidious"
#if (__GNUC__ >= 4) || defined(__clang__) || defined(HAVE_FUNC_ATTRIBUTE_VISIBILITY)
#define PERFIDIOUS_PUBLIC __attribute__((visibility("default")))
#define PERFIDIOUS_LOCAL __attribute__((visibility("hidden")))
#elif defined(PHP_WIN32) && defined(PERF_EXPORTS)
#define PERFIDIOUS_PUBLIC __declspec(dllexport)
#define PERFIDIOUS_LOCAL
#else
#define PERFIDIOUS_PUBLIC
#define PERFIDIOUS_LOCAL
#endif
#if (__GNUC__ >= 3) || defined(__clang__)
#define PERFIDIOUS_ATTR_NONNULL(...) __attribute__((nonnull(__VA_ARGS__)))
#define PERFIDIOUS_ATTR_NONNULL_ALL __attribute__((nonnull))
#define PERFIDIOUS_ATTR_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
#else
#define PERFIDIOUS_ATTR_NONNULL(...)
#define PERFIDIOUS_ATTR_NONNULL_ALL
#define PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
#endif
#if ((__GNUC__ >= 5) || ((__GNUC__ >= 4) && (__GNUC_MINOR__ >= 9))) || defined(__clang__)
#define PERFIDIOUS_ATTR_RETURNS_NONNULL __attribute__((returns_nonnull))
#else
#define PERFIDIOUS_ATTR_RETURNS_NONNULL
#endif
#ifndef ZEND_HOT
#if defined(__GNUC__) && ZEND_GCC_VERSION >= 4003
#define ZEND_HOT __attribute__((hot))
#else
#define ZEND_HOT
#endif
#endif
extern zend_module_entry perfidious_module_entry;
#define phpext_perfidious_ptr &perfidious_module_entry
#if defined(ZTS) && ZTS
#include "TSRM.h"
#endif
#if defined(ZTS) && defined(COMPILE_DL_PERFIDIOUS)
ZEND_TSRMLS_CACHE_EXTERN();
#endif
struct perfidious_handle;
enum perfidious_error_mode
{
PERFIDIOUS_ERROR_MODE_THROW = 0,
PERFIDIOUS_ERROR_MODE_WARNING = 1,
};
enum perfidious_overflow_mode
{
PERFIDIOUS_OVERFLOW_THROW = 0,
PERFIDIOUS_OVERFLOW_WARN = 1,
PERFIDIOUS_OVERFLOW_SATURATE = 2,
PERFIDIOUS_OVERFLOW_WRAP = 3,
PERFIDIOUS_OVERFLOW_MAX = 3,
};
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_exception_interface_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_pmu_not_found_exception_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_pmu_event_not_found_exception_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_overflow_exception_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_io_exception_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_pmu_event_info_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_pmu_info_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_handle_ce;
PERFIDIOUS_PUBLIC extern zend_class_entry *perfidious_read_result_ce;
ZEND_BEGIN_MODULE_GLOBALS(perfidious)
zend_bool global_enable;
zend_string *global_metrics;
struct perfidious_handle *global_handle;
zend_bool request_enable;
zend_string *request_metrics;
struct perfidious_handle *request_handle;
enum perfidious_error_mode error_mode;
enum perfidious_overflow_mode overflow_mode;
ZEND_END_MODULE_GLOBALS(perfidious)
ZEND_EXTERN_MODULE_GLOBALS(perfidious);
#define PERFIDIOUS_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(perfidious, v)
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
zend_result perfidious_handle_reset(struct perfidious_handle *restrict handle);
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
zend_result perfidious_handle_enable(struct perfidious_handle *restrict handle);
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
zend_result perfidious_handle_disable(struct perfidious_handle *restrict handle);
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
zend_result perfidious_handle_close(struct perfidious_handle *restrict handle);
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
struct perfidious_handle *
perfidious_handle_open(zend_string **restrict event_names, size_t event_names_length, bool persist);
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
struct perfidious_handle *perfidious_handle_open_ex(
zend_string **restrict event_names, size_t event_names_length, pid_t pid, int cpu, bool persist
);
ZEND_HOT
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
size_t perfidious_handle_read_buffer_size(const struct perfidious_handle *restrict handle);
ZEND_HOT
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
zend_result
perfidious_handle_read_raw(const struct perfidious_handle *restrict handle, size_t size, void *restrict buffer);
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
zend_result
perfidious_handle_read_to_array(const struct perfidious_handle *restrict handle, zval *restrict return_value);
ZEND_HOT
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
zend_result perfidious_handle_read_to_array_with_times(
const struct perfidious_handle *restrict handle,
zval *restrict return_value,
uint64_t *restrict time_enabled,
uint64_t *restrict time_running
);
ZEND_HOT
PERFIDIOUS_PUBLIC
PERFIDIOUS_ATTR_NONNULL_ALL
PERFIDIOUS_ATTR_WARN_UNUSED_RESULT
zend_result
perfidious_handle_read_to_result(const struct perfidious_handle *restrict handle, zval *restrict return_value);
#endif /* PHP_PERFIDIOUS_H */