DAW JSON Link
daw_json_defs.h
Go to the documentation of this file.
1 // Copyright (c) Darrell Wright
2 //
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)
5 //
6 // Official repository: https://github.com/beached/
7 //
8 
9 #pragma once
10 
11 #if defined( __GNUC__ ) or defined( __clang__ )
12 #define DAW_JSON_LIKELY( Bool ) ( __builtin_expect( !!( Bool ), 1 ) )
13 #define DAW_JSON_UNLIKELY( Bool ) ( __builtin_expect( !!( Bool ), 0 ) )
14 #define DAW_JSON_NOINLINE [[gnu::noinline]]
15 // __attribute__( ( noinline ) )
16 #elif defined( _MSC_VER )
17 #define DAW_JSON_LIKELY( Bool ) !!( Bool )
18 #define DAW_JSON_UNLIKELY( Bool ) !!( Bool )
19 #define DAW_JSON_NOINLINE __declspec( noinline )
20 #else
21 #define DAW_JSON_LIKELY( Bool ) !!( Bool )
22 #define DAW_JSON_UNLIKELY( Bool ) !!( Bool )
23 #define DAW_JSON_NOINLINE [[gnu::noinline]]
24 #endif
25 
26 #if not defined( DAW_NO_FLATTEN ) and not defined( _MSC_VER )
27 #define DAW_ONLY_FLATTEN [[gnu::flatten]]
28 #define DAW_ONLY_INLINE [[gnu::always_inline]]
29 #else
30 #define DAW_ONLY_FLATTEN
31 #define DAW_ONLY_INLINE
32 #endif