ReactOS 0.4.16-dev-109-gf4cb10f
lfs_alias.c
Go to the documentation of this file.
1/*
2 lfs_alias: Aliases to the small/native API functions with the size of long int as suffix.
3
4 copyright 2010-2020 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6 initially written by Thomas Orgis
7
8 Use case: Client code on Linux/x86-64 that defines _FILE_OFFSET_BITS to 64,
9 which is the only choice on that platform anyway. It should be no-op, but
10 prompts the platform-agnostic header of mpg123 to define API calls with the
11 corresponding suffix. This file provides the names for this case. It's cruft,
12 but glibc does it, too -- so people rely on it.
13 Oh, and it also caters for the lunatics that define _FILE_OFFSET_BITS=32 on
14 32 bit platforms. In addition, it's needed for platforms that always have
15 off_t /= long, and clients still insisting on defining _FILE_OFFSET_BITS.
16
17 Depending on use case, the aliases map to 32 (small) or 64 bit (large) offset
18 functions, to the ones from libmpg123 or the ones from lfs_wrap.
19
20 So, two basic cases:
21 1. mpg123_bla_32 alias for mpg123_bla (native)
22 2. mpg123_bla alias for mpg123_bla_32 (wrapper)
23 Same for 64 bits. Confusing, I know. It sucks.
24
25 Note that the mpg123 header is _not_ used here to avoid definition with whacky off_t.
26 The aliases are always about arguments of native alias_t type. This can be off_t, but
27 on Linux/x86, this is long int. The off_t declarations in mpg123.h confuse things,
28 so reproduce definitions for the wrapper functions in that case. The definitions are
29 pulled by an inline Perl script in any case ... no need to copy anything manually!
30 As a benefit, one can skip undefining possible largefile namings.
31*/
32
33#include "config.h"
34
35/* Hack for Solaris: Some system headers included from compat.h might force _FILE_OFFSET_BITS. Need to follow that here.
36 Also, want it around to have types defined. */
37#include "compat.h"
38
39#ifndef LFS_ALIAS_BITS
40#error "I need the count of alias bits here."
41#endif
42
43#define MACROCAT_REALLY(a, b) a ## b
44#define MACROCAT(a, b) MACROCAT_REALLY(a, b)
45
46/* This is wicked switchery: Decide which way the aliases are facing. */
47
48#if _FILE_OFFSET_BITS+0 == LFS_ALIAS_BITS
49
50/* The native functions have suffix, the aliases not. */
51#define NATIVE_SUFFIX MACROCAT(_, _FILE_OFFSET_BITS)
52#define NATIVE_NAME(func) MACROCAT(func, NATIVE_SUFFIX)
53#define ALIAS_NAME(func) func
54
55#else
56
57/* The alias functions have suffix, the native ones not. */
58#define ALIAS_SUFFIX MACROCAT(_, LFS_ALIAS_BITS)
59#define ALIAS_NAME(func) MACROCAT(func, ALIAS_SUFFIX)
60#define NATIVE_NAME(func) func
61
62#endif
63
64/* Copy of necessary definitions, actually just forward declarations. */
67
68
69/* Get attribute_align_arg, to stay safe. */
70#include "abi_align.h"
71
72/*
73 Extract the list of functions we need wrappers for, pregenerating the wrappers for simple cases (inline script for nedit):
74perl -ne '
75if(/^\s*MPG123_EXPORT\s+(\S+)\s+(mpg123_\S+)\‍((.*)\‍);\s*$/)
76{
77 my $type = $1;
78 my $name = $2;
79 my $args = $3;
80 next unless ($type =~ /off_t/ or $args =~ /off_t/ or ($name =~ /open/ and $name ne mpg123_open_feed));
81 $type =~ s/off_t/lfs_alias_t/g;
82 my @nargs = ();
83 $args =~ s/off_t/lfs_alias_t/g;
84 foreach my $a (split(/,/, $args))
85 {
86 $a =~ s/^.*\s\**([a-z_]+)$/$1/;
87 push(@nargs, $a);
88 }
89 my $nargs = join(", ", @nargs);
90 $nargs = "Human: figure me out." if($nargs =~ /\‍(/);
91 print <<EOT
92
93$type NATIVE_NAME($name)($args);
94$type attribute_align_arg ALIAS_NAME($name)($args)
95{
96 return NATIVE_NAME($name)($nargs);
97}
98EOT
99
100}' < mpg123.h.in
101*/
102
103int NATIVE_NAME(mpg123_open_fixed)( mpg123_handle *mh, const char *path
104, int channels, int encoding );
106, int channels, int encoding )
107{
109}
110
111int NATIVE_NAME(mpg123_open)(mpg123_handle *mh, const char *path);
113{
114 return NATIVE_NAME(mpg123_open)(mh, path);
115}
116
119{
120 return NATIVE_NAME(mpg123_open_fd)(mh, fd);
121}
122
123int NATIVE_NAME(mpg123_open_handle)(mpg123_handle *mh, void *iohandle);
125{
126 return NATIVE_NAME(mpg123_open_handle)(mh, iohandle);
127}
128
129int NATIVE_NAME(mpg123_decode_frame)(mpg123_handle *mh, lfs_alias_t *num, unsigned char **audio, size_t *bytes);
131{
132 return NATIVE_NAME(mpg123_decode_frame)(mh, num, audio, bytes);
133}
134
135int NATIVE_NAME(mpg123_framebyframe_decode)(mpg123_handle *mh, lfs_alias_t *num, unsigned char **audio, size_t *bytes);
137{
138 return NATIVE_NAME(mpg123_framebyframe_decode)(mh, num, audio, bytes);
139}
140
143{
144 return NATIVE_NAME(mpg123_framepos)(mh);
145}
146
149{
150 return NATIVE_NAME(mpg123_tell)(mh);
151}
152
155{
156 return NATIVE_NAME(mpg123_tellframe)(mh);
157}
158
161{
163}
164
165lfs_alias_t NATIVE_NAME(mpg123_seek)(mpg123_handle *mh, lfs_alias_t sampleoff, int whence);
167{
168 return NATIVE_NAME(mpg123_seek)(mh, sampleoff, whence);
169}
170
173{
174 return NATIVE_NAME(mpg123_feedseek)(mh, sampleoff, whence, input_offset);
175}
176
179{
180 return NATIVE_NAME(mpg123_seek_frame)(mh, frameoff, whence);
181}
182
185{
186 return NATIVE_NAME(mpg123_timeframe)(mh, sec);
187}
188
191{
192 return NATIVE_NAME(mpg123_index)(mh, offsets, step, fill);
193}
194
197{
198 return NATIVE_NAME(mpg123_set_index)(mh, offsets, step, fill);
199}
200
201int NATIVE_NAME(mpg123_position)( mpg123_handle *mh, lfs_alias_t frame_offset, lfs_alias_t buffered_bytes, lfs_alias_t *current_frame, lfs_alias_t *frames_left, double *current_seconds, double *seconds_left);
202int attribute_align_arg ALIAS_NAME(mpg123_position)( mpg123_handle *mh, lfs_alias_t frame_offset, lfs_alias_t buffered_bytes, lfs_alias_t *current_frame, lfs_alias_t *frames_left, double *current_seconds, double *seconds_left)
203{
204 return NATIVE_NAME(mpg123_position)(mh, frame_offset, buffered_bytes, current_frame, frames_left, current_seconds, seconds_left);
205}
206
209{
211}
212
215{
216 return NATIVE_NAME(mpg123_length)(mh);
217}
218
221{
223}
224
225int NATIVE_NAME(mpg123_replace_reader)(mpg123_handle *mh, ssize_t (*r_read) (int, void *, size_t), lfs_alias_t (*r_lseek)(int, lfs_alias_t, int));
227{
228 return NATIVE_NAME(mpg123_replace_reader)(mh, r_read, r_lseek);
229}
230
231int NATIVE_NAME(mpg123_replace_reader_handle)(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), lfs_alias_t (*r_lseek)(void *, lfs_alias_t, int), void (*cleanup)(void*));
232int attribute_align_arg ALIAS_NAME(mpg123_replace_reader_handle)(mpg123_handle *mh, ssize_t (*r_read) (void *, void *, size_t), lfs_alias_t (*r_lseek)(void *, lfs_alias_t, int), void (*cleanup)(void*))
233{
234 return NATIVE_NAME(mpg123_replace_reader_handle)(mh, r_read, r_lseek, cleanup);
235}
236
_STLP_MOVE_TO_STD_NAMESPACE void fill(_ForwardIter __first, _ForwardIter __last, const _Tp &__val)
Definition: _algobase.h:449
#define attribute_align_arg
Definition: abi_align.h:30
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
static void cleanup(void)
Definition: main.c:1335
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
__kernel_size_t size_t
Definition: linux.h:237
static const FxOffsetAndName offsets[]
GLsizeiptr size
Definition: glext.h:5919
GLuint GLuint num
Definition: glext.h:9618
int NATIVE_NAME() mpg123_open(mpg123_handle *mh, const char *path)
Definition: lfs_alias.c:112
int NATIVE_NAME() mpg123_open_fd(mpg123_handle *mh, int fd)
Definition: lfs_alias.c:118
int NATIVE_NAME() mpg123_open_fixed(mpg123_handle *mh, const char *path, int channels, int encoding)
Definition: lfs_alias.c:105
int NATIVE_NAME() mpg123_open_handle(mpg123_handle *mh, void *iohandle)
Definition: lfs_alias.c:124
lfs_alias_t NATIVE_NAME() mpg123_framepos(mpg123_handle *mh)
Definition: lfs_alias.c:142
lfs_alias_t NATIVE_NAME() mpg123_tell_stream(mpg123_handle *mh)
Definition: lfs_alias.c:160
lfs_alias_t NATIVE_NAME() mpg123_tellframe(mpg123_handle *mh)
Definition: lfs_alias.c:154
lfs_alias_t NATIVE_NAME() mpg123_tell(mpg123_handle *mh)
Definition: lfs_alias.c:148
lfs_alias_t NATIVE_NAME() mpg123_timeframe(mpg123_handle *mh, double sec)
Definition: lfs_alias.c:184
lfs_alias_t NATIVE_NAME() mpg123_length(mpg123_handle *mh)
Definition: lfs_alias.c:214
lfs_alias_t NATIVE_NAME() mpg123_framelength(mpg123_handle *mh)
Definition: lfs_alias.c:208
#define frame_offset
Definition: intsym.h:201
lfs_alias_t NATIVE_NAME() mpg123_seek(mpg123_handle *mh, lfs_alias_t sampleoff, int whence)
Definition: lfs_alias.c:166
lfs_alias_t NATIVE_NAME() mpg123_feedseek(mpg123_handle *mh, lfs_alias_t sampleoff, int whence, lfs_alias_t *input_offset)
Definition: lfs_alias.c:172
int NATIVE_NAME() mpg123_set_index(mpg123_handle *mh, lfs_alias_t *offsets, lfs_alias_t step, size_t fill)
Definition: lfs_alias.c:196
int NATIVE_NAME() mpg123_replace_reader(mpg123_handle *mh, ssize_t(*r_read)(int, void *, size_t), lfs_alias_t(*r_lseek)(int, lfs_alias_t, int))
Definition: lfs_alias.c:226
int NATIVE_NAME() mpg123_decode_frame(mpg123_handle *mh, lfs_alias_t *num, unsigned char **audio, size_t *bytes)
Definition: lfs_alias.c:130
int NATIVE_NAME() mpg123_replace_reader_handle(mpg123_handle *mh, ssize_t(*r_read)(void *, void *, size_t), lfs_alias_t(*r_lseek)(void *, lfs_alias_t, int), void(*cleanup)(void *))
Definition: lfs_alias.c:232
#define ALIAS_NAME(func)
Definition: lfs_alias.c:53
int NATIVE_NAME() mpg123_position(mpg123_handle *mh, lfs_alias_t frame_offset, lfs_alias_t buffered_bytes, lfs_alias_t *current_frame, lfs_alias_t *frames_left, double *current_seconds, double *seconds_left)
Definition: lfs_alias.c:202
int NATIVE_NAME() mpg123_framebyframe_decode(mpg123_handle *mh, lfs_alias_t *num, unsigned char **audio, size_t *bytes)
Definition: lfs_alias.c:136
int NATIVE_NAME() mpg123_set_filesize(mpg123_handle *mh, lfs_alias_t size)
Definition: lfs_alias.c:220
int NATIVE_NAME() mpg123_index(mpg123_handle *mh, lfs_alias_t **offsets, lfs_alias_t *step, size_t *fill)
Definition: lfs_alias.c:190
#define NATIVE_NAME(func)
Definition: lfs_alias.c:52
lfs_alias_t NATIVE_NAME() mpg123_seek_frame(mpg123_handle *mh, lfs_alias_t frameoff, int whence)
Definition: lfs_alias.c:178
int This channels
Definition: rdpsnd_libao.c:37
#define lfs_alias_t
Definition: config.h:508
#define ssize_t
Definition: config.h:517
static int fd
Definition: io.c:51
off_t input_offset
Definition: frame.h:217
static char * encoding
Definition: xmllint.c:155