]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/bc_types.h
Complete port to Windows
[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-2006 Kern Sibbald
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    version 2 as amended with additional clauses defined in the
23    file LICENSE in the main source directory.
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    the file LICENSE for additional details.
29
30  */
31
32
33 #ifndef __bc_types_INCLUDED
34 #define __bc_types_INCLUDED
35
36 typedef char POOLMEM;
37
38
39 /* Types */
40
41 /* If sys/types.h does not supply intXX_t, supply them ourselves */
42 /* (or die trying) */
43
44 #ifndef HAVE_U_INT
45 typedef unsigned int u_int;
46 #endif
47
48 #ifndef HAVE_INTXX_T
49 # if (SIZEOF_CHAR == 1)
50 typedef char int8_t;
51 # else
52 #  error "8 bit int type not found."
53 # endif
54 # if (SIZEOF_SHORT_INT == 2)
55 typedef short int int16_t;
56 # else
57 #  error "16 bit int type not found."
58 # endif
59 # if (SIZEOF_INT == 4)
60 typedef int int32_t;
61 # else
62 #  error "32 bit int type not found."
63 # endif
64 #endif
65
66 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
67 #ifndef HAVE_U_INTXX_T
68 # ifdef HAVE_UINTXX_T
69 typedef uint8_t u_int8_t;
70 typedef uint16_t u_int16_t;
71 typedef uint32_t u_int32_t;
72 # define HAVE_U_INTXX_T 1
73 # else
74 #  if (SIZEOF_CHAR == 1)
75 typedef unsigned char u_int8_t;
76 #  else
77 #   error "8 bit int type not found. Required!"
78 #  endif
79 #  if (SIZEOF_SHORT_INT == 2)
80 typedef unsigned short int u_int16_t;
81 #  else
82 #   error "16 bit int type not found. Required!"
83 #  endif
84 #  if (SIZEOF_INT == 4)
85 typedef unsigned int u_int32_t;
86 #  else
87 #   error "32 bit int type not found. Required!"
88 #  endif
89 # endif
90 #endif
91
92 /* 64-bit types */
93 #ifndef HAVE_INT64_T
94 # if (SIZEOF_LONG_LONG_INT == 8)
95 typedef long long int int64_t;
96 #   define HAVE_INT64_T 1
97 # else
98 #  if (SIZEOF_LONG_INT == 8)
99 typedef long int int64_t;
100 #   define HAVE_INT64_T 1
101 #  endif
102 # endif
103 #endif
104
105 #ifndef HAVE_INTMAX_T
106 # ifdef HAVE_INT64_T
107 typedef int64_t intmax_t;
108 # else
109 #   error "64 bit type not found. Required!"
110 # endif
111 #endif
112
113 #ifndef HAVE_U_INT64_T
114 # if (SIZEOF_LONG_LONG_INT == 8)
115 typedef unsigned long long int u_int64_t;
116 #   define HAVE_U_INT64_T 1
117 # else
118 #  if (SIZEOF_LONG_INT == 8)
119 typedef unsigned long int u_int64_t;
120 #   define HAVE_U_INT64_T 1
121 #  else
122 #   error "64 bit type not found. Required!"
123 #  endif
124 # endif
125 #endif
126
127 #ifndef HAVE_U_INTMAX_T
128 # ifdef HAVE_U_INT64_T
129 typedef u_int64_t u_intmax_t;
130 # else
131 #   error "64 bit type not found. Required!"
132 # endif
133 #endif
134
135
136 /* Limits for the above types. */
137 #undef INT8_MIN
138 #undef INT8_MAX
139 #undef UINT8_MAX
140 #undef INT16_MIN
141 #undef INT16_MAX
142 #undef UINT16_MAX
143 #undef INT32_MIN
144 #undef INT32_MAX
145 #undef UINT32_MAX
146
147 #define INT8_MIN        (-127-1)
148 #define INT8_MAX        (127)
149 #define UINT8_MAX       (255u)
150 #define INT16_MIN       (-32767-1)
151 #define INT16_MAX       (32767)
152 #define UINT16_MAX      (65535u)
153 #define INT32_MIN       (-2147483647-1)
154 #define INT32_MAX       (2147483647)
155 #define UINT32_MAX      (4294967295u)
156
157 typedef double            float64_t;
158 typedef float             float32_t;
159
160 #endif /* __bc_types_INCLUDED */
161
162 /* Define the uint versions actually used in Bacula */
163 #ifndef uint8_t
164 #define uint8_t u_int8_t
165 #define uint16_t u_int16_t
166 #define uint32_t u_int32_t
167 #define uint64_t u_int64_t
168 #define uintmax_t u_intmax_t
169 #endif
170
171 /* Bacula time -- Unix time with microseconds */
172 #define btime_t int64_t
173 /* Unix time (time_t) widened to 64 bits */
174 #define utime_t int64_t
175
176 #ifndef HAVE_SOCKLEN_T
177 #define socklen_t int
178 #endif
179
180 #ifdef HAVE_OLD_SOCKOPT
181 #define sockopt_val_t char *
182 #else
183 #define sockopt_val_t void *
184 #endif