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