Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 1 | /* |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 2 | * Copyright 2011 The LibYuv Project Authors. All rights reserved. |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 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 |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 7 | * in the file PATENTS. All contributing project authors may |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 11 | #ifndef INCLUDE_LIBYUV_BASIC_TYPES_H_ // NOLINT |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 12 | #define INCLUDE_LIBYUV_BASIC_TYPES_H_ |
| 13 | |
| 14 | #include <stddef.h> // for NULL, size_t |
| 15 | |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 16 | #if defined(__ANDROID__) || (defined(_MSC_VER) && (_MSC_VER < 1600)) |
| 17 | #include <sys/types.h> // for uintptr_t on x86 |
| 18 | #else |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 19 | #include <stdint.h> // for uintptr_t |
| 20 | #endif |
| 21 | |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 22 | #ifndef GG_LONGLONG |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 23 | #ifndef INT_TYPES_DEFINED |
| 24 | #define INT_TYPES_DEFINED |
| 25 | #ifdef COMPILER_MSVC |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 26 | typedef unsigned __int64 uint64; |
| 27 | typedef __int64 int64; |
| 28 | #ifndef INT64_C |
| 29 | #define INT64_C(x) x ## I64 |
| 30 | #endif |
| 31 | #ifndef UINT64_C |
| 32 | #define UINT64_C(x) x ## UI64 |
| 33 | #endif |
| 34 | #define INT64_F "I64" |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 35 | #else // COMPILER_MSVC |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 36 | #if defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 37 | typedef unsigned long uint64; // NOLINT |
| 38 | typedef long int64; // NOLINT |
| 39 | #ifndef INT64_C |
| 40 | #define INT64_C(x) x ## L |
| 41 | #endif |
| 42 | #ifndef UINT64_C |
| 43 | #define UINT64_C(x) x ## UL |
| 44 | #endif |
| 45 | #define INT64_F "l" |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 46 | #else // defined(__LP64__) && !defined(__OpenBSD__) && !defined(__APPLE__) |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 47 | typedef unsigned long long uint64; // NOLINT |
| 48 | typedef long long int64; // NOLINT |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 49 | #ifndef INT64_C |
| 50 | #define INT64_C(x) x ## LL |
| 51 | #endif |
| 52 | #ifndef UINT64_C |
| 53 | #define UINT64_C(x) x ## ULL |
| 54 | #endif |
| 55 | #define INT64_F "ll" |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 56 | #endif // __LP64__ |
| 57 | #endif // COMPILER_MSVC |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 58 | typedef unsigned int uint32; |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 59 | typedef int int32; |
| 60 | typedef unsigned short uint16; // NOLINT |
| 61 | typedef short int16; // NOLINT |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 62 | typedef unsigned char uint8; |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 63 | typedef signed char int8; |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 64 | #endif // INT_TYPES_DEFINED |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 65 | #endif // GG_LONGLONG |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 66 | |
| 67 | // Detect compiler is for x86 or x64. |
| 68 | #if defined(__x86_64__) || defined(_M_X64) || \ |
| 69 | defined(__i386__) || defined(_M_IX86) |
| 70 | #define CPU_X86 1 |
| 71 | #endif |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 72 | // Detect compiler is for ARM. |
| 73 | #if defined(__arm__) || defined(_M_ARM) |
| 74 | #define CPU_ARM 1 |
| 75 | #endif |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 76 | |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 77 | #ifndef ALIGNP |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 78 | #ifdef __cplusplus |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 79 | #define ALIGNP(p, t) \ |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 80 | (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \ |
| 81 | ((t) - 1)) & ~((t) - 1)))) |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 82 | #else |
| 83 | #define ALIGNP(p, t) \ |
| 84 | ((uint8*)((((uintptr_t)(p) + ((t) - 1)) & ~((t) - 1)))) /* NOLINT */ |
| 85 | #endif |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 86 | #endif |
Shri Borde | 7cd8149 | 2011-11-02 13:20:24 -0700 | [diff] [blame] | 87 | |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 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 | |
Hangyu Kuang | f047e7c | 2016-07-06 14:21:45 -0700 | [diff] [blame] | 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 | |
Hendrik Dahlkamp | 33cfdeb | 2013-01-23 18:27:37 -0800 | [diff] [blame] | 118 | #endif // INCLUDE_LIBYUV_BASIC_TYPES_H_ NOLINT |