59
59
void my_write_core(int sig);
65
Async-signal-safe utility functions used by signal handler routines.
66
Declared here in order to unit-test them.
67
These are not general-purpose, but tailored to the signal handling routines.
70
Converts a longlong value to string.
71
@param base 10 for decimal, 16 for hex values (0..9a..f)
72
@param val The value to convert
73
@param buf Assumed to point to the *end* of the buffer.
74
@returns Pointer to the first character of the converted string.
76
for base-10 the return string will be prepended with '-'
77
for base-16 the return string will contain 16 characters
78
Implemented with simplicity, and async-signal-safety in mind.
80
char *my_safe_itoa(int base, longlong val, char *buf);
83
Converts a ulonglong value to string.
84
@param base 10 for decimal, 16 for hex values (0..9a..f)
85
@param val The value to convert
86
@param buf Assumed to point to the *end* of the buffer.
87
@returns Pointer to the first character of the converted string.
88
Implemented with simplicity, and async-signal-safety in mind.
90
char *my_safe_utoa(int base, ulonglong val, char *buf);
93
A (very) limited version of snprintf.
94
@param to Destination buffer.
95
@param n Size of destination buffer.
96
@param fmt printf() style format string.
97
@returns Number of bytes written, including terminating '\0'
98
Supports 'd' 'i' 'u' 'x' 'p' 's' conversion.
99
Supports 'l' and 'll' modifiers for integral types.
100
Does not support any width/precision.
101
Implemented with simplicity, and async-signal-safety in mind.
103
size_t my_safe_snprintf(char* to, size_t n, const char* fmt, ...)
104
ATTRIBUTE_FORMAT(printf, 3, 4);
107
A (very) limited version of snprintf, which writes the result to STDERR.
109
Implemented with simplicity, and async-signal-safety in mind.
110
@note Has an internal buffer capacity of 512 bytes,
111
which should suffice for our signal handling routines.
113
size_t my_safe_printf_stderr(const char* fmt, ...)
114
ATTRIBUTE_FORMAT(printf, 1, 2);
117
Writes up to count bytes from buffer to STDERR.
118
Implemented with simplicity, and async-signal-safety in mind.
119
@param buf Buffer containing data to be written.
120
@param count Number of bytes to write.
121
@returns Number of bytes written.
123
size_t my_write_stderr(const void *buf, size_t count);
64
127
#endif /* _my_stacktrace_h_ */