ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

lfs_alias.c
Go to the documentation of this file.
00001 /*
00002     lfs_alias: Aliases to the small/native API functions with the size of long int as suffix.
00003 
00004     copyright 2010 by the mpg123 project - free software under the terms of the LGPL 2.1
00005     see COPYING and AUTHORS files in distribution or http://mpg123.org
00006     initially written by Thomas Orgis
00007 
00008     Use case: Client code on Linux/x86-64 that defines _FILE_OFFSET_BITS to 64, which is the only choice on that platform anyway. It should be no-op, but prompts the platform-agnostic header of mpg123 to define API calls with the corresponding suffix.
00009     This file provides the names for this case. It's cruft, but glibc does it, too -- so people rely on it.
00010     Oh, and it also caters for the lunatics that define _FILE_OFFSET_BITS=32 on 32 bit platforms.
00011 
00012     There is also the strange case that the mpg123 build itself is configured for unnecessary _FILE_OFFSET_BITS == LFS_ALIAS_BITS =^ sizeof(long). In that case, the "native" function will have the suffix and the alias shall be provided without the suffix.
00013 
00014     So, two basic cases:
00015     1. mpg123_bla_32 alias for mpg123_bla
00016     2. mpg123_bla    alias for mpg123_bla_32
00017     Confusing, I know. It sucks.
00018 */
00019 
00020 #include "config.h"
00021 
00022 /* Hack for Solaris: Some system headers included from compat.h might force _FILE_OFFSET_BITS. Need to follow that here. */
00023 #include "compat.h"
00024 
00025 #ifndef LFS_ALIAS_BITS
00026 #error "I need the count of alias bits here."
00027 #endif
00028 
00029 #define MACROCAT_REALLY(a, b) a ## b
00030 #define MACROCAT(a, b) MACROCAT_REALLY(a, b)
00031 
00032 /* This is wicked switchery: Decide which way the aliases are facing. */
00033 
00034 #if _FILE_OFFSET_BITS+0 == LFS_ALIAS_BITS
00035 
00036 /* The native functions are actually _with_ suffix, so let the mpg123 header use large file hackery to define the correct interfaces. */
00037 #include "mpg123.h"
00038 /* Don't forget to undef the function symbols before usage... */
00039 
00040 /* The native functions have suffix, the aliases not. */
00041 #define NATIVE_SUFFIX MACROCAT(_, _FILE_OFFSET_BITS)
00042 #define NATIVE_NAME(func) MACROCAT(func, NATIVE_SUFFIX)
00043 #define ALIAS_NAME(func) func
00044 
00045 #else
00046 
00047 /* Native functions are without suffix... */
00048 #define MPG123_NO_LARGENAME
00049 #include "mpg123.h"
00050 
00051 /* The alias functions have suffix, the native ones not. */
00052 #define ALIAS_SUFFIX MACROCAT(_, LFS_ALIAS_BITS)
00053 #define ALIAS_NAME(func) MACROCAT(func, ALIAS_SUFFIX)
00054 #define NATIVE_NAME(func) func
00055 
00056 #endif
00057 
00058 /* Now get the rest of the infrastructure on speed, namely attribute_align_arg, to stay safe. */
00059 #include "mpg123lib_intern.h"
00060 
00061 /*
00062     Extract the list of functions we need wrappers for, pregenerating the wrappers for simple cases (inline script for nedit):
00063 perl -ne '
00064 if(/^\s*EXPORT\s+(\S+)\s+(mpg123_\S+)\((.*)\);\s*$/)
00065 {
00066     my $type = $1;
00067     my $name = $2;
00068     my $args = $3;
00069     next unless ($type =~ /off_t/ or $args =~ /off_t/ or ($name =~ /open/ and $name ne mpg123_open_feed));
00070     $type =~ s/off_t/long/g;
00071     my @nargs = ();
00072     $args =~ s/off_t/long/g;
00073     foreach my $a (split(/,/, $args))
00074     {
00075         $a =~ s/^.*\s\**([a-z_]+)$/$1/;
00076         push(@nargs, $a);
00077     }
00078     my $nargs = join(", ", @nargs);
00079     $nargs = "Human: figure me out." if($nargs =~ /\(/);
00080     print <<EOT
00081 
00082 ##ifdef $name
00083 ##undef $name
00084 ##endif
00085 $type attribute_align_arg ALIAS_NAME($name)($args)
00086 {
00087     return NATIVE_NAME($name)($nargs);
00088 }
00089 EOT
00090 
00091 }' < mpg123.h.in
00092 */
00093 
00094 #ifdef mpg123_open
00095 #undef mpg123_open
00096 #endif
00097 int attribute_align_arg ALIAS_NAME(mpg123_open)(mpg123_handle *mh, const char *path)
00098 {
00099     return NATIVE_NAME(mpg123_open)(mh, path);
00100 }
00101 
00102 #ifdef mpg123_open_fd
00103 #undef mpg123_open_fd
00104 #endif
00105 int attribute_align_arg ALIAS_NAME(mpg123_open_fd)(mpg123_handle *mh, int fd)
00106 {
00107     return NATIVE_NAME(mpg123_open_fd)(mh, fd);
00108 }
00109 
00110 #ifdef mpg123_open_handle
00111 #undef mpg123_open_handle
00112 #endif
00113 int attribute_align_arg ALIAS_NAME(mpg123_open_handle)(mpg123_handle *mh, void *iohandle)
00114 {
00115     return NATIVE_NAME(mpg123_open_handle)(mh, iohandle);
00116 }
00117 
00118 #ifdef mpg123_decode_frame
00119 #undef mpg123_decode_frame
00120 #endif
00121 int attribute_align_arg ALIAS_NAME(mpg123_decode_frame)(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
00122 {
00123     return NATIVE_NAME(mpg123_decode_frame)(mh, num, audio, bytes);
00124 }
00125 
00126 #ifdef mpg123_framebyframe_decode
00127 #undef mpg123_framebyframe_decode
00128 #endif
00129 int attribute_align_arg ALIAS_NAME(mpg123_framebyframe_decode)(mpg123_handle *mh, long *num, unsigned char **audio, size_t *bytes)
00130 {
00131     return NATIVE_NAME(mpg123_framebyframe_decode)(mh, num, audio, bytes);
00132 }
00133 
00134 #ifdef mpg123_tell
00135 #undef mpg123_tell
00136 #endif
00137 long attribute_align_arg ALIAS_NAME(mpg123_tell)(mpg123_handle *mh)
00138 {
00139     return NATIVE_NAME(mpg123_tell)(mh);
00140 }
00141 
00142 #ifdef mpg123_tellframe
00143 #undef mpg123_tellframe
00144 #endif
00145 long attribute_align_arg ALIAS_NAME(mpg123_tellframe)(mpg123_handle *mh)
00146 {
00147     return NATIVE_NAME(mpg123_tellframe)(mh);
00148 }
00149 
00150 #ifdef mpg123_tell_stream
00151 #undef mpg123_tell_stream
00152 #endif
00153 long attribute_align_arg ALIAS_NAME(mpg123_tell_stream)(mpg123_handle *mh)
00154 {
00155     return NATIVE_NAME(mpg123_tell_stream)(mh);
00156 }
00157 
00158 #ifdef mpg123_seek
00159 #undef mpg123_seek
00160 #endif
00161 long attribute_align_arg ALIAS_NAME(mpg123_seek)(mpg123_handle *mh, long sampleoff, int whence)
00162 {
00163     return NATIVE_NAME(mpg123_seek)(mh, sampleoff, whence);
00164 }
00165 
00166 #ifdef mpg123_feedseek
00167 #undef mpg123_feedseek
00168 #endif
00169 long attribute_align_arg ALIAS_NAME(mpg123_feedseek)(mpg123_handle *mh, long sampleoff, int whence, long *input_offset)
00170 {
00171     return NATIVE_NAME(mpg123_feedseek)(mh, sampleoff, whence, input_offset);
00172 }
00173 
00174 #ifdef mpg123_seek_frame
00175 #undef mpg123_seek_frame
00176 #endif
00177 long attribute_align_arg ALIAS_NAME(mpg123_seek_frame)(mpg123_handle *mh, long frameoff, int whence)
00178 {
00179     return NATIVE_NAME(mpg123_seek_frame)(mh, frameoff, whence);
00180 }
00181 
00182 #ifdef mpg123_timeframe
00183 #undef mpg123_timeframe
00184 #endif
00185 long attribute_align_arg ALIAS_NAME(mpg123_timeframe)(mpg123_handle *mh, double sec)
00186 {
00187     return NATIVE_NAME(mpg123_timeframe)(mh, sec);
00188 }
00189 
00190 #ifdef mpg123_index
00191 #undef mpg123_index
00192 #endif
00193 int attribute_align_arg ALIAS_NAME(mpg123_index)(mpg123_handle *mh, long **offsets, long *step, size_t *fill)
00194 {
00195     return NATIVE_NAME(mpg123_index)(mh, offsets, step, fill);
00196 }
00197 
00198 #ifdef mpg123_set_index
00199 #undef mpg123_set_index
00200 #endif
00201 int attribute_align_arg ALIAS_NAME(mpg123_set_index)(mpg123_handle *mh, long *offsets, long step, size_t fill)
00202 {
00203     return NATIVE_NAME(mpg123_set_index)(mh, offsets, step, fill);
00204 }
00205 
00206 #ifdef mpg123_position
00207 #undef mpg123_position
00208 #endif
00209 int attribute_align_arg ALIAS_NAME(mpg123_position)( mpg123_handle *mh, long frame_offset, long buffered_bytes, long *current_frame, long *frames_left, double *current_seconds, double *seconds_left)
00210 {
00211     return NATIVE_NAME(mpg123_position)(mh, frame_offset, buffered_bytes, current_frame, frames_left, current_seconds, seconds_left);
00212 }
00213 
00214 #ifdef mpg123_length
00215 #undef mpg123_length
00216 #endif
00217 long attribute_align_arg ALIAS_NAME(mpg123_length)(mpg123_handle *mh)
00218 {
00219     return NATIVE_NAME(mpg123_length)(mh);
00220 }
00221 
00222 #ifdef mpg123_set_filesize
00223 #undef mpg123_set_filesize
00224 #endif
00225 int attribute_align_arg ALIAS_NAME(mpg123_set_filesize)(mpg123_handle *mh, long size)
00226 {
00227     return NATIVE_NAME(mpg123_set_filesize)(mh, size);
00228 }
00229 
00230 #ifdef mpg123_replace_reader
00231 #undef mpg123_replace_reader
00232 #endif
00233 int attribute_align_arg ALIAS_NAME(mpg123_replace_reader)(mpg123_handle *mh, long (*r_read) (int, void *, size_t), long (*r_lseek)(int, long, int))
00234 {
00235     return NATIVE_NAME(mpg123_replace_reader)(mh, r_read, r_lseek);
00236 }
00237 
00238 #ifdef mpg123_replace_reader_handle
00239 #undef mpg123_replace_reader_handle
00240 #endif
00241 int attribute_align_arg ALIAS_NAME(mpg123_replace_reader_handle)(mpg123_handle *mh, long (*r_read) (void *, void *, size_t), long (*r_lseek)(void *, long, int), void (*cleanup)(void*))
00242 {
00243     return NATIVE_NAME(mpg123_replace_reader_handle)(mh, r_read, r_lseek, cleanup);
00244 }

Generated on Sat May 26 2012 04:33:01 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.