| 1 |
|
| #include "poexs.h" |
| 2 |
|
| |
| 3 |
|
| static NV (*th_nvtime)(void); |
| 4 |
|
| |
| 5 |
|
| /* |
| 6 |
|
| =head1 NAME |
| 7 |
|
| |
| 8 |
|
| poexs.c - provide XS functions useful in implementing a POE::Loop implementation |
| 9 |
|
| |
| 10 |
|
| =head1 SYNOPSIS |
| 11 |
|
| |
| 12 |
|
| #include "poexs.h" |
| 13 |
|
| |
| 14 |
|
| int fds[] = { ready fds }; |
| 15 |
|
| poe_enqueue_data_ready(kernel, MODE_RD, fds, fd_count); |
| 16 |
|
| poe_data_ev_dispatch_due(kernel); |
| 17 |
|
| poe_test_if_kernel_idle(kernel); |
| 18 |
|
| int count = poe_data_ses_count(kernel); |
| 19 |
|
| const char *mode_name = poe_mode_names(MODE_RD); |
| 20 |
|
| |
| 21 |
|
| // tracing enabled |
| 22 |
|
| POE_TRACE_FILE(("<fh> something to do with files\n", ...)); |
| 23 |
|
| POE_TRACE_EVENT(("<ev> something to do with events\n", ...)); |
| 24 |
|
| POE_TRACE_CALL(("<cl> trace a function call\n", ...)); |
| 25 |
|
| |
| 26 |
|
| =head1 DESCRIPTION |
| 27 |
|
| |
| 28 |
|
| This C source file provides functions and macros useful for |
| 29 |
|
| implementing a POE::Loop class in XS. |
| 30 |
|
| |
| 31 |
|
| =head1 CONSTANTS |
| 32 |
|
| |
| 33 |
|
| =over |
| 34 |
|
| |
| 35 |
|
| =item MODE_RD |
| 36 |
|
| |
| 37 |
|
| =item MODE_WR |
| 38 |
|
| |
| 39 |
|
| =item MODE_EX |
| 40 |
|
| |
| 41 |
|
| Filehandle modes supplied to loop_watch_filehandle(), |
| 42 |
|
| loop_ignore_filehandle(), loop_pause_filehandle(), |
| 43 |
|
| loop_resume_filehandle(), and supplied to poe_enqueue_data_ready() |
| 44 |
|
| when filehandles become ready. |
| 45 |
|
| |
| 46 |
|
| =item POE_SV_FORMAT |
| 47 |
|
| |
| 48 |
|
| The format string perl's sprintf() style formatters recognize to |
| 49 |
|
| format a SV*. This is "%_" up to perl 5.9 and "%-p" from 5.10 |
| 50 |
|
| onwards. This isn't really POE specific, but it's useful for |
| 51 |
|
| formatting SVs. |
| 52 |
|
| |
| 53 |
|
| =back |
| 54 |
|
| |
| 55 |
|
| =head1 FUNCTIONS |
| 56 |
|
| |
| 57 |
|
| =over |
| 58 |
|
| |
| 59 |
|
| =item poe_initialize() |
| 60 |
|
| |
| 61 |
|
| =cut |
| 62 |
|
| */ |
| 63 |
|
| |
| 64 |
|
| void |
| 65 |
50 |
| poe_initialize(void) { |
| 66 |
50 |
| SV **svp = hv_fetch(PL_modglobal, "Time::NVtime", 12, 0); |
| 67 |
50 |
▶ | if (svp && SvIOK(*svp)) { |
Branch: 2 branches
| Branch | True | False | Total |
| if (svp && SvIOK(*svp)) { |
50 |
0 |
50 |
| if (svp && SvIOK(*svp)) { |
50 |
0 |
50 |
|
| 68 |
|
| POE_TRACE_CALL(("<cl> Using Time::HiRes for time")); |
| 69 |
50 |
| th_nvtime = INT2PTR(NV (*)(void), SvIV(*svp)); |
| 70 |
|
| } |
| 71 |
50 |
| } |
| 72 |
|
| |
| 73 |
|
| /* |
| 74 |
|
| =item poe_enqueue_data_ready(kernel, mode, fds, fd_count) |
| 75 |
|
| |
| 76 |
|
| Calls the _enqueue_data_ready() perl method on the given kernel |
| 77 |
|
| object. |
| 78 |
|
| |
| 79 |
|
| Enqueues events with the POE kernel that the the given fds are ready |
| 80 |
|
| for the type of I/O indicated by mode. |
| 81 |
|
| |
| 82 |
|
| This should be called by your loop_do_timeslice() implementation when |
| 83 |
|
| those filehandles are ready for I/O. |
| 84 |
|
| |
| 85 |
|
| I<kernel> should be the kernel SV supplied to loop_do_timeslice(), |
| 86 |
|
| mode should be any of MODE_RD, MODE_WR or MODE_EX. |
| 87 |
|
| |
| 88 |
|
| Warning: POE will make calls to loop_pause_filehandle() in processing |
| 89 |
|
| filehandles, make sure your filehandle structures can handle this |
| 90 |
|
| re-entrancy. |
| 91 |
|
| |
| 92 |
|
| Return: void |
| 93 |
|
| |
| 94 |
|
| =cut |
| 95 |
|
| */ |
| 96 |
|
| |
| 97 |
|
| #ifdef XS_LOOP_TRACE |
| 98 |
|
| |
| 99 |
|
| static int trace_initialized; |
| 100 |
|
| |
| 101 |
|
| static int trace_files; |
| 102 |
|
| static int trace_events; |
| 103 |
|
| static int trace_calls; |
| 104 |
|
| static int trace_statistics; |
| 105 |
|
| |
| 106 |
|
| static void |
| 107 |
|
| do_trace_initialize(void); |
| 108 |
|
| |
| 109 |
|
| #define TRACE_INITIALIZE() if (!trace_initialized) do_trace_initialize() |
| 110 |
|
| |
| 111 |
|
| #endif |
| 112 |
|
| |
| 113 |
|
| void |
| 114 |
320 |
| poe_enqueue_data_ready(SV *kernel, int mode, int *fds, int fd_count) { |
| 115 |
320 |
| dSP; |
| 116 |
|
| int i; |
| 117 |
|
| |
| 118 |
|
| #ifdef XS_LOOP_TRACE |
| 119 |
|
| if (poe_tracing_calls()) { |
| 120 |
|
| SV *sv = newSVpvf("<cl> poe_enqueue_data_ready(mode %d (%s)", mode, poe_mode_names(mode)); |
| 121 |
|
| for (i = 0; i < fd_count; ++i) { |
| 122 |
|
| sv_catpvf(sv, ", %d", fds[i]); |
| 123 |
|
| } |
| 124 |
|
| sv_catpv(sv, ")\n"); |
| 125 |
|
| poexs_trace_call("%s", SvPV_nolen(sv)); |
| 126 |
|
| SvREFCNT_dec(sv); |
| 127 |
|
| } |
| 128 |
|
| #endif |
| 129 |
|
| |
| 130 |
320 |
| ENTER; |
| 131 |
320 |
| SAVETMPS; |
| 132 |
320 |
▶ | EXTEND(SP, fd_count+2); |
Branch: 2 branches
| Branch | True | False | Total |
| EXTEND(SP, fd_count+2); |
320 |
0 |
320 |
| EXTEND(SP, fd_count+2); |
0 |
320 |
320 |
|
| 133 |
320 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
320 |
320 |
|
| 134 |
320 |
| PUSHs(sv_2mortal(newSVsv(kernel))); |
| 135 |
320 |
| PUSHs(sv_2mortal(newSViv(mode))); |
| 136 |
895 |
▶ | for (i = 0; i < fd_count; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for (i = 0; i < fd_count; ++i) { |
575 |
320 |
895 |
|
| 137 |
575 |
| PUSHs(sv_2mortal(newSViv(fds[i]))); |
| 138 |
|
| } |
| 139 |
320 |
| PUTBACK; |
| 140 |
|
| |
| 141 |
320 |
| perl_call_method("_data_handle_enqueue_ready", G_DISCARD); |
| 142 |
|
| |
| 143 |
320 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
320 |
0 |
320 |
|
| 144 |
320 |
| LEAVE; |
| 145 |
320 |
| } |
| 146 |
|
| |
| 147 |
|
| /* |
| 148 |
|
| =item poe_data_ev_dispatch_due(kernel) |
| 149 |
|
| |
| 150 |
|
| Calls the _data_ev_dispatch_due() method on the given kernel object. |
| 151 |
|
| |
| 152 |
|
| This should be called at the end of your loop_do_timeslice() |
| 153 |
|
| implementation to dispatch any waiting events. |
| 154 |
|
| |
| 155 |
|
| Return: void |
| 156 |
|
| |
| 157 |
|
| =cut |
| 158 |
|
| */ |
| 159 |
|
| |
| 160 |
|
| void |
| 161 |
652 |
| poe_data_ev_dispatch_due(SV *kernel) { |
| 162 |
652 |
| dSP; |
| 163 |
|
| |
| 164 |
652 |
| ENTER; |
| 165 |
652 |
| SAVETMPS; |
| 166 |
652 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
652 |
652 |
|
| 167 |
652 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
652 |
652 |
|
| 168 |
652 |
| PUSHs(sv_2mortal(newSVsv(kernel))); |
| 169 |
652 |
| PUTBACK; |
| 170 |
|
| |
| 171 |
652 |
| perl_call_method("_data_ev_dispatch_due", G_DISCARD); |
| 172 |
|
| |
| 173 |
652 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
652 |
0 |
652 |
|
| 174 |
652 |
| LEAVE; |
| 175 |
652 |
| } |
| 176 |
|
| |
| 177 |
|
| /* |
| 178 |
|
| =item poe_test_if_kernel_idle(kernel) |
| 179 |
|
| |
| 180 |
|
| Calls the _test_if_kernel_is_idle() method on the given POE kernel |
| 181 |
|
| object. |
| 182 |
|
| |
| 183 |
|
| This should be called at the beginning of your loop_do_timeslice() |
| 184 |
|
| implementation. |
| 185 |
|
| |
| 186 |
|
| Return: void |
| 187 |
|
| |
| 188 |
|
| =cut |
| 189 |
|
| */ |
| 190 |
|
| |
| 191 |
|
| void |
| 192 |
652 |
| poe_test_if_kernel_idle(SV *kernel) { |
| 193 |
652 |
| dSP; |
| 194 |
|
| |
| 195 |
652 |
| ENTER; |
| 196 |
652 |
| SAVETMPS; |
| 197 |
652 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
652 |
652 |
|
| 198 |
652 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
652 |
652 |
|
| 199 |
652 |
| PUSHs(sv_2mortal(newSVsv(kernel))); |
| 200 |
652 |
| PUTBACK; |
| 201 |
|
| |
| 202 |
652 |
| perl_call_method("_test_if_kernel_is_idle", G_DISCARD); |
| 203 |
|
| |
| 204 |
652 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
652 |
0 |
652 |
|
| 205 |
652 |
| LEAVE; |
| 206 |
652 |
| } |
| 207 |
|
| |
| 208 |
|
| /* |
| 209 |
|
| =item poe_data_ses_count(kernel) |
| 210 |
|
| |
| 211 |
|
| Calls the _data_ses_count() perl method on the given kernel object. |
| 212 |
|
| |
| 213 |
|
| Your loop_run() implementation should call your loop_do_timeslice() |
| 214 |
|
| implementation while this function returns non-zero. |
| 215 |
|
| |
| 216 |
|
| Returns non-zero if there are active POE sessions. |
| 217 |
|
| |
| 218 |
|
| =cut |
| 219 |
|
| */ |
| 220 |
|
| |
| 221 |
|
| int |
| 222 |
698 |
| poe_data_ses_count(SV *kernel) { |
| 223 |
698 |
| dSP; |
| 224 |
|
| int count; |
| 225 |
|
| SV *result_sv; |
| 226 |
|
| int result; |
| 227 |
|
| |
| 228 |
698 |
| ENTER; |
| 229 |
698 |
| SAVETMPS; |
| 230 |
698 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
698 |
698 |
|
| 231 |
698 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
698 |
698 |
|
| 232 |
698 |
| PUSHs(sv_2mortal(newSVsv(kernel))); |
| 233 |
698 |
| PUTBACK; |
| 234 |
|
| |
| 235 |
698 |
| count = perl_call_method("_data_ses_count", G_SCALAR); |
| 236 |
|
| |
| 237 |
698 |
| SPAGAIN; |
| 238 |
|
| |
| 239 |
698 |
▶ | if (count != 1) |
Branch: 1 branch
| Branch | True | False | Total |
| if (count != 1) |
0 |
698 |
698 |
|
| 240 |
0 |
| croak("Result of perl_call_method(..., G_SCALAR) != 1"); |
| 241 |
|
| |
| 242 |
698 |
| result_sv = POPs; |
| 243 |
698 |
| result = SvTRUE(result_sv); |
| 244 |
|
| |
| 245 |
698 |
| PUTBACK; |
| 246 |
698 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
698 |
0 |
698 |
|
| 247 |
698 |
| LEAVE; |
| 248 |
|
| |
| 249 |
698 |
| return result; |
| 250 |
|
| } |
| 251 |
|
| |
| 252 |
|
| /* |
| 253 |
|
| =item poe_mode_names(mode) |
| 254 |
|
| |
| 255 |
|
| Returns a string describing a POE I/O mode, any of MODE_RD, MODE_WR, |
| 256 |
|
| MODE_EX. |
| 257 |
|
| |
| 258 |
|
| Supplying any other value will croak() |
| 259 |
|
| |
| 260 |
|
| Returns: a const char *. |
| 261 |
|
| |
| 262 |
|
| =cut |
| 263 |
|
| |
| 264 |
|
| =back |
| 265 |
|
| */ |
| 266 |
|
| |
| 267 |
|
| const char * |
| 268 |
0 |
| poe_mode_names(int mode) { |
| 269 |
0 |
| switch (mode) { |
| 270 |
0 |
| case MODE_RD: |
| 271 |
0 |
| return "MODE_RD"; |
| 272 |
|
| |
| 273 |
0 |
| case MODE_WR: |
| 274 |
0 |
| return "MODE_WR"; |
| 275 |
|
| |
| 276 |
0 |
| case MODE_EX: |
| 277 |
0 |
| return "MODE_EX"; |
| 278 |
|
| |
| 279 |
0 |
| default: |
| 280 |
0 |
| croak("Unknown filehandle watch mode %d", mode); |
| 281 |
|
| } |
| 282 |
|
| } |
| 283 |
|
| |
| 284 |
|
| /* |
| 285 |
|
| =item poe_timeh() |
| 286 |
|
| |
| 287 |
|
| Returns the current epoch time as a floating point value. |
| 288 |
|
| |
| 289 |
|
| =cut |
| 290 |
|
| */ |
| 291 |
|
| |
| 292 |
|
| double |
| 293 |
652 |
| poe_timeh(void) { |
| 294 |
652 |
▶ | if (th_nvtime) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (th_nvtime) { |
652 |
0 |
652 |
|
| 295 |
652 |
| return th_nvtime(); |
| 296 |
|
| } |
| 297 |
|
| else { |
| 298 |
|
| struct timeval tv; |
| 299 |
|
| |
| 300 |
0 |
| gettimeofday(&tv, NULL); |
| 301 |
|
| |
| 302 |
0 |
| return tv.tv_sec + 1e-6 * tv.tv_usec; |
| 303 |
|
| } |
| 304 |
|
| } |
| 305 |
|
| |
| 306 |
|
| /* |
| 307 |
|
| =item poe_trap(fmt, ...); |
| 308 |
|
| |
| 309 |
|
| Call POE::Kernel::_trap() with the formatted string as the parameter. |
| 310 |
|
| |
| 311 |
|
| =cut |
| 312 |
|
| */ |
| 313 |
|
| void |
| 314 |
0 |
| poe_trap(const char *fmt, ...) { |
| 315 |
0 |
| SV *out = sv_2mortal(newSVpv("", 0)); |
| 316 |
|
| va_list va; |
| 317 |
0 |
| dSP; |
| 318 |
|
| int count; |
| 319 |
|
| |
| 320 |
0 |
| va_start(va, fmt); |
| 321 |
0 |
| sv_vcatpvf(out, fmt, &va); |
| 322 |
0 |
| va_end(va); |
| 323 |
|
| |
| 324 |
0 |
| ENTER; |
| 325 |
0 |
| SAVETMPS; |
| 326 |
0 |
▶ | EXTEND(SP, 1); |
Branch: 1 branch
| Branch | True | False | Total |
| EXTEND(SP, 1); |
0 |
0 |
0 |
|
| 327 |
0 |
▶ | PUSHMARK(SP); |
Branch: 1 branch
| Branch | True | False | Total |
| PUSHMARK(SP); |
0 |
0 |
0 |
|
| 328 |
0 |
| PUSHs(out); |
| 329 |
0 |
| PUTBACK; |
| 330 |
|
| |
| 331 |
0 |
| count = perl_call_pv("POE::Kernel::_trap", G_VOID | G_DISCARD); |
| 332 |
|
| |
| 333 |
|
| /* not sure we ever get here */ |
| 334 |
0 |
▶ | FREETMPS; |
Branch: 1 branch
| Branch | True | False | Total |
| FREETMPS; |
0 |
0 |
0 |
|
| 335 |
0 |
| LEAVE; |
| 336 |
0 |
| } |
| 337 |
|
| |
| 338 |
|
| #ifdef XS_LOOP_TRACE |
| 339 |
|
| |
| 340 |
|
| static int |
| 341 |
|
| get_trace_flag(const char *name) { |
| 342 |
|
| dSP; |
| 343 |
|
| int result; |
| 344 |
|
| int count; |
| 345 |
|
| SV *result_sv; |
| 346 |
|
| |
| 347 |
|
| ENTER; |
| 348 |
|
| SAVETMPS; |
| 349 |
|
| PUSHMARK(SP); |
| 350 |
|
| PUTBACK; |
| 351 |
|
| |
| 352 |
|
| count = perl_call_pv(name, G_SCALAR); |
| 353 |
|
| |
| 354 |
|
| SPAGAIN; |
| 355 |
|
| |
| 356 |
|
| if (count != 1) |
| 357 |
|
| croak("Result of perl_call_pv(\"%s\", G_SCALAR) != 1 %d", name, count); |
| 358 |
|
| |
| 359 |
|
| result_sv = POPs; |
| 360 |
|
| result = SvTRUE(result_sv); |
| 361 |
|
| |
| 362 |
|
| FREETMPS; |
| 363 |
|
| LEAVE; |
| 364 |
|
| |
| 365 |
|
| return result; |
| 366 |
|
| } |
| 367 |
|
| |
| 368 |
|
| |
| 369 |
|
| static void |
| 370 |
|
| do_trace_initialize(void) { |
| 371 |
|
| trace_files = get_trace_flag("POE::Kernel::TRACE_FILES"); |
| 372 |
|
| trace_events = get_trace_flag("POE::Kernel::TRACE_EVENTS"); |
| 373 |
|
| trace_statistics = get_trace_flag("POE::Kernel::TRACE_STATISTICS"); |
| 374 |
|
| trace_calls = get_trace_flag("POE::Kernel::TRACE_CALLS"); |
| 375 |
|
| trace_initialized = 1; |
| 376 |
|
| } |
| 377 |
|
| |
| 378 |
|
| /* |
| 379 |
|
| =head1 TRACE MACROS |
| 380 |
|
| |
| 381 |
|
| These macros are used for writing trace output to POE's trace file. |
| 382 |
|
| |
| 383 |
|
| When trace is not enabled these macros are replaced with nothing. |
| 384 |
|
| |
| 385 |
|
| Note the doubles parentheses on the POE_TRACE_ macros. |
| 386 |
|
| |
| 387 |
|
| =over |
| 388 |
|
| |
| 389 |
|
| =item POE_TRACE_FILE((format, ...)) |
| 390 |
|
| |
| 391 |
|
| Trace a file handle change, controlled by the POE TRACE_FILES |
| 392 |
|
| constant. |
| 393 |
|
| |
| 394 |
|
| =item POE_TRACE_EVENT((format, ...)) |
| 395 |
|
| |
| 396 |
|
| Trace an event, controlled by the POE TRACE_EVENTS constant. |
| 397 |
|
| |
| 398 |
|
| =item POE_TRACE_CALL((format, ...)) |
| 399 |
|
| |
| 400 |
|
| Trace a function call, controlled by the POE::Kernel::TRACE_CALLS |
| 401 |
|
| constant. This must be set by your .pm if not set by POE's |
| 402 |
|
| mechanisms. |
| 403 |
|
| |
| 404 |
|
| #define POE_STAT_ADD(kernel, name, value) |
| 405 |
|
| |
| 406 |
|
| Update a statistic, controlled by the POE TRACE_STATISTICS constant. |
| 407 |
|
| |
| 408 |
|
| =cut |
| 409 |
|
| */ |
| 410 |
|
| |
| 411 |
|
| void |
| 412 |
|
| poexs_trace_file(const char *fmt, ...) { |
| 413 |
|
| va_list va; |
| 414 |
|
| dSP; |
| 415 |
|
| |
| 416 |
|
| if (!trace_initialized) |
| 417 |
|
| do_trace_initialize(); |
| 418 |
|
| if (!trace_files) |
| 419 |
|
| return; |
| 420 |
|
| |
| 421 |
|
| ENTER; |
| 422 |
|
| SAVETMPS; |
| 423 |
|
| EXTEND(SP, 3); |
| 424 |
|
| PUSHMARK(SP); |
| 425 |
|
| va_start(va, fmt); |
| 426 |
|
| PUSHs(sv_2mortal(vnewSVpvf(fmt, &va))); |
| 427 |
|
| va_end(va); |
| 428 |
|
| PUTBACK; |
| 429 |
|
| |
| 430 |
|
| perl_call_pv("POE::Kernel::_warn", G_DISCARD); |
| 431 |
|
| |
| 432 |
|
| FREETMPS; |
| 433 |
|
| LEAVE; |
| 434 |
|
| } |
| 435 |
|
| |
| 436 |
|
| void |
| 437 |
|
| poexs_trace_event(const char *fmt, ...) { |
| 438 |
|
| va_list va; |
| 439 |
|
| dSP; |
| 440 |
|
| |
| 441 |
|
| if (!trace_initialized) |
| 442 |
|
| do_trace_initialize(); |
| 443 |
|
| if (!trace_events) |
| 444 |
|
| return; |
| 445 |
|
| |
| 446 |
|
| ENTER; |
| 447 |
|
| SAVETMPS; |
| 448 |
|
| EXTEND(SP, 3); |
| 449 |
|
| PUSHMARK(SP); |
| 450 |
|
| va_start(va, fmt); |
| 451 |
|
| PUSHs(sv_2mortal(vnewSVpvf(fmt, &va))); |
| 452 |
|
| va_end(va); |
| 453 |
|
| PUTBACK; |
| 454 |
|
| |
| 455 |
|
| perl_call_pv("POE::Kernel::_warn", G_DISCARD); |
| 456 |
|
| |
| 457 |
|
| FREETMPS; |
| 458 |
|
| LEAVE; |
| 459 |
|
| } |
| 460 |
|
| |
| 461 |
|
| void |
| 462 |
|
| poexs_trace_call(const char *fmt, ...) { |
| 463 |
|
| va_list va; |
| 464 |
|
| dSP; |
| 465 |
|
| |
| 466 |
|
| if (!trace_initialized) |
| 467 |
|
| do_trace_initialize(); |
| 468 |
|
| if (!trace_calls) |
| 469 |
|
| return; |
| 470 |
|
| |
| 471 |
|
| ENTER; |
| 472 |
|
| SAVETMPS; |
| 473 |
|
| EXTEND(SP, 3); |
| 474 |
|
| PUSHMARK(SP); |
| 475 |
|
| va_start(va, fmt); |
| 476 |
|
| PUSHs(sv_2mortal(vnewSVpvf(fmt, &va))); |
| 477 |
|
| va_end(va); |
| 478 |
|
| PUTBACK; |
| 479 |
|
| |
| 480 |
|
| perl_call_pv("POE::Kernel::_warn", G_DISCARD); |
| 481 |
|
| |
| 482 |
|
| FREETMPS; |
| 483 |
|
| LEAVE; |
| 484 |
|
| } |
| 485 |
|
| |
| 486 |
|
| void |
| 487 |
|
| poexs_data_stat_add(SV *kernel, const char *name, double value) { |
| 488 |
|
| dSP; |
| 489 |
|
| |
| 490 |
|
| if (!trace_initialized) |
| 491 |
|
| do_trace_initialize(); |
| 492 |
|
| if (!trace_statistics) |
| 493 |
|
| return; |
| 494 |
|
| |
| 495 |
|
| ENTER; |
| 496 |
|
| SAVETMPS; |
| 497 |
|
| EXTEND(SP, 3); |
| 498 |
|
| PUSHMARK(SP); |
| 499 |
|
| PUSHs(sv_2mortal(newSVsv(kernel))); |
| 500 |
|
| PUSHs(sv_2mortal(newSVpv(name, 0))); |
| 501 |
|
| PUSHs(sv_2mortal(newSVnv(value))); |
| 502 |
|
| PUTBACK; |
| 503 |
|
| |
| 504 |
|
| perl_call_pv("_data_stat_add", G_DISCARD); |
| 505 |
|
| |
| 506 |
|
| FREETMPS; |
| 507 |
|
| LEAVE; |
| 508 |
|
| } |
| 509 |
|
| |
| 510 |
|
| /* |
| 511 |
|
| =item poe_tracing_files() |
| 512 |
|
| |
| 513 |
|
| Returns non-zero if file tracing is enabled. |
| 514 |
|
| |
| 515 |
|
| Only available if XS_LOOP_TRACE is defined. |
| 516 |
|
| |
| 517 |
|
| =cut |
| 518 |
|
| */ |
| 519 |
|
| |
| 520 |
|
| int |
| 521 |
|
| poe_tracing_files(void) { |
| 522 |
|
| if (!trace_initialized) |
| 523 |
|
| do_trace_initialize(); |
| 524 |
|
| |
| 525 |
|
| return trace_files; |
| 526 |
|
| } |
| 527 |
|
| |
| 528 |
|
| /* |
| 529 |
|
| =item poe_tracing_events() |
| 530 |
|
| |
| 531 |
|
| Returns non-zero if event tracing is enabled. |
| 532 |
|
| |
| 533 |
|
| Only available if XS_LOOP_TRACE is defined. |
| 534 |
|
| |
| 535 |
|
| =cut |
| 536 |
|
| */ |
| 537 |
|
| |
| 538 |
|
| int |
| 539 |
|
| poe_tracing_events(void) { |
| 540 |
|
| if (!trace_initialized) |
| 541 |
|
| do_trace_initialize(); |
| 542 |
|
| |
| 543 |
|
| return trace_events; |
| 544 |
|
| } |
| 545 |
|
| |
| 546 |
|
| /* |
| 547 |
|
| =item poe_tracing_calls() |
| 548 |
|
| |
| 549 |
|
| Returns non-zero if call tracing is enabled. |
| 550 |
|
| |
| 551 |
|
| Only available if XS_LOOP_TRACE is defined. |
| 552 |
|
| |
| 553 |
|
| =cut |
| 554 |
|
| */ |
| 555 |
|
| |
| 556 |
|
| int |
| 557 |
|
| poe_tracing_calls(void) { |
| 558 |
|
| if (!trace_initialized) |
| 559 |
|
| do_trace_initialize(); |
| 560 |
|
| |
| 561 |
|
| return trace_calls; |
| 562 |
|
| } |
| 563 |
|
| |
| 564 |
|
| #endif |