blob: e89f1eb8989e231a9c926584673e026eda3c74c1 (
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
|
#ifndef AMALGAM_MISC_H
#define AMALGAM_MISC_H
#ifndef AMAL_PEDANTIC
#include "log.h"
#endif
#ifdef AMAL_PEDANTIC
#define throw_debug_msg do {} while(0)
#else
#define throw_debug_msg do { amal_log_error("Throwing from %s:%d", __FILE__, __LINE__); } while(0)
#endif
#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 { amal_log_error("Return from %s:%d", __FILE__, __LINE__); } while(0)
#define cleanup_if_debug_msg do { amal_log_error("cleanup from %s:%d", __FILE__, __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)
#endif
|