00001 // Copyright (c) 2005, Google Inc. 00002 // All rights reserved. 00003 // 00004 // Redistribution and use in source and binary forms, with or without 00005 // modification, are permitted provided that the following conditions are 00006 // met: 00007 // 00008 // * Redistributions of source code must retain the above copyright 00009 // notice, this list of conditions and the following disclaimer. 00010 // * Redistributions in binary form must reproduce the above 00011 // copyright notice, this list of conditions and the following disclaimer 00012 // in the documentation and/or other materials provided with the 00013 // distribution. 00014 // * Neither the name of Google Inc. nor the names of its 00015 // contributors may be used to endorse or promote products derived from 00016 // this software without specific prior written permission. 00017 // 00018 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00019 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00020 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00021 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00022 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00023 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00024 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00025 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00026 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00027 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00028 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00029 00030 #ifndef _BASICTYPES_H_ 00031 #define _BASICTYPES_H_ 00032 00033 #include "config.h" 00034 00035 // To use this in an autoconf setting, make sure you run the following 00036 // autoconf macros: 00037 // AC_HEADER_STDC /* for stdint_h and inttypes_h */ 00038 // AC_CHECK_TYPES([__int64]) /* defined in some windows platforms */ 00039 00040 #if defined HAVE_STDINT_H 00041 #include <stdint.h> // to get uint16_t (ISO naming madness) 00042 #elif defined HAVE_INTTYPES_H 00043 #include <inttypes.h> // another place uint16_t might be defined 00044 #else 00045 #include <sys/types.h> // our last best hope 00046 #endif 00047 00048 // Standard typedefs 00049 // All Google code is compiled with -funsigned-char to make "char" 00050 // unsigned. Google code therefore doesn't need a "uchar" type. 00051 // TODO(csilvers): how do we make sure unsigned-char works on non-gcc systems? 00052 typedef signed char schar; 00053 typedef int8_t int8; 00054 typedef int16_t int16; 00055 typedef int32_t int32; 00056 #ifdef HAVE___INT64 00057 typedef __int64 int64; 00058 #else 00059 typedef int64_t int64; 00060 #endif 00061 00062 // NOTE: unsigned types are DANGEROUS in loops and other arithmetical 00063 // places. Use the signed types unless your variable represents a bit 00064 // pattern (eg a hash value) or you really need the extra bit. Do NOT 00065 // use 'unsigned' to express "this value should always be positive"; 00066 // use assertions for this. 00067 00068 typedef uint8_t uint8; 00069 typedef uint16_t uint16; 00070 typedef uint32_t uint32; 00071 #ifdef HAVE___INT64 00072 typedef unsigned __int64 uint64; 00073 #else 00074 typedef uint64_t uint64; 00075 #endif 00076 00077 const uint16 kuint16max = ( (uint16) 0xFFFF); 00078 const uint32 kuint32max = ( (uint32) 0xFFFFFFFF); 00079 const uint64 kuint64max = ( (((uint64) kuint32max) << 32) | kuint32max ); 00080 00081 const int8 kint8max = ( ( int8) 0x7F); 00082 const int16 kint16max = ( ( int16) 0x7FFF); 00083 const int32 kint32max = ( ( int32) 0x7FFFFFFF); 00084 const int64 kint64max = ( ((( int64) kint32max) << 32) | kuint32max ); 00085 00086 const int8 kint8min = ( ( int8) 0x80); 00087 const int16 kint16min = ( ( int16) 0x8000); 00088 const int32 kint32min = ( ( int32) 0x80000000); 00089 const int64 kint64min = ( ((( int64) kint32min) << 32) | 0 ); 00090 00091 // A macro to disallow the evil copy constructor and operator= functions 00092 // This should be used in the private: declarations for a class 00093 #define DISALLOW_EVIL_CONSTRUCTORS(TypeName) \ 00094 TypeName(const TypeName&); \ 00095 void operator=(const TypeName&) 00096 00097 #endif // _BASICTYPES_H_