Author: manx Date: Mon Oct 28 15:03:35 2024 New Revision: 22013 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22013 Log: Merged revision(s) 21998, 22007 from trunk/OpenMPT: [Fix] mpg123: Work-around really weird "warning LNK4286: symbol 'lseek' defined in 'ucrt.lib(api-ms-win-crt-stdio-l1-1-0.dll)' is imported by 'lfs_wrap.obj'" when building for ARM64EC. See <https://sourceforge.net/p/mpg123/bugs/373/>. ........ [Var] mpg123: Update to 1.32.9-dev+r5448 (2024-10-28). ........ Modified: branches/OpenMPT-1.29/ (props changed) branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c branches/OpenMPT-1.29/include/mpg123/src/version.h Modified: branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/OpenMPT.txt Mon Oct 28 15:03:35 2024 (r22013) @@ -1,4 +1,4 @@ -libmpg123 library version 1.32.8 (2024-10-26). +libmpg123 library version 1.32.9-dev+r5448 (2024-10-28). The following changes have been made: * `ports/makefile/config.h` has been added for plain `Makefile` builds. * `ports/MSVC++/config.h` has been added for MSVC builds. Modified: branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/compat/compat.c Mon Oct 28 15:03:35 2024 (r22013) @@ -88,7 +88,7 @@ open_fallback: #endif -#if (defined(WIN32) && !defined (__CYGWIN__)) +#if defined(MPG123_COMPAT_MSVCRT_IO) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ /* Try plain old _open(), if it fails, do nothing */ ret = _open(filename, flags|_O_BINARY, _S_IREAD | _S_IWRITE); @@ -138,12 +138,16 @@ FILE* INT123_compat_fdopen(int fd, const char *mode) { +#if defined(MPG123_COMPAT_MSVCRT_IO) + return _fdopen(fd, mode); +#else return fdopen(fd, mode); +#endif } int INT123_compat_close(int infd) { -#if (defined(WIN32) && !defined (__CYGWIN__)) /* MSDN says POSIX function is deprecated beginning in Visual C++ 2005 */ +#if defined(MPG123_COMPAT_MSVCRT_IO) return _close(infd); #else return close(infd); Modified: branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/compat/compat.h Mon Oct 28 15:03:35 2024 (r22013) @@ -110,7 +110,35 @@ typedef unsigned char byte; +#if (defined(_UCRT) || defined(_MSC_VER) || (defined(__MINGW32__) || defined(__MINGW64__))) && !defined(__CYGWIN__) +#define MPG123_COMPAT_MSVCRT_IO +#endif + +#if defined(MPG123_COMPAT_MSVCRT_IO) +#if defined(_UCRT) +// needs to get checked separately from MSVC and MinGW becuase it is also used by native Clang on Windows +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif #if defined(_MSC_VER) +#if (_MSC_VER >= 1200) +// >= VC6 +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#if defined(__MINGW32__) || defined(__MINGW64__) +#if (defined(__MSVCRT__) || defined(_UCRT)) && !defined(__CRTDLL__) +#ifndef MPG123_COMPAT_MSVCRT_IO_64 +#define MPG123_COMPAT_MSVCRT_IO_64 +#endif +#endif +#endif +#endif + +#if defined(HAVE__SETMODE) || defined(HAVE_SETMODE) || defined(MPG123_COMPAT_MSVCRT_IO) // For _setmode(), at least. #include <io.h> #endif Modified: branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/include/mpg123.h Mon Oct 28 15:03:35 2024 (r22013) @@ -19,7 +19,7 @@ */ #define MPG123_API_VERSION 48 /** library patch level at client build time */ -#define MPG123_PATCHLEVEL 2 +#define MPG123_PATCHLEVEL 3 #ifndef MPG123_EXPORT /** Defines needed for MS Visual Studio(tm) DLL builds. Modified: branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/libmpg123/lfs_wrap.c Mon Oct 28 15:03:35 2024 (r22013) @@ -137,7 +137,11 @@ if(ioh->my_fd >= 0) { mdebug("closing my fd %d", ioh->my_fd); +#if defined(MPG123_COMPAT_MSVCRT_IO) + _close(ioh->my_fd); +#else close(ioh->my_fd); +#endif ioh->my_fd = -1; } } @@ -699,6 +703,35 @@ return -1; } +// Defining a wrapper to the native read to be sure the prototype matches. +// There are platforms where it is read(int, void*, unsigned int). +// We know that we read small chunks where the difference does not matter. Could +// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system +// specifics. +static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + if(count > UINT_MAX) + { + errno = EOVERFLOW; + return -1; + } + return _read(fd, buf, (unsigned int)count); +#else + return read(fd, buf, count); +#endif +} + +static off_t fallback_lseek(int fd, off_t offset, int whence) +{ +#if defined(MPG123_COMPAT_MSVCRT_IO) + // Off_t is 32 bit and does fit into long. We know that. + return _lseek(fd, (long)offset, whence); +#else + return lseek(fd, offset, whence); +#endif +} + // This is assuming an internally opened file, which usually will be // using 64 bit offsets. It keeps reading on on trivial interruptions. // I guess any file descriptor that matches the libc should work fine. @@ -730,7 +763,7 @@ } #endif errno = 0; - ptrdiff_t part = read(fd, (char*)buf+got, bytes); + ptrdiff_t part = fallback_read(fd, (char*)buf+got, bytes); if(part > 0) // == 0 is end of file { SATURATE_SUB(bytes, part, 0) @@ -755,13 +788,15 @@ struct wrap_data* ioh = handle; #ifdef LFS_LARGEFILE_64 return lseek64(ioh->fd, offset, whence); +#elif defined(MPG123_COMPAT_MSVCRT_IO_64) + return _lseeki64(ioh->fd, offset, whence); #else if(offset < OFF_MIN || offset > OFF_MAX) { errno = EOVERFLOW; return -1; } - return lseek(ioh->fd, (off_t)offset, whence); + return fallback_lseek(ioh->fd, (off_t)offset, whence); #endif } @@ -861,16 +896,6 @@ // So, native off_t reader replacement. -// Defining a wrapper to the native read to be sure the prototype matches. -// There are platforms where it is read(int, void*, unsigned int). -// We know that we read small chunks where the difference does not matter. Could -// apply specific hackery, use a common compat_read() (INT123_unintr_read()?) with system -// specifics. -static mpg123_ssize_t fallback_read(int fd, void *buf, size_t count) -{ - return read(fd, buf, count); -} - // In forced 64 bit offset mode, the only definitions of these are // the _64 ones. #ifdef FORCED_OFF_64 @@ -902,7 +927,7 @@ ioh->iotype = IO_FD; ioh->fd = -1; /* On next mpg123_open_fd(), this gets a value. */ ioh->r_read = r_read != NULL ? r_read : fallback_read; - ioh->r_lseek = r_lseek != NULL ? r_lseek : lseek; + ioh->r_lseek = r_lseek != NULL ? r_lseek : fallback_lseek; } /* The real reader replacement will happen while opening. */ Modified: branches/OpenMPT-1.29/include/mpg123/src/version.h ============================================================================== --- branches/OpenMPT-1.29/include/mpg123/src/version.h Mon Oct 28 15:02:59 2024 (r22012) +++ branches/OpenMPT-1.29/include/mpg123/src/version.h Mon Oct 28 15:03:35 2024 (r22013) @@ -16,10 +16,10 @@ // only single spaces as separator to ease parsing by build scripts #define MPG123_MAJOR 1 #define MPG123_MINOR 32 -#define MPG123_PATCH 8 +#define MPG123_PATCH 9 // Don't get too wild with that to avoid confusing m4. No brackets. // Also, it should fit well into a sane file name for the tarball. -#define MPG123_SUFFIX "" +#define MPG123_SUFFIX "-dev" #define MPG123_VERSION_CAT_REALLY(a, b, c) #a "." #b "." #c #define MPG123_VERSION_CAT(a, b, c) MPG123_VERSION_CAT_REALLY(a, b, c) |