| Disk ARchive 2.6.12 Full featured and portable backup and archiving tool

integers.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
25
26
27 #ifndef INTEGERS_HPP
28 #define INTEGERS_HPP
29
30 #include "../my_config.h"
31 #include <string>
32
35
36 #ifndef OS_BITS
37
38 #if HAVE_INTTYPES_H
39 extern "C"
40 {
41 #if HAVE_INTTYPES_H
42 #include <inttypes.h>
43 #endif
44 #if HAVE_LIMITS_H
45 #include <limits.h>
46 #endif
47 } // end extern "C"
48
49 namespace libdar
50 {
51 using U_8 = unsigned char;
52 using U_16 = uint16_t;
53 using U_32 = uint32_t;
54 using U_64 = uint64_t;
55 using U_I = size_t;
56 // configure will define size_t as "unsigned int" if it not defined by system headers
57 // thus using U_I we are sure we can compare buffer sizes with SSIZE_MAX
58 using S_8 = signed char;
59 using S_16 = int16_t;
60 using S_32 = int32_t;
61 using S_64 = int64_t;
62 using S_I = signed int;
63
64 }
65
66 #else // HAVE_INTTYPES_H
67 #error "Cannot determine interger types, use --enable-os-bits=... with the 'configure' script according to your system's CPU register size"
68 #endif // HAVE_INTTYPES_H
69
70 #else // OS_BITS is defined
71 #if OS_BITS == 32
72
73 namespace libdar
74 {
75 using U_8 = unsigned char;
76 using U_16 = unsigned short;
77 using U_32 = unsigned long;
78 using U_64 = unsigned long long;
79 using U_I = size_t;
80 using S_8 = signed char;
81 using S_16 = signed short;
82 using S_32 = signed long;
83 using S_64 = signed long long;
84 using S_I = signed int;
85
86 }
87
88 #else // OS_BITS != 32
89 #if OS_BITS == 64
90
91 namespace libdar
92 {
93 using U_8 = unsigned char;
94 using U_16 = unsigned short;
95 using U_32 = unsigned int;
96 using U_64 = unsigned long long;
97 using U_I = size_t;
98 using S_8 = signed char;
99 using S_16 = signed short;
100 using S_32 = signed int;
101 using S_64 = signed long long;
102 using S_I = signed int;
103
104 }
105
106 #else // OS_BITS != 32 and OS_BITS != 64
107 #error "unknown value given to --enable-os-bits=... check the 'configure' script arguments"
108 // unknown OS_BITS value ! use --enable-os-bits=... option to configure script
109 //
110 // the previous line should not compile, this is the expected behaviour
111
112 #endif // OS_BITS == 64
113 #endif // OS_BITS == 32
114 #endif // OS_BITS not defined
115
116 namespace libdar
117 {
118
119
121
123 void integer_check();
124
125
127
130 bool integers_system_is_big_endian();
131
132 }
133
135
136
137 #endif // header file multiple inclusion protection
libdar::integers_system_is_big_endian
bool integers_system_is_big_endian()
returns true if the system is big endian, false else
libdar::integer_check
void integer_check()
checks sign and width of integer types
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47