mirror of
https://github.com/GerbilSoft/rom-properties.git
synced 2025-06-18 11:35:38 -04:00

The MSVC build (64-bit, at least...) now builds with no warnings. Tested using MSVC 2022 17.6.5. NOTE: /W4 adds a *lot* of warnings that are mostly just noise. Need to check /W4 and selectively enable at least some of them... Removed /wd4482. I don't think this warning is relevant anymore. Warning fixes: [extlib] Add (unsigned int) casts where necessary. [librpbase] Config::ImgTypePrio_t, KeyManager::KeyData_t: - Change `length` from unsigned int to size_t. The struct is 16 bytes on 64-bit either way, but making it size_t fixes some conversion warnings. [librpbase] Hash::Process(): - crc32() returns `unsigned long`, not `uint32_t`, for some reason. - Also, its length parameter is `unsigned int`, not `size_t`. - KeyManager::hexStringToBytes(): Take a `size_t` length parameter. [librpfile] scsi: - Change cdb_len from `uint8_t` to `size_t`. Using a `uint8_t` argument doesn't actually save any memory, since it uses 4 bytes on the stack for 32-bit, and one register on 64-bit, regardless. - Also, limit the maximum cdb size to 260. [rp-download] Disable warning C4996 when calling GetVersionEx(). [librptexture] DirectDrawSurface: - Change some `expected_size` variables from `unsigned int` to `size_t`. [librptexture] PalmOS_Tbmp: - Change d->bitmapTypeAddr from `off64_t` to `uint32_t`. - Change some size variables from `unsigned int` to `size_t`. - loadTbmp(): v3 transparency: Explicitly cast the transparency value to uint16_t. (It's stored as a big-endian 32-bit value, but only 16 bits are used.) - getNextTbmpAddress(): Cast addresses to `uint32_t`. PalmOS executables are 32-bit and cannot possibly exceed 4 GB. - FIXME: This function isn't used? (Was it ever used?) [libromdata] - DMGPrivate::CartType(): Make `end_offset` constexpr. - NCCHReader: Add casts for EncSections when using sizeof(). - KeyStoreUIPrivate: binToHexStr(), verifyKeyData(): - Take a `size_t` length parameter. - WiiUPackagePrivate: Added a parseHexBinary32() wrapper function that returns `uint32_t` instead of `uint64_t`. [librpbyteswap/tests] - BitstuffTest: Cast time(nullptr) to `unsigned int`. srand() takes `unsigned int`, not `time_t`. [librpbase/tests] - RpPngFormatTest: crc32()'s length parameter is `unsigned int`, not `size_t`. [libromdata/tests] - SuperMagicDriveTest: zlib uses `unsigned int`, so cast array sizes to `unsigned int` instead of changing decompress() to take `size_t`.
49 lines
1.7 KiB
C
Vendored
49 lines
1.7 KiB
C
Vendored
/* Three-level bitmap lookup.
|
|
Copyright (C) 2000-2002, 2005-2007, 2009-2024 Free Software Foundation, Inc.
|
|
Written by Bruno Haible <bruno@clisp.org>, 2000-2002.
|
|
|
|
This file is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Lesser General Public License as
|
|
published by the Free Software Foundation; either version 2.1 of the
|
|
License, or (at your option) any later version.
|
|
|
|
This file is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Lesser General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
|
|
|
static inline int bitmap_lookup (const void *table, ucs4_t uc);
|
|
|
|
/* These values are currently hardcoded into gen-uni-tables.c, function
|
|
output_predicate(). */
|
|
#define header_0 16
|
|
#define header_2 9
|
|
#define header_3 127
|
|
#define header_4 15
|
|
|
|
static inline int
|
|
bitmap_lookup (const void *table, ucs4_t uc)
|
|
{
|
|
unsigned int index1 = uc >> header_0;
|
|
if (index1 < (unsigned int)((const int *) table)[0])
|
|
{
|
|
int lookup1 = ((const int *) table)[1 + index1];
|
|
if (lookup1 >= 0)
|
|
{
|
|
unsigned int index2 = (uc >> header_2) & header_3;
|
|
int lookup2 = ((const short *) table)[lookup1 + index2];
|
|
if (lookup2 >= 0)
|
|
{
|
|
unsigned int index3 = (uc >> 5) & header_4;
|
|
unsigned int lookup3 = ((const unsigned int *) table)[lookup2 + index3];
|
|
|
|
return (lookup3 >> (uc & 0x1f)) & 1;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|