[librpbyteswap,librptexture] If arm_neon.h isn't available, don't compile
any NEON-optimized functions.
Just in case someone wants to build rom-properties for an ancient ARM
system that was introduced before NEON...
While the main NEON instructions only operate on one vector at a time,
the load/store instructions can operate on multiple vectors.
On ARM64:
- Four vld1q_u32() intrinsics compile into two ldp instructions.
- One vld4q_u32() intrinsic compiles into one ld4 instruction.
On ARM:
- Four vld1_u32() intrinsics compile into four vld1.32 instructions.
- One vld4_u32() intrinsic compiles into one vld4.32 instruction.
Note that the st versions are identical with regards to the number of
instructions each intrinsic compiles into.
Also note that accessing the .val[] array in uint32x?x4_t is fast, since
it's compiled directly into a vector register access.
This only happened in MSVC 2022 for 32-bit ARM. (Might happen for
32-bit i386 on MSVC and gcc, too...)
src\librptexture\fileformat\GodotSTEX.cpp(1096,46): warning C4018: '<': signed/unsigned mismatch
src\librptexture\fileformat\GodotSTEX.cpp(1101,46): warning C4018: '<': signed/unsigned mismatch
This broke the MSVC 2022 arm64 build:
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(176,3): error C2360: initialization of 'shuf_mask_Swap_ARGB32' is skipped by 'case' label
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(169,36): message : see declaration of 'shuf_mask_Swap_ARGB32'
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(177,3): error C2360: initialization of 'shuf_mask_Swap_ARGB32' is skipped by 'case' label
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(169,36): message : see declaration of 'shuf_mask_Swap_ARGB32'
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(187,3): error C2360: initialization of 'shuf_mask_Swap_ARGB32' is skipped by 'case' label
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(169,36): message : see declaration of 'shuf_mask_Swap_ARGB32'
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(199,3): error C2360: initialization of 'shuf_mask_Swap_ARGB32' is skipped by 'case' label
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(169,36): message : see declaration of 'shuf_mask_Swap_ARGB32'
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(208,3): error C2361: initialization of 'shuf_mask_Swap_ARGB32' is skipped by 'default' label
src\librptexture\decoder\ImageDecoder_Linear_neon.cpp(169,36): message : see declaration of 'shuf_mask_Swap_ARGB32'
Not sure why gcc seemingly didn't care...
ImageDecoder_common.hpp: Add NEON dispatch.
[librptexture/tests] ImageDecoderLinearTest: Test NEON versions.
TODO:
- For byteswapped, use vrev instead of vtbl.
- Add 24-bit linear image decoding, and maybe 15/16-bit.
- Use 64-bit vectors on aarch32.
Ideally, we'd make it use size_t for all size parameters, but this is
old code, and doing that would require going through a lot of stuff,
so just cast it to int for now.
FIXME: unice68 is expecting fread() and fwrite() to return -1 on error,
but these functions return size_t, which is unsigned...
This ensures the bounds are checked properly, and might provide for some
optimization that isn't possible with the pointer method.
MSVC 2022's code analysis shows warning C33011:
Unchecked upper bound for enum ((this->LibRpTexture::FileFormat::d_ptr)->LibRpTexture::GodotSTEXPrivate::PixelFormat) used as index.
Fixes this warning on Android: (clang-20.1.2)
src/rp-stub/rp-stub.c:394:4: error: label followed by a declaration is a C23 extension [-Werror,-Wc23-extensions]
394 | const char *const source_file = argv[optind];
| ^
1 error generated.
clang complains about moc headers due to how automoc handles things:
In file included from build/src/kde/kf5/overlayiconplugin_rom-properties-kf5_autogen/mocs_compilation.cpp:2:
build/src/kde/kf5/overlayiconplugin_rom-properties-kf5_autogen/BKZOEHIFDQ/moc_OverlayIconPluginKF5.cpp:1340:17: error: using namespace directive in global context in header [-Werror,-Wheader-hygiene]
1340 | using namespace RomPropertiesKF5;
| ^
1 error generated.
clang complained about unused typedefs, since we only used the enum values
and not the typedef name.
enum class does require some extra casting, but it works better here.
Fixes these clang warnings:
src/libromdata/Other/EXE_manifest.cpp:273:4: error: unused typedef 'WindowsSettings_t' [-Werror,-Wunused-local-typedef]
273 | } WindowsSettings_t;
| ^
src/libromdata/Other/EXE_manifest.cpp:346:4: error: unused typedef 'OS_Compatibility_t' [-Werror,-Wunused-local-typedef]
346 | } OS_Compatibility_t;
| ^
2 errors generated.
It isn't needed in Wim_p.hpp, and this fixes a clang warning:
In file included from src/libromdata/Media/Wim.cpp:13:
src/libromdata/Media/Wim_p.hpp:21:17: error: using namespace directive in global context in header [-Werror,-Wheader-hygiene]
21 | using namespace pugi;
| ^
1 error generated.
This clang warning is currently "intentional", though I might rename the
not-virtual open() function later:
In file included from src/libromdata/Handheld/Nintendo3DS.cpp:14:
In file included from src/libromdata/Handheld/Nintendo3DS_p.hpp:19:
src/libromdata/Handheld/../disc/NCCHReader.hpp:193:24: error: 'LibRomData::NCCHReader::open' hides overloaded virtual function [-Werror,-Woverloaded-virtual]
193 | LibRpFile::IRpFilePtr open(int section, const char *filename);
| ^
src/libromdata/../librpbase/disc/IPartition.hpp:104:32: note: hidden overloaded virtual function 'LibRpBase::IPartition::open' declared here: different number of parameters (1 vs 2)
104 | virtual LibRpFile::IRpFilePtr open(const char *filename);
| ^
1 error generated.
It's not used for JSON output, since the JSON output has *all* of the
localized strings for RFT_STRING_MULTI fields (and multi-language
RFT_LISTDATA fields).
Fixes this clang warning:
In file included from src/librpbase/TextOut_json.cpp:11:
src/librpbase/TextOut.hpp:52:11: error: private field 'lc' is not used [-Werror,-Wunused-private-field]
52 | uint32_t lc;
| ^
1 error generated.
In file included from src/libcachecommon/CacheKeys.cpp:10:
src/libcachecommon/CacheKeys.hpp:46:2: error: ignoring return value of function declared with 'nodiscard' attribute [-Werror,-Wunused-result]
46 | cacheKey.c_str();
| ^~~~~~~~~~~~~~
1 error generated.
clang complains because it's unused:
src/librpfile/IRpFile.hpp:309:10: error: private field 'm_padding' is not used [-Werror,-Wunused-private-field]
309 | uint8_t m_padding; // pad to 8 bytes
| ^
1 error generated.
This effectively reverts commit 9d19c28379
([librpfile] IRpFile: Explicitly add a byte of padding.)
but it isn't a direct revert due to un-indenting.
Compiling on Xubuntu 16.04 results in the following warning:
src/libromdata/Console/SNES.cpp: In static member function ‘static bool LibRomData::SNESPrivate::isSnesRomHeaderValid(const SNES_RomHeader*, bool)’:
src/libromdata/Console/SNES.cpp:404:55: error: comparison of promoted ~unsigned with unsigned [-Werror=sign-compare]
if (static_cast<uint16_t>( romHeader->snes.checksum) !=
^
cc1plus: all warnings being treated as errors
It doesn't make sense at all, but using `unsigned int` temporaries
seems to work around it. Also, use "^ 0xFFFF" instead of ~ so we
only invert the 16-bit value, not the full 32 bits of `unsigned int`.
Initialize some variables, and use memcpy() instead of strncpy().
Remove the -Wno-error options. This broke on Debian 8 ppc (gcc-4.9.2),
which doesn't support -Wstringop-overflow or -Wstringop-truncation.
extlib/minizip-ng/compat/unzip.c: In function ‘unzGetFilePos’:
extlib/minizip-ng/compat/unzip.c:563:38: error: ‘file_pos64.pos_in_zip_directory’ may be used uninitialized [-Werror=maybe-uninitialized]
563 | file_pos->pos_in_zip_directory = (uint32_t)file_pos64.pos_in_zip_directory;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/compat/unzip.c:556:20: note: ‘file_pos64.pos_in_zip_directory’ was declared here
556 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
extlib/minizip-ng/compat/unzip.c:564:29: error: ‘file_pos64.num_of_file’ may be used uninitialized [-Werror=maybe-uninitialized]
564 | file_pos->num_of_file = (uint32_t)file_pos64.num_of_file;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/compat/unzip.c:556:20: note: ‘file_pos64.num_of_file’ was declared here
556 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
cc1: all warnings being treated as errors
extlib/minizip-ng/mz_zip.c: In function ‘mz_zip_set_comment’:
extlib/minizip-ng/mz_zip.c:1569:5: error: ‘__builtin___strncpy_chk’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
1569 | strncpy(zip->comment, comment, comment_size);
| ^
extlib/minizip-ng/mz_zip.c:1563:29: note: length computed here
1563 | comment_size = (int32_t)strlen(comment);
| ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
A change in 4.0.8 results in ZEXPORT defaulting to nothing, which breaks
dllexports in the Windows version (and results in no import library
being generated).
Define ZEXPORT=__declspec(dllexport) to have the same behavior as 4.0.7.
Fixes what appears to be a false-positive warning-as-error in the
Release build:
src/librpbase/img/RpPng.cpp: In function ‘LibRpTexture::rp_image_ptr LibRpBase::RpPng::loadPng(png_structp, png_infop)’:
src/librpbase/img/RpPng.cpp:181:42: error: variable ‘color’ might be clobbered by ‘longjmp’ or ‘vfork’ [-Werror=clobbered]
181 | argb32_t color;
| ^~~~~
cc1plus: all warnings being treated as errors
scsi_read(): Passing pBuf (read_only) to scsi_send_cdb (which takes
read_write) causes a warning in the Release build:
src/librpfile/scsi/RpFile_scsi.cpp: In member function ‘int LibRpFile::RpFilePrivate::scsi_read(uint32_t, uint16_t, uint8_t*, size_t)’:
src/librpfile/scsi/RpFile_scsi.cpp:463:29: error: ‘pBuf’ may be used uninitialized [-Werror=maybe-uninitialized]
463 | return scsi_send_cdb(&cdb10, sizeof(cdb10), pBuf, req_buf_size, ScsiDirection::In);
| ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/librpfile/scsi/RpFile_scsi.cpp:427:77: note: accessing argument 4 of a function declared with attribute ‘access (write_only, 4, 5)’
427 | int RpFilePrivate::scsi_read(uint32_t lbaStart, uint16_t lbaCount, uint8_t *pBuf, size_t bufLen)
| ~~~~~~~~~^~~~
cc1plus: all warnings being treated as errors
This broke the Ubuntu 22.04 AppVeyor build:
extlib/microtar/src/microtar.c: In function ‘mtar_read_header’:
extlib/microtar/src/microtar.c:111:3: error: ‘__builtin_strncpy’ output may be truncated copying 99 bytes from a string of length 99 [-Werror=stringop-truncation]
111 | strncpy(h->name, rh->name, sizeof(h->name));
| ^
extlib/microtar/src/microtar.c:112:3: error: ‘__builtin_strncpy’ output may be truncated copying 99 bytes from a string of length 99 [-Werror=stringop-truncation]
112 | strncpy(h->linkname, rh->linkname, sizeof(h->linkname));
| ^
cc1: all warnings being treated as errors
This broke the Ubuntu 22.04 AppVeyor build:
extlib/minizip-ng/mz_compat.c: In function ‘unzGetFilePos’:
extlib/minizip-ng/mz_compat.c:1201:38: error: ‘file_pos64.pos_in_zip_directory’ may be used uninitialized [-Werror=maybe-uninitialized]
1201 | file_pos->pos_in_zip_directory = (uint32_t)file_pos64.pos_in_zip_directory;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/mz_compat.c:1194:20: note: ‘file_pos64.pos_in_zip_directory’ was declared here
1194 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
extlib/minizip-ng/mz_compat.c:1202:29: error: ‘file_pos64.num_of_file’ may be used uninitialized [-Werror=maybe-uninitialized]
1202 | file_pos->num_of_file = (uint32_t)file_pos64.num_of_file;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
extlib/minizip-ng/mz_compat.c:1194:20: note: ‘file_pos64.num_of_file’ was declared here
1194 | unz64_file_pos file_pos64;
| ^~~~~~~~~~
cc1: all warnings being treated as errors
DreamcastSave: Use aligned_uptr<> instead.
N64: Remove ALIGNED(). The header is located at a 16-byte multiple offset
within N64Private. 64-bit Windows uses 16-byte alignment for memory
allocations, but 32-bit (i386) Windows uses 4-byte alignment, so it's
possible that things might be slightly slower on 32-bit.
This broke the Ubuntu 22.04 AppVeyor build:
extlib/minizip-ng/mz_zip_rw.c: In function ‘mz_zip_reader_entry_save_file’:
extlib/minizip-ng/mz_zip_rw.c:668:5: error: ‘__builtin_strncat’ specified bound depends on the length of the source argument [-Werror=stringop-overflow=]
668 | strncat(pathwfs, path, path_length);
| ^
extlib/minizip-ng/mz_zip_rw.c:662:19: note: length computed here
662 | path_length = strlen(path);
| ^~~~~~~~~~~~
cc1: all warnings being treated as errors
extlib/minizip-ng/mz_zip.c: In function ‘mz_zip_set_comment’:
extlib/minizip-ng/mz_zip.c:1574:5: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation]
1574 | strncpy(zip->comment, comment, comment_size);
| ^
extlib/minizip-ng/mz_zip.c:1568:29: note: length computed here
1568 | comment_size = (int32_t)strlen(comment);
| ^~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
If this is the case, then none of the vectorized functions will help
at all, so immediately fall back to the C version.
NOTE: This check is done in the dispatch functions, not the vectorized
functions, to allow the vectorized functions to be used for testing.