Support: quest -f cjk_ngram
[xapian.git] / xapian-core / common / internaltypes.h
blob7f2d1570c20fb65f10143941461ce592d23e8662
1 /** @file internaltypes.h
2 * @brief Types used internally.
3 */
4 /* Copyright (C) 2009,2010,2014 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19 * USA
22 #ifndef XAPIAN_INCLUDED_INTERNALTYPES_H
23 #define XAPIAN_INCLUDED_INTERNALTYPES_H
25 #include <climits>
27 /// Unsigned 8 bit type.
28 typedef unsigned char byte;
30 #ifndef SIZEOF_SHORT
31 # error SIZEOF_SHORT is not defined
32 #endif
33 #ifndef SIZEOF_INT
34 # error SIZEOF_INT is not defined
35 #endif
36 #ifndef SIZEOF_LONG
37 # error SIZEOF_LONG is not defined
38 #endif
40 #if SIZEOF_SHORT * CHAR_BIT == 16
41 typedef unsigned short uint2;
42 #else
43 # error Type short is more than 16 bits, which Xapian does not currently handle
44 #endif
46 #if SIZEOF_INT * CHAR_BIT >= 32
47 typedef unsigned int uint4;
48 #elif SIZEOF_LONG * CHAR_BIT >= 32
49 typedef unsigned long uint4;
50 #else
51 # error Type long is less than 32 bits, which ISO does not allow!
52 #endif
54 #if SIZEOF_LONG * CHAR_BIT >= 64
55 typedef unsigned long uint8;
56 #else
57 /* C99 and C++11 actually standardised "long long", but it seems to be widely
58 * supported (e.g. GCC has supported it for ages, MSVC since at least 2003 it
59 * appears) and we've not had any reports of compilation failing due to lack of
60 * support for it.
62 typedef unsigned long long uint8;
63 #endif
65 /// Integer type used to hold the total length of all documents in a database.
66 typedef uint8 totlen_t;
68 #endif // XAPIAN_INCLUDED_INTERNALTYPES_H