rk: ion: resolve build err
[firefly-linux-kernel-4.4.55.git] / drivers / gpu / arm / t6xx / kbase / malisw / arm_cstd / arm_cstd_compilers.h
1 /*
2  *
3  * (C) COPYRIGHT ARM Limited. All rights reserved.
4  *
5  * This program is free software and is provided to you under the terms of the
6  * GNU General Public License version 2 as published by the Free Software
7  * Foundation, and any use by you of this program is subject to the terms
8  * of such GNU licence.
9  *
10  * A copy of the licence is included with the program, and can also be obtained
11  * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
12  * Boston, MA  02110-1301, USA.
13  *
14  */
15
16
17
18
19
20 #ifndef _ARM_CSTD_COMPILERS_H_
21 #define _ARM_CSTD_COMPILERS_H_
22
23 /* ============================================================================
24         Document default definitions - assuming nothing set at this point.
25 ============================================================================ */
26 /**
27  * @addtogroup arm_cstd_coding_standard
28  * @{
29  */
30
31 /**
32  * @hideinitializer
33  * Defined with value of 1 if toolchain is Microsoft Visual Studio, 0
34  * otherwise.
35  */
36 #define CSTD_TOOLCHAIN_MSVC         0
37
38 /**
39  * @hideinitializer
40  * Defined with value of 1 if toolchain is the GNU Compiler Collection, 0
41  * otherwise.
42  */
43 #define CSTD_TOOLCHAIN_GCC          0
44
45 /**
46  * @hideinitializer
47  * Defined with value of 1 if toolchain is ARM RealView Compiler Tools, 0
48  * otherwise. Note - if running RVCT in GCC mode this define will be set to 0;
49  * @c CSTD_TOOLCHAIN_GCC and @c CSTD_TOOLCHAIN_RVCT_GCC_MODE will both be
50  * defined as 1.
51  */
52 #define CSTD_TOOLCHAIN_RVCT         0
53
54 /**
55  * @hideinitializer
56  * Defined with value of 1 if toolchain is ARM RealView Compiler Tools running
57  * in GCC mode, 0 otherwise.
58  */
59 #define CSTD_TOOLCHAIN_RVCT_GCC_MODE 0
60
61 /**
62  * @hideinitializer
63  * Defined with value of 1 if processor is an x86 32-bit machine, 0 otherwise.
64  */
65 #define CSTD_CPU_X86_32             0
66
67 /**
68  * @hideinitializer
69  * Defined with value of 1 if processor is an x86-64 (AMD64) machine, 0
70  * otherwise.
71  */
72 #define CSTD_CPU_X86_64             0
73
74 /**
75  * @hideinitializer
76  * Defined with value of 1 if processor is an ARM machine, 0 otherwise.
77  */
78 #define CSTD_CPU_ARM                0
79
80 /**
81  * @hideinitializer
82  * Defined with value of 1 if processor is an AARCH64 machine, 0 otherwise.
83  */
84 #define CSTD_CPU_AARCH64            0
85
86
87 /**
88  * @hideinitializer
89  * Defined with value of 1 if processor is a MIPS machine, 0 otherwise.
90  */
91 #define CSTD_CPU_MIPS               0
92
93 /**
94  * @hideinitializer
95  * Defined with value of 1 if CPU is 32-bit, 0 otherwise.
96  */
97 #define CSTD_CPU_32BIT              0
98
99 /**
100  * @hideinitializer
101  * Defined with value of 1 if CPU is 64-bit, 0 otherwise.
102  */
103 #define CSTD_CPU_64BIT              0
104
105 /**
106  * @hideinitializer
107  * Defined with value of 1 if processor configured as big-endian, 0 if it
108  * is little-endian.
109  */
110 #define CSTD_CPU_BIG_ENDIAN         0
111
112 /**
113  * @hideinitializer
114  * Defined with value of 1 if operating system is a version of Windows, 0 if
115  * it is not.
116  */
117 #define CSTD_OS_WINDOWS             0
118
119 /**
120  * @hideinitializer
121  * Defined with value of 1 if operating system is a 32-bit version of Windows,
122  * 0 if it is not.
123  */
124 #define CSTD_OS_WIN32               0
125
126 /**
127  * @hideinitializer
128  * Defined with value of 1 if operating system is a 64-bit version of Windows,
129  * 0 if it is not.
130  */
131 #define CSTD_OS_WIN64               0
132
133 /**
134  * @hideinitializer
135  * Defined with value of 1 if operating system is Linux, 0 if it is not.
136  */
137 #define CSTD_OS_LINUX               0
138
139 /**
140  * @hideinitializer
141  * Defined with value of 1 if we are compiling Linux kernel code, 0 otherwise.
142  */
143 #define CSTD_OS_LINUX_KERNEL        0
144
145 /**
146  * @hideinitializer
147  * Defined with value of 1 if operating system is a 32-bit version of Linux,
148  * 0 if it is not.
149  */
150 #define CSTD_OS_LINUX32             0
151
152 /**
153  * @hideinitializer
154  * Defined with value of 1 if operating system is a 64-bit version of Linux,
155  * 0 if it is not.
156  */
157 #define CSTD_OS_LINUX64             0
158
159 /**
160  * @hideinitializer
161  * Defined with value of 1 if operating system is Android, 0 if it is not.
162  */
163 #define CSTD_OS_ANDROID             0
164
165 /**
166  * @hideinitializer
167  * Defined with value of 1 if we are compiling Android kernel code, 0 otherwise.
168  */
169 #define CSTD_OS_ANDROID_KERNEL      0
170
171 /**
172  * @hideinitializer
173  * Defined with value of 1 if operating system is a 32-bit version of Android,
174  * 0 if it is not.
175  */
176 #define CSTD_OS_ANDROID32           0
177
178 /**
179  * @hideinitializer
180  * Defined with value of 1 if operating system is a 64-bit version of Android,
181  * 0 if it is not.
182  */
183 #define CSTD_OS_ANDROID64           0
184
185 /**
186  * @hideinitializer
187  * Defined with value of 1 if operating system is a version of Apple OS,
188  * 0 if it is not.
189  */
190 #define CSTD_OS_APPLEOS             0
191
192 /**
193  * @hideinitializer
194  * Defined with value of 1 if operating system is a 32-bit version of Apple OS,
195  * 0 if it is not.
196  */
197 #define CSTD_OS_APPLEOS32           0
198
199 /**
200  * @hideinitializer
201  * Defined with value of 1 if operating system is a 64-bit version of Apple OS,
202  * 0 if it is not.
203  */
204 #define CSTD_OS_APPLEOS64           0
205
206 /**
207  * @def CSTD_OS_SYMBIAN
208  * @hideinitializer
209  * Defined with value of 1 if operating system is Symbian, 0 if it is not.
210  */
211 #define CSTD_OS_SYMBIAN             0
212
213 /**
214  * @def CSTD_OS_NONE
215  * @hideinitializer
216  * Defined with value of 1 if there is no operating system (bare metal), 0
217  * otherwise
218  */
219 #define CSTD_OS_NONE                0
220
221 /* ============================================================================
222         Determine the compiler in use
223 ============================================================================ */
224
225 /* Default empty definitions of compiler-specific option enable/disable.  This will be overridden 
226  * if applicable by preprocessor defines below. */
227 #define CSTD_PUSH_WARNING_GCC_WADDRESS
228 #define CSTD_POP_WARNING_GCC_WADDRESS
229
230 #if defined(_MSC_VER)
231         #undef CSTD_TOOLCHAIN_MSVC
232         #define CSTD_TOOLCHAIN_MSVC         1
233
234 #elif defined(__GNUC__)
235         #undef CSTD_TOOLCHAIN_GCC
236         #define CSTD_TOOLCHAIN_GCC          1
237
238         /* Detect RVCT pretending to be GCC. */
239         #if defined(__ARMCC_VERSION)
240                 #undef CSTD_TOOLCHAIN_RVCT_GCC_MODE
241                 #define CSTD_TOOLCHAIN_RVCT_GCC_MODE    1
242         #endif
243
244         #if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 && MALI_GCC_WORKAROUND_MIDCOM_4598 == 0)
245                 /* As a workaround to MIDCOM-4598 (GCC internal defect), these pragmas are not compiled if the GCC version 
246                  * is within a certain range, or if a #define is enabled by the build system.  For more, see a comment 
247                  * in the build system also referring to the MIDCOM issue mentioned, where the environment is updated 
248                  * for the GNU toolchain.  */
249                 #undef CSTD_PUSH_WARNING_GCC_WADDRESS
250                 #define CSTD_PUSH_WARNING_GCC_WADDRESS \
251                         do\
252                         {\
253                                 _Pragma("GCC diagnostic push")\
254                                 _Pragma("GCC diagnostic ignored \"-Waddress\"")\
255                         }while(MALI_FALSE)
256
257                 #undef CSTD_POP_WARNING_GCC_WADDRESS
258                 #define CSTD_POP_WARNING_GCC_WADDRESS \
259                         do\
260                         {\
261                                 _Pragma("GCC diagnostic pop")\
262                         }while(MALI_FALSE)
263         #endif
264
265 #elif defined(__ARMCC_VERSION)
266         #undef CSTD_TOOLCHAIN_RVCT
267         #define CSTD_TOOLCHAIN_RVCT         1
268
269 #else
270         #warning "Unsupported or unknown toolchain"
271
272 #endif
273
274 /* ============================================================================
275         Determine the processor
276 ============================================================================ */
277 #if 1 == CSTD_TOOLCHAIN_MSVC
278         #if defined(_M_IX86)
279                 #undef CSTD_CPU_X86_32
280                 #define CSTD_CPU_X86_32         1
281
282         #elif defined(_M_X64) || defined(_M_AMD64)
283                 #undef CSTD_CPU_X86_64
284                 #define CSTD_CPU_X86_64         1
285
286         #elif defined(_M_ARM)
287                 #undef CSTD_CPU_ARM
288                 #define CSTD_CPU_ARM            1
289
290         #elif defined(_M_MIPS)
291                 #undef CSTD_CPU_MIPS
292                 #define CSTD_CPU_MIPS           1
293
294         #else
295                 #warning "Unsupported or unknown host CPU for MSVC tools"
296
297         #endif
298
299 #elif 1 == CSTD_TOOLCHAIN_GCC
300         #if defined(__amd64__)
301                 #undef CSTD_CPU_X86_64
302                 #define CSTD_CPU_X86_64         1
303
304         #elif defined(__i386__)
305                 #undef CSTD_CPU_X86_32
306                 #define CSTD_CPU_X86_32         1
307
308         #elif defined(__arm__)
309                 #undef CSTD_CPU_ARM
310                 #define CSTD_CPU_ARM            1
311
312         #elif defined(__aarch64__)
313                 #undef CSTD_CPU_AARCH64
314                 #define CSTD_CPU_AARCH64        1
315
316         #elif defined(__mips__)
317                 #undef CSTD_CPU_MIPS
318                 #define CSTD_CPU_MIPS           1
319
320         #else
321                 #warning "Unsupported or unknown host CPU for GCC tools"
322
323         #endif
324
325 #elif 1 == CSTD_TOOLCHAIN_RVCT
326         #undef CSTD_CPU_ARM
327         #define CSTD_CPU_ARM                1
328
329 #else
330         #warning "Unsupported or unknown toolchain"
331
332 #endif
333
334 /* ============================================================================
335         Determine the Processor Endianness
336 ============================================================================ */
337
338 #if ((1 == CSTD_CPU_X86_32) || (1 == CSTD_CPU_X86_64))
339         /* Note: x86 and x86-64 are always little endian, so leave at default. */
340
341 #elif 1 == CSTD_CPU_AARCH64
342         /* No big endian support? */
343
344 #elif 1 == CSTD_TOOLCHAIN_RVCT
345         #if defined(__BIG_ENDIAN)
346                 #undef CSTD_ENDIAN_BIG
347                 #define CSTD_ENDIAN_BIG         1
348         #endif
349
350 #elif ((1 == CSTD_TOOLCHAIN_GCC) && (1 == CSTD_CPU_ARM))
351         #if defined(__ARMEB__)
352                 #undef CSTD_ENDIAN_BIG
353                 #define CSTD_ENDIAN_BIG         1
354         #endif
355
356 #elif ((1 == CSTD_TOOLCHAIN_GCC) && (1 == CSTD_CPU_MIPS))
357         #if defined(__MIPSEB__)
358                 #undef CSTD_ENDIAN_BIG
359                 #define CSTD_ENDIAN_BIG         1
360         #endif
361
362 #elif 1 == CSTD_TOOLCHAIN_MSVC
363         /* Note: Microsoft only support little endian, so leave at default. */
364
365 #else
366         #warning "Unsupported or unknown CPU"
367
368 #endif
369
370 /* ============================================================================
371         Determine the operating system and addressing width
372 ============================================================================ */
373 #if 1 == CSTD_TOOLCHAIN_MSVC
374         #if defined(_WIN32) && !defined(_WIN64)
375                 #undef CSTD_OS_WINDOWS
376                 #define CSTD_OS_WINDOWS         1
377                 #undef CSTD_OS_WIN32
378                 #define CSTD_OS_WIN32           1
379                 #undef CSTD_CPU_32BIT
380                 #define CSTD_CPU_32BIT          1
381
382         #elif defined(_WIN32) && defined(_WIN64)
383                 #undef CSTD_OS_WINDOWS
384                 #define CSTD_OS_WINDOWS         1
385                 #undef CSTD_OS_WIN64
386                 #define CSTD_OS_WIN64           1
387                 #undef CSTD_CPU_64BIT
388                 #define CSTD_CPU_64BIT          1
389
390         #else
391                 #warning "Unsupported or unknown host OS for MSVC tools"
392
393         #endif
394
395 #elif 1 == CSTD_TOOLCHAIN_GCC
396         #if defined(_WIN32) && defined(_WIN64)
397                 #undef CSTD_OS_WINDOWS
398                 #define CSTD_OS_WINDOWS         1
399                 #undef CSTD_OS_WIN64
400                 #define CSTD_OS_WIN64           1
401                 #undef CSTD_CPU_64BIT
402                 #define CSTD_CPU_64BIT          1
403
404         #elif defined(_WIN32) && !defined(_WIN64)
405                 #undef CSTD_OS_WINDOWS
406                 #define CSTD_OS_WINDOWS         1
407                 #undef CSTD_OS_WIN32
408                 #define CSTD_OS_WIN32           1
409                 #undef CSTD_CPU_32BIT
410                 #define CSTD_CPU_32BIT          1
411
412         #elif defined(ANDROID)
413                 #undef CSTD_OS_ANDROID
414                 #define CSTD_OS_ANDROID         1
415
416                 #if defined(__KERNEL__)
417                         #undef CSTD_OS_ANDROID_KERNEL
418                         #define CSTD_OS_ANDROID_KERNEL  1
419                 #endif
420
421                 #if defined(__LP64__) || defined(_LP64)
422                         #undef CSTD_OS_ANDROID64
423                         #define CSTD_OS_ANDROID64       1
424                         #undef CSTD_CPU_64BIT
425                         #define CSTD_CPU_64BIT          1
426                 #else
427                         #undef CSTD_OS_ANDROID32
428                         #define CSTD_OS_ANDROID32       1
429                         #undef CSTD_CPU_32BIT
430                         #define CSTD_CPU_32BIT          1
431                 #endif
432
433         #elif defined(__KERNEL__) || defined(__linux)
434                 #undef CSTD_OS_LINUX
435                 #define CSTD_OS_LINUX           1
436                 
437                 #if defined(__KERNEL__)
438                         #undef CSTD_OS_LINUX_KERNEL
439                         #define CSTD_OS_LINUX_KERNEL    1
440                 #endif
441
442                 #if defined(__LP64__) || defined(_LP64)
443                         #undef CSTD_OS_LINUX64
444                         #define CSTD_OS_LINUX64         1
445                         #undef CSTD_CPU_64BIT
446                         #define CSTD_CPU_64BIT          1
447                 #else
448                         #undef CSTD_OS_LINUX32
449                         #define CSTD_OS_LINUX32         1
450                         #undef CSTD_CPU_32BIT
451                         #define CSTD_CPU_32BIT          1
452                 #endif
453
454         #elif defined(__APPLE__)
455                 #undef CSTD_OS_APPLEOS
456                 #define CSTD_OS_APPLEOS         1
457
458                 #if defined(__LP64__) || defined(_LP64)
459                         #undef CSTD_OS_APPLEOS64
460                         #define CSTD_OS_APPLEOS64       1
461                         #undef CSTD_CPU_64BIT
462                         #define CSTD_CPU_64BIT          1
463                 #else
464                         #undef CSTD_OS_APPLEOS32
465                         #define CSTD_OS_APPLEOS32       1
466                         #undef CSTD_CPU_32BIT
467                         #define CSTD_CPU_32BIT          1
468                 #endif
469
470         #elif defined(__SYMBIAN32__)
471                 #undef CSTD_OS_SYMBIAN
472                 #define CSTD_OS_SYMBIAN         1
473                 #undef CSTD_CPU_32BIT
474                 #define CSTD_CPU_32BIT          1
475
476         #else
477                 #undef CSTD_OS_NONE
478                 #define CSTD_OS_NONE            1
479                 #undef CSTD_CPU_32BIT
480                 #define CSTD_CPU_32BIT          1
481
482 #endif
483
484 #elif 1 == CSTD_TOOLCHAIN_RVCT
485
486         #if defined(ANDROID)
487                 #undef CSTD_OS_ANDROID
488                 #undef CSTD_OS_ANDROID32
489                 #define CSTD_OS_ANDROID         1
490                 #define CSTD_OS_ANDROID32       1
491
492         #elif defined(__linux)
493                 #undef CSTD_OS_LINUX
494                 #undef CSTD_OS_LINUX32
495                 #define CSTD_OS_LINUX           1
496                 #define CSTD_OS_LINUX32         1
497
498         #elif defined(__SYMBIAN32__)
499                 #undef CSTD_OS_SYMBIAN
500                 #define CSTD_OS_SYMBIAN         1
501
502         #else
503                 #undef CSTD_OS_NONE
504                 #define CSTD_OS_NONE            1
505
506 #endif
507
508 #else
509         #warning "Unsupported or unknown host OS"
510
511 #endif
512
513 /* ============================================================================
514         Determine the correct linker symbol Import and Export Macros
515 ============================================================================ */
516 /**
517  * @defgroup arm_cstd_linkage_specifiers Linkage Specifiers
518  * @{
519  *
520  * This set of macros contain system-dependent linkage specifiers which
521  * determine the visibility of symbols across DLL boundaries. A header for a
522  * particular DLL should define a set of local macros derived from these,
523  * and should not use these macros to decorate functions directly as there may
524  * be multiple DLLs being used.
525  *
526  * These DLL library local macros should be (with appropriate library prefix)
527  * <tt>[MY_LIBRARY]_API</tt>, <tt>[MY_LIBRARY]_IMPL</tt>, and
528  * <tt>[MY_LIBRARY]_LOCAL</tt>.
529  *
530  *    - <tt>[MY_LIBRARY]_API</tt> should be use to decorate the function
531  *      declarations in the header. It should be defined as either
532  *      @c CSTD_LINK_IMPORT or @c CSTD_LINK_EXPORT, depending whether the
533  *      current situation is a compile of the DLL itself (use export) or a
534  *      compile of an external user of the DLL (use import).
535  *    - <tt>[MY_LIBRARY]_IMPL</tt> should be defined as @c CSTD_LINK_IMPL
536  *      and should be used to decorate the definition of functions in the C
537  *      file.
538  *    - <tt>[MY_LIBRARY]_LOCAL</tt> should be used to decorate function
539  *      declarations which are exported across translation units within the
540  *      DLL, but which are not exported outside of the DLL boundary.
541  *
542  * Functions which are @c static in either a C file or in a header file do not
543  * need any form of linkage decoration, and should therefore have no linkage
544  * macro applied to them.
545  */
546
547 /**
548  * @def CSTD_LINK_IMPORT
549  * Specifies a function as being imported to a translation unit across a DLL
550  * boundary.
551  */
552
553 /**
554  * @def CSTD_LINK_EXPORT
555  * Specifies a function as being exported across a DLL boundary by a
556  * translation unit.
557  */
558
559 /**
560  * @def CSTD_LINK_IMPL
561  * Specifies a function which will be exported across a DLL boundary as
562  * being implemented by a translation unit.
563  */
564
565 /**
566  * @def CSTD_LINK_LOCAL
567  * Specifies a function which is internal to a DLL, and which should not be
568  * exported outside of it.
569  */
570
571 /**
572  * @}
573  */
574
575 #if 1 ==  CSTD_OS_LINUX
576         #define CSTD_LINK_IMPORT __attribute__((visibility("default")))
577         #define CSTD_LINK_EXPORT __attribute__((visibility("default")))
578         #define CSTD_LINK_IMPL   __attribute__((visibility("default")))
579         #define CSTD_LINK_LOCAL  __attribute__((visibility("hidden")))
580
581 #elif 1 ==  CSTD_OS_WINDOWS
582         #define CSTD_LINK_IMPORT __declspec(dllimport)
583         #define CSTD_LINK_EXPORT __declspec(dllexport)
584         #define CSTD_LINK_IMPL   __declspec(dllexport)
585         #define CSTD_LINK_LOCAL
586
587 #elif 1 ==  CSTD_OS_SYMBIAN
588         #define CSTD_LINK_IMPORT IMPORT_C
589         #define CSTD_LINK_EXPORT IMPORT_C
590         #define CSTD_LINK_IMPL   EXPORT_C
591         #define CSTD_LINK_LOCAL
592
593 #elif 1 ==  CSTD_OS_APPLEOS
594         #define CSTD_LINK_IMPORT __attribute__((visibility("default")))
595         #define CSTD_LINK_EXPORT __attribute__((visibility("default")))
596         #define CSTD_LINK_IMPL   __attribute__((visibility("default")))
597         #define CSTD_LINK_LOCAL  __attribute__((visibility("hidden")))
598
599 #elif 1 ==  CSTD_OS_ANDROID
600         #define CSTD_LINK_IMPORT __attribute__((visibility("default")))
601         #define CSTD_LINK_EXPORT __attribute__((visibility("default")))
602         #define CSTD_LINK_IMPL   __attribute__((visibility("default")))
603         #define CSTD_LINK_LOCAL  __attribute__((visibility("hidden")))
604
605 #else /* CSTD_OS_NONE */
606         #define CSTD_LINK_IMPORT
607         #define CSTD_LINK_EXPORT
608         #define CSTD_LINK_IMPL
609         #define CSTD_LINK_LOCAL
610
611 #endif
612
613 /**
614  * @}
615  */
616
617 #endif /* End (_ARM_CSTD_COMPILERS_H_) */