cstdint.hpp

Go to the documentation of this file.
00001 /******************************************************************************
00002  * $Id: cstdint.hpp 838 2008-08-18 21:40:44Z hobu $
00003  *
00004  * Project:  libLAS - http://liblas.org - A BSD library for LAS format data.
00005  * Purpose:  Integer types definitions
00006  * Author:   Mateusz Loskot, mateusz@loskot.net
00007  *
00008  * This file has been stolen from <boost/cstdint.hpp> and
00009  * modified for libLAS purposes.
00010  * 
00011  * (C) Copyright Mateusz Loskot 2007, mateusz@loskot.net
00012  * (C) Copyright Phil Vachon 2007, philippe@cowpig.ca
00013  * (C) Copyright John Maddock 2001
00014  * (C) Copyright Jens Mauer 2001
00015  * (C) Copyright Beman Dawes 1999
00016  * Distributed under the Boost  Software License, Version 1.0.
00017  * (See accompanying file LICENSE_1_0.txt or copy at
00018  * http://www.boost.org/LICENSE_1_0.txt)
00019  * 
00020  ******************************************************************************
00021  *
00022  * All rights reserved.
00023  * 
00024  * Redistribution and use in source and binary forms, with or without 
00025  * modification, are permitted provided that the following 
00026  * conditions are met:
00027  * 
00028  *     * Redistributions of source code must retain the above copyright 
00029  *       notice, this list of conditions and the following disclaimer.
00030  *     * Redistributions in binary form must reproduce the above copyright 
00031  *       notice, this list of conditions and the following disclaimer in 
00032  *       the documentation and/or other materials provided 
00033  *       with the distribution.
00034  *     * Neither the name of the Martin Isenburg or Iowa Department 
00035  *       of Natural Resources nor the names of its contributors may be 
00036  *       used to endorse or promote products derived from this software 
00037  *       without specific prior written permission.
00038  * 
00039  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00040  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00041  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
00042  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
00043  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
00044  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
00045  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
00046  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
00047  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 
00048  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
00049  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00050  * OF SUCH DAMAGE.
00051  ****************************************************************************/
00052
00053 #ifndef LIBLAS_CSTDINT_HPP_INCLUDED
00054 #define LIBLAS_CSTDINT_HPP_INCLUDED
00055 
00056 #ifdef LIBLAS_C_API
00057 #  include <limits.h>
00058 #  ifndef _MSC_VER
00059 #    include <stdint.h>
00060 #  endif /* _MSC_VER */
00061 #else /* LIBLAS_C_API */
00062 #  include <climits>
00063 namespace liblas
00064 {
00065 #endif /* LIBLAS_C_API */
00066
00067 /*
00068 //  These are fairly safe guesses for some 16-bit, and most 32-bit and 64-bit
00069 //  platforms.  For other systems, they will have to be hand tailored.
00070 //
00071 //  Because the fast types are assumed to be the same as the undecorated types,
00072 //  it may be possible to hand tailor a more efficient implementation.  Such
00073 //  an optimization may be illusionary; on the Intel x86-family 386 on, for
00074 //  example, byte arithmetic and load/stores are as fast as "int" sized ones.
00075 
00076 //  8-bit types  ------------------------------------------------------------//
00077 */
00078
00079 #ifndef UINT8_C
00080 # if UCHAR_MAX == 0xff
00081     typedef unsigned char   uint8_t;
00082     typedef signed char     int8_t;
00083 # else
00084 #  error defaults not correct; you must hand modify liblas/cstdint.hpp
00085 # endif
00086 #else
00087 # ifndef LIBLAS_C_API
00088     typedef ::uint8_t uint8_t;
00089     typedef ::int8_t int8_t;
00090 # endif
00091 
00092 #endif /* UINT8_C */
00093
00094 /*
00095 //  16-bit types  -----------------------------------------------------------//
00096 */
00097
00098 #ifndef UINT16_C
00099 # if USHRT_MAX == 0xffff
00100     typedef unsigned short  uint16_t;
00101     typedef short           int16_t;
00102 # else
00103 #   error defaults not correct; you must hand modify liblas/cstdint.hpp
00104 # endif
00105 #else
00106 # ifndef LIBLAS_C_API
00107     typedef ::uint16_t uint16_t;
00108     typedef ::int16_t int16_t;
00109 # endif
00110 #endif /* UINT16_C */
00111
00112 /*
00113 //  32-bit types  -----------------------------------------------------------//
00114 */
00115
00116 #ifndef UINT32_C
00117 # if ULONG_MAX == 0xffffffff
00118     typedef unsigned long   uint32_t;
00119 # elif UINT_MAX == 0xffffffff
00120     typedef unsigned int    uint32_t;
00121 # else
00122 #   error defaults not correct; you must hand modify liblas/cstdint.hpp
00123 # endif
00124 #else
00125 # ifndef LIBLAS_C_API
00126     typedef ::uint32_t uint32_t;
00127 # endif
00128 #endif /* UINT32_C */
00129
00130 #ifndef INT32_C
00131 # if ULONG_MAX == 0xffffffff
00132     typedef long            int32_t;
00133 # elif UINT_MAX == 0xffffffff
00134     typedef int             int32_t;
00135 # else
00136 #   error defaults not correct; you must hand modify liblas/cstdint.hpp
00137 # endif
00138 #else
00139 # ifndef LIBLAS_C_API
00140     typedef ::int32_t int32_t;
00141 # endif
00142 #endif /* INT32_C */
00143
00144 /*
00145 //  64-bit types + intmax_t and uintmax_t  ----------------------------------//
00146 */
00147
00148 #ifndef UINT64_C
00149 # if ULONG_MAX != 0xffffffffu
00150 #  if ULONG_MAX == 18446744073709551615u /* 2**64 - 1 */
00151     typedef long                int64_t;
00152     typedef unsigned long       uint64_t;
00153 #  else
00154 #   error defaults not correct; you must hand modify boost/cstdint.hpp
00155 #  endif
00156 # elif defined(__GNUC__) || defined(HAVE_LONG_LONG)
00157     __extension__ typedef long long            int64_t;
00158     __extension__ typedef unsigned long long   uint64_t;
00159 # elif defined(_MSC_VER)
00160 /*    // we have Borland/Intel/Microsoft __int64: */
00161     typedef __int64             int64_t;
00162     typedef unsigned __int64    uint64_t;
00163 # else /* // assume no 64-bit integers */
00164 #  define LIBLAS_NO_INT64_T
00165 # endif
00166 #endif /* UINT64_C */
00167
00168 #ifndef LIBLAS_C_API
00169 }  /* namespace liblas */
00170 #endif /* LIBLAS_C_API */
00171
00172 #endif /* LIBLAS_CSTDINT_HPP_INCLUDED */
00173