Disk ARchive  2.4.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
integers.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 // $Id: integers.hpp,v 1.17 2011/02/17 21:45:22 edrusb Rel $
22 //
23 /*********************************************************************/
24 
25 
29 
30 
31 #ifndef INTEGERS_HPP
32 #define INTEGERS_HPP
33 
34 #include "../my_config.h"
35 #include <string>
36 
39 
40 #ifndef OS_BITS
41 
42 #if HAVE_INTTYPES_H
43 extern "C"
44 {
45 #if HAVE_INTTYPES_H
46 #include <inttypes.h>
47 #endif
48 #if HAVE_LIMITS_H
49 #include <limits.h>
50 #endif
51 } // end extern "C"
52 
53 namespace libdar
54 {
55  typedef unsigned char U_8;
56  typedef uint16_t U_16;
57  typedef uint32_t U_32;
58  typedef uint64_t U_64;
59  typedef size_t U_I;
60  // configure will define size_t as "unsigned int" if it not defined by system headers
61  // thus using U_I we are sure we can compare buffer sizes with SSIZE_MAX
62  typedef signed char S_8;
63  typedef int16_t S_16;
64  typedef int32_t S_32;
65  typedef int64_t S_64;
66  typedef signed int S_I;
67 
68 }
69 
70 #else // HAVE_INTTYPES_H
71 #error "Cannot determine interger types, use --enable-os-bits=... with the 'configure' script according to your system's CPU register size"
72 #endif // HAVE_INTTYPES_H
73 
74 #else // OS_BITS is defined
75 #if OS_BITS == 32
76 
77 namespace libdar
78 {
79  typedef unsigned char U_8;
80  typedef unsigned short U_16;
81  typedef unsigned long U_32;
82  typedef unsigned long long U_64;
83  typedef size_t U_I;
84  typedef signed char S_8;
85  typedef signed short S_16;
86  typedef signed long S_32;
87  typedef signed long long S_64;
88  typedef signed int S_I;
89 
90 }
91 
92 #else // OS_BITS != 32
93 #if OS_BITS == 64
94 
95 namespace libdar
96 {
97  typedef unsigned char U_8;
98  typedef unsigned short U_16;
99  typedef unsigned int U_32;
100  typedef unsigned long long U_64;
101  typedef size_t U_I;
102  typedef signed char S_8;
103  typedef signed short S_16;
104  typedef signed int S_32;
105  typedef signed long long S_64;
106  typedef signed int S_I;
107 
108 }
109 
110 #else // OS_BITS != 32 and OS_BITS != 64
111 #error "unknown value given to --enable-os-bits=... check the 'configure' script arguments"
112  // unknown OS_BITS value ! use --enable-os-bits=... option to configure script
113  //
114  // the previous line should not compile, this is the expected behaviour
115 
116 #endif // OS_BITS == 64
117 #endif // OS_BITS == 32
118 #endif // OS_BITS not defined
119 
120 namespace libdar
121 {
122 
123 
125 
127  void integer_check();
128 
129 
131 
135 
136 }
137 
139 
140 
141 #endif // header file multiple inclusion protection