JasPer  3.0.3
jas_compiler.h
Go to the documentation of this file.
1 /* __START_OF_JASPER_LICENSE__
2  *
3  * JasPer License Version 2.0
4  *
5  * Copyright (c) 2001-2006 Michael David Adams
6  * Copyright (c) 1999-2000 Image Power, Inc.
7  * Copyright (c) 1999-2000 The University of British Columbia
8  *
9  * All rights reserved.
10  *
11  * Permission is hereby granted, free of charge, to any person (the
12  * "User") obtaining a copy of this software and associated documentation
13  * files (the "Software"), to deal in the Software without restriction,
14  * including without limitation the rights to use, copy, modify, merge,
15  * publish, distribute, and/or sell copies of the Software, and to permit
16  * persons to whom the Software is furnished to do so, subject to the
17  * following conditions:
18  *
19  * 1. The above copyright notices and this permission notice (which
20  * includes the disclaimer below) shall be included in all copies or
21  * substantial portions of the Software.
22  *
23  * 2. The name of a copyright holder shall not be used to endorse or
24  * promote products derived from the Software without specific prior
25  * written permission.
26  *
27  * THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS
28  * LICENSE. NO USE OF THE SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER
29  * THIS DISCLAIMER. THE SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
30  * "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
31  * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
32  * PARTICULAR PURPOSE AND NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO
33  * EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
34  * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
35  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
36  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
37  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. NO ASSURANCES ARE
38  * PROVIDED BY THE COPYRIGHT HOLDERS THAT THE SOFTWARE DOES NOT INFRINGE
39  * THE PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF ANY OTHER ENTITY.
40  * EACH COPYRIGHT HOLDER DISCLAIMS ANY LIABILITY TO THE USER FOR CLAIMS
41  * BROUGHT BY ANY OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL
42  * PROPERTY RIGHTS OR OTHERWISE. AS A CONDITION TO EXERCISING THE RIGHTS
43  * GRANTED HEREUNDER, EACH USER HEREBY ASSUMES SOLE RESPONSIBILITY TO SECURE
44  * ANY OTHER INTELLECTUAL PROPERTY RIGHTS NEEDED, IF ANY. THE SOFTWARE
45  * IS NOT FAULT-TOLERANT AND IS NOT INTENDED FOR USE IN MISSION-CRITICAL
46  * SYSTEMS, SUCH AS THOSE USED IN THE OPERATION OF NUCLEAR FACILITIES,
47  * AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS, AIR TRAFFIC CONTROL
48  * SYSTEMS, DIRECT LIFE SUPPORT MACHINES, OR WEAPONS SYSTEMS, IN WHICH
49  * THE FAILURE OF THE SOFTWARE OR SYSTEM COULD LEAD DIRECTLY TO DEATH,
50  * PERSONAL INJURY, OR SEVERE PHYSICAL OR ENVIRONMENTAL DAMAGE ("HIGH
51  * RISK ACTIVITIES"). THE COPYRIGHT HOLDERS SPECIFICALLY DISCLAIM ANY
52  * EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR HIGH RISK ACTIVITIES.
53  *
54  * __END_OF_JASPER_LICENSE__
55  */
56 
62 #ifndef JAS_COMPILER_H
63 #define JAS_COMPILER_H
64 
65 /* The configuration header file should be included first. */
66 #include <jasper/jas_config.h>
67 
68 #ifdef _MSC_VER
69 # ifndef __cplusplus
70 # undef inline
71 # define inline __inline
72 # endif
73 #endif
74 
75 #if defined(__GNUC__)
76 # define JAS_DEPRECATED __attribute__((deprecated))
77 #else
78 # define JAS_DEPRECATED
79 #endif
80 
81 #if defined(__GNUC__)
82 # define JAS_ATTRIBUTE_CONST __attribute__((const))
83 #else
84 # define JAS_ATTRIBUTE_CONST
85 #endif
86 
87 #if defined(__GNUC__)
88 # define JAS_ATTRIBUTE_PURE __attribute__((pure))
89 #else
90 # define JAS_ATTRIBUTE_PURE
91 #endif
92 
93 #if defined(__GNUC__)
94 # define JAS_FORCE_INLINE inline __attribute__((always_inline))
95 #else
96 # define JAS_FORCE_INLINE inline
97 #endif
98 
99 #if defined(__GNUC__)
100 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)
101 # define JAS_UNREACHABLE() __builtin_unreachable()
102 # else
103 # define JAS_UNREACHABLE()
104 # endif
105 #elif defined(__clang__)
106 # define JAS_UNREACHABLE() __builtin_unreachable()
107 #elif defined(_MSC_VER)
108 # define JAS_UNREACHABLE() __assume(0)
109 #else
110 # define JAS_UNREACHABLE()
111 #endif
112 
113 #if defined(__GNUC__)
114 # define JAS_LIKELY(x) __builtin_expect (!!(x), 1)
115 #else
116 # define JAS_LIKELY(x) (x)
117 #endif
118 
119 #if defined(__GNUC__)
120 # define JAS_UNLIKELY(x) __builtin_expect (!!(x), 0)
121 #else
122 # define JAS_UNLIKELY(x) (x)
123 #endif
124 
125 #if defined(__GNUC__) && __GNUC__ >= 6
126 # define JAS_ATTRIBUTE_DISABLE_UBSAN \
127  __attribute__((no_sanitize_undefined))
128 #elif defined(__clang__)
129 # define JAS_ATTRIBUTE_DISABLE_UBSAN \
130  __attribute__((no_sanitize("undefined")))
131 #else
132 # define JAS_ATTRIBUTE_DISABLE_UBSAN
133 #endif
134 
135 #ifdef __has_builtin
136 #define jas_has_builtin(x) __has_builtin(x)
137 #else
138 #define jas_has_builtin(x) 0
139 #endif
140 
145 #define JAS_UNUSED(x) ((void) x)
146 
147 #endif