Skip to content

Commit ba1e1b9

Browse files
committed
Windows support
Windows support phacility#34
1 parent c6d439b commit ba1e1b9

3 files changed

Lines changed: 39 additions & 29 deletions

File tree

extension/php_xhprof.h

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern zend_module_entry xhprof_module_entry;
3939
*/
4040

4141
/* XHProf version */
42-
#define XHPROF_VERSION "2.1.3"
42+
#define XHPROF_VERSION "2.1.4"
4343

4444
/* Fictitious function name to represent top of the call tree. The paranthesis
4545
* in the name is to ensure we don't conflict with user function names. */
@@ -72,10 +72,6 @@ extern zend_module_entry xhprof_module_entry;
7272
#define XHPROF_IGNORED_FUNCTION_FILTER_SIZE \
7373
((XHPROF_MAX_IGNORED_FUNCTIONS + 7)/8)
7474

75-
#if !defined(uint64)
76-
typedef unsigned long long uint64;
77-
#endif
78-
7975
#if !defined(uint32)
8076
typedef unsigned int uint32;
8177
#endif
@@ -154,8 +150,8 @@ do { \
154150
typedef struct hp_entry_t {
155151
char *name_hprof; /* function name */
156152
int rlvl_hprof; /* recursion level for function */
157-
uint64 tsc_start; /* start value for TSC counter */
158-
uint64 cpu_start;
153+
zend_ulong tsc_start; /* start value for TSC counter */
154+
zend_ulong cpu_start;
159155
long int mu_start_hprof; /* memory usage */
160156
long int pmu_start_hprof; /* peak memory usage */
161157
struct hp_entry_t *prev_hprof; /* ptr to prev entry being profiled */
@@ -203,17 +199,17 @@ ZEND_DLEXPORT zend_op_array* hp_compile_string(zval *source_string, char *filena
203199
*/
204200
static void hp_register_constants(INIT_FUNC_ARGS);
205201

206-
static void hp_begin(long level, long xhprof_flags);
202+
static void hp_begin(zend_long level, zend_long xhprof_flags);
207203
static void hp_stop();
208204
static void hp_end();
209205

210-
static inline uint64 cycle_timer();
206+
static inline zend_ulong cycle_timer();
211207

212208
static void hp_free_the_free_list();
213209
static hp_entry_t *hp_fast_alloc_hprof_entry();
214210
static void hp_fast_free_hprof_entry(hp_entry_t *p);
215211
static inline uint8 hp_inline_hash(char *str);
216-
static void incr_us_interval(struct timeval *start, uint64 incr);
212+
static void incr_us_interval(struct timeval *start, zend_ulong incr);
217213

218214
static void hp_get_ignored_functions_from_arg(zval *args);
219215

@@ -270,11 +266,11 @@ ZEND_BEGIN_MODULE_GLOBALS(xhprof)
270266

271267
/* Global to track the time of the last sample in time and ticks */
272268
struct timeval last_sample_time;
273-
uint64 last_sample_tsc;
269+
zend_ulong last_sample_tsc;
274270
/* XHPROF_SAMPLING_INTERVAL in ticks */
275-
long sampling_interval;
276-
uint64 sampling_interval_tsc;
277-
long sampling_depth;
271+
zend_long sampling_interval;
272+
zend_ulong sampling_interval_tsc;
273+
zend_long sampling_depth;
278274
/* XHProf flags */
279275
uint32 xhprof_flags;
280276

extension/xhprof.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ PHP_INI_END()
158158
*/
159159
PHP_FUNCTION(xhprof_enable)
160160
{
161-
long xhprof_flags = 0; /* XHProf flags */
161+
zend_long xhprof_flags = 0; /* XHProf flags */
162162
zval *optional_array = NULL; /* optional array arg: for future use */
163163

164164
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|lz", &xhprof_flags, &optional_array) == FAILURE) {
@@ -195,7 +195,7 @@ PHP_FUNCTION(xhprof_disable)
195195
*/
196196
PHP_FUNCTION(xhprof_sample_enable)
197197
{
198-
long xhprof_flags = 0; /* XHProf flags */
198+
zend_long xhprof_flags = 0; /* XHProf flags */
199199
hp_get_ignored_functions_from_arg(NULL);
200200
hp_begin(XHPROF_MODE_SAMPLED, xhprof_flags);
201201
}
@@ -754,7 +754,7 @@ static void hp_fast_free_hprof_entry(hp_entry_t *p)
754754
* @return void
755755
* @author kannan
756756
*/
757-
void hp_inc_count(zval *counts, char *name, long count)
757+
void hp_inc_count(zval *counts, char *name, zend_long count)
758758
{
759759
HashTable *ht;
760760
zval *data, val;
@@ -789,9 +789,9 @@ void hp_inc_count(zval *counts, char *name, long count)
789789
* @return void
790790
* @author veeve
791791
*/
792-
void hp_trunc_time(struct timeval *tv, uint64 intr)
792+
void hp_trunc_time(struct timeval *tv, zend_ulong intr)
793793
{
794-
uint64 time_in_micro;
794+
zend_ulong time_in_micro;
795795

796796
/* Convert to microsecs and trunc that first */
797797
time_in_micro = (tv->tv_sec * 1000000) + tv->tv_usec;
@@ -817,7 +817,7 @@ void hp_sample_stack(hp_entry_t **entries)
817817
char symbol[SCRATCH_BUF_LEN * 1000];
818818

819819
/* Build key */
820-
snprintf(key, sizeof(key), "%d.%06d", XHPROF_G(last_sample_time).tv_sec, XHPROF_G(last_sample_time).tv_usec);
820+
snprintf(key, sizeof(key), "%d.%06d", (uint32) XHPROF_G(last_sample_time).tv_sec, (uint32) XHPROF_G(last_sample_time).tv_usec);
821821

822822
/* Init stats in the global stats_count hashtable */
823823
hp_get_function_stack(*entries, XHPROF_G(sampling_depth), symbol, sizeof(symbol));
@@ -863,7 +863,7 @@ void hp_sample_check(hp_entry_t **entries)
863863
* ***********************
864864
*/
865865

866-
static inline uint64 cycle_timer()
866+
static inline zend_ulong cycle_timer()
867867
{
868868
#if defined(__APPLE__) && defined(__MACH__)
869869
return mach_absolute_time() / XHPROF_G(timebase_conversion);
@@ -884,7 +884,7 @@ static inline uint64 cycle_timer()
884884
/**
885885
* Get the current real CPU clock timer
886886
*/
887-
static uint64 cpu_timer()
887+
static zend_ulong cpu_timer()
888888
{
889889
#if defined(CLOCK_PROCESS_CPUTIME_ID)
890890
struct timespec s;
@@ -902,7 +902,7 @@ static uint64 cpu_timer()
902902
/**
903903
* Incr time with the given microseconds.
904904
*/
905-
static void incr_us_interval(struct timeval *start, uint64 incr)
905+
static void incr_us_interval(struct timeval *start, zend_ulong incr)
906906
{
907907
incr += (start->tv_sec * 1000000 + start->tv_usec);
908908
start->tv_sec = incr / 1000000;
@@ -1266,7 +1266,7 @@ ZEND_DLEXPORT zend_op_array* hp_compile_string(zval *source_string, char *filena
12661266
* It replaces all the functions like zend_execute, zend_execute_internal,
12671267
* etc that needs to be instrumented with their corresponding proxies.
12681268
*/
1269-
static void hp_begin(long level, long xhprof_flags)
1269+
static void hp_begin(zend_long level, zend_long xhprof_flags)
12701270
{
12711271
if (!XHPROF_G(enabled)) {
12721272
int hp_profile_flag = 1;

package.xml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,19 @@
4040
<email>longxinhui@php.net</email>
4141
<active>yes</active>
4242
</lead>
43-
<date>2019-12-10</date>
44-
<time>11:06:00</time>
43+
<date>2019-12-17</date>
44+
<time>01:06:00</time>
4545
<version>
46-
<release>2.1.3</release>
47-
<api>2.1.3</api>
46+
<release>2.1.4</release>
47+
<api>2.1.4</api>
4848
</version>
4949
<stability>
5050
<release>stable</release>
5151
<api>stable</api>
5252
</stability>
5353
<license uri="http://www.apache.org/licenses/LICENSE-2.0.html">Apache 2.0</license>
5454
<notes>
55-
- Fix s390x accuracy loss #15
55+
- Windows support #34
5656
</notes>
5757
<contents>
5858
<dir name="/">
@@ -113,6 +113,20 @@
113113
<providesextension>xhprof</providesextension>
114114
<extsrcrelease />
115115
<changelog>
116+
<release>
117+
<date>2019-12-17</date>
118+
<version>
119+
<release>2.1.4</release>
120+
<api>2.1.4</api>
121+
</version>
122+
<stability>
123+
<release>stable</release>
124+
<api>stable</api>
125+
</stability>
126+
<notes>
127+
- Windows support #34
128+
</notes>
129+
</release>
116130
<release>
117131
<date>2019-12-10</date>
118132
<version>

0 commit comments

Comments
 (0)