libcdio 2.1.1
types.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2008, 2012, 2017, 2019, 2024
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#ifdef _MSC_VER
134#define __PRETTY_FUNCTION__ __FUNCSIG__
135#endif
136#endif /* !__GNUC__ */
137
138#if defined(__MINGW32__) || (defined( __clang_major__) && __clang_major__ > 9)
139# define PRAGMA_BEGIN_PACKED _Pragma("pack(push)") \
140 _Pragma("pack(1)")
141# define PRAGMA_END_PACKED _Pragma("pack(pop)")
142#elif __GNUC__ > 4 || (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
143 /* should work with GCC > 4.0 clang and most EDG-frontend based C
144 and C++ compilers */
145# define PRAGMA_BEGIN_PACKED _Pragma("pack(1)")
146# define PRAGMA_END_PACKED _Pragma("pack()")
147#elif defined(_MSC_VER)
148# define PRAGMA_BEGIN_PACKED __pragma(pack(push, 1))
149# define PRAGMA_END_PACKED __pragma(pack(pop))
150#else /* neither gcc nor _Pragma() available... */
151 /* ...so let's be naive and hope the regression testsuite is run... */
152# define PRAGMA_BEGIN_PACKED
153# define PRAGMA_END_PACKED
154#endif
155
156 /*
157 * user directed static branch prediction gcc 2.96+
158 */
159#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 95)
160# define GNUC_LIKELY(x) __builtin_expect((x),true)
161# define GNUC_UNLIKELY(x) __builtin_expect((x),false)
162#else
163# define GNUC_LIKELY(x) (x)
164# define GNUC_UNLIKELY(x) (x)
165#endif
166
167#ifndef NULL
168# define NULL ((void*) 0)
169#endif
170
173#if defined(__GNUC__)
174# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
175# define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated(notice)))
176# else
177# define LIBCDIO_DEPRECATED(object, notice) object __attribute__ ((deprecated))
178# endif
179#elif defined(_MSC_VER)
180#define LIBCDIO_DEPRECATED(object, notice) __declspec(deprecated(notice)) object
181#else
182#define LIBCDIO_DEPRECATED(object, notice)
183#endif
184
186#define __cd_offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
187
203 struct msf_s {
204 uint8_t m, s, f; /* BCD encoded! */
207
208 typedef struct msf_s msf_t;
209
210#define msf_t_SIZEOF 3
211
218 typedef char cdio_utf8_t;
219
220 typedef enum {
221 nope = 0,
222 yep = 1,
223 dunno = 2
225
226 /* type used for bit-fields in structs (1 <= bits <= 8) */
227#if defined(__GNUC__)
228 /* this is strict ISO C99 which allows only 'unsigned int', 'signed
229 int' and '_Bool' explicitly as bit-field type */
230 typedef unsigned int bitfield_t;
231#else
232 /* other compilers might increase alignment requirements to match the
233 'unsigned int' type -- fixme: find out how unalignment accesses can
234 be pragma'ed on non-gcc compilers */
235 typedef uint8_t bitfield_t;
236#endif
237
243 typedef int32_t lba_t;
244
250 typedef int32_t lsn_t;
251
252 /* Address in either MSF or logical format */
258
260 typedef uint8_t track_t;
261
263 typedef uint8_t session_t;
264
268#define CDIO_INVALID_SESSION 0xFF
269
275#define CDIO_INVALID_LBA -45301
276
280#define CDIO_INVALID_LSN CDIO_INVALID_LBA
281
286#define CDIO_MCN_SIZE 13
287
292 typedef char cdio_mcn_t[CDIO_MCN_SIZE+1];
293
294
298#define CDIO_ISRC_SIZE 12
299
305
306 typedef int cdio_fs_anal_t;
307
321
322
323/* Note that this matches the free() prototype.*/
324typedef void (*CdioDataFree_t)(void *ptr);
325
326#ifdef __cplusplus
327}
328#endif /* __cplusplus */
329
330#endif /* CDIO_TYPES_H_ */
331
332
333/*
334 * Local variables:
335 * c-file-style: "gnu"
336 * tab-width: 8
337 * indent-tabs-mode: nil
338 * End:
339 */
MSF (minute/second/frame) structure.
Definition types.h:203
uint8_t s
Definition types.h:204
uint8_t m
Definition types.h:204
uint8_t f
Definition types.h:204
uint8_t session_t
Definition types.h:263
bool_3way_t
Definition types.h:220
@ nope
Definition types.h:221
@ yep
Definition types.h:222
@ dunno
Definition types.h:223
char cdio_utf8_t
UTF-8 char definition.
Definition types.h:218
typedefPRAGMA_END_PACKED struct msf_s msf_t
Definition types.h:208
#define PRAGMA_BEGIN_PACKED
Definition types.h:152
#define PRAGMA_END_PACKED
Definition types.h:153
#define CDIO_ISRC_SIZE
Definition types.h:298
char cdio_mcn_t[CDIO_MCN_SIZE+1]
Definition types.h:292
uint8_t track_t
Definition types.h:260
uint8_t bitfield_t
Definition types.h:235
cdio_track_flag
Definition types.h:312
@ CDIO_TRACK_FLAG_DATA
Definition types.h:317
@ CDIO_TRACK_FLAG_PRE_EMPHASIS
Definition types.h:314
@ CDIO_TRACK_FLAG_FOUR_CHANNEL_AUDIO
Definition types.h:318
@ CDIO_TRACK_FLAG_SCMS
Definition types.h:319
@ CDIO_TRACK_FLAG_COPY_PERMITTED
Definition types.h:316
@ CDIO_TRACK_FLAG_NONE
Definition types.h:313
#define GNUC_PACKED
Definition types.h:132
int cdio_fs_anal_t
Definition types.h:306
int32_t lba_t
Definition types.h:243
int32_t lsn_t
Definition types.h:250
#define CDIO_MCN_SIZE
Definition types.h:286
void(* CdioDataFree_t)(void *ptr)
Definition types.h:324
uint8_t ubyte
Definition types.h:53
char cdio_isrc_t[CDIO_ISRC_SIZE+1]
Definition types.h:304
Definition types.h:254
lba_t lba
Definition types.h:256
msf_t msf
Definition types.h:255