1 /* 2 * Copyright 2011 The LibYuv Project Authors. All rights reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ 12 #define INCLUDE_LIBYUV_BASIC_TYPES_H_ 13 14 #include <stddef.h> // for NULL, size_t 15 16 #if defined(_MSC_VER) && (_MSC_VER < 1600) 17 #include <sys/types.h> // for uintptr_t on x86 18 #else 19 #include <stdint.h> // for uintptr_t 20 #endif 21 22 typedef uint64_t uint64; 23 typedef int64_t int64; 24 #if defined(_MSC_VER) 25 // nsprpub/pr/include/obsolete/protypes.h defines these weirdly 26 typedef long int32; 27 typedef unsigned long uint32; 28 #else 29 typedef uint32_t uint32; 30 typedef int32_t int32; 31 #endif 32 typedef uint16_t uint16; 33 typedef int16_t int16; 34 typedef uint8_t uint8; 35 typedef int8_t int8; 36 #define INT_TYPES_DEFINED 1 37 38 #ifndef GG_LONGLONG 39 #ifndef INT_TYPES_DEFINED 40 #define INT_TYPES_DEFINED 41 #ifdef COMPILER_MSVC 42 typedef unsigned __int64 uint64; 43 typedef __int64 int64; 44 #ifndef INT64_C 45 #define INT64_C(x) x##I64 46 #endif 47 #ifndef UINT64_C 48 #define UINT64_C(x) x##UI64 49 #endif 50 #define INT64_F "I64" 51 #else // COMPILER_MSVC 52 #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 53 typedef unsigned long uint64; // NOLINT 54 typedef long int64; // NOLINT 55 #ifndef INT64_C 56 #define INT64_C(x) x##L 57 #endif 58 #ifndef UINT64_C 59 #define UINT64_C(x) x##UL 60 #endif 61 #define INT64_F "l" 62 #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) 63 typedef unsigned long long uint64; // NOLINT 64 typedef long long int64; // NOLINT 65 #ifndef INT64_C 66 #define INT64_C(x) x##LL 67 #endif 68 #ifndef UINT64_C 69 #define UINT64_C(x) x##ULL 70 #endif 71 #define INT64_F "ll" 72 #endif // __LP64__ 73 #endif // COMPILER_MSVC 74 typedef unsigned int uint32; 75 typedef int int32; 76 typedef unsigned short uint16; // NOLINT 77 typedef short int16; // NOLINT 78 typedef unsigned char uint8; 79 typedef signed char int8; 80 #endif // INT_TYPES_DEFINED 81 #endif // GG_LONGLONG 82 83 // Detect compiler is for x86 or x64. 84 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ 85 defined(_M_IX86) 86 #define CPU_X86 1 87 #endif 88 // Detect compiler is for ARM. 89 #if defined(__arm__) || defined(_M_ARM) 90 #define CPU_ARM 1 91 #endif 92 93 #ifndef ALIGNP 94 #ifdef __cplusplus 95 #define ALIGNP(p, t) \ 96 reinterpret_cast<uint8*>( \ 97 ((reinterpret_cast<uintptr_t>(p) + ((t)-1)) & ~((t)-1))) 98 #else 99 #define ALIGNP(p, t) \ 100 (uint8*)((((uintptr_t)(p) + ((t)-1)) & ~((t)-1))) /* NOLINT */ 101 #endif 102 #endif 103 104 #if !defined(LIBYUV_API) 105 #if defined(_WIN32) || defined(__CYGWIN__) 106 #if defined(LIBYUV_BUILDING_SHARED_LIBRARY) 107 #define LIBYUV_API __declspec(dllexport) 108 #elif defined(LIBYUV_USING_SHARED_LIBRARY) 109 #define LIBYUV_API __declspec(dllimport) 110 #else 111 #define LIBYUV_API 112 #endif // LIBYUV_BUILDING_SHARED_LIBRARY 113 #elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \ 114 (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \ 115 defined(LIBYUV_USING_SHARED_LIBRARY)) 116 #define LIBYUV_API __attribute__((visibility("default"))) 117 #else 118 #define LIBYUV_API 119 #endif // __GNUC__ 120 #endif // LIBYUV_API 121 122 #define LIBYUV_BOOL int 123 #define LIBYUV_FALSE 0 124 #define LIBYUV_TRUE 1 125 126 // Visual C x86 or GCC little endian. 127 #if defined(__x86_64__) || defined(_M_X64) || defined(__i386__) || \ 128 defined(_M_IX86) || defined(__arm__) || defined(_M_ARM) || \ 129 (defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__) 130 #define LIBYUV_LITTLE_ENDIAN 131 #endif 132 133 #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ 134