Make sndfile.h independent of build system variables

Fixes <https://github.com/libsndfile/libsndfile/issues/868>.
This commit is contained in:
Jörn Heusipp 2022-09-11 14:01:11 +02:00 committed by David Seifert
parent cefd7b59df
commit bd951f9a47
10 changed files with 9 additions and 109 deletions

View File

@ -220,8 +220,6 @@ feature_summary (WHAT ALL)
configure_file (src/config.h.cmake src/config.h)
configure_file (include/sndfile.h.in include/sndfile.h)
if (INSTALL_PKGCONFIG_MODULE)
set (prefix ${CMAKE_INSTALL_PREFIX})
@ -250,8 +248,8 @@ endif ()
# Public libsndfile headers
set (sndfile_HDRS
include/sndfile.h
include/sndfile.hh
${CMAKE_CURRENT_BINARY_DIR}/include/sndfile.h
)
#

View File

@ -46,7 +46,7 @@ BUILT_SOURCES = src/test_endswap.c
SYMBOL_FILES = src/Symbols.gnu-binutils src/Symbols.darwin src/libsndfile-1.def src/Symbols.os2 src/Symbols.static
EXTRA_DIST += include/sndfile.h.in src/config.h.in src/test_endswap.tpl src/test_endswap.def \
EXTRA_DIST += src/config.h.in src/test_endswap.tpl src/test_endswap.def \
$(SYMBOL_FILES) src/create_symbols_file.py src/binheader_writef_check.py \
src/GSM610/README src/GSM610/COPYRIGHT src/GSM610/ChangeLog \
src/G72x/README src/G72x/README.original src/G72x/ChangeLog \
@ -62,8 +62,7 @@ endif
#===============================================================================
lib_LTLIBRARIES = src/libsndfile.la
include_HEADERS = include/sndfile.hh
nodist_include_HEADERS = include/sndfile.h
include_HEADERS = include/sndfile.h include/sndfile.hh
src_libsndfile_la_CFLAGS = $(EXTERNAL_XIPH_CFLAGS) $(MPEG_CFLAGS)
# MinGW requires -no-undefined if a DLL is to be built.
src_libsndfile_la_LDFLAGS = -no-undefined -version-info $(SHARED_VERSION_INFO) $(SHLIB_VERSION_ARG)

View File

@ -16,13 +16,6 @@ if (LARGE_FILES_DEFINITIONS)
add_definitions(${LARGE_FILES_DEFINITIONS})
endif ()
if (WIN32)
set(TYPEOF_SF_COUNT_T __int64)
else ()
set(TYPEOF_SF_COUNT_T int64_t)
endif ()
set (SF_COUNT_MAX 0x7fffffffffffffffll)
if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
find_package (Sndio)
elseif (NOT WIN32)
@ -121,28 +114,6 @@ if (ENABLE_TESTING)
check_type_size (void* SIZEOF_VOIDP)
endif()
if ((SIZEOF_OFF_T EQUAL 8) OR (SIZEOF_LOFF_T EQUAL 8) OR (SIZEOF_OFF64_T EQUAL 8))
set (TYPEOF_SF_COUNT_T "int64_t")
set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL")
set (SIZEOF_SF_COUNT_T 8)
else ()
if (WIN32)
set (TYPEOF_SF_COUNT_T "__int64")
set (SF_COUNT_MAX "0x7FFFFFFFFFFFFFFFLL")
set (SIZEOF_SF_COUNT_T 8)
else ()
message ("")
message ("*** The configure process has determined that this system is capable")
message ("*** of Large File Support but has not been able to find a type which")
message ("*** is an unambiguous 64 bit file offset.")
message ("*** Please contact the author to help resolve this problem.")
message ("")
message (FATAL_ERROR "Bad file offset type.")
endif ()
endif ()
check_type_size (${TYPEOF_SF_COUNT_T} SIZEOF_SF_COUNT_T)
if (NOT WIN32)
check_library_exists (m floor "" LIBM_REQUIRED)
if (LIBM_REQUIRED)

