From: <sv...@op...> - 2024-12-30 16:21:46
|
Author: manx Date: Mon Dec 30 17:21:32 2024 New Revision: 22640 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22640 Log: [Mod] mpg123: Modify compat.c to exclude all functionality that is not actually used by libmpg123. This solves a lot of the portability build problems with a single approach. Modified: trunk/OpenMPT/include/mpg123/OpenMPT.txt trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h trunk/OpenMPT/include/mpg123/ports/makefile/config.h trunk/OpenMPT/include/mpg123/src/compat/compat.c trunk/OpenMPT/include/mpg123/src/compat/compat.h Modified: trunk/OpenMPT/include/mpg123/OpenMPT.txt ============================================================================== --- trunk/OpenMPT/include/mpg123/OpenMPT.txt Sun Dec 29 00:01:50 2024 (r22639) +++ trunk/OpenMPT/include/mpg123/OpenMPT.txt Mon Dec 30 17:21:32 2024 (r22640) @@ -6,9 +6,10 @@ * `ports/Xcode/config.h` has been modified to let the build system set `OPT_*`. * `ports/Xcode/config.h` has been modified to `#define HAVE_DIRENT_H`. - * `src/compat/compat.c` has been modified for DJGPP compatibility. * `src/compat/compat.c` has been modified to silence MSVC static analyzer warnings. + * `src/compat/compat.c` and `src/compat/compat.c` have been modified for to + exclude unneeded functionality. * Modifications are marked by `// OpenMPT` or `/* OpenMPT */`. * Obviously, unnecessary folders and files have been removed. * For building, premake is used to generate Visual Studio project files. Modified: trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h ============================================================================== --- trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h Sun Dec 29 00:01:50 2024 (r22639) +++ trunk/OpenMPT/include/mpg123/ports/MSVC++/config.h Mon Dec 30 17:21:32 2024 (r22640) @@ -34,14 +34,23 @@ #define strncasecmp _strnicmp /* Windows/DOS */ -#define HAVE__SETMODE /* Features */ /* #define LFS_LARGEFILE_64 1 */ +/* libmpg123 does not care about signals */ #define NO_CATCHSIGNAL +/* libmpg123 does not care about directories */ +#define NO_DIR + +/* libmpg123 does not care about environment variables */ +#define NO_ENV + +/* libmpg123 does not care about file mode */ +#define NO_FILEMODE + /* We want some frame index, eh? */ #define FRAME_INDEX 1 #define INDEX_SIZE 1000 Modified: trunk/OpenMPT/include/mpg123/ports/makefile/config.h ============================================================================== --- trunk/OpenMPT/include/mpg123/ports/makefile/config.h Sun Dec 29 00:01:50 2024 (r22639) +++ trunk/OpenMPT/include/mpg123/ports/makefile/config.h Mon Dec 30 17:21:32 2024 (r22640) @@ -17,7 +17,6 @@ #if !defined(__DJGPP__) #define HAVE_SYS_SIGNAL_H 1 #endif -#define HAVE_SYS_STAT_H 1 #define HAVE_SYS_TIME_H 1 #define HAVE_SYS_TYPES_H 1 #define HAVE_UNISTD_H 1 @@ -48,18 +47,23 @@ #endif /* Windows/DOS */ -#if defined(__DJGPP__) -#define HAVE_SETMODE -#elif defined(_WIN32) -#define HAVE__SETMODE -#endif /* Features */ /* #define LFS_LARGEFILE_64 1 */ +/* libmpg123 does not care about signals */ #define NO_CATCHSIGNAL +/* libmpg123 does not care about directories */ +#define NO_DIR + +/* libmpg123 does not care about environment variables */ +#define NO_ENV + +/* libmpg123 does not care about file mode */ +#define NO_FILEMODE + /* We want some frame index, eh? */ #define FRAME_INDEX 1 #define INDEX_SIZE 1000 @@ -85,3 +89,5 @@ /* use rounding instead of trunction */ #define ACCURATE_ROUNDING 1 + +/* Platform */ Modified: trunk/OpenMPT/include/mpg123/src/compat/compat.c ============================================================================== --- trunk/OpenMPT/include/mpg123/src/compat/compat.c Sun Dec 29 00:01:50 2024 (r22639) +++ trunk/OpenMPT/include/mpg123/src/compat/compat.c Mon Dec 30 17:21:32 2024 (r22640) @@ -10,10 +10,10 @@ */ #include "config.h" -#if !defined(__DJGPP__) /* OpenMPT */ +#ifndef NO_CATCHSIGNAL /* OpenMPT */ /* This source file does need _POSIX_SOURCE to get some sigaction. */ #define _POSIX_SOURCE -#endif /* OpenMPT */ +#endif // NO_CATCHSIGNAL /* OpenMPT */ #include "compat.h" #ifdef _MSC_VER @@ -24,12 +24,14 @@ #endif #endif +#ifndef NO_DIR /* OpenMPT */ #ifdef HAVE_SYS_STAT_H # include <sys/stat.h> #endif #ifdef HAVE_DIRENT_H # include <dirent.h> #endif +#endif // NO_DIR /* OpenMPT */ /* Win32 is only supported with unicode now. These headers also cover module stuff. The WANT_WIN32_UNICODE macro is synonymous with @@ -43,6 +45,8 @@ #include "../common/debug.h" +#ifndef NO_ENV /* OpenMPT */ + #ifndef WINDOWS_UWP char *INT123_compat_getenv(const char* name) @@ -68,6 +72,8 @@ #endif +#endif // NO_ENV /* OpenMPT */ + #include "wpathconv.h" /* Always add a default permission mask in case of flags|O_CREAT. */ @@ -161,6 +167,8 @@ return fclose(stream); } +#ifndef NO_FILEMODE /* OpenMPT */ + void INT123_compat_binmode(int fd, int enable) { #if defined(HAVE__SETMODE) @@ -172,6 +180,10 @@ #endif } +#endif // NO_FILEMODE /* OpenMPT */ + +#ifndef NO_DIR /* OpenMPT */ + #ifndef WINDOWS_UWP /* @@ -431,6 +443,8 @@ #endif +#endif // NO_DIR /* OpenMPT */ + // Revisit logic of write(): // Return -1 if interrupted before any data was written, // set errno to EINTR. Any other error value is serious Modified: trunk/OpenMPT/include/mpg123/src/compat/compat.h ============================================================================== --- trunk/OpenMPT/include/mpg123/src/compat/compat.h Sun Dec 29 00:01:50 2024 (r22639) +++ trunk/OpenMPT/include/mpg123/src/compat/compat.h Mon Dec 30 17:21:32 2024 (r22640) @@ -189,12 +189,14 @@ int INT123_compat_close(int infd); int INT123_compat_fclose(FILE* stream); +#ifndef NO_FILEMODE /* OpenMPT */ /** * Setting binary mode on a descriptor, where necessary. * We do not bother with errors. This has to work. * You can enable or disable binary mode. */ void INT123_compat_binmode(int fd, int enable); +#endif // NO_FILEMODE /* OpenMPT */ /* Those do make sense in a separate file, but I chose to include them in compat.c because that's the one source whose object is shared between mpg123 and libmpg123 -- and both need the functionality internally. */ @@ -240,6 +242,8 @@ int INT123_win32_utf8_wide(const char *const mbptr, wchar_t **wptr, size_t *buflen); #endif +#ifndef NO_DIR /* OpenMPT */ + /* A little bit of path abstraction: We always work with plain char strings that usually represent POSIX-ish UTF-8 paths (something like c:/some/file @@ -288,6 +292,8 @@ The returned string is a copy that needs to be freed after use. */ char* INT123_compat_nextdir (struct compat_dir*); +#endif // NO_DIR /* OpenMPT */ + #ifdef USE_MODULES /* For keeping the path mess local, a system-specific dlopen() variant @@ -316,9 +322,11 @@ #include "../common/true.h" +#ifndef NO_CATCHSIGNAL /* OpenMPT */ #if (!defined(WIN32) || defined (__CYGWIN__)) && defined(HAVE_SIGNAL_H) void (*INT123_catchsignal(int signum, void(*handler)(int)))(int); #endif +#endif // NO_CATCHSIGNAL /* OpenMPT */ // Some ancient toolchains miss the documented errno value. #if defined(_WIN32) && !defined(EOVERFLOW) |