From f69d40564d69feefd884f298d4de1bfb5b486328 Mon Sep 17 00:00:00 2001 From: Solomon Peachy Date: Sun, 5 Jul 2026 07:30:19 -0400 Subject: [PATCH] rbutil: Add file missing from mspack update Change-Id: Ie764ed422c328da10e0a6c4144bf3abd30b98d68 --- utils/rbutilqt/CMakeLists.txt | 1 + utils/rbutilqt/mspack/macros.h | 64 +++++++++++++++++++++++++++ utils/rbutilqt/mspack/system-mspack.h | 49 +------------------- 3 files changed, 66 insertions(+), 48 deletions(-) create mode 100644 utils/rbutilqt/mspack/macros.h diff --git a/utils/rbutilqt/CMakeLists.txt b/utils/rbutilqt/CMakeLists.txt index 8d2374c926..60289b8ca0 100644 --- a/utils/rbutilqt/CMakeLists.txt +++ b/utils/rbutilqt/CMakeLists.txt @@ -315,6 +315,7 @@ add_library(mspack mspack/lzxc.c mspack/lzxd.c mspack/lzx.h + mspack/macros.h mspack/mspack.h mspack/mszipc.c mspack/mszipd.c diff --git a/utils/rbutilqt/mspack/macros.h b/utils/rbutilqt/mspack/macros.h new file mode 100644 index 0000000000..427b705b36 --- /dev/null +++ b/utils/rbutilqt/mspack/macros.h @@ -0,0 +1,64 @@ +/* This file is part of libmspack. + * (C) 2003-2020 Stuart Caie. + * + * libmspack is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License (LGPL) version 2.1 + * + * For further details, see the file COPYING.LIB distributed with libmspack + */ + +#ifndef MSPACK_MACROS_H +#define MSPACK_MACROS_H 1 + +/* define LD and LU as printf-format for signed and unsigned long offsets */ +#if HAVE_INTTYPES_H +# include +#else +# define PRId64 "lld" +# define PRIu64 "llu" +# define PRId32 "ld" +# define PRIu32 "lu" +#endif + +#if SIZEOF_OFF_T >= 8 +# define LD PRId64 +# define LU PRIu64 +#else +# define LD PRId32 +# define LU PRIu32 +#endif + +/* endian-neutral reading of little-endian data */ +#define __egi32(a,n) (((unsigned int) ((unsigned char *)(a))[n+3] << 24) | \ + ((unsigned int) ((unsigned char *)(a))[n+2] << 16) | \ + ((unsigned int) ((unsigned char *)(a))[n+1] << 8) | \ + ((unsigned int) ((unsigned char *)(a))[n])) +#define EndGetI64(a) (((unsigned long long int) __egi32(a,4) << 32) | __egi32(a,0)) +#define EndGetI32(a) __egi32(a,0) +#define EndGetI16(a) ((((a)[1])<<8)|((a)[0])) + +/* endian-neutral reading of big-endian data */ +#define EndGetM32(a) (((unsigned int) ((unsigned char *)(a))[0] << 24) | \ + ((unsigned int) ((unsigned char *)(a))[1] << 16) | \ + ((unsigned int) ((unsigned char *)(a))[2] << 8) | \ + ((unsigned int) ((unsigned char *)(a))[3])) +#define EndGetM16(a) ((((a)[0])<<8)|((a)[1])) + +/* D(("formatstring", args)) prints debug messages if DEBUG defined */ +#if DEBUG + /* http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html */ +# if __STDC_VERSION__ < 199901L +# if __GNUC__ >= 2 +# define __func__ __FUNCTION__ +# else +# define __func__ "" +# endif +# endif +# include +# define D(x) do { printf("%s:%d (%s) ",__FILE__, __LINE__, __func__); \ + printf x ; fputc('\n', stdout); fflush(stdout);} while (0); +#else +# define D(x) +#endif + +#endif diff --git a/utils/rbutilqt/mspack/system-mspack.h b/utils/rbutilqt/mspack/system-mspack.h index 2d9ae1747f..5c356036b4 100644 --- a/utils/rbutilqt/mspack/system-mspack.h +++ b/utils/rbutilqt/mspack/system-mspack.h @@ -20,6 +20,7 @@ extern "C" { #endif #include "mspack.h" +#include "macros.h" /* fix for problem with GCC 4 and glibc (thanks to Ville Skytta) * http://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=150429 @@ -28,24 +29,6 @@ extern "C" { # undef read #endif -#ifdef DEBUG -# include -/* Old GCCs don't have __func__, but __FUNCTION__: - * http://gcc.gnu.org/onlinedocs/gcc/Function-Names.html - */ -# if __STDC_VERSION__ < 199901L -# if __GNUC__ >= 2 -# define __func__ __FUNCTION__ -# else -# define __func__ "" -# endif -# endif -# define D(x) do { printf("%s:%d (%s) ",__FILE__, __LINE__, __func__); \ - printf x ; fputc('\n', stdout); fflush(stdout);} while (0); -#else -# define D(x) -#endif - /* CAB supports searching through files over 4GB in size, and the CHM file * format actively uses 64-bit offsets. These can only be fully supported * if the system the code runs on supports large files. If not, the library @@ -57,36 +40,6 @@ extern "C" { # include #endif -#if ((defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS >= 64) || \ - (defined(FILESIZEBITS) && FILESIZEBITS >= 64) || \ - (defined(SIZEOF_OFF_T) && SIZEOF_OFF_T >= 8) || \ - defined(_LARGEFILE_SOURCE) || defined(_LARGEFILE64_SOURCE)) -# define LARGEFILE_SUPPORT 1 -# define LD "lld" -# define LU "llu" -#else -extern const char *largefile_msg; -# define LD "ld" -# define LU "lu" -#endif - -/* endian-neutral reading of little-endian data */ -#define __egi32(a,n) ( ((((unsigned char *) a)[n+3]) << 24) | \ - ((((unsigned char *) a)[n+2]) << 16) | \ - ((((unsigned char *) a)[n+1]) << 8) | \ - ((((unsigned char *) a)[n+0]))) -#define EndGetI64(a) ((((unsigned long long int) __egi32(a,4)) << 32) | \ - ((unsigned int) __egi32(a,0))) -#define EndGetI32(a) __egi32(a,0) -#define EndGetI16(a) ((((a)[1])<<8)|((a)[0])) - -/* endian-neutral reading of big-endian data */ -#define EndGetM32(a) (((((unsigned char *) a)[0]) << 24) | \ - ((((unsigned char *) a)[1]) << 16) | \ - ((((unsigned char *) a)[2]) << 8) | \ - ((((unsigned char *) a)[3]))) -#define EndGetM16(a) ((((a)[0])<<8)|((a)[1])) - extern struct mspack_system *mspack_default_system; /* returns the length of a file opened for reading */