]> 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     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 /* Types */
44
45 /* If sys/types.h does not supply intXX_t, supply them ourselves */
46 /* (or die trying) */
47
48 #ifndef HAVE_U_INT
49 typedef unsigned int u_int;
50 #endif
51
52 #ifndef HAVE_INTXX_T
53 # if (SIZEOF_CHAR == 1)
54 typedef char int8_t;
55 # else
56 #  error "8 bit int type not found."
57 # endif
58 # if (SIZEOF_SHORT_INT == 2)
59 typedef short int int16_t;
60 # else
61 #  error "16 bit int type not found."
62 # endif
63 # if (SIZEOF_INT == 4)
64 typedef int int32_t;
65 # else
66 #  error "32 bit int type not found."
67 # endif
68 #endif
69
70 /* If sys/types.h does not supply u_intXX_t, supply them ourselves */
71 #ifndef HAVE_U_INTXX_T
72 # ifdef HAVE_UINTXX_T
73 typedef uint8_t u_int8_t;
74 typedef uint16_t u_int16_t;
75 typedef uint32_t u_int32_t;
76 # define HAVE_U_INTXX_T 1
77 # else
78 #  if (SIZEOF_CHAR == 1)
79 typedef unsigned char u_int8_t;
80 #  else
81 #   error "8 bit int type not found."
82 #  endif
83 #  if (SIZEOF_SHORT_INT == 2)
84 typedef unsigned short int u_int16_t;
85 #  else
86 #   error "16 bit int type not found."
87 #  endif
88 #  if (SIZEOF_INT == 4)
89 typedef unsigned int u_int32_t;
90 #  else
91 #   error "32 bit int type not found."
92 #  endif
93 # endif
94 #endif
95
96 /* 64-bit types */
97 #ifndef HAVE_INT64_T
98 # if (SIZEOF_LONG_LONG_INT == 8)
99 typedef long long int int64_t;
100 #   define HAVE_INT64_T 1
101 # else
102 #  if (SIZEOF_LONG_INT == 8)
103 typedef long int int64_t;
104 #   define HAVE_INT64_T 1
105 #  endif
106 # endif
107 #endif
108
109 #ifndef HAVE_INTMAX_T
110 # ifdef HAVE_INT64_T
111 typedef int64_t intmax_t;
112 # else
113 typedef int32_t intmax_t;
114 # endif
115 #endif
116
117 #ifndef HAVE_U_INT64_T
118 # if (SIZEOF_LONG_LONG_INT == 8)
119 typedef unsigned long long int u_int64_t;
120 #   define HAVE_U_INT64_T 1
121 # else
122 #  if (SIZEOF_LONG_INT == 8)
123 typedef unsigned long int u_int64_t;
124 #   define HAVE_U_INT64_T 1
125 #  endif
126 # endif
127 #endif
128
129 #ifndef HAVE_U_INTMAX_T
130 # ifdef HAVE_U_INT64_T
131 typedef u_int64_t u_intmax_t;
132 # else
133 typedef u_int32_t u_intmax_t;
134 # endif
135 #endif
136
137
138 /* Limits for the above types. */
139 #undef INT8_MIN  
140 #undef INT8_MAX  
141 #undef UINT8_MAX 
142 #undef INT16_MIN 
143 #undef INT16_MAX 
144 #undef UINT16_MAX
145 #undef INT32_MIN 
146 #undef INT32_MAX 
147 #undef UINT32_MAX
148
149 #define INT8_MIN        (-127-1)
150 #define INT8_MAX        (127)
151 #define UINT8_MAX       (255u)
152 #define INT16_MIN       (-32767-1)
153 #define INT16_MAX       (32767)
154 #define UINT16_MAX      (65535u)
155 #define INT32_MIN       (-2147483647-1)
156 #define INT32_MAX       (2147483647)
157 #define UINT32_MAX      (4294967295u)
158
159 typedef double            float64_t;
160 typedef float             float32_t;
161
162 #endif /* __bc_types_INCLUDED */
163
164 /* Define the uint versions actually used in Bacula */
165 #define uint8_t u_int8_t
166 #define uint16_t u_int16_t
167 #define uint32_t u_int32_t
168 #define uint64_t u_int64_t
169 #define uintmax_t u_intmax_t
170
171 #define btime_t uint64_t
172
173 #ifdef HAVE_CYGWIN
174 #define socklen_t int
175 #endif