aboutsummaryrefslogtreecommitdiff
path: root/include/std/misc.h
blob: b979d9c8e72c88f294aa43f2e70fce68805c31c8 (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
#ifndef AMALGAM_MISC_H
#define AMALGAM_MISC_H

#define return_if_error(result) \
do { \
    int return_if_result; \
    return_if_result = (result); \
    if((return_if_result) != 0) \
        return return_if_result; \
} while(0)

#define cleanup_if_error(result) do { if((result) != 0) 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