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_  // NOLINT
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 <stdint.h>  // for uintptr_t
18#endif
19
20#ifndef INT_TYPES_DEFINED
21#define INT_TYPES_DEFINED
22#ifdef COMPILER_MSVC
23typedef unsigned __int64 uint64;
24typedef __int64 int64;
25#ifndef INT64_C
26#define INT64_C(x) x ## I64
27#endif
28#ifndef UINT64_C
29#define UINT64_C(x) x ## UI64
30#endif
31#define INT64_F "I64"
32#else  // COMPILER_MSVC
33#ifdef __LP64__
34typedef unsigned long uint64;  // NOLINT
35typedef long int64;  // NOLINT
36#ifndef INT64_C
37#define INT64_C(x) x ## L
38#endif
39#ifndef UINT64_C
40#define UINT64_C(x) x ## UL
41#endif
42#define INT64_F "l"
43#else  // __LP64__
44typedef unsigned long long uint64;  // NOLINT
45typedef long long int64;  // NOLINT
46#ifndef INT64_C
47#define INT64_C(x) x ## LL
48#endif
49#ifndef UINT64_C
50#define UINT64_C(x) x ## ULL
51#endif
52#define INT64_F "ll"
53#endif  // __LP64__
54#endif  // COMPILER_MSVC
55typedef unsigned int uint32;
56typedef int int32;
57typedef unsigned short uint16;  // NOLINT
58typedef short int16;  // NOLINT
59typedef unsigned char uint8;
60typedef signed char int8;
61#endif  // INT_TYPES_DEFINED
62
63// Detect compiler is for x86 or x64.
64#if defined(__x86_64__) || defined(_M_X64) || \
65    defined(__i386__) || defined(_M_IX86)
66#define CPU_X86 1
67#endif
68// Detect compiler is for ARM.
69#if defined(__arm__) || defined(_M_ARM)
70#define CPU_ARM 1
71#endif
72
73#ifndef ALIGNP
74#define ALIGNP(p, t) \
75    (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
76    ((t) - 1)) & ~((t) - 1))))
77#endif
78
79#if !defined(LIBYUV_API)
80#if defined(_WIN32) || defined(__CYGWIN__)
81#if defined(LIBYUV_BUILDING_SHARED_LIBRARY)
82#define LIBYUV_API __declspec(dllexport)
83#elif defined(LIBYUV_USING_SHARED_LIBRARY)
84#define LIBYUV_API __declspec(dllimport)
85#else
86#define LIBYUV_API
87#endif  // LIBYUV_BUILDING_SHARED_LIBRARY
88#elif defined(__GNUC__) && (__GNUC__ >= 4) && !defined(__APPLE__) && \
89    (defined(LIBYUV_BUILDING_SHARED_LIBRARY) || \
90    defined(LIBYUV_USING_SHARED_LIBRARY))
91#define LIBYUV_API __attribute__ ((visibility ("default")))
92#else
93#define LIBYUV_API
94#endif  // __GNUC__
95#endif  // LIBYUV_API
96
97#endif  // INCLUDE_LIBYUV_BASIC_TYPES_H_  NOLINT
98