View File

@ -194,12 +194,6 @@ AC_CHECK_SIZEOF([size_t], [4])
AC_CHECK_SIZEOF([int64_t], [8])
AC_CHECK_SIZEOF([long long], [8])
dnl ====================================================================================
dnl Find an appropriate type for sf_count_t.
dnl On systems supporting files larger than 2 Gig, sf_count_t must be a 64 bit value.
dnl Unfortunately there is more than one way of ensuring this so need to do some
dnl pretty rigourous testing here.
dnl Check for common 64 bit file offset types.
AC_CHECK_SIZEOF([off_t], [1])
@ -209,25 +203,12 @@ AS_IF([test "x$enable_largefile:$ac_cv_sizeof_off_t" = "xno:8"], [
AS_CASE([$host_os],
[mingw32*], [
TYPEOF_SF_COUNT_T="__int64"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
SIZEOF_SF_COUNT_T=8
AC_DEFINE([__USE_MINGW_ANSI_STDIO], [1], [Set to 1 to use C99 printf/snprintf in MinGW.])
],
[linux-android*], [
TYPEOF_SF_COUNT_T="int64_t"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
SIZEOF_SF_COUNT_T=8
],
[
SIZEOF_SF_COUNT_T=0
AS_IF([test "x$ac_cv_sizeof_off_t" = "x8"], [
dnl If sizeof (off_t) is 8, no further checking is needed.
TYPEOF_SF_COUNT_T="int64_t"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
SIZEOF_SF_COUNT_T=8
], [
dnl Save the old sizeof (off_t) value and then unset it to see if it
dnl changes when Large File Support is enabled.
@ -246,43 +227,9 @@ AS_CASE([$host_os],
])
AC_CHECK_SIZEOF(off_t,1)
AS_IF([test "x$ac_cv_sizeof_off_t" = "x8"], [
TYPEOF_SF_COUNT_T="int64_t"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
SIZEOF_SF_COUNT_T=8
], [test "x$TYPEOF_SF_COUNT_T" = "xunknown"], [
AS_ECHO([""])
AS_ECHO(["*** The configure process has determined that this system is capable"])
AS_ECHO(["*** of Large File Support but has not been able to find a type which"])
AS_ECHO(["*** is an unambiguous 64 bit file offset."])
AS_ECHO(["*** Please contact the author to help resolve this problem."])
AS_ECHO([""])
AC_MSG_ERROR([[Bad file offset type.]])
])
])
])
AS_CASE([$host_vendor],
[vita], [
TYPEOF_SF_COUNT_T="int64_t"
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
SIZEOF_SF_COUNT_T=8
])
AS_IF([test "x$SIZEOF_SF_COUNT_T" = "x4"], [
SF_COUNT_MAX="0x7FFFFFFF"
])
AC_DEFINE_UNQUOTED([TYPEOF_SF_COUNT_T], [${TYPEOF_SF_COUNT_T}], [Set to long if unknown.])
AC_SUBST(TYPEOF_SF_COUNT_T)
AC_DEFINE_UNQUOTED([SIZEOF_SF_COUNT_T], [${SIZEOF_SF_COUNT_T}], [Set to sizeof (long) if unknown.])
AC_SUBST(SIZEOF_SF_COUNT_T)
AC_DEFINE_UNQUOTED([SF_COUNT_MAX], [${SF_COUNT_MAX}], [Set to maximum allowed value of sf_count_t type.])
AC_SUBST(SF_COUNT_MAX)
AC_TYPE_SSIZE_T
dnl ====================================================================================
@ -750,7 +697,7 @@ AC_SUBST(TEST_BINDIR)
AC_CONFIG_FILES([
Makefile Octave/Makefile
src/version-metadata.rc include/sndfile.h
src/version-metadata.rc
tests/test_wrapper.sh tests/pedantic-header-test.sh
libsndfile.spec sndfile.pc
Scripts/build-test-tarball.mk

View File

@ -55,7 +55,7 @@ to disable gcc optimisations and make debugging with gdb/ddd easier.
Add a unique identifier for the new file type.
Edit src/sndfile.h.in and find the enum containing the SF_FORMAT_XXX identifiers.
Edit src/sndfile.h and find the enum containing the SF_FORMAT_XXX identifiers.
Since you will be adding a major file type you should add your identifier to the
top part of the list where the values are above 0x10000 in value. The easiest
way to do this is to find the largest value in the list, add 0x10000 to it and

View File

@ -365,9 +365,9 @@ typedef struct sf_private_tag SNDFILE ;
** and the Microsoft compiler.
*/
typedef @TYPEOF_SF_COUNT_T@ sf_count_t ;
typedef int64_t sf_count_t ;
#ifndef SF_COUNT_MAX
#define SF_COUNT_MAX @SF_COUNT_MAX@
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
#endif

View File

@ -540,8 +540,6 @@ header_put_le_int (SF_PRIVATE *psf, int x)
psf->header.ptr [psf->header.indx++] = (x >> 24) ;
} /* header_put_le_int */
#if (SIZEOF_SF_COUNT_T == 8)
static inline void
header_put_be_8byte (SF_PRIVATE *psf, sf_count_t x)
{ psf->header.ptr [psf->header.indx++] = (x >> 56) ;
@ -566,10 +564,6 @@ header_put_le_8byte (SF_PRIVATE *psf, sf_count_t x)
psf->header.ptr [psf->header.indx++] = (x >> 56) ;
} /* header_put_le_8byte */
#else
#error "SIZEOF_SF_COUNT_T != 8"
#endif
int
psf_binheader_writef (SF_PRIVATE *psf, const char *format, ...)
{ va_list argptr ;

View File

@ -223,9 +223,6 @@
/* Define to the version of this package. */
#define PACKAGE_VERSION "@CPACK_PACKAGE_VERSION_FULL@"
/* Set to maximum allowed value of sf_count_t type. */
#define SF_COUNT_MAX @SF_COUNT_MAX@
/* The size of `double', as computed by sizeof. */
@SIZEOF_DOUBLE_CODE@
@ -253,9 +250,6 @@
/* The size of `off_t', as computed by sizeof. */
@SIZEOF_OFF_T_CODE@
/* Set to sizeof (long) if unknown. */
@SIZEOF_SF_COUNT_T_CODE@
/* The size of `short', as computed by sizeof. */
@SIZEOF_SHORT_CODE@
@ -271,9 +265,6 @@
/* The size of `wchar_t', as computed by sizeof. */
@SIZEOF_WCHAR_T_CODE@
/* Set to long if unknown. */
#define TYPEOF_SF_COUNT_T @TYPEOF_SF_COUNT_T@
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE

View File

@ -505,7 +505,7 @@ psf_is_pipe (SF_PRIVATE *psf)
static sf_count_t
psf_get_filelen_fd (int fd)
{
#if (SIZEOF_OFF_T == 4 && SIZEOF_SF_COUNT_T == 8 && HAVE_FSTAT64)
#if (SIZEOF_OFF_T == 4 && HAVE_FSTAT64)
struct stat64 statbuf ;
if (fstat64 (fd, &statbuf) == -1)

View File

@ -42,7 +42,7 @@ if test -n "@GCC_MAJOR_VERSION@" ; then
CC=`echo "@CC@" | sed "s/.*shave cc //"`
# Compile with -Werror and -pedantic.
$CC -std=c99 -Werror -pedantic -I@top_srcdir@/src -I@abs_top_builddir@/src -I@abs_top_builddir@/include -c @top_srcdir@/tests/sfversion.c -o /dev/null
$CC -std=c99 -Werror -pedantic -I@top_srcdir@/src -I@abs_top_builddir@/src -I@top_srcdir@/include -c @top_srcdir@/tests/sfversion.c -o /dev/null
# Check compiler return status.
if test $? -ne 0 ; then