libcdio 2.1.1.dev0
types.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2008, 2012, 2017 2019
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
29extern "C" {
30#else
31# include <stdbool.h>
32#endif /* __cplusplus */
33
34/* If <sys/types.h> is not available on your platform please
35 contact the libcdio mailing list so that we can fix it! */
36#if !defined(ARE_THERE_STILL_ENVS_WITHOUT_SYS_TYPES)
37#include <sys/types.h>
38#endif
39
40#if defined(AMIGA)
41typedef u_int8_t uint8_t;
42typedef u_int16_t uint16_t;
43typedef u_int32_t uint32_t;
44typedef u_int64_t uint64_t;
45#else
46/* If <stdint.h> is not available on your platform please
47 contact the libcdio mailing list so that we can fix it!
48 For MSVC, you can find both a public domain stdint.h and
49 inttypes.h in the MSVC/missing directory of libcdio. */
50#include <stdint.h>
51#endif
52
53typedef uint8_t ubyte;
54
55/* MSVC does not define mode_t and ssize_t by default. The way
56 to compensate for missing UNIX types is to include a custom
57 unistd.h that defines them. Such a file is provided with
58 the libcdio source, in the MSVC/missing directory */
59#if defined(_MSC_VER)
60#include <unistd.h>
61#endif
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 /* some GCC optimizations -- gcc 2.5+ */
109
110#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
111#define GNUC_PRINTF( format_idx, arg_idx ) \
112 __attribute__((format (printf, format_idx, arg_idx)))
113#define GNUC_SCANF( format_idx, arg_idx ) \
114 __attribute__((format (scanf, format_idx, arg_idx)))
115#define GNUC_FORMAT( arg_idx ) \
116 __attribute__((format_arg (arg_idx)))
117#define GNUC_NORETURN \
118 __attribute__((noreturn))
119#define GNUC_CONST \
120 __attribute__((const))
121#define GNUC_UNUSED \
122 __attribute__((unused))
123#define GNUC_PACKED \
124 __attribute__((packed))
125#else /* !__GNUC__ */
126#define GNUC_PRINTF( format_idx, arg_idx )
127#define GNUC_SCANF( format_idx, arg_idx )
128#define GNUC_FORMAT( arg_idx )
129#define GNUC_NORETURN
130#define GNUC_CONST
131#define GNUC_UNUSED
132#define GNUC_PACKED
133#endif /* !__GNUC__ */
134
135#if defined(__MINGW32__) || (defined( __clang_major__) && __clang_major__ > 9)
136# define PRAGMA_BEGIN_PACKED _Pragma("pack(push)") \
137 _Pragma("pack(1)")
138# define PRAGMA_END_PACKED _Pragma("pack(pop)")
139#elif __GNUC__ > 4 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
140 /* should work with GCC > 4.0 clang and most EDG-frontend based C
141 and C++ compilers */
142# define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
143# define PRAGMA_END_PACKED _Pragma("pack()")
144#elif defined(_MSC_VER)
145# define PRAGMA_BEGIN_PACKED __pragma(pack(push, 1))
146# define PRAGMA_END_PACKED __pragma(pack(pop))
147#else /* neither gcc nor _Pragma() available... */
148 /* ...so let's be naive and hope the regression testsuite is run... */
149# define PRAGMA_BEGIN_PACKED
150# define PRAGMA_END_PACKED
151#endif
152
153 /*
154 * user directed static branch prediction gcc 2.96+
155 */
156#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
157# define GNUC_LIKELY(x) __builtin_expect((x),true)
158# define GNUC_UNLIKELY(x) __builtin_expect((x),false)
159#else
160# define GNUC_LIKELY(x) (x)
161# define GNUC_UNLIKELY(x) (x)
162#endif
163
164#ifndef NULL
165# define NULL ((void*) 0)
166#endif
167
170#if defined(__GNUC__)
171# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
172# define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated(notice)))
173# else
174# define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated))
175# endif
176#elif defined(_MSC_VER)
177#define LIBCDIO_DEPRECATED(object, notice) __declspec(deprecated(notice)) object
178#else
179#define LIBCDIO_DEPRECATED(object, notice)
180#endif
181
183#define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
184
200 struct msf_s {
201 uint8_t m, s, f; /* BCD encoded! */
204
205 typedef struct msf_s msf_t;
206
207#define msf_t_SIZEOF 3
208
215 typedef char cdio_utf8_t;
216
217 typedef enum {
218 nope = 0,
219 yep = 1,
220 dunno = 2
222
223 /* type used for bit-fields in structs (1 <= bits <= 8) */
224#if defined(__GNUC__)
225 /* this is strict ISO C99 which allows only 'unsigned int', 'signed
226 int' and '_Bool' explicitly as bit-field type */
227 typedef unsigned int bitfield_t;
228#else
229 /* other compilers might increase alignment requirements to match the
230 'unsigned int' type -- fixme: find out how unalignment accesses can
231 be pragma'ed on non-gcc compilers */
232 typedef uint8_t bitfield_t;
233#endif
234
240 typedef int32_t lba_t;
241
247 typedef int32_t lsn_t;
248
249 /* Address in either MSF or logical format */
251 {
254 };
255
257 typedef uint8_t track_t;
258
260 typedef uint8_t session_t;
261
265#define CDIO_INVALID_SESSION 0xFF
266
272#define CDIO_INVALID_LBA -45301
273
277#define CDIO_INVALID_LSN CDIO_INVALID_LBA
278
283#define CDIO_MCN_SIZE 13
284
289 typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
290
291
295#define CDIO_ISRC_SIZE 12
296
302
303 typedef int cdio_fs_anal_t;
304
309 typedef enum {
318
319
320/* Note that this matches the free() prototype.*/
321typedef void (*CdioDataFree_t)(void *ptr);
322
323#ifdef __cplusplus
324}
325#endif /* __cplusplus */
326
327#endif /* CDIO_TYPES_H_ */
328
329
330/*
331 * Local variables:
332 * c-file-style: "gnu"
333 * tab-width: 8
334 * indent-tabs-mode: nil
335 * End:
336 */
MSF (minute/second/frame) structure.
Definition: types.h:200
uint8_t s
Definition: types.h:201
uint8_t m
Definition: types.h:201
uint8_t f
Definition: types.h:201
uint8_t session_t
Definition: types.h:260
bool_3way_t
Definition: types.h:217
@ nope
Definition: types.h:218
@ yep
Definition: types.h:219
@ dunno
Definition: types.h:220
char cdio_utf8_t
UTF-8 char definition.
Definition: types.h:215
typedefPRAGMA_END_PACKED struct msf_s msf_t
Definition: types.h:205
#define PRAGMA_BEGIN_PACKED
Definition: types.h:149
#define PRAGMA_END_PACKED
Definition: types.h:150
#define CDIO_ISRC_SIZE
Definition: types.h:295
char cdio_mcn_t[CDIO_MCN_SIZE+1]
Definition: types.h:289
uint8_t track_t
Definition: types.h:257
uint8_t bitfield_t
Definition: types.h:232
cdio_track_flag
Definition: types.h:309
@ CDIO_TRACK_FLAG_DATA
Definition: types.h:314
@ CDIO_TRACK_FLAG_PRE_EMPHASIS
Definition: types.h:311
@ CDIO_TRACK_FLAG_FOUR_CHANNEL_AUDIO
Definition: types.h:315
@ CDIO_TRACK_FLAG_SCMS
Definition: types.h:316
@ CDIO_TRACK_FLAG_COPY_PERMITTED
Definition: types.h:313
@ CDIO_TRACK_FLAG_NONE
Definition: types.h:310
#define GNUC_PACKED
Definition: types.h:132
int cdio_fs_anal_t
Definition: types.h:303
int32_t lba_t
Definition: types.h:240
int32_t lsn_t
Definition: types.h:247
#define CDIO_MCN_SIZE
Definition: types.h:283
void(* CdioDataFree_t)(void *ptr)
Definition: types.h:321
uint8_t ubyte
Definition: types.h:53
char cdio_isrc_t[CDIO_ISRC_SIZE+1]
Definition: types.h:301
Definition: types.h:251
lba_t lba
Definition: types.h:253
msf_t msf
Definition: types.h:252

Generated for libcdio by doxygen 1.9.6