libcdio  0.91
types.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008, 2012
3  Rocky Bernstein <rocky@gnu.org>
4  Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
5 
6  This program is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
24 
25 #ifndef CDIO_TYPES_H_
26 #define CDIO_TYPES_H_
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif /* __cplusplus */
31 
32 /* If <sys/types.h> is not available on your platform please
33  contact the libcdio mailing list so that we can fix it! */
34 #if !defined(ARE_THERE_STILL_ENVS_WITHOUT_SYS_TYPES)
35 #include <sys/types.h>
36 #endif
37 
38 #if defined(AMIGA)
39 typedef u_int8_t uint8_t;
40 typedef u_int16_t uint16_t;
41 typedef u_int32_t uint32_t;
42 typedef u_int64_t uint64_t;
43 #else
44 /* If <stdint.h> is not available on your platform please
45  contact the libcdio mailing list so that we can fix it!
46  For MSVC, you can find both a public domain stdint.h and
47  inttypes.h in the MSVC/missing directory of libcdio. */
48 #if defined(_AIX) && !defined(_AIX52)
49 #include <inttypes.h>
50 #else
51 #include <stdint.h>
52 #endif
53 #endif
54 
55 typedef uint8_t ubyte;
56 
57 /* MSVC does not define mode_t and ssize_t by default. The way
58  to compensate for missing UNIX types is to include a custom
59  unistd.h that defines them. Such a file is provided with
60  the libcdio source, in the MSVC/missing directory */
61 #if defined(_MSC_VER)
62 #include <unistd.h>
63 #endif
64 
65  /* default HP/UX macros are broken */
66 #if defined(__hpux__)
67 # undef UINT16_C
68 # undef UINT32_C
69 # undef UINT64_C
70 # undef INT64_C
71 #endif
72 
73  /* if it's still not defined, take a good guess... should work for
74  most 32bit and 64bit archs */
75 
76 #ifndef UINT16_C
77 # define UINT16_C(c) c ## U
78 #endif
79 
80 #ifndef UINT32_C
81 # if defined (SIZEOF_INT) && SIZEOF_INT == 4
82 # define UINT32_C(c) c ## U
83 # elif defined (SIZEOF_LONG) && SIZEOF_LONG == 4
84 # define UINT32_C(c) c ## UL
85 # else
86 # define UINT32_C(c) c ## U
87 # endif
88 #endif
89 
90 #ifndef UINT64_C
91 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
92 # define UINT64_C(c) c ## UL
93 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
94 # define UINT64_C(c) c ## U
95 # else
96 # define UINT64_C(c) c ## ULL
97 # endif
98 #endif
99 
100 #ifndef INT64_C
101 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
102 # define INT64_C(c) c ## L
103 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
104 # define INT64_C(c) c
105 # else
106 # define INT64_C(c) c ## LL
107 # endif
108 #endif
109 
110 #ifndef __cplusplus
111 
112 /* All the stdbool.h seem to define those */
113 #ifndef __bool_true_false_are_defined
114 #define __bool_true_false_are_defined 1
115 
116 #undef bool
117 #undef true
118 #undef false
119 
120 #ifdef _Bool
121 #define bool _Bool
122 #else
123 #define bool unsigned char
124 #endif
125 #define true 1
126 #define false 0
127 
128 #endif /* __bool_true_false_are_defined */
129 #endif /*C++*/
130 
131  /* some GCC optimizations -- gcc 2.5+ */
132 
133 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
134 #define GNUC_PRINTF( format_idx, arg_idx ) \
135  __attribute__((format (printf, format_idx, arg_idx)))
136 #define GNUC_SCANF( format_idx, arg_idx ) \
137  __attribute__((format (scanf, format_idx, arg_idx)))
138 #define GNUC_FORMAT( arg_idx ) \
139  __attribute__((format_arg (arg_idx)))
140 #define GNUC_NORETURN \
141  __attribute__((noreturn))
142 #define GNUC_CONST \
143  __attribute__((const))
144 #define GNUC_UNUSED \
145  __attribute__((unused))
146 #define GNUC_PACKED \
147  __attribute__((packed))
148 #else /* !__GNUC__ */
149 #define GNUC_PRINTF( format_idx, arg_idx )
150 #define GNUC_SCANF( format_idx, arg_idx )
151 #define GNUC_FORMAT( arg_idx )
152 #define GNUC_NORETURN
153 #define GNUC_CONST
154 #define GNUC_UNUSED
155 #define GNUC_PACKED
156 #endif /* !__GNUC__ */
157 
158 #if defined(__MINGW32__)
159 # define PRAGMA_BEGIN_PACKED _Pragma("pack(push)") \
160  _Pragma("pack(1)")
161 # define PRAGMA_END_PACKED _Pragma("pack(pop)")
162 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
163  /* should work with most EDG-frontend based compilers */
164 # define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
165 # define PRAGMA_END_PACKED _Pragma("pack()")
166 #elif defined(_MSC_VER)
167 # define PRAGMA_BEGIN_PACKED __pragma(pack(push, 1))
168 # define PRAGMA_END_PACKED __pragma(pack(pop))
169 #else /* neither gcc nor _Pragma() available... */
170  /* ...so let's be naive and hope the regression testsuite is run... */
171 # define PRAGMA_BEGIN_PACKED
172 # define PRAGMA_END_PACKED
173 #endif
174 
175  /*
176  * user directed static branch prediction gcc 2.96+
177  */
178 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
179 # define GNUC_LIKELY(x) __builtin_expect((x),true)
180 # define GNUC_UNLIKELY(x) __builtin_expect((x),false)
181 #else
182 # define GNUC_LIKELY(x) (x)
183 # define GNUC_UNLIKELY(x) (x)
184 #endif
185 
186 #ifndef NULL
187 # define NULL ((void*) 0)
188 #endif
189 
192 #if defined(__GNUC__) && !defined(_AIX)
193 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
194 # define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated(notice)))
195 # else
196 # define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated))
197 # endif
198 #elif defined(_MSC_VER)
199 #define LIBCDIO_DEPRECATED(object, notice) __declspec(deprecated(notice)) object
200 #else
201 #define LIBCDIO_DEPRECATED(object, notice) object
202 #endif
203 
205 #define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
206 
222  struct msf_s {
223  uint8_t m, s, f; /* BCD encoded! */
224  } GNUC_PACKED;
226 
227  typedef struct msf_s msf_t;
228 
229 #define msf_t_SIZEOF 3
230 
237  typedef char cdio_utf8_t;
238 
239  typedef enum {
240  nope = 0,
241  yep = 1,
242  dunno = 2
243  } bool_3way_t;
244 
245  /* type used for bit-fields in structs (1 <= bits <= 8) */
246 #if defined(__GNUC__)
247  /* this is strict ISO C99 which allows only 'unsigned int', 'signed
248  int' and '_Bool' explicitly as bit-field type */
249  typedef unsigned int bitfield_t;
250 #else
251  /* other compilers might increase alignment requirements to match the
252  'unsigned int' type -- fixme: find out how unalignment accesses can
253  be pragma'ed on non-gcc compilers */
254  typedef uint8_t bitfield_t;
255 #endif
256 
262  typedef int32_t lba_t;
263 
269  typedef int32_t lsn_t;
270 
271  /* Address in either MSF or logical format */
273  {
275  lba_t lba;
276  };
277 
279  typedef uint8_t track_t;
280 
282  typedef uint8_t session_t;
283 
287 #define CDIO_INVALID_SESSION 0xFF
288 
294 #define CDIO_INVALID_LBA -45301
295 
299 #define CDIO_INVALID_LSN CDIO_INVALID_LBA
300 
305 #define CDIO_MCN_SIZE 13
306 
311  typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
312 
313 
317 #define CDIO_ISRC_SIZE 12
318 
323  typedef char cdio_isrc_t[CDIO_ISRC_SIZE+1];
324 
325  typedef int cdio_fs_anal_t;
326 
331  typedef enum {
340 
341 #ifdef __cplusplus
342 }
343 #endif /* __cplusplus */
344 
345 #endif /* CDIO_TYPES_H_ */
346 
347 
348 /*
349  * Local variables:
350  * c-file-style: "gnu"
351  * tab-width: 8
352  * indent-tabs-mode: nil
353  * End:
354  */
Definition: types.h:335
#define PRAGMA_END_PACKED
Definition: types.h:172
int cdio_fs_anal_t
Definition: types.h:325
char cdio_mcn_t[CDIO_MCN_SIZE+1]
Definition: types.h:311
Definition: types.h:240
int32_t lsn_t
Definition: types.h:269
#define PRAGMA_BEGIN_PACKED
Definition: types.h:171
Definition: types.h:272
Definition: types.h:333
uint8_t track_t
Definition: types.h:279
typedefPRAGMA_END_PACKED struct msf_s msf_t
Definition: types.h:227
uint8_t session_t
Definition: types.h:282
#define CDIO_MCN_SIZE
Definition: types.h:305
int32_t lba_t
Definition: types.h:262
Definition: types.h:332
Definition: types.h:241
Definition: types.h:337
uint8_t ubyte
Definition: types.h:55
Definition: types.h:338
uint8_t f
Definition: types.h:223
uint8_t m
Definition: types.h:223
Definition: types.h:242
#define CDIO_ISRC_SIZE
Definition: types.h:317
uint8_t s
Definition: types.h:223
char cdio_utf8_t
UTF-8 char definition.
Definition: types.h:237
lba_t lba
Definition: types.h:275
bool_3way_t
Definition: types.h:239
Definition: types.h:336
char cdio_isrc_t[CDIO_ISRC_SIZE+1]
Definition: types.h:323
MSF (minute/second/frame) structure.
Definition: types.h:222
#define GNUC_PACKED
Definition: types.h:155
cdio_track_flag
Definition: types.h:331
uint8_t bitfield_t
Definition: types.h:254
msf_t msf
Definition: types.h:274

Generated for libcdio by doxygen 1.8.6