From b60382d7acdd10c374868193fc64bcf7e89a092d Mon Sep 17 00:00:00 2001 From: thor Date: Mon, 16 Sep 2013 23:43:23 +0000 Subject: [PATCH] LFS aliases of coure weren't really right yet. One needs to avoid the off_t definitions altogether. Just redeclare the aliased functions using alias_t just before aliasing. Difficult testing this ... as things don't actually break necessarily if that is not done properly. git-svn-id: svn://scm.orgis.org/mpg123/trunk@3399 35dc7657-300d-0410-a2e5-dc2837fedb53 --- src/libmpg123/abi_align.h | 39 +++++++++++ src/libmpg123/lfs_alias.c | 112 +++++++++++-------------------- src/libmpg123/mpg123lib_intern.h | 24 +------ 3 files changed, 78 insertions(+), 97 deletions(-) create mode 100644 src/libmpg123/abi_align.h diff --git a/src/libmpg123/abi_align.h b/src/libmpg123/abi_align.h new file mode 100644 index 00000000..42222a12 --- /dev/null +++ b/src/libmpg123/abi_align.h @@ -0,0 +1,39 @@ +/* + mpg123lib_intern: Common non-public stuff for libmpg123 + + copyright 1995-2008 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 + + derived from the old mpg123.h +*/ + +#ifndef MPG123_H_ABI_ALIGN +#define MPG123_H_ABI_ALIGN + +#include "config.h" + +/* ABI conformance for other compilers. + mpg123 needs 16byte-aligned stack for SSE and friends. + gcc provides that, but others don't necessarily. */ +#ifdef ABI_ALIGN_FUN +#ifndef attribute_align_arg +#if defined(__GNUC__) && (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__>1) +# define attribute_align_arg __attribute__((force_align_arg_pointer)) +/* The gcc that can align the stack does not need the check... nor does it work with gcc 4.3+, anyway. */ +#else + +# define attribute_align_arg +/* Other compilers get code to catch misaligned stack. + Well, except Sun Studio, which accepts the aligned attribute but does not honor it. */ +#if !defined(__SUNPRO_C) +# define NEED_ALIGNCHECK +#endif + +#endif +#endif +#else +#define attribute_align_arg +/* We won't try the align check... */ +#endif + +#endif diff --git a/src/libmpg123/lfs_alias.c b/src/libmpg123/lfs_alias.c index da42a792..864b4fbb 100644 --- a/src/libmpg123/lfs_alias.c +++ b/src/libmpg123/lfs_alias.c @@ -21,11 +21,19 @@ 1. mpg123_bla_32 alias for mpg123_bla (native) 2. mpg123_bla alias for mpg123_bla_32 (wrapper) Same for 64 bits. Confusing, I know. It sucks. + + Note that the mpg123 header is _not_ used here to avoid definition with whacky off_t. + The aliases are always about arguments of native alias_t type. This can be off_t, but + on Linux/x86, this is long int. The off_t declarations in mpg123.h confuse things, + so reproduce definitions for the wrapper functions in that case. The definitions are + pulled by an inline Perl script in any case ... no need to copy anything manually! + As a benefit, one can skip undefining possible largefile namings. */ #include "config.h" -/* Hack for Solaris: Some system headers included from compat.h might force _FILE_OFFSET_BITS. Need to follow that here. */ +/* Hack for Solaris: Some system headers included from compat.h might force _FILE_OFFSET_BITS. Need to follow that here. + Also, want it around to have types defined. */ #include "compat.h" #ifndef LFS_ALIAS_BITS @@ -39,10 +47,6 @@ #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) @@ -50,10 +54,6 @@ #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) @@ -61,8 +61,13 @@ #endif -/* Now get the rest of the infrastructure on speed, namely attribute_align_arg, to stay safe. */ -#include "mpg123lib_intern.h" +/* Copy of necessary definitions, actually just forward declarations. */ +struct mpg123_handle_struct; +typedef struct mpg123_handle_struct mpg123_handle; + + +/* Get attribute_align_arg, to stay safe. */ +#include "abi_align.h" /* Extract the list of functions we need wrappers for, pregenerating the wrappers for simple cases (inline script for nedit): @@ -85,9 +90,7 @@ if(/^\s*EXPORT\s+(\S+)\s+(mpg123_\S+)\((.*)\);\s*$/) $nargs = "Human: figure me out." if($nargs =~ /\(/); print < 4 || __GNUC__ == 4 && __GNUC_MINOR__>1) -# define attribute_align_arg __attribute__((force_align_arg_pointer)) -/* The gcc that can align the stack does not need the check... nor does it work with gcc 4.3+, anyway. */ -#else - -# define attribute_align_arg -/* Other compilers get code to catch misaligned stack. - Well, except Sun Studio, which accepts the aligned attribute but does not honor it. */ -#if !defined(__SUNPRO_C) -# define NEED_ALIGNCHECK -#endif - -#endif -#endif -#else -#define attribute_align_arg -/* We won't try the align check... */ -#endif +#include "abi_align.h" /* export DLL symbols */ #if defined(WIN32) && defined(DYNAMIC_BUILD)