/*
 * Copyright 2015 Telenav Inc. All rights reserved.
 */
#ifndef TN_FOUNDATION_STDINT_HPP
#define TN_FOUNDATION_STDINT_HPP

#include "foundation/cxx11compat.hpp"

#if _TN_FOUNDATION_USE_STD
#  include <cstdint>
#else
#  include "boost/cstdint.hpp"
#endif 

// Theoretically we should put those in tn:: and not in global namespace, but in practice there's too
// much of a chance that something will also include <stdint.h> and then compiler will complain about
// ambigous definitions.
using _TN_FOUNDATION_STD_NS::int8_t;  
using _TN_FOUNDATION_STD_NS::int16_t; 
using _TN_FOUNDATION_STD_NS::int32_t; 
using _TN_FOUNDATION_STD_NS::int64_t; 

using _TN_FOUNDATION_STD_NS::int_fast8_t;
using _TN_FOUNDATION_STD_NS::int_fast16_t;
using _TN_FOUNDATION_STD_NS::int_fast32_t;
using _TN_FOUNDATION_STD_NS::int_fast64_t;

using _TN_FOUNDATION_STD_NS::int_least8_t;
using _TN_FOUNDATION_STD_NS::int_least16_t;
using _TN_FOUNDATION_STD_NS::int_least32_t;
using _TN_FOUNDATION_STD_NS::int_least64_t;

using _TN_FOUNDATION_STD_NS::intmax_t;


using _TN_FOUNDATION_STD_NS::uint8_t;  
using _TN_FOUNDATION_STD_NS::uint16_t; 
using _TN_FOUNDATION_STD_NS::uint32_t; 
using _TN_FOUNDATION_STD_NS::uint64_t; 

using _TN_FOUNDATION_STD_NS::uint_fast8_t;
using _TN_FOUNDATION_STD_NS::uint_fast16_t;
using _TN_FOUNDATION_STD_NS::uint_fast32_t;
using _TN_FOUNDATION_STD_NS::uint_fast64_t;

using _TN_FOUNDATION_STD_NS::uint_least8_t;
using _TN_FOUNDATION_STD_NS::uint_least16_t;
using _TN_FOUNDATION_STD_NS::uint_least32_t;
using _TN_FOUNDATION_STD_NS::uint_least64_t;

using _TN_FOUNDATION_STD_NS::uintmax_t;

#ifndef INT8_MIN
# define INT8_MIN (-128)
#endif
#ifndef INT16_MIN
# define INT16_MIN (-32767-1)
#endif
#ifndef INT32_MIN
# define INT32_MIN (-2147483647-1)
#endif
#ifndef INT64_MIN
# define INT64_MIN (-9223372036854775807LL-1)
#endif
#ifndef INT8_MAX
# define INT8_MAX (127)
#endif
#ifndef INT16_MAX
# define INT16_MAX (32767)
#endif
#ifndef INT32_MAX
# define INT32_MAX (2147483647)
#endif
#ifndef INT64_MAX
# define INT64_MAX  (9223372036854775807LL)
#endif
#ifndef UINT8_MAX
# define UINT8_MAX (255)
#endif
#ifndef UINT16_MAX
# define UINT16_MAX (65535)
#endif
#ifndef UINT32_MAX
# define UINT32_MAX (4294967295U)
#endif
#ifndef UINT64_MAX
# define UINT64_MAX (18446744073709551615ULL)
#endif

#ifndef INT_LEAST8_MIN
# define INT_LEAST8_MIN INT8_MIN
#endif
#ifndef INT_LEAST16_MIN
# define INT_LEAST16_MIN INT16_MIN
#endif
#ifndef INT_LEAST32_MIN
# define INT_LEAST32_MIN INT32_MIN
#endif
#ifndef INT_LEAST64_MIN
# define INT_LEAST64_MIN INT64_MIN
#endif
#ifndef INT_LEAST8_MAX
# define INT_LEAST8_MAX INT8_MAX
#endif
#ifndef INT_LEAST16_MAX
# define INT_LEAST16_MAX INT16_MAX
#endif
#ifndef INT_LEAST32_MAX
# define INT_LEAST32_MAX INT32_MAX
#endif
#ifndef INT_LEAST64_MAX
# define INT_LEAST64_MAX INT64_MAX
#endif
#ifndef UINT_LEAST8_MAX
# define UINT_LEAST8_MAX UINT8_MAX
#endif
#ifndef UINT_LEAST16_MAX
# define UINT_LEAST16_MAX UINT16_MAX
#endif
#ifndef UINT_LEAST32_MAX
# define UINT_LEAST32_MAX UINT32_MAX
#endif
#ifndef UINT_LEAST64_MAX
# define UINT_LEAST64_MAX UINT64_MAX
#endif

#ifndef INT_FAST8_MIN
# define INT_FAST8_MIN INT8_MIN
#endif
#ifndef INT_FAST16_MIN
# define INT_FAST16_MIN INT16_MIN
#endif
#ifndef INT_FAST32_MIN
# define INT_FAST32_MIN INT32_MIN
#endif
#ifndef INT_FAST64_MIN
# define INT_FAST64_MIN INT64_MIN
#endif
#ifndef INT_FAST8_MAX
# define INT_FAST8_MAX INT8_MAX
#endif
#ifndef INT_FAST16_MAX
# define INT_FAST16_MAX INT16_MAX
#endif
#ifndef INT_FAST32_MAX
# define INT_FAST32_MAX INT32_MAX
#endif
#ifndef INT_FAST64_MAX
# define INT_FAST64_MAX INT64_MAX
#endif
#ifndef UINT_FAST8_MAX
# define UINT_FAST8_MAX UINT8_MAX
#endif
#ifndef UINT_FAST16_MAX
# define UINT_FAST16_MAX UINT16_MAX
#endif
#ifndef UINT_FAST32_MAX
# define UINT_FAST32_MAX UINT32_MAX
#endif
#ifndef UINT_FAST64_MAX
# define UINT_FAST64_MAX UINT64_MAX
#endif

// Not quite right, of course, but will do as a fallback.
// Hopefully by the time we worry about 128 bit compilers they will sort out constant 
// definitions in the standard library.
#ifndef INTMAX_MIN
# define INTMAX_MIN INT64_MIN
#endif
#ifndef INTMAX_MAX
# define INTMAX_MAX INT64_MAX
#endif


#endif /* TN_FOUNDATION_STDINT_HPP */
