summaryrefslogtreecommitdiff
path: root/die.h
blob: 0ca9e86c56f0fcdee51ed8161919dfd49fc60d70 (plain)
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
#ifndef DIE_H
#define DIE_H

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdbool.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <syslog.h>

#include "built_in.h"

extern void panic_handler_add(void (*on_panic)(void *arg), void *arg);
extern void call_panic_handlers(void);

static inline void panic(const char *format, ...)  __check_format_printf(1, 2);
static inline void syslog_panic(const char *format,
				...) __check_format_printf(1, 2);
static inline void syslog_maybe(bool cond, int priority,
				const char *format, ...) __check_format_printf(3, 4);

static inline void __noreturn __die_hard(void)
{
	call_panic_handlers();
	exit(EXIT_FAILURE);
}

static inline void __noreturn __die_harder(void)
{
	call_panic_handlers();
	_exit(EXIT_FAILURE);
}

static inline void __noreturn die(void)
{
	__die_hard();
}

static inline void __noreturn _die(void)
{
	__die_harder();
}

static inline void __noreturn panic(const char *format, ...)
{
	va_list vl;

	va_start(vl, format);
	vfprintf(stderr, format, vl);
	va_end(vl);

	die();
}

static inline void __noreturn syslog_panic(const char *format, ...)
{
	va_list vl;

	va_start(vl, format);
	vsyslog(LOG_ERR, format, vl);
	va_end(vl);

	die();
}

static inline void syslog_maybe(bool cond, int priority,
				const char *format, ...)
{
	if (cond) {
		va_list vl;

		va_start(vl, format);
		vsyslog(priority, format, vl);
		va_end(vl);
	}
}

#endif /* DIE_H */
D additions * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid: (63 commits) HID: fix missing irq field HID: i2c-hid: fix build HID: i2c-hid: Disable IRQ before freeing buffers HID: usbhid: fix improper return value HID: wacom: generic: Don't sync input on empty input packets HID: wacom: generic: Pad supports more than buttons HID: wacom: generic: Send data only when the interface is defined HID: wacom: generic: Don't return a value for wacom_wac_event HID: intel_ish-hid: use %pUL for uuid formatting HID: cp2112: explicitly require irqchip support in gpiolib HID: asus: Add i2c touchpad support HID: intel-ish-hid: Fix potential race condition HID: sony: Support DS4 dongle HID: sony: Comply to Linux gamepad spec for DS4 HID: sony: Make the DS4 touchpad a separate device HID: sony: Fix memory issue when connecting device using both Bluetooth and USB HID: cp2112: add IRQ chip handling HID: i2c-hid: force the IRQ level trigger only when not set HID: multitouch: do not retrieve all reports for all devices HID: multitouch: enable the Surface 3 Type Cover to report multitouch data ...
Diffstat (limited to 'tools/testing')