RK3368 GPU version: Rogue L 0.22
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue / include / img_defs.h
1 /*************************************************************************/ /*!
2 @File
3 @Title          Common header containing type definitions for portability
4 @Copyright      Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description    Contains variable and structure definitions. Any platform
6                 specific types should be defined in this file.
7 @License        Dual MIT/GPLv2
8
9 The contents of this file are subject to the MIT license as set out below.
10
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
17
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
20
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
24
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
32
33 This License is also included in this distribution in the file called
34 "MIT-COPYING".
35
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
44
45 #if !defined (__IMG_DEFS_H__)
46 #define __IMG_DEFS_H__
47
48 #include <stddef.h>
49
50 #include "img_types.h"
51
52 #if defined (NO_INLINE_FUNCS)
53         #define INLINE
54         #define FORCE_INLINE
55 #else
56 #if defined (__cplusplus)
57         #define INLINE                                  inline
58         #define FORCE_INLINE                    inline
59 #else
60 #if     !defined(INLINE)
61         #define INLINE                                  __inline
62 #endif
63 #if defined(UNDER_WDDM) && defined(_X86_)
64         #define FORCE_INLINE                    __forceinline
65 #else
66         #define FORCE_INLINE                    static __inline
67 #endif
68 #endif
69 #endif
70
71
72 /* Use this in any file, or use attributes under GCC - see below */
73 #ifndef PVR_UNREFERENCED_PARAMETER
74 #define PVR_UNREFERENCED_PARAMETER(param) ((void)(param))
75 #endif
76
77 /*! Macro used to check structure size and alignment at compile time. */
78 #define BLD_ASSERT(expr, file) _impl_ASSERT_LINE(expr,__LINE__,file)
79 #define _impl_JOIN(a,b) a##b
80 #define _impl_ASSERT_LINE(expr, line, file) \
81         typedef char _impl_JOIN(build_assertion_failed_##file##_,line)[2*!!(expr)-1];
82
83 /*! Macro to calculate the n-byte aligned value from that supplied rounding up.
84  * n must be a power of two.
85  *
86  * Both arguments should be of a type with the same size otherwise the macro may
87  * cut off digits, e.g. imagine a 64 bit address in _x and a 32 bit value in _n.
88  */
89 #define PVR_ALIGN(_x, _n)   (((_x)+((_n)-1)) & ~((_n)-1))
90
91
92 /* The best way to supress unused parameter warnings using GCC is to use a
93  * variable attribute.  Place the unref__ between the type and name of an
94  * unused parameter in a function parameter list, eg `int unref__ var'. This
95  * should only be used in GCC build environments, for example, in files that
96  * compile only on Linux. Other files should use UNREFERENCED_PARAMETER */
97 #ifdef __GNUC__
98 #define unref__ __attribute__ ((unused))
99 #else
100 #define unref__
101 #endif
102
103 #if defined(_WIN32)
104 #if defined(UNDER_CE)
105         #include "windowsce_img_defs.h"
106 #else
107         #define IMG_CALLCONV __stdcall
108         #define IMG_INTERNAL
109         #define IMG_EXPORT      __declspec(dllexport)
110         #define IMG_RESTRICT __restrict
111         #define C_CALLCONV      __cdecl
112
113         /* IMG_IMPORT is defined as IMG_EXPORT so that headers and implementations match.
114          * Some compilers require the header to be declared IMPORT, while the implementation is declared EXPORT 
115          */
116         #define IMG_IMPORT      IMG_EXPORT
117
118 #if defined(UNDER_WDDM)
119         #ifndef _INC_STDLIB
120                         #if defined (UNDER_MSBUILD)
121                         _CRTIMP __declspec(noreturn) void __cdecl abort(void);
122                 #else
123                         _CRTIMP void __cdecl abort(void);
124                 #endif
125         #endif
126         #if defined(EXIT_ON_ABORT)
127                 #define IMG_ABORT()     exit(1);
128         #else
129                 #define IMG_ABORT()     abort();
130         #endif
131 //      #define IMG_ABORT()     img_abort()
132 #endif /* UNDER_WDDM */
133 #endif /* UNDER_CE */
134 #else
135         #if defined(LINUX) || defined(__METAG) || defined(__QNXNTO__)
136
137                 #define IMG_CALLCONV
138                 #define C_CALLCONV
139                 #if defined(__linux__) || defined(__QNXNTO__)
140                         #define IMG_INTERNAL    __attribute__((visibility("hidden")))
141                 #else
142                         #define IMG_INTERNAL
143                 #endif
144                 #define IMG_EXPORT              __attribute__((visibility("default")))
145                 #define IMG_IMPORT
146                 #define IMG_RESTRICT    __restrict__
147
148         #else
149                 #error("define an OS")
150         #endif
151 #endif
152
153 // Use default definition if not overridden
154 #ifndef IMG_ABORT
155         #if defined(EXIT_ON_ABORT)
156                 #define IMG_ABORT()     exit(1)
157         #else
158 #if defined UNDER_CE
159                 /* WinCE / WinEC does not have an abort() function */
160                 #define IMG_ABORT()     exit(1)
161 #else
162                 #define IMG_ABORT()     abort()
163 #endif
164         #endif
165 #endif
166
167 #if defined(__GNUC__)
168 #define IMG_FORMAT_PRINTF(x,y)          __attribute__((format(printf,x,y)))
169 #else
170 #define IMG_FORMAT_PRINTF(x,y)
171 #endif
172
173 #if defined(__GNUC__)
174 #define IMG_WARN_UNUSED_RESULT          __attribute__((warn_unused_result))
175 #else
176 #define IMG_WARN_UNUSED_RESULT
177 #endif
178
179 #if defined(_MSC_VER) || defined(CC_ARM)
180         #define IMG_NORETURN __declspec(noreturn)
181 #else
182         #if defined(__GNUC__)
183                 #define IMG_NORETURN __attribute__((noreturn))
184         #else
185                 #define IMG_NORETURN
186         #endif
187 #endif
188
189 #define MAX(a,b)                                        (((a) > (b)) ? (a) : (b))
190 #define MIN(a,b)                                        (((a) < (b)) ? (a) : (b))
191
192 /* Get a structures address from the address of a member */
193 #define IMG_CONTAINER_OF(ptr, type, member) \
194         (type *) ((IMG_UINT8 *) (ptr) - offsetof(type, member))
195
196 /* The number of elements in a fixed-sized array */
197 #define IMG_ARR_NUM_ELEMS(ARR) \
198         (sizeof(ARR) / sizeof((ARR)[0]))
199
200 /* To guarantee that __func__ can be used, define it as a macro here if it
201    isn't already provided by the compiler. */
202 #if defined(_MSC_VER)
203 #define __func__ __FUNCTION__
204 #endif
205
206 #if defined(__cplusplus)
207 /* C++ Specific:
208  * Disallow use of copy and assignment operator within a class.
209  * Should be placed under private. */
210 #define IMG_DISALLOW_COPY_AND_ASSIGN(C) \
211         C(const C&); \
212         void operator=(const C&)
213 #endif
214
215 #if defined(SUPPORT_PVR_VALGRIND)
216         #if !defined(__METAG)
217                 #include "/usr/include/valgrind/memcheck.h"
218
219                 #define VALGRIND_HEADER_PRESENT
220
221                 #define VG_MARK_INITIALIZED(pvData,ui32Size)  VALGRIND_MAKE_MEM_DEFINED(pvData,ui32Size)
222         #else
223                 #define VG_MARK_INITIALIZED(pvData,ui32Size) do { } while(0)
224         #endif
225 #else
226
227         #define VG_MARK_INITIALIZED(pvData,ui32Size) do { } while(0)
228 #endif
229
230
231 #endif /* #if !defined (__IMG_DEFS_H__) */
232 /*****************************************************************************
233  End of file (IMG_DEFS.H)
234 *****************************************************************************/
235