1 /*============================================================================== 2 Copyright(c) 2017 Intel Corporation 3 4 Permission is hereby granted, free of charge, to any person obtaining a 5 copy of this software and associated documentation files(the "Software"), 6 to deal in the Software without restriction, including without limitation 7 the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 and / or sell copies of the Software, and to permit persons to whom the 9 Software is furnished to do so, subject to the following conditions: 10 11 The above copyright notice and this permission notice shall be included 12 in all copies or substantial portions of the Software. 13 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 OTHER DEALINGS IN THE SOFTWARE. 21 ============================================================================*/ 22 23 #ifndef UFO_PORTABLE_COMPILER_H 24 #define UFO_PORTABLE_COMPILER_H 25 26 #if __GNUC__ 27 28 #if __GNUC__ < 4 29 #error "Unsupported GCC version. Please use 4.0+" 30 #endif 31 32 #define __noop 33 #define __fastcall 34 #if defined __x86_64__ 35 #define __stdcall // deprecated for x86-64 36 #define __cdecl // deprecated for x86-64 37 #elif defined(__ARM_ARCH) 38 #define __stdcall 39 #define __cdecl 40 #else 41 #define __cdecl __attribute__((__cdecl__)) 42 #define __stdcall __attribute__((__stdcall__)) 43 #endif 44 45 #define __declspec(x) __declspec_##x 46 #define __declspec_align(y) __attribute__((aligned(y))) 47 #define __declspec_deprecated __attribute__((deprecated)) 48 #define __declspec_dllexport 49 #define __declspec_dllimport 50 #define __declspec_noinline __attribute__((__noinline__)) 51 #define __declspec_nothrow __attribute__((nothrow)) 52 #define __declspec_novtable 53 #define __declspec_thread __thread 54 55 #define __forceinline inline __attribute__((__always_inline__)) 56 57 #define __debugbreak() do { asm volatile ("int3;"); } while (0) 58 #define __popcnt __builtin_popcount 59 60 #else 61 62 #pragma message "unknown compiler!" 63 64 #endif 65 66 67 /* compile-time ASSERT */ 68 69 #ifndef C_ASSERT 70 #define __CONCATING( a1, a2 ) a1 ## a2 71 72 #define __UNIQUENAME( a1, a2 ) __CONCATING( a1, a2 ) 73 74 #define UNIQUENAME( __text ) __UNIQUENAME( __text, __COUNTER__ ) 75 76 #define C_ASSERT(e) typedef char UNIQUENAME(STATIC_ASSERT_)[(e)?1:-1] 77 #endif 78 79 80 #endif // UFO_PORTABLE_COMPILER_H 81