1
/******************************************************************************
4
* Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5
* Purpose: Integer types definitions
6
* Author: Mateusz Loskot, mateusz@loskot.net
8
* This file has been stolen from <boost/cstdint.hpp> and
9
* modified for libLAS purposes.
11
* (C) Copyright Mateusz Loskot 2007, mateusz@loskot.net
12
* (C) Copyright Phil Vachon 2007, philippe@cowpig.ca
13
* (C) Copyright John Maddock 2001
14
* (C) Copyright Jens Mauer 2001
15
* (C) Copyright Beman Dawes 1999
16
* Distributed under the Boost Software License, Version 1.0.
17
* (See accompanying file LICENSE_1_0.txt or copy at
18
* http://www.boost.org/LICENSE_1_0.txt)
20
******************************************************************************
22
* All rights reserved.
24
* Redistribution and use in source and binary forms, with or without
25
* modification, are permitted provided that the following
28
* * Redistributions of source code must retain the above copyright
29
* notice, this list of conditions and the following disclaimer.
30
* * Redistributions in binary form must reproduce the above copyright
31
* notice, this list of conditions and the following disclaimer in
32
* the documentation and/or other materials provided
33
* with the distribution.
34
* * Neither the name of the Martin Isenburg or Iowa Department
35
* of Natural Resources nor the names of its contributors may be
36
* used to endorse or promote products derived from this software
37
* without specific prior written permission.
39
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
40
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
41
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
42
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
43
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
44
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
45
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
46
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
47
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
51
****************************************************************************/
53
#ifndef LIBLAS_CSTDINT_HPP_INCLUDED
54
#define LIBLAS_CSTDINT_HPP_INCLUDED
60
# endif /* _MSC_VER */
61
#else /* LIBLAS_C_API */
65
#endif /* LIBLAS_C_API */
68
// These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
69
// platforms. For other systems, they will have to be hand tailored.
71
// Because the fast types are assumed to be the same as the undecorated types,
72
// it may be possible to hand tailor a more efficient implementation. Such
73
// an optimization may be illusionary; on the Intel x86-family 386 on, for
74
// example, byte arithmetic and load/stores are as fast as "int" sized ones.
76
// 8-bit types ------------------------------------------------------------//
80
# if UCHAR_MAX == 0xff
81
typedef unsigned char uint8_t;
82
typedef signed char int8_t;
84
# error defaults not correct; you must hand modify liblas/cstdint.hpp
88
typedef ::uint8_t uint8_t;
89
typedef ::int8_t int8_t;
95
// 16-bit types -----------------------------------------------------------//
99
# if USHRT_MAX == 0xffff
100
typedef unsigned short uint16_t;
101
typedef short int16_t;
103
# error defaults not correct; you must hand modify liblas/cstdint.hpp
106
# ifndef LIBLAS_C_API
107
typedef ::uint16_t uint16_t;
108
typedef ::int16_t int16_t;
110
#endif /* UINT16_C */
113
// 32-bit types -----------------------------------------------------------//
117
# if ULONG_MAX == 0xffffffff
118
typedef unsigned long uint32_t;
119
# elif UINT_MAX == 0xffffffff
120
typedef unsigned int uint32_t;
122
# error defaults not correct; you must hand modify liblas/cstdint.hpp
125
# ifndef LIBLAS_C_API
126
typedef ::uint32_t uint32_t;
128
#endif /* UINT32_C */
131
# if ULONG_MAX == 0xffffffff
132
typedef long int32_t;
133
# elif UINT_MAX == 0xffffffff
136
# error defaults not correct; you must hand modify liblas/cstdint.hpp
139
# ifndef LIBLAS_C_API
140
typedef ::int32_t int32_t;
145
// 64-bit types + intmax_t and uintmax_t ----------------------------------//
149
# if ULONG_MAX != 0xffffffffu
150
# if ULONG_MAX == 18446744073709551615u /* 2**64 - 1 */
151
typedef long int64_t;
152
typedef unsigned long uint64_t;
154
# error defaults not correct; you must hand modify boost/cstdint.hpp
156
# elif defined(__GNUC__) || defined(HAVE_LONG_LONG)
157
__extension__ typedef long long int64_t;
158
__extension__ typedef unsigned long long uint64_t;
159
# elif defined(_MSC_VER)
160
/* // we have Borland/Intel/Microsoft __int64: */
161
typedef __int64 int64_t;
162
typedef unsigned __int64 uint64_t;
163
# else /* // assume no 64-bit integers */
164
# define LIBLAS_NO_INT64_T
166
#endif /* UINT64_C */
169
} /* namespace liblas */
170
#endif /* LIBLAS_C_API */
172
#endif /* LIBLAS_CSTDINT_HPP_INCLUDED */