MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
types.hpp
1 /*
2  Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; version 2 of the License.
7 
8  This program is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License
14  along with this program; see the file COPYING. If not, write to the
15  Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
16  MA 02110-1301 USA.
17 */
18 
19 /* based on Wei Dai's misc.h from CryptoPP, basic crypt types */
20 
21 
22 #ifndef TAO_CRYPT_TYPES_HPP
23 #define TAO_CRYPT_TYPES_HPP
24 
25 #ifdef HAVE_CONFIG_H
26  #include "config.h"
27 #endif
28 
29 namespace TaoCrypt {
30 
31 
32 #if defined(WORDS_BIGENDIAN) || (defined(__MWERKS__) && !defined(__INTEL__))
33  #define BIG_ENDIAN_ORDER
34 #endif
35 
36 #ifndef BIG_ENDIAN_ORDER
37  #define LITTLE_ENDIAN_ORDER
38 #endif
39 
40 
41 typedef unsigned char byte;
42 typedef unsigned short word16;
43 typedef unsigned int word32;
44 
45 #if defined(_MSC_VER) || defined(__BCPLUSPLUS__)
46  #define WORD64_AVAILABLE
47  #define WORD64_IS_DISTINCT_TYPE
48  typedef unsigned __int64 word64;
49  #define W64LIT(x) x##ui64
50 #elif SIZEOF_LONG == 8
51  #define WORD64_AVAILABLE
52  typedef unsigned long word64;
53  #define W64LIT(x) x##LL
54 #elif SIZEOF_LONG_LONG == 8
55  #define WORD64_AVAILABLE
56  #define WORD64_IS_DISTINCT_TYPE
57  typedef unsigned long long word64;
58  #define W64LIT(x) x##LL
59 #endif
60 
61 
62 // compilers we've found 64-bit multiply insructions for
63 #if defined(__GNUC__) || defined(_MSC_VER) || defined(__DECCXX)
64  #if !(defined(__ICC) || defined(__INTEL_COMPILER))
65  #define HAVE_64_MULTIPLY
66  #endif
67 #endif
68 
69 
70 #if defined(HAVE_64_MULTIPLY) && (defined(__alpha__) || defined(__ia64__) \
71  || defined(_ARCH_PPC64) || defined(__mips64) || defined(__x86_64__) \
72  || defined(_M_X64) || defined(_M_IA64))
73 // These platforms have 64-bit CPU registers. Unfortunately most C++ compilers
74 // don't allow any way to access the 64-bit by 64-bit multiply instruction
75 // without using assembly, so in order to use word64 as word, the assembly
76 // instruction must be defined in Dword::Multiply().
77  typedef word32 hword;
78  typedef word64 word;
79 #else
80  #define TAOCRYPT_NATIVE_DWORD_AVAILABLE
81  #ifdef WORD64_AVAILABLE
82  #define TAOCRYPT_SLOW_WORD64
83  typedef word16 hword;
84  typedef word32 word;
85  typedef word64 dword;
86  #else
87  typedef byte hword;
88  typedef word16 word;
89  typedef word32 dword;
90  #endif
91 #endif
92 
93 const word32 WORD_SIZE = sizeof(word);
94 const word32 WORD_BITS = WORD_SIZE * 8;
95 
96 
97 } // namespace
98 
99 #endif // TAO_CRYPT_TYPES_HPP