]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/bc_types.h
This commit was manufactured by cvs2svn to create tag
[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, 2001, 2002 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 #define mp_chr(x) x
43 #ifdef  xxxxx
44 #define mp_chr(x) ((char*)(x))
45 class POOLMEM { 
46 public:
47    POOLMEM();
48    operator char * const() { return this; }
49 };
50 #endif
51
52
53 /* Types */
54
55 /* If sys/types.h does not supply intXX_t, supply them ourselves */
56 /* (or die trying) */
57
58 #ifndef HAVE_U_INT
59 typedef unsigned int u_int;
60 #endif
61
62 #ifndef HAVE_INTXX_T
63 # if (SIZEOF_CHAR == 1)
64 typedef char int8_t;
65 # else
66 #  error "8 bit int type not found."
67 # endif
68 # if (SIZEOF_SHORT_INT == 2)
69 typedef short int int16_t;
70 # else
71 #  error "16 bit int type not found."
72 # endif
73 # if (SIZEOF_INT == 4)
74 typedef int int32_t;
75 # else
76 #  error "32 bit int type not found."
77 # endif
78 #endif
79
80 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
81 #ifndef HAVE_U_INTXX_T
82 # ifdef HAVE_UINTXX_T
83 typedef uint8_t u_int8_t;
84 typedef uint16_t u_int16_t;
85 typedef uint32_t u_int32_t;
86 # define HAVE_U_INTXX_T 1
87 # else
88 #  if (SIZEOF_CHAR == 1)
89 typedef unsigned char u_int8_t;
90 #  else
91 #   error "8 bit int type not found. Required!"
92 #  endif
93 #  if (SIZEOF_SHORT_INT == 2)
94 typedef unsigned short int u_int16_t;
95 #  else
96 #   error "16 bit int type not found. Required!"
97 #  endif
98 #  if (SIZEOF_INT == 4)
99 typedef unsigned int u_int32_t;
100 #  else
101 #   error "32 bit int type not found. Required!"
102 #  endif
103 # endif
104 #endif
105
106 /* 64-bit types */
107 #ifndef HAVE_INT64_T
108 # if (SIZEOF_LONG_LONG_INT == 8)
109 typedef long long int int64_t;
110 #   define HAVE_INT64_T 1
111 # else
112 #  if (SIZEOF_LONG_INT == 8)
113 typedef long int int64_t;
114 #   define HAVE_INT64_T 1
115 #  endif
116 # endif
117 #endif
118
119 #ifndef HAVE_INTMAX_T
120 # ifdef HAVE_INT64_T
121 typedef int64_t intmax_t;
122 # else
123 #   error "64 bit type not found. Required!"
124 # endif
125 #endif
126
127 #ifndef HAVE_U_INT64_T
128 # if (SIZEOF_LONG_LONG_INT == 8)
129 typedef unsigned long long int u_int64_t;
130 #   define HAVE_U_INT64_T 1
131 # else
132 #  if (SIZEOF_LONG_INT == 8)
133 typedef unsigned long int u_int64_t;
134 #   define HAVE_U_INT64_T 1
135 #  else
136 #   error "64 bit type not found. Required!"
137 #  endif
138 # endif
139 #endif
140
141 #ifndef HAVE_U_INTMAX_T
142 # ifdef HAVE_U_INT64_T
143 typedef u_int64_t u_intmax_t;
144 # else
145 #   error "64 bit type not found. Required!"
146 # endif
147 #endif
148
149
150 /* Limits for the above types. */
151 #undef INT8_MIN  
152 #undef INT8_MAX  
153 #undef UINT8_MAX 
154 #undef INT16_MIN 
155 #undef INT16_MAX 
156 #undef UINT16_MAX
157 #undef INT32_MIN 
158 #undef INT32_MAX 
159 #undef UINT32_MAX
160
161 #define INT8_MIN        (-127-1)
162 #define INT8_MAX        (127)
163 #define UINT8_MAX       (255u)
164 #define INT16_MIN       (-32767-1)
165 #define INT16_MAX       (32767)
166 #define UINT16_MAX      (65535u)
167 #define INT32_MIN       (-2147483647-1)
168 #define INT32_MAX       (2147483647)
169 #define UINT32_MAX      (4294967295u)
170
171 typedef double            float64_t;
172 typedef float             float32_t;
173
174 #endif /* __bc_types_INCLUDED */
175
176 /* Define the uint versions actually used in Bacula */
177 #define uint8_t u_int8_t
178 #define uint16_t u_int16_t
179 #define uint32_t u_int32_t
180 #define uint64_t u_int64_t
181 #define uintmax_t u_intmax_t
182
183 /* Bacula time -- Unix time with microseconds */
184 #define btime_t int64_t
185 /* Unix time (time_t) widened to 64 bits */
186 #define utime_t int64_t
187
188 #ifdef HAVE_CYGWIN
189 #define int_least16_t int32_t
190 #endif
191
192 #ifndef HAVE_SOCKLEN_T
193 #define socklen_t int
194 #endif
195
196 #ifdef HAVE_OLD_SOCKOPT
197 #define sockopt_val_t char *
198 #else
199 #define sockopt_val_t void *
200 #endif