]> wimlib.net Git - wimlib/blob - include/wimlib/compiler.h
compiler.h: Force compiler to inline inline functions
[wimlib] / include / wimlib / compiler.h
1 #ifndef _WIMLIB_COMPILER_H
2 #define _WIMLIB_COMPILER_H
3
4 #ifdef __GNUC__
5 #       if defined(__CYGWIN__) || defined(__WIN32__)
6 #               define WIMLIBAPI __declspec(dllexport)
7 #       else
8 #               define WIMLIBAPI __attribute__((visibility("default")))
9 #       endif
10 #       define _always_inline_attribute inline __attribute__((always_inline))
11 #       define _packed_attribute __attribute__((packed))
12 #       define _format_attribute(type, format_str, args_start) \
13                         /*__attribute__((format(type, format_str, args_start))) */
14 #       if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
15 #               define _cold_attribute     __attribute__((cold))
16 #       else
17 #               define _cold_attribute
18 #       endif
19 #       define _malloc_attribute __attribute__((malloc))
20 #       define _warn_unused_result_attribute __attribute__((warn_unused_result))
21 #       define _aligned_attribute(size) __attribute__((aligned(size)))
22 #       define likely(x) __builtin_expect(!!(x), 1)
23 #       define unlikely(x) __builtin_expect(!!(x), 0)
24 #       define inline inline __attribute__((always_inline))
25 #else
26 #       define WIMLIBAPI
27 #       define _always_inline_attribute inline
28 #       define _format_attribute(type, format_str, args_start)
29 #       define _cold_attribute
30 #       define _packed_attribute
31 #       define _malloc_attribute
32 #       define _warn_unused_result_attribute
33 #       define _aligned_attribute(size)
34 #       define likely(x) (x)
35 #       define unlikely(x) (x)
36 #endif /* __GNUC__ */
37
38 #endif /* _WIMLIB_COMPILER_H */