2 Define integer types for Bacula -- Kern Sibbald
4 Integer types. These types should be be used in all
5 contexts in which the length of an integer stored on
6 removable media must be known regardless of the
7 architecture of the platform.
11 int8_t, int16_t, int32_t, int64_t
12 uint8_t, uint16_t, uint32_t, uint64_t
14 Also, we define types such as file address lengths.
20 Bacula® - The Network Backup Solution
22 Copyright (C) 2000-2006 Free Software Foundation Europe e.V.
24 The main author of Bacula is Kern Sibbald, with contributions from
25 many others, a complete list can be found in the file AUTHORS.
26 This program is Free Software; you can redistribute it and/or
27 modify it under the terms of version two of the GNU General Public
28 License as published by the Free Software Foundation plus additions
29 that are listed in the file LICENSE.
31 This program is distributed in the hope that it will be useful, but
32 WITHOUT ANY WARRANTY; without even the implied warranty of
33 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
34 General Public License for more details.
36 You should have received a copy of the GNU General Public License
37 along with this program; if not, write to the Free Software
38 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
41 Bacula® is a registered trademark of John Walker.
42 The licensor of Bacula is the Free Software Foundation Europe
43 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
44 Switzerland, email:ftf@fsfeurope.org.
48 #ifndef __bc_types_INCLUDED
49 #define __bc_types_INCLUDED
56 /* If sys/types.h does not supply intXX_t, supply them ourselves */
60 typedef unsigned int u_int;
64 # if (SIZEOF_CHAR == 1)
67 # error "8 bit int type not found."
69 # if (SIZEOF_SHORT_INT == 2)
70 typedef short int int16_t;
72 # error "16 bit int type not found."
74 # if (SIZEOF_INT == 4)
77 # error "32 bit int type not found."
81 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
82 #ifndef HAVE_U_INTXX_T
84 typedef uint8_t u_int8_t;
85 typedef uint16_t u_int16_t;
86 typedef uint32_t u_int32_t;
87 # define HAVE_U_INTXX_T 1
89 # if (SIZEOF_CHAR == 1)
90 typedef unsigned char u_int8_t;
92 # error "8 bit int type not found. Required!"
94 # if (SIZEOF_SHORT_INT == 2)
95 typedef unsigned short int u_int16_t;
97 # error "16 bit int type not found. Required!"
99 # if (SIZEOF_INT == 4)
100 typedef unsigned int u_int32_t;
102 # error "32 bit int type not found. Required!"
109 # if (SIZEOF_LONG_LONG_INT == 8)
110 typedef long long int int64_t;
111 # define HAVE_INT64_T 1
113 # if (SIZEOF_LONG_INT == 8)
114 typedef long int int64_t;
115 # define HAVE_INT64_T 1
120 #ifndef HAVE_INTMAX_T
122 typedef int64_t intmax_t;
124 # error "64 bit type not found. Required!"
128 #ifndef HAVE_U_INT64_T
129 # if (SIZEOF_LONG_LONG_INT == 8)
130 typedef unsigned long long int u_int64_t;
131 # define HAVE_U_INT64_T 1
133 # if (SIZEOF_LONG_INT == 8)
134 typedef unsigned long int u_int64_t;
135 # define HAVE_U_INT64_T 1
137 # error "64 bit type not found. Required!"
142 #ifndef HAVE_U_INTMAX_T
143 # ifdef HAVE_U_INT64_T
144 typedef u_int64_t u_intmax_t;
146 # error "64 bit type not found. Required!"
151 /* Limits for the above types. */
162 #define INT8_MIN (-127-1)
163 #define INT8_MAX (127)
164 #define UINT8_MAX (255u)
165 #define INT16_MIN (-32767-1)
166 #define INT16_MAX (32767)
167 #define UINT16_MAX (65535u)
168 #define INT32_MIN (-2147483647-1)
169 #define INT32_MAX (2147483647)
170 #define UINT32_MAX (4294967295u)
172 typedef double float64_t;
173 typedef float float32_t;
175 #endif /* __bc_types_INCLUDED */
177 /* Define the uint versions actually used in Bacula */
179 #define uint8_t u_int8_t
180 #define uint16_t u_int16_t
181 #define uint32_t u_int32_t
182 #define uint64_t u_int64_t
183 #define uintmax_t u_intmax_t
186 /* Bacula time -- Unix time with microseconds */
187 #define btime_t int64_t
188 /* Unix time (time_t) widened to 64 bits */
189 #define utime_t int64_t
191 #ifndef HAVE_SOCKLEN_T
192 #define socklen_t int
195 #ifdef HAVE_OLD_SOCKOPT
196 #define sockopt_val_t char *
198 #define sockopt_val_t void *