RK3368 GPU version Rogue M 1.28
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / rogue_m / 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         #define IMG_CALLCONV __stdcall
105         #define IMG_INTERNAL
106         #define IMG_EXPORT      __declspec(dllexport)
107         #define IMG_RESTRICT __restrict
108         #define C_CALLCONV      __cdecl
109
110         /* IMG_IMPORT is defined as IMG_EXPORT so that headers and implementations match.
111          * Some compilers require the header to be declared IMPORT, while the implementation is declared EXPORT 
112          */
113         #define IMG_IMPORT      IMG_EXPORT
114
115 #if defined(UNDER_WDDM)
116         #ifndef _INC_STDLIB
117                         #if defined (UNDER_MSBUILD)
118                         _CRTIMP __declspec(noreturn) void __cdecl abort(void);
119                 #else
120                         _CRTIMP void __cdecl abort(void);
121                 #endif
122         #endif
123         #if defined(EXIT_ON_ABORT)
124                 #define IMG_ABORT()     exit(1);
125         #else
126                 #define IMG_ABORT()     abort();
127         #endif
128 //      #define IMG_ABORT()     img_abort()
129 #endif /* UNDER_WDDM */
130 #else
131         #if defined(LINUX) || defined(__METAG) || defined(__QNXNTO__)
132
133                 #define IMG_CALLCONV
134                 #define C_CALLCONV
135                 #if defined(__linux__) || defined(__QNXNTO__)
136                         #define IMG_INTERNAL    __attribute__((visibility("hidden")))
137                 #else
138                         #define IMG_INTERNAL
139                 #endif
140                 #define IMG_EXPORT              __attribute__((visibility("default")))
141                 #define IMG_IMPORT
142                 #define IMG_RESTRICT    __restrict__
143
144         #else
145                 #error("define an OS")
146         #endif
147 #endif
148
149 // Use default definition if not overridden
150 #ifndef IMG_ABORT
151         #if defined(EXIT_ON_ABORT)
152                 #define IMG_ABORT()     exit(1)
153         #else
154                 #define IMG_ABORT()     abort()
155         #endif
156 #endif
157
158 #if defined(__GNUC__)
159 #define IMG_FORMAT_PRINTF(x,y)          __attribute__((format(printf,x,y)))
160 #else
161 #define IMG_FORMAT_PRINTF(x,y)
162 #endif
163
164 #if defined(__GNUC__)
165 #define IMG_WARN_UNUSED_RESULT          __attribute__((warn_unused_result))
166 #else
167 #define IMG_WARN_UNUSED_RESULT
168 #endif
169
170 #if defined(_MSC_VER) || defined(CC_ARM)
171         #define IMG_NORETURN __declspec(noreturn)
172 #else
173         #if defined(__GNUC__)
174                 #define IMG_NORETURN __attribute__((noreturn))
175         #else
176                 #define IMG_NORETURN
177         #endif
178 #endif
179
180 #define MAX(a,b)                                        (((a) > (b)) ? (a) : (b))
181 #define MIN(a,b)                                        (((a) < (b)) ? (a) : (b))
182
183 /* Get a structures address from the address of a member */
184 #define IMG_CONTAINER_OF(ptr, type, member) \
185         (type *) ((IMG_UINT8 *) (ptr) - offsetof(type, member))
186
187 /* The number of elements in a fixed-sized array, IMGs ARRAY_SIZE macro */
188 #define IMG_ARR_NUM_ELEMS(ARR) \
189         (sizeof(ARR) / sizeof((ARR)[0]))
190
191 /* To guarantee that __func__ can be used, define it as a macro here if it
192    isn't already provided by the compiler. */
193 #if defined(_MSC_VER)
194 #define __func__ __FUNCTION__
195 #endif
196
197 #if defined(__cplusplus)
198 /* C++ Specific:
199  * Disallow use of copy and assignment operator within a class.
200  * Should be placed under private. */
201 #define IMG_DISALLOW_COPY_AND_ASSIGN(C) \
202         C(const C&); \
203         void operator=(const C&)
204 #endif
205
206 #if defined(SUPPORT_PVR_VALGRIND)
207         #if !defined(__METAG)
208                 #include "/usr/include/valgrind/memcheck.h"
209
210                 #define VALGRIND_HEADER_PRESENT
211
212                 #define VG_MARK_INITIALIZED(pvData,ui32Size)  VALGRIND_MAKE_MEM_DEFINED(pvData,ui32Size)
213         #else
214                 #define VG_MARK_INITIALIZED(pvData,ui32Size) do { } while(0)
215         #endif
216 #else
217
218         #define VG_MARK_INITIALIZED(pvData,ui32Size) do { } while(0)
219 #endif
220
221
222 #endif /* #if !defined (__IMG_DEFS_H__) */
223 /*****************************************************************************
224  End of file (IMG_DEFS.H)
225 *****************************************************************************/
226