libcdio  0.83
types.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002, 2003, 2004, 2005, 2006, 2008
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 #ifndef EXTERNAL_LIBCDIO_CONFIG_H
33 #define EXTERNAL_LIBCDIO_CONFIG_H
34 #include <cdio/cdio_config.h>
35 #endif
36 
37 #ifdef HAVE_SYS_TYPES_H
38 #include <sys/types.h>
39 #endif
40 
41  /* provide some C99 definitions */
42 
43 #if defined(HAVE_SYS_TYPES_H)
44 #include <sys/types.h>
45 #endif
46 
47 #if defined(HAVE_STDINT_H)
48 # include <stdint.h>
49 #elif defined(HAVE_INTTYPES_H)
50 # include <inttypes.h>
51 #elif defined(AMIGA) || defined(__linux__)
52  typedef u_int8_t uint8_t;
53  typedef u_int16_t uint16_t;
54  typedef u_int32_t uint32_t;
55  typedef u_int64_t uint64_t;
56 #else
57  /* warning ISO/IEC 9899:1999 <stdint.h> was missing and even <inttypes.h> */
58  /* fixme */
59 #endif /* HAVE_STDINT_H */
60 
61 typedef uint8_t ubyte;
62 
63  /* default HP/UX macros are broken */
64 #if defined(__hpux__)
65 # undef UINT16_C
66 # undef UINT32_C
67 # undef UINT64_C
68 # undef INT64_C
69 #endif
70 
71  /* if it's still not defined, take a good guess... should work for
72  most 32bit and 64bit archs */
73 
74 #ifndef UINT16_C
75 # define UINT16_C(c) c ## U
76 #endif
77 
78 #ifndef UINT32_C
79 # if defined (SIZEOF_INT) && SIZEOF_INT == 4
80 # define UINT32_C(c) c ## U
81 # elif defined (SIZEOF_LONG) && SIZEOF_LONG == 4
82 # define UINT32_C(c) c ## UL
83 # else
84 # define UINT32_C(c) c ## U
85 # endif
86 #endif
87 
88 #ifndef UINT64_C
89 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
90 # define UINT64_C(c) c ## UL
91 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
92 # define UINT64_C(c) c ## U
93 # else
94 # define UINT64_C(c) c ## ULL
95 # endif
96 #endif
97 
98 #ifndef INT64_C
99 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
100 # define INT64_C(c) c ## L
101 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
102 # define INT64_C(c) c
103 # else
104 # define INT64_C(c) c ## LL
105 # endif
106 #endif
107 
108 #ifndef __cplusplus
109 # if defined(HAVE_STDBOOL_H)
110 # include <stdbool.h>
111 # else
112  /* ISO/IEC 9899:1999 <stdbool.h> missing -- enabling workaround */
113 
114 # define false 0
115 # define true 1
116 # define bool uint8_t
117 # endif /*HAVE_STDBOOL_H*/
118 #endif /*C++*/
119 
120  /* some GCC optimizations -- gcc 2.5+ */
121 
122 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
123 #define GNUC_PRINTF( format_idx, arg_idx ) \
124  __attribute__((format (printf, format_idx, arg_idx)))
125 #define GNUC_SCANF( format_idx, arg_idx ) \
126  __attribute__((format (scanf, format_idx, arg_idx)))
127 #define GNUC_FORMAT( arg_idx ) \
128  __attribute__((format_arg (arg_idx)))
129 #define GNUC_NORETURN \
130  __attribute__((noreturn))
131 #define GNUC_CONST \
132  __attribute__((const))
133 #define GNUC_UNUSED \
134  __attribute__((unused))
135 #define GNUC_PACKED \
136  __attribute__((packed))
137 #else /* !__GNUC__ */
138 #define GNUC_PRINTF( format_idx, arg_idx )
139 #define GNUC_SCANF( format_idx, arg_idx )
140 #define GNUC_FORMAT( arg_idx )
141 #define GNUC_NORETURN
142 #define GNUC_CONST
143 #define GNUC_UNUSED
144 #define GNUC_PACKED
145 #endif /* !__GNUC__ */
146 
147 #if defined(__GNUC__)
148  /* for GCC we try to use GNUC_PACKED */
149 # define PRAGMA_BEGIN_PACKED
150 # define PRAGMA_END_PACKED
151 #elif defined(HAVE_ISOC99_PRAGMA)
152  /* should work with most EDG-frontend based compilers */
153 # define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
154 # define PRAGMA_END_PACKED _Pragma("pack()")
155 #else /* neither gcc nor _Pragma() available... */
156  /* ...so let's be naive and hope the regression testsuite is run... */
157 # define PRAGMA_BEGIN_PACKED
158 # define PRAGMA_END_PACKED
159 #endif
160 
161  /*
162  * user directed static branch prediction gcc 2.96+
163  */
164 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
165 # define GNUC_LIKELY(x) __builtin_expect((x),true)
166 # define GNUC_UNLIKELY(x) __builtin_expect((x),false)
167 #else
168 # define GNUC_LIKELY(x) (x)
169 # define GNUC_UNLIKELY(x) (x)
170 #endif
171 
172 #ifndef NULL
173 # define NULL ((void*) 0)
174 #endif
175 
176  /* our own offsetof()-like macro */
177 #define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
178 
194  struct msf_s {
195  uint8_t m, s, f; /* BCD encoded! */
196  } GNUC_PACKED;
198 
199  typedef struct msf_s msf_t;
200 
201 #define msf_t_SIZEOF 3
202 
209  typedef char cdio_utf8_t;
210 
211  typedef enum {
212  nope = 0,
213  yep = 1,
214  dunno = 2
215  } bool_3way_t;
216 
217  /* type used for bit-fields in structs (1 <= bits <= 8) */
218 #if defined(__GNUC__)
219  /* this is strict ISO C99 which allows only 'unsigned int', 'signed
220  int' and '_Bool' explicitly as bit-field type */
221  typedef unsigned int bitfield_t;
222 #else
223  /* other compilers might increase alignment requirements to match the
224  'unsigned int' type -- fixme: find out how unalignment accesses can
225  be pragma'ed on non-gcc compilers */
226  typedef uint8_t bitfield_t;
227 #endif
228 
234  typedef int32_t lba_t;
235 
241  typedef int32_t lsn_t;
242 
243  /* Address in either MSF or logical format */
245  {
247  lba_t lba;
248  };
249 
251  typedef uint8_t track_t;
252 
254  typedef uint8_t session_t;
255 
259 #define CDIO_INVALID_SESSION 0xFF
260 
266 #define CDIO_INVALID_LBA -45301
267 
271 #define CDIO_INVALID_LSN CDIO_INVALID_LBA
272 
277 #define CDIO_MCN_SIZE 13
278 
283  typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
284 
285 
289 #define CDIO_ISRC_SIZE 12
290 
295  typedef char cdio_isrc_t[CDIO_ISRC_SIZE+1];
296 
297  typedef int cdio_fs_anal_t;
298 
303  typedef enum {
312 
313 #ifdef __cplusplus
314 }
315 #endif /* __cplusplus */
316 
317 #endif /* __CDIO_TYPES_H__ */
318 
319 
320 /*
321  * Local variables:
322  * c-file-style: "gnu"
323  * tab-width: 8
324  * indent-tabs-mode: nil
325  * End:
326  */

Generated for libcdio by doxygen 1.8.1.1