~ubuntu-branches/ubuntu/wily/liblas/wily

« back to all changes in this revision

Viewing changes to include/liblas/cstdint.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Francesco Paolo Lovergine
  • Date: 2009-10-02 12:36:21 UTC
  • Revision ID: james.westby@ubuntu.com-20091002123621-xrf0hhzxbwloga43
Tags: upstream-1.2.1
ImportĀ upstreamĀ versionĀ 1.2.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/******************************************************************************
 
2
 * $Id$
 
3
 *
 
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
 
7
 *
 
8
 * This file has been stolen from <boost/cstdint.hpp> and
 
9
 * modified for libLAS purposes.
 
10
 * 
 
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)
 
19
 * 
 
20
 ******************************************************************************
 
21
 *
 
22
 * All rights reserved.
 
23
 * 
 
24
 * Redistribution and use in source and binary forms, with or without 
 
25
 * modification, are permitted provided that the following 
 
26
 * conditions are met:
 
27
 * 
 
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.
 
38
 * 
 
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 
 
50
 * OF SUCH DAMAGE.
 
51
 ****************************************************************************/
 
52
 
 
53
#ifndef LIBLAS_CSTDINT_HPP_INCLUDED
 
54
#define LIBLAS_CSTDINT_HPP_INCLUDED
 
55
 
 
56
#ifdef LIBLAS_C_API
 
57
#  include <limits.h>
 
58
#  ifndef _MSC_VER
 
59
#    include <stdint.h>
 
60
#  endif /* _MSC_VER */
 
61
#else /* LIBLAS_C_API */
 
62
#  include <climits>
 
63
namespace liblas
 
64
{
 
65
#endif /* LIBLAS_C_API */
 
66
 
 
67
/*
 
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.
 
70
//
 
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.
 
75
 
 
76
//  8-bit types  ------------------------------------------------------------//
 
77
*/
 
78
 
 
79
#ifndef UINT8_C
 
80
# if UCHAR_MAX == 0xff
 
81
    typedef unsigned char   uint8_t;
 
82
    typedef signed char     int8_t;
 
83
# else
 
84
#  error defaults not correct; you must hand modify liblas/cstdint.hpp
 
85
# endif
 
86
#else
 
87
# ifndef LIBLAS_C_API
 
88
    typedef ::uint8_t uint8_t;
 
89
    typedef ::int8_t int8_t;
 
90
# endif
 
91
 
 
92
#endif /* UINT8_C */
 
93
 
 
94
/*
 
95
//  16-bit types  -----------------------------------------------------------//
 
96
*/
 
97
 
 
98
#ifndef UINT16_C
 
99
# if USHRT_MAX == 0xffff
 
100
    typedef unsigned short  uint16_t;
 
101
    typedef short           int16_t;
 
102
# else
 
103
#   error defaults not correct; you must hand modify liblas/cstdint.hpp
 
104
# endif
 
105
#else
 
106
# ifndef LIBLAS_C_API
 
107
    typedef ::uint16_t uint16_t;
 
108
    typedef ::int16_t int16_t;
 
109
# endif
 
110
#endif /* UINT16_C */
 
111
 
 
112
/*
 
113
//  32-bit types  -----------------------------------------------------------//
 
114
*/
 
115
 
 
116
#ifndef UINT32_C
 
117
# if ULONG_MAX == 0xffffffff
 
118
    typedef unsigned long   uint32_t;
 
119
# elif UINT_MAX == 0xffffffff
 
120
    typedef unsigned int    uint32_t;
 
121
# else
 
122
#   error defaults not correct; you must hand modify liblas/cstdint.hpp
 
123
# endif
 
124
#else
 
125
# ifndef LIBLAS_C_API
 
126
    typedef ::uint32_t uint32_t;
 
127
# endif
 
128
#endif /* UINT32_C */
 
129
 
 
130
#ifndef INT32_C
 
131
# if ULONG_MAX == 0xffffffff
 
132
    typedef long            int32_t;
 
133
# elif UINT_MAX == 0xffffffff
 
134
    typedef int             int32_t;
 
135
# else
 
136
#   error defaults not correct; you must hand modify liblas/cstdint.hpp
 
137
# endif
 
138
#else
 
139
# ifndef LIBLAS_C_API
 
140
    typedef ::int32_t int32_t;
 
141
# endif
 
142
#endif /* INT32_C */
 
143
 
 
144
/*
 
145
//  64-bit types + intmax_t and uintmax_t  ----------------------------------//
 
146
*/
 
147
 
 
148
#ifndef UINT64_C
 
149
# if ULONG_MAX != 0xffffffffu
 
150
#  if ULONG_MAX == 18446744073709551615u /* 2**64 - 1 */
 
151
    typedef long                int64_t;
 
152
    typedef unsigned long       uint64_t;
 
153
#  else
 
154
#   error defaults not correct; you must hand modify boost/cstdint.hpp
 
155
#  endif
 
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
 
165
# endif
 
166
#endif /* UINT64_C */
 
167
 
 
168
#ifndef LIBLAS_C_API
 
169
}  /* namespace liblas */
 
170
#endif /* LIBLAS_C_API */
 
171
 
 
172
#endif /* LIBLAS_CSTDINT_HPP_INCLUDED */
 
173