/* lfs_alias: Aliases to the small/native API functions with the size of long int as suffix. copyright 2010 by the mpg123 project - free software under the terms of the LGPL 2.1 see COPYING and AUTHORS files in distribution or http://mpg123.org initially written by Thomas Orgis 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. This file provides the names for this case. It's cruft, but glibc does it, too -- so people rely on it. Oh, and it also caters for the lunatics that define _FILE_OFFSET_BITS=32 on 32 bit platforms. 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. So, two basic cases: 1. mpg123_bla_32 alias for mpg123_bla 2. mpg123_bla alias for mpg123_bla_32 Confusing, I know. It sucks. */ #include "config.h" /* Hack for Solaris: Some system headers included from compat.h might force _FILE_OFFSET_BITS. Need to follow that here. */ #include "compat.h" #ifndef LFS_ALIAS_BITS #error "I need the count of alias bits here." #endif #define MACROCAT_REALLY(a, b) a ## b #define MACROCAT(a, b) MACROCAT_REALLY(a, b) /* This is wicked switchery: Decide which way the aliases are facing. */ #if _FILE_OFFSET_BITS+0 == LFS_ALIAS_BITS /* The native functions are actually _with_ suffix, so let the mpg123 header use large file hackery to define the correct interfaces. */ #include "mpg123.h" /* Don't forget to undef the function symbols before usage... */ /* The native functions have suffix, the aliases not. */ #define NATIVE_SUFFIX MACROCAT(_, _FILE_OFFSET_BITS) #define NATIVE_NAME(func) MACROCAT(func, NATIVE_SUFFIX) #define ALIAS_NAME(func) func #else /* Native functions are without suffix... */ #define MPG123_NO_LARGENAME #include "mpg123.h" /* The alias functions have suffix, the native ones not. */ #define ALIAS_SUFFIX MACROCAT(_, LFS_ALIAS_BITS) #define ALIAS_NAME(func) MACROCAT(func, ALIAS_SUFFIX) #define NATIVE_NAME(func) func #endif /* Now get the rest of the infrastructure on speed, namely attribute_align_arg, to stay safe. */ #include "mpg123lib_intern.h" /* Extract the list of functions we need wrappers for, pregenerating the wrappers for simple cases (inline script for nedit): perl -ne ' if(/^\s*EXPORT\s+(\S+)\s+(mpg123_\S+)\((.*)\);\s*$/) { my $type = $1; my $name = $2; my $args = $3; next unless ($type =~ /off_t/ or $args =~ /off_t/ or ($name =~ /open/ and $name ne mpg123_open_feed)); $type =~ s/off_t/long/g; my @nargs = (); $args =~ s/off_t/long/g; foreach my $a (split(/,/, $args)) { $a =~ s/^.*\s\**([a-z_]+)$/$1/; push(@nargs, $a); } my $nargs = join(", ", @nargs); $nargs = "Human: figure me out." if($nargs =~ /\(/); print <