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