vpx_integer.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2010 The WebM 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. #ifndef VPX_VPX_INTEGER_H_
  11. #define VPX_VPX_INTEGER_H_
  12. /* get ptrdiff_t, size_t, wchar_t, NULL */
  13. #include <stddef.h>
  14. #if defined(_MSC_VER)
  15. #define VPX_FORCE_INLINE __forceinline
  16. #define VPX_INLINE __inline
  17. #else
  18. #define VPX_FORCE_INLINE __inline__ __attribute__(always_inline)
  19. // TODO(jbb): Allow a way to force inline off for older compilers.
  20. #define VPX_INLINE inline
  21. #endif
  22. #if !defined(VPX_DONT_DEFINE_STDINT_TYPES)
  23. #if (defined(_MSC_VER) && (_MSC_VER < 1600)) || defined(VPX_EMULATE_INTTYPES)
  24. typedef signed char int8_t;
  25. typedef signed short int16_t;
  26. typedef signed int int32_t;
  27. typedef unsigned char uint8_t;
  28. typedef unsigned short uint16_t;
  29. typedef unsigned int uint32_t;
  30. #if (defined(_MSC_VER) && (_MSC_VER < 1600))
  31. typedef signed __int64 int64_t;
  32. typedef unsigned __int64 uint64_t;
  33. #define INT64_MAX _I64_MAX
  34. #define INT32_MAX _I32_MAX
  35. #define INT32_MIN _I32_MIN
  36. #define INT16_MAX _I16_MAX
  37. #define INT16_MIN _I16_MIN
  38. #endif
  39. #ifndef _UINTPTR_T_DEFINED
  40. typedef size_t uintptr_t;
  41. #endif
  42. #else
  43. /* Most platforms have the C99 standard integer types. */
  44. #if defined(__cplusplus)
  45. # if !defined(__STDC_FORMAT_MACROS)
  46. # define __STDC_FORMAT_MACROS
  47. # endif
  48. # if !defined(__STDC_LIMIT_MACROS)
  49. # define __STDC_LIMIT_MACROS
  50. # endif
  51. #endif // __cplusplus
  52. #include <stdint.h>
  53. #endif
  54. #endif // VPX_DONT_DEFINE_STDINT_TYPES
  55. /* VS2010 defines stdint.h, but not inttypes.h */
  56. #if defined(_MSC_VER) && _MSC_VER < 1800
  57. #define PRId64 "I64d"
  58. #else
  59. #include <inttypes.h>
  60. #endif
  61. #endif // VPX_VPX_INTEGER_H_