]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/bc_types.h
1.20 update -- kes18May02
[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  */
16 /*
17
18    Copyright (C) 2000, 2001 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
22    as published by the Free Software Foundation; either version 2
23    of 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
28    GNU General Public License for more details.
29
30    You should have received a copy of the GNU General Public License
31    along with this program; if not, write to the Free Software
32    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
33
34  */
35
36
37 #ifndef __bc_types_INCLUDED
38 #define __bc_types_INCLUDED
39
40 /* ****FIXME***** implement 64 bit file addresses ! */
41 #define faddr_t long 
42
43 #define POOLMEM char
44
45 /* Types */
46
47 /* If sys/types.h does not supply intXX_t, supply them ourselves */
48 /* (or die trying) */
49
50 #ifndef HAVE_U_INT
51 typedef unsigned int u_int;
52 #endif
53
54 #ifndef HAVE_INTXX_T
55 # if (SIZEOF_CHAR == 1)
56 typedef char int8_t;
57 # else
58 #  error "8 bit int type not found."
59 # endif
60 # if (SIZEOF_SHORT_INT == 2)
61 typedef short int int16_t;
62 # else
63 #  error "16 bit int type not found."
64 # endif
65 # if (SIZEOF_INT == 4)
66 typedef int int32_t;
67 # else
68 #  error "32 bit int type not found."
69 # endif
70 #endif
71
72 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
73 #ifndef HAVE_U_INTXX_T
74 # ifdef HAVE_UINTXX_T
75 typedef uint8_t u_int8_t;
76 typedef uint16_t u_int16_t;
77 typedef uint32_t u_int32_t;
78 # define HAVE_U_INTXX_T 1
79 # else
80 #  if (SIZEOF_CHAR == 1)
81 typedef unsigned char u_int8_t;
82 #  else
83 #   error "8 bit int type not found."
84 #  endif
85 #  if (SIZEOF_SHORT_INT == 2)
86 typedef unsigned short int u_int16_t;
87 #  else
88 #   error "16 bit int type not found."
89 #  endif
90 #  if (SIZEOF_INT == 4)
91 typedef unsigned int u_int32_t;
92 #  else
93 #   error "32 bit int type not found."
94 #  endif
95 # endif
96 #endif
97
98 /* 64-bit types */
99 #ifndef HAVE_INT64_T
100 # if (SIZEOF_LONG_LONG_INT == 8)
101 typedef long long int int64_t;
102 #   define HAVE_INT64_T 1
103 # else
104 #  if (SIZEOF_LONG_INT == 8)
105 typedef long int int64_t;
106 #   define HAVE_INT64_T 1
107 #  endif
108 # endif
109 #endif
110
111 #ifndef HAVE_INTMAX_T
112 # ifdef HAVE_INT64_T
113 typedef int64_t intmax_t;
114 # else
115 typedef int32_t intmax_t;
116 # endif
117 #endif
118
119 #ifndef HAVE_U_INT64_T
120 # if (SIZEOF_LONG_LONG_INT == 8)
121 typedef unsigned long long int u_int64_t;
122 #   define HAVE_U_INT64_T 1
123 # else
124 #  if (SIZEOF_LONG_INT == 8)
125 typedef unsigned long int u_int64_t;
126 #   define HAVE_U_INT64_T 1
127 #  endif
128 # endif
129 #endif
130
131 #ifndef HAVE_U_INTMAX_T
132 # ifdef HAVE_U_INT64_T
133 typedef u_int64_t u_intmax_t;
134 # else
135 typedef u_int32_t u_intmax_t;
136 # endif
137 #endif
138
139
140 /* Limits for the above types. */
141 #undef INT8_MIN  
142 #undef INT8_MAX  
143 #undef UINT8_MAX 
144 #undef INT16_MIN 
145 #undef INT16_MAX 
146 #undef UINT16_MAX
147 #undef INT32_MIN 
148 #undef INT32_MAX 
149 #undef UINT32_MAX
150
151 #define INT8_MIN        (-127-1)
152 #define INT8_MAX        (127)
153 #define UINT8_MAX       (255u)
154 #define INT16_MIN       (-32767-1)
155 #define INT16_MAX       (32767)
156 #define UINT16_MAX      (65535u)
157 #define INT32_MIN       (-2147483647-1)
158 #define INT32_MAX       (2147483647)
159 #define UINT32_MAX      (4294967295u)
160
161 typedef double            float64_t;
162 typedef float             float32_t;
163
164 #endif /* __bc_types_INCLUDED */
165
166 /* Define the uint versions actually used in Bacula */
167 #define uint8_t u_int8_t
168 #define uint16_t u_int16_t
169 #define uint32_t u_int32_t
170 #define uint64_t u_int64_t
171 #define uintmax_t u_intmax_t
172
173 #define btime_t uint64_t
174
175 #ifdef HAVE_CYGWIN
176 #define socklen_t int
177 #endif