blob: e28ed48c4b3254341386e9dc78e6ff4ad700af46 (
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
|
#ifndef AMALGAM_MISC_H
#define AMALGAM_MISC_H
#include <stdio.h>
#ifdef AMAL_PEDANTIC
#define return_if_debug_msg do {} while(0)
#define cleanup_if_debug_msg do {} while(0)
#else
#define return_if_debug_msg do { fprintf(stderr, "Return from %s:%d\n", __FUNCTION__, __LINE__); } while(0)
#define cleanup_if_debug_msg do { fprintf(stderr, "cleanup from %s:%d\n", __FUNCTION__, __LINE__); } while(0)
#endif
#define return_if_error(result) \
do { \
int return_if_result; \
return_if_result = (result); \
if((return_if_result) != 0) { \
return_if_debug_msg; \
return return_if_result; \
} \
} while(0)
#define cleanup_if_error(result) do { if((result) != 0) { cleanup_if_debug_msg; goto cleanup; } } while(0)
#if defined(__GNUC__) && __GNUC__ >= 4
#define CHECK_RESULT __attribute__ ((warn_unused_result))
#elif defined(_MSC_VER) && _MSC_VER >= 1700
#define CHECK_RESULT _Check_return_
#else
#define CHECK_RESULT
#endif
#define ignore_result_int(expr) (void)((expr)+1)
typedef enum {
bool_false,
bool_true
} bool;
#ifndef NULL
#define NULL ((void*)0)
#endif
#endif
|