libcdio  0.93
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 #include <stdint.h>
49 #endif
50 
51 typedef uint8_t ubyte;
52 
53 /* MSVC does not define mode_t and ssize_t by default. The way
54  to compensate for missing UNIX types is to include a custom
55  unistd.h that defines them. Such a file is provided with
56  the libcdio source, in the MSVC/missing directory */
57 #if defined(_MSC_VER)
58 #include <unistd.h>
59 #endif
60 
61  /* default HP/UX macros are broken */
62 #if defined(__hpux__)
63 # undef UINT16_C
64 # undef UINT32_C
65 # undef UINT64_C
66 # undef INT64_C
67 #endif
68 
69  /* if it's still not defined, take a good guess... should work for
70  most 32bit and 64bit archs */
71 
72 #ifndef UINT16_C
73 # define UINT16_C(c) c ## U
74 #endif
75 
76 #ifndef UINT32_C
77 # if defined (SIZEOF_INT) && SIZEOF_INT == 4
78 # define UINT32_C(c) c ## U
79 # elif defined (SIZEOF_LONG) && SIZEOF_LONG == 4
80 # define UINT32_C(c) c ## UL
81 # else
82 # define UINT32_C(c) c ## U
83 # endif
84 #endif
85 
86 #ifndef UINT64_C
87 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
88 # define UINT64_C(c) c ## UL
89 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
90 # define UINT64_C(c) c ## U
91 # else
92 # define UINT64_C(c) c ## ULL
93 # endif
94 #endif
95 
96 #ifndef INT64_C
97 # if defined (SIZEOF_LONG) && SIZEOF_LONG == 8
98 # define INT64_C(c) c ## L
99 # elif defined (SIZEOF_INT) && SIZEOF_INT == 8
100 # define INT64_C(c) c
101 # else
102 # define INT64_C(c) c ## LL
103 # endif
104 #endif
105 
106 #ifndef __cplusplus
107 
108 /* All the stdbool.h seem to define those */
109 #ifndef __bool_true_false_are_defined
110 #define __bool_true_false_are_defined 1
111 
112 #undef bool
113 #undef true
114 #undef false
115 
116 #ifdef _Bool
117 #define bool _Bool
118 #else
119 #define bool unsigned char
120 #endif
121 #define true 1
122 #define false 0
123 
124 #endif /* __bool_true_false_are_defined */
125 #endif /*C++*/
126 
127  /* some GCC optimizations -- gcc 2.5+ */
128 
129 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
130 #define GNUC_PRINTF( format_idx, arg_idx ) \
131  __attribute__((format (printf, format_idx, arg_idx)))
132 #define GNUC_SCANF( format_idx, arg_idx ) \
133  __attribute__((format (scanf, format_idx, arg_idx)))
134 #define GNUC_FORMAT( arg_idx ) \
135  __attribute__((format_arg (arg_idx)))
136 #define GNUC_NORETURN \
137  __attribute__((noreturn))
138 #define GNUC_CONST \
139  __attribute__((const))
140 #define GNUC_UNUSED \
141  __attribute__((unused))
142 #define GNUC_PACKED \
143  __attribute__((packed))
144 #else /* !__GNUC__ */
145 #define GNUC_PRINTF( format_idx, arg_idx )
146 #define GNUC_SCANF( format_idx, arg_idx )
147 #define GNUC_FORMAT( arg_idx )
148 #define GNUC_NORETURN
149 #define GNUC_CONST
150 #define GNUC_UNUSED
151 #define GNUC_PACKED
152 #endif /* !__GNUC__ */
153 
154 #if defined(__MINGW32__)
155 # define PRAGMA_BEGIN_PACKED _Pragma("pack(push)") \
156  _Pragma("pack(1)")
157 # define PRAGMA_END_PACKED _Pragma("pack(pop)")
158 #elif defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901)
159  /* should work with most EDG-frontend based compilers */
160 # define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
161 # define PRAGMA_END_PACKED _Pragma("pack()")
162 #elif defined(_MSC_VER)
163 # define PRAGMA_BEGIN_PACKED __pragma(pack(push, 1))
164 # define PRAGMA_END_PACKED __pragma(pack(pop))
165 #else /* neither gcc nor _Pragma() available... */
166  /* ...so let's be naive and hope the regression testsuite is run... */
167 # define PRAGMA_BEGIN_PACKED
168 # define PRAGMA_END_PACKED
169 #endif
170 
171  /*
172  * user directed static branch prediction gcc 2.96+
173  */
174 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
175 # define GNUC_LIKELY(x) __builtin_expect((x),true)
176 # define GNUC_UNLIKELY(x) __builtin_expect((x),false)
177 #else
178 # define GNUC_LIKELY(x) (x)
179 # define GNUC_UNLIKELY(x) (x)
180 #endif
181 
182 #ifndef NULL
183 # define NULL ((void*) 0)
184 #endif
185 
188 #if defined(__GNUC__)
189 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
190 # define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated(notice)))
191 # else
192 # define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated))
193 # endif
194 #elif defined(_MSC_VER)
195 #define LIBCDIO_DEPRECATED(object, notice) __declspec(deprecated(notice)) object
196 #else
197 #define LIBCDIO_DEPRECATED(object, notice)
198 #endif
199 
201 #define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
202 
218  struct msf_s {
219  uint8_t m, s, f; /* BCD encoded! */
220  } GNUC_PACKED;
222 
223  typedef struct msf_s msf_t;
224 
225 #define msf_t_SIZEOF 3
226 
233  typedef char cdio_utf8_t;
234 
235  typedef enum {
236  nope = 0,
237  yep = 1,
238  dunno = 2
239  } bool_3way_t;
240 
241  /* type used for bit-fields in structs (1 <= bits <= 8) */
242 #if defined(__GNUC__)
243  /* this is strict ISO C99 which allows only 'unsigned int', 'signed
244  int' and '_Bool' explicitly as bit-field type */
245  typedef unsigned int bitfield_t;
246 #else
247  /* other compilers might increase alignment requirements to match the
248  'unsigned int' type -- fixme: find out how unalignment accesses can
249  be pragma'ed on non-gcc compilers */
250  typedef uint8_t bitfield_t;
251 #endif
252 
258  typedef int32_t lba_t;
259 
265  typedef int32_t lsn_t;
266 
267  /* Address in either MSF or logical format */
269  {
271  lba_t lba;
272  };
273 
275  typedef uint8_t track_t;
276 
278  typedef uint8_t session_t;
279 
283 #define CDIO_INVALID_SESSION 0xFF
284 
290 #define CDIO_INVALID_LBA -45301
291 
295 #define CDIO_INVALID_LSN CDIO_INVALID_LBA
296 
301 #define CDIO_MCN_SIZE 13
302 
307  typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
308 
309 
313 #define CDIO_ISRC_SIZE 12
314 
319  typedef char cdio_isrc_t[CDIO_ISRC_SIZE+1];
320 
321  typedef int cdio_fs_anal_t;
322 
327  typedef enum {
336 
337 #ifdef __cplusplus
338 }
339 #endif /* __cplusplus */
340 
341 #endif /* CDIO_TYPES_H_ */
342 
343 
344 /*
345  * Local variables:
346  * c-file-style: "gnu"
347  * tab-width: 8
348  * indent-tabs-mode: nil
349  * End:
350  */
Definition: types.h:331
#define PRAGMA_END_PACKED
Definition: types.h:168
int cdio_fs_anal_t
Definition: types.h:321
char cdio_mcn_t[CDIO_MCN_SIZE+1]
Definition: types.h:307
Definition: types.h:236
int32_t lsn_t
Definition: types.h:265
#define PRAGMA_BEGIN_PACKED
Definition: types.h:167
Definition: types.h:268
Definition: types.h:329
uint8_t track_t
Definition: types.h:275
typedefPRAGMA_END_PACKED struct msf_s msf_t
Definition: types.h:223
uint8_t session_t
Definition: types.h:278
#define CDIO_MCN_SIZE
Definition: types.h:301
int32_t lba_t
Definition: types.h:258
Definition: types.h:328
Definition: types.h:237
Definition: types.h:333
uint8_t ubyte
Definition: types.h:51
Definition: types.h:334
uint8_t f
Definition: types.h:219
uint8_t m
Definition: types.h:219
Definition: types.h:238
#define CDIO_ISRC_SIZE
Definition: types.h:313
uint8_t s
Definition: types.h:219
char cdio_utf8_t
UTF-8 char definition.
Definition: types.h:233
lba_t lba
Definition: types.h:271
bool_3way_t
Definition: types.h:235
Definition: types.h:332
char cdio_isrc_t[CDIO_ISRC_SIZE+1]
Definition: types.h:319
MSF (minute/second/frame) structure.
Definition: types.h:218
#define GNUC_PACKED
Definition: types.h:151
cdio_track_flag
Definition: types.h:327
uint8_t bitfield_t
Definition: types.h:250
msf_t msf
Definition: types.h:270