File: timerlib_config.h

package info (click to toggle)
php-excimer 1.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 348 kB
  • sloc: ansic: 2,513; xml: 233; php: 82; makefile: 2
file content (45 lines) | stat: -rw-r--r-- 1,313 bytes parent folder | download
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
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <php.h>
#include <signal.h>
#include "excimer_events.h"

#if defined(HAVE_SIGEV_THREAD_ID)
#define TIMERLIB_USE_POSIX
#elif defined(HAVE_KQUEUE)
#define TIMERLIB_USE_KQUEUE
#else
#error "No timer implementation available"
#endif

#define TIMERLIB_REAL EXCIMER_REAL
#define TIMERLIB_CPU EXCIMER_CPU
#define TIMERLIB_FAILURE FAILURE
#define TIMERLIB_SUCCESS SUCCESS

// PHP uses SIGRTMIN for request timeouts
#define TIMERLIB_SIGNAL (SIGRTMIN + 1)

/**
 * Report an error from a C library function in the main thread
 * @param func The function which encountered the error
 * @param error_number The error number, e.g. EINVAL
 */
inline static void timerlib_report_errno(const char *func, int error_number)
{
	php_error_docref(NULL, E_WARNING, "Error in %s(): %s", func, strerror(error_number));
}

/**
 * Report an error from a C library function and abort the program
 * @param tlfunc The timerlib function which caused the error
 * @param libfunc The C library function which caused the error
 * @param error_number The error number, e.g. EINVAL
 */
inline static void timerlib_abort_func(const char *tlfunc, const char *libfunc, int error_number) {
	fprintf(stderr, "Fatal error in %s/%s(): %s\n", tlfunc, libfunc, strerror(error_number));
	abort();
}