]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/bc_types.h
1f5738c37ccc09f3b3a61d67c5509aad05b3acbe
[bacula/bacula] / bacula / src / bc_types.h
1 /*
2     Integer types.  These types should be be used in all
3     contexts in which the length of an integer stored on
4     removable media must be known regardless of the
5     architecture of the platform.
6
7     Bacula types are:
8
9     int8_t,  int16_t,  int32_t,  int64_t
10     uint8_t, uint16_t, uint32_t, uint64_t
11
12     Also, we define types such as file address lengths.
13
14     Version $Id$
15
16  */
17 /*
18    Copyright (C) 2000-2004 Kern Sibbald and John Walker
19
20    This program is free software; you can redistribute it and/or
21    modify it under the terms of the GNU General Public License as
22    published by the Free Software Foundation; either version 2 of
23    the License, or (at your option) any later version.
24
25    This program is distributed in the hope that it will be useful,
26    but WITHOUT ANY WARRANTY; without even the implied warranty of
27    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28    General Public License for more details.
29
30    You should have received a copy of the GNU General Public
31    License along with this program; if not, write to the Free
32    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
33    MA 02111-1307, USA.
34
35  */
36
37
38 #ifndef __bc_types_INCLUDED
39 #define __bc_types_INCLUDED
40
41 typedef char POOLMEM;   
42
43
44 /* Types */
45
46 /* If sys/types.h does not supply intXX_t, supply them ourselves */
47 /* (or die trying) */
48
49 #ifndef HAVE_U_INT
50 typedef unsigned int u_int;
51 #endif
52
53 #ifndef HAVE_INTXX_T
54 # if (SIZEOF_CHAR == 1)
55 typedef char int8_t;
56 # else
57 #  error "8 bit int type not found."
58 # endif
59 # if (SIZEOF_SHORT_INT == 2)
60 typedef short int int16_t;
61 # else
62 #  error "16 bit int type not found."
63 # endif
64 # if (SIZEOF_INT == 4)
65 typedef int int32_t;
66 # else
67 #  error "32 bit int type not found."
68 # endif
69 #endif
70
71 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
72 #ifndef HAVE_U_INTXX_T
73 # ifdef HAVE_UINTXX_T
74 typedef uint8_t u_int8_t;
75 typedef uint16_t u_int16_t;
76 typedef uint32_t u_int32_t;
77 # define HAVE_U_INTXX_T 1
78 # else
79 #  if (SIZEOF_CHAR == 1)
80 typedef unsigned char u_int8_t;
81 #  else
82 #   error "8 bit int type not found. Required!"
83 #  endif
84 #  if (SIZEOF_SHORT_INT == 2)
85 typedef unsigned short int u_int16_t;
86 #  else
87 #   error "16 bit int type not found. Required!"
88 #  endif
89 #  if (SIZEOF_INT == 4)
90 typedef unsigned int u_int32_t;
91 #  else
92 #   error "32 bit int type not found. Required!"
93 #  endif
94 # endif
95 #endif
96
97 /* 64-bit types */
98 #ifndef HAVE_INT64_T
99 # if (SIZEOF_LONG_LONG_INT == 8)
100 typedef long long int int64_t;
101 #   define HAVE_INT64_T 1
102 # else
103 #  if (SIZEOF_LONG_INT == 8)
104 typedef long int int64_t;
105 #   define HAVE_INT64_T 1
106 #  endif
107 # endif
108 #endif
109
110 #ifndef HAVE_INTMAX_T
111 # ifdef HAVE_INT64_T
112 typedef int64_t intmax_t;
113 # else
114 #   error "64 bit type not found. Required!"
115 # endif
116 #endif
117
118 #ifndef HAVE_U_INT64_T
119 # if (SIZEOF_LONG_LONG_INT == 8)
120 typedef unsigned long long int u_int64_t;
121 #   define HAVE_U_INT64_T 1
122 # else
123 #  if (SIZEOF_LONG_INT == 8)
124 typedef unsigned long int u_int64_t;
125 #   define HAVE_U_INT64_T 1
126 #  else
127 #   error "64 bit type not found. Required!"
128 #  endif
129 # endif
130 #endif
131
132 #ifndef HAVE_U_INTMAX_T
133 # ifdef HAVE_U_INT64_T
134 typedef u_int64_t u_intmax_t;
135 # else
136 #   error "64 bit type not found. Required!"
137 # endif
138 #endif
139
140
141 /* Limits for the above types. */
142 #undef INT8_MIN  
143 #undef INT8_MAX  
144 #undef UINT8_MAX 
145 #undef INT16_MIN 
146 #undef INT16_MAX 
147 #undef UINT16_MAX
148 #undef INT32_MIN 
149 #undef INT32_MAX 
150 #undef UINT32_MAX
151
152 #define INT8_MIN        (-127-1)
153 #define INT8_MAX        (127)
154 #define UINT8_MAX       (255u)
155 #define INT16_MIN       (-32767-1)
156 #define INT16_MAX       (32767)
157 #define UINT16_MAX      (65535u)
158 #define INT32_MIN       (-2147483647-1)
159 #define INT32_MAX       (2147483647)
160 #define UINT32_MAX      (4294967295u)
161
162 typedef double            float64_t;
163 typedef float             float32_t;
164
165 #endif /* __bc_types_INCLUDED */
166
167 /* Define the uint versions actually used in Bacula */
168 #ifndef uint8_t
169 #define uint8_t u_int8_t
170 #define uint16_t u_int16_t
171 #define uint32_t u_int32_t
172 #define uint64_t u_int64_t
173 #define uintmax_t u_intmax_t
174 #endif
175
176 /* Bacula time -- Unix time with microseconds */
177 #define btime_t int64_t
178 /* Unix time (time_t) widened to 64 bits */
179 #define utime_t int64_t
180
181 #ifdef HAVE_CYGWIN
182 #define int_least16_t int32_t
183 #endif
184
185 #ifndef HAVE_SOCKLEN_T
186 #define socklen_t int
187 #endif
188
189 #ifdef HAVE_OLD_SOCKOPT
190 #define sockopt_val_t char *
191 #else
192 #define sockopt_val_t void *
193 #endif