Line data Source code
1 : #ifdef HAVE_CONFIG_H 2 : #include <config.h> 3 : #endif 4 : 5 : #include <php.h> 6 : #include <signal.h> 7 : #include "excimer_events.h" 8 : 9 : #if defined(HAVE_SIGEV_THREAD_ID) 10 : #define TIMERLIB_USE_POSIX 11 : #elif defined(HAVE_KQUEUE) 12 : #define TIMERLIB_USE_KQUEUE 13 : #else 14 : #error "No timer implementation available" 15 : #endif 16 : 17 : #define TIMERLIB_REAL EXCIMER_REAL 18 : #define TIMERLIB_CPU EXCIMER_CPU 19 : #define TIMERLIB_FAILURE FAILURE 20 : #define TIMERLIB_SUCCESS SUCCESS 21 : 22 : // PHP uses SIGRTMIN for request timeouts 23 : #define TIMERLIB_SIGNAL (SIGRTMIN + 1) 24 : 25 : /** 26 : * Report an error from a C library function in the main thread 27 : * @param func The function which encountered the error 28 : * @param error_number The error number, e.g. EINVAL 29 : */ 30 0 : inline static void timerlib_report_errno(const char *func, int error_number) 31 : { 32 0 : php_error_docref(NULL, E_WARNING, "Error in %s(): %s", func, strerror(error_number)); 33 0 : } 34 : 35 : /** 36 : * Report an error from a C library function and abort the program 37 : * @param tlfunc The timerlib function which caused the error 38 : * @param libfunc The C library function which caused the error 39 : * @param error_number The error number, e.g. EINVAL 40 : */ 41 0 : inline static void timerlib_abort_func(const char *tlfunc, const char *libfunc, int error_number) { 42 0 : fprintf(stderr, "Fatal error in %s/%s(): %s\n", tlfunc, libfunc, strerror(error_number)); 43 0 : abort(); 44 : } 45 :