1/*
2 *  Copyright (c) 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#ifndef WIN32
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 __int64 int64;
24#else
25typedef long long int64;
26#endif /* COMPILER_MSVC */
27typedef int int32;
28typedef short int16;
29typedef char int8;
30
31#ifdef COMPILER_MSVC
32typedef unsigned __int64 uint64;
33typedef __int64 int64;
34#ifndef INT64_C
35#define INT64_C(x) x ## I64
36#endif
37#ifndef UINT64_C
38#define UINT64_C(x) x ## UI64
39#endif
40#define INT64_F "I64"
41#else
42typedef unsigned long long uint64;
43typedef long long int64;
44#ifndef INT64_C
45#define INT64_C(x) x ## LL
46#endif
47#ifndef UINT64_C
48#define UINT64_C(x) x ## ULL
49#endif
50#define INT64_F "ll"
51#endif /* COMPILER_MSVC */
52typedef unsigned int uint32;
53typedef unsigned short uint16;
54typedef unsigned char uint8;
55#endif  // INT_TYPES_DEFINED
56
57// Detect compiler is for x86 or x64.
58#if defined(__x86_64__) || defined(_M_X64) || \
59    defined(__i386__) || defined(_M_IX86)
60#define CPU_X86 1
61#endif
62
63#define IS_ALIGNED(p, a) (0==(reinterpret_cast<uintptr_t>(p) & ((a)-1)))
64#define ALIGNP(p, t) \
65  (reinterpret_cast<uint8*>(((reinterpret_cast<uintptr_t>(p) + \
66  ((t)-1)) & ~((t)-1))))
67
68#endif // INCLUDE_LIBYUV_BASIC_TYPES_H_
69