summaryrefslogtreecommitdiff
path: root/src/shared.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared.h')
-rw-r--r--src/shared.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/shared.h b/src/shared.h
index efb95ad..3ff7b2d 100644
--- a/src/shared.h
+++ b/src/shared.h
@@ -3,11 +3,11 @@
3 3
4#include <stddef.h> 4#include <stddef.h>
5 5
6#define STATIC_ARRAY_LEN(arr) (sizeof((arr))/sizeof((arr)[0]))
7
8typedef int (*gcallback)(void*); // Generic callback signature 6typedef int (*gcallback)(void*); // Generic callback signature
9typedef void (*fcallback)(void*); // free()-like callback signature 7typedef void (*fcallback)(void*); // free()-like callback signature
10 8
9#define STATIC_ARRAY_LEN(arr) (sizeof((arr))/sizeof((arr)[0]))
10
11#define ERRRET(errval, retval) do {\ 11#define ERRRET(errval, retval) do {\
12 errno = (errval);\ 12 errno = (errval);\
13 return (retval);\ 13 return (retval);\
@@ -37,6 +37,7 @@ typedef void (*fcallback)(void*); // free()-like callback signature
37 37
38// Error macro that gcc will not complain about 38// Error macro that gcc will not complain about
39#define ERROR(status, errnum, format, ...) do {error((status), (errnum), (format)__VA_ARGS__); exit((status));} while (0) 39#define ERROR(status, errnum, format, ...) do {error((status), (errnum), (format)__VA_ARGS__); exit((status));} while (0)
40// Spit out a warning using `error`
40#define WARN(errnum, format, ...) do {error(0, (errnum), (format)__VA_ARGS__);} while (0) 41#define WARN(errnum, format, ...) do {error(0, (errnum), (format)__VA_ARGS__);} while (0)
41 42
42// Read the entire contents of a file descriptor into a malloc()'ed buffer 43// Read the entire contents of a file descriptor into a malloc()'ed buffer