Commit Graph

17 Commits

Author SHA1 Message Date
David Korth
78cb92f273 [libmspack-xenia] lzxd.c: Fix some warnings in the 32-bit (i386) MSVC build. 2025-03-31 21:55:21 -04:00
David Korth
f0647da5eb Remove CheckHiddenVisibility.cmake.
The root CMakeLists.txt has a minimum CMake version of 3.5, and
CheckHiddenVisibility.cmake's workarounds are only needed for
CMake 3.2 and earlier.

Set CMP0063 unconditionally (added in CMake 3.3) and set the
CMAKE_<LANG>_VISIBILITY_PRESET and CMAKE_VISIBILITY_INLINES_HIDDEN
variables where CHECK_HIDDEN_VISIBILITY() was called before.

There should effectively be no code changes with this commit.
2025-01-18 22:34:24 -05:00
David Korth
d470035e61 Switch to CMake's POSITION_INDEPENDENT_CODE property instead of manually adding "-fpic -fPIC".
Something changed that caused the build on Xubuntu 16.04 (32-bit) to fail:

[ 63%] Linking CXX shared library ../../lib/libromdata.so
/usr/bin/ld: read-only segment has dynamic IFUNC relocations; recompile with -fPIC
/usr/bin/ld: failed to set dynamic section sizes: Bad value
collect2: error: ld returned 1 exit status
src/libromdata/CMakeFiles/romdata.dir/build.make:3614: recipe for target 'lib/libromdata.so.6.0' failed
make[2]: *** [lib/libromdata.so.6.0] Error 1

Setting POSITION_INDEPENDENT_CODE instead of "-fpic -fPIC" fixes this.

[extlib] Correctly set properties on the 'mspack' target instead of
'libmspack'. Otherwise, libmspack won't have either EXCLUDE_FROM_ALL
or POSITION_INDEPENDENT_CODE.
2025-01-05 14:02:13 -05:00
David Korth
251d9060cf Fix and/or silence a bunch of MSVC warnings.
[libmspack-xenia] lzxd.c: Cast pointer differences to int.

[microtar] microtar.c: fwrite() and fread() return size_t.

[libcachecommon] CacheKeys.hpp: Silence C4834 and gcc -Wunused-result
for cacheKeys.c_str().

[libromdata] ELF.cpp: Cast val_dtag[] to uint32_t.

[libromdata] EXE_NE.cpp: Cast ao::uvector<> sizes to uint32_t.

[libromdata/tests] microtar_zstd.c: Cast toCopy to unsigned when passing
it to microtar functions.

[librpfile] RpFile_scsi_win32.cpp: Windows 8.1 SDK's ntddscsi.h doesn't
properly declare _NV_SEP_WRITE_CACHE_TYPE as an enum.

[librptext/tests] TextFuncsTest: Silence warnings about implicit
conversoin from double to unsigned int by only doing integer
calculations. (It's done at compile time, not runtime.)

[librptexture] PowerVR3, ValveVTF3: Explicitly cast some size_t
calculations to unsigned int.

[win32] KeyManagerTab: Explicitly cast the return value from
std::count_if() to int.
2023-07-23 13:06:53 -04:00
David Korth
ded146a6c1 [libmspack-xenia] lzxd.c: Change position_slots from unsigned int to unsigned short.
Very minor space optimization. `position_slots` is only referenced once
during lzxd initialization, so this shouldn't cause a performance issue.

Code size differences: (64-bit Gentoo Linux, gcc-12.1.0, release build, no LTO)

   text    data     bss     dec     hex filename
  14091       0       0   14091    370b ./extlib/libmspack-xenia/CMakeFiles/mspack.dir/lzxd.c.o
  14053       0       0   14053    36e5 ./extlib/libmspack-xenia/CMakeFiles/mspack.dir/lzxd.c.o
    -38       0       0     -38     -26 Difference

I would have expected the difference to be 22, since position_slots has
11 elements, but I guess reducing the size may have reduced some padding
as well.
2022-07-03 12:42:39 -04:00
David Korth
c67e06b6b2 Disable symbol visibility in several extlib modules using static linking.
PowerVR, basisu_astc, inih, libmspack-xenia, and unice68 were leaking
externally-visible symbols in the Linux builds of UI frontends.
2022-06-18 15:29:52 -04:00
David Korth
86dbf36f3e [cmake] gcc.cmake: Enable -Werror for several different format warnings.
Reference: https://fedoraproject.org/wiki/Format-Security-FAQ

-Werror=format-nonliteral is *not* enabled because there are some
legitimate uses of non-literal format strings.

Separated the warning flags into multiple variables.

Updated everything to build with this change.
2021-09-06 01:41:59 -04:00
David Korth
a1a2e0895c Set all projects to require CMake 3.0.
- Added language specifications.
- Set the top-level project version in the PROJECT() call.
- Set CMP0063 to NEW if it's available. This enables the symbol
  visibility presets on *all* target types, not just shared libraries,
  module libraries, and executables with ENABLE_EXPORTS set.
2020-06-19 18:02:04 -04:00
David Korth
ebdb96da6d [libmspack-xenia] xenia_lzx.c: Use _BitScanForward() in MinGW builds.
ffs() is not declared in headers, even though it's a gcc built-in.

extlib/libmspack-xenia/xenia_lzx.c: In function 'bit_scan_forward':
extlib/libmspack-xenia/xenia_lzx.c:39:10: warning: implicit declaration of function 'ffs' [-Wimplicit-function-declaration]
   39 |  int i = ffs(v);
      |          ^~~
extlib/libmspack-xenia/xenia_lzx.c:39:14: warning: 'ffs' argument 1 promotes to 'uint32_t' {aka 'unsigned int'} where 'int' is expected in a call to built-in function declared without prototype [-Wbuiltin-declaration-mismatch]
   39 |  int i = ffs(v);
      |              ^
<built-in>: note: built-in 'ffs' declared here
2020-03-07 16:12:16 -05:00
David Korth
844e7f85fa [libmspack-xenia] Ported some changes over from Xenia's libmspack.
Upstream changes:

[CPU] Use window size for LZX ref_data_size
71780838f0

[CPU] Properly clear LZX window
c213f7d7a3

Added xe::bit_scan_forward, referenced in these commits:

[CPU] Minor LZX code cleanup.
29665ae79c

[CPU] Fix lzx_decompress misuse of xe::bit_count.
e14639c6c0

There's also a fix for the non-Windows implementation (off-by-one).

Fixes PVS-Studio V127 (Med): An overflow of the 32-bit 'window_bits'
variable is possible inside a long cycle which utilizes a memsize-type
loop counter.
2020-01-15 22:44:32 -05:00
David Korth
2e6a37b8e1 [libmspack-xenia] Rebased to libmspack-1.9.1.
Not too many changes. Most of it is casting and `register` keywords.
2019-09-23 00:14:42 -04:00
David Korth
e4f85bbf93 Updated lots of includes using include-what-you-use. (v8.0.0)
[librpbase] TextFuncs.hpp:
- Don't #include "TextFuncs_libc.h". Anything that uses strnlen() or
  memmem() has to include this header file directly.
- Moved RP_WIS16 from config.librpbase.h to TextFuncs.hpp. This wasn't
  actually configured by cmake; it's set on Windows and unsaet on
  everything else.

[libromdata] WiiWAD.cpp: #include "librpbase/config.librpbase.h"
for ENABLE_DECRYPTION.
2019-06-09 13:37:29 -04:00
David Korth
333a1e0537 [libmspack-xenia] xenia_lzx.c: Rearrange variable declarations to fix compilation with MSVC 2010.
MSVC 2010 requires all variables to be declared before code when
compiling C code.
2019-02-02 23:57:33 -05:00
David Korth
45c09e6cc2 [libmspack-xenia] lzxd.c: Removed calls to xenia_log().
This function isn't implemented in rom-properties for obvious reasons.
2019-02-02 09:28:50 -05:00
David Korth
58154ffe2c [libmspack-xenia] xenia_lzx.c: Silenced a few -Wunused-parameter warnings.
_MODIFIED_LIBMSPACK.txt: s/compiled/compiler/
2019-02-02 00:40:24 -05:00
David Korth
bab9228cf2 [libmspack-xenia] xenia_lzx.c, xenia_lzx.h: Added Xenia's lzx_decompress() wrapper function.
Partially rewritten so it compiles as C code.

References:
- https://github.com/xenia-project/xenia/blob/master/src/xenia/cpu/lzx.cc
- https://github.com/xenia-project/xenia/blob/master/src/xenia/cpu/lzx.h

debian/copyright: Added copyright notices for these files.
2019-02-01 22:37:26 -05:00
David Korth
22ef7f5637 [extlib] libmspack-xenia: Imported libmspack code from the Xenia emulator.
This is a stripped-down version of libmspack containing only the necessary
functionality for Xbox 360 executables.

Xenia commit: e706cf0d5413c31b7e80a50411cc88cc7c71af30
License: LGPLv2.1

config.h.in: Modified for cmake; removed unnecessary checks.

debian/copyright: Added copyright information.
cmake/options.cmake: Added an ENABLE_LIBMSPACK option. (default is ON)
2019-02-01 22:17:56 -05:00