Use UINT32_C / UINT64_C throughout the codebase

This commit is contained in:
twinaphex 2020-07-29 04:48:11 +02:00
parent 1f0529a275
commit 4f931f2729
7 changed files with 25 additions and 25 deletions

14
deps/libz/inffast.c vendored
View File

@ -69,8 +69,8 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start)
unsigned bits = state->bits; unsigned bits = state->bits;
code const FAR *lcode = state->lencode; code const FAR *lcode = state->lencode;
code const FAR *dcode = state->distcode; code const FAR *dcode = state->distcode;
unsigned lmask = (1U << state->lenbits) - 1; unsigned lmask = (UINT32_C(1) << state->lenbits) - 1;
unsigned dmask = (1U << state->distbits) - 1; unsigned dmask = (UINT32_C(1) << state->distbits) - 1;
/* decode literals and length/distances until end-of-block or not enough /* decode literals and length/distances until end-of-block or not enough
input data or output space */ input data or output space */
@ -102,7 +102,7 @@ dolen:
hold += (unsigned long)(*in++) << bits; hold += (unsigned long)(*in++) << bits;
bits += 8; bits += 8;
} }
len += (unsigned)hold & ((1U << op) - 1); len += (unsigned)hold & ((UINT32_C(1) << op) - 1);
hold >>= op; hold >>= op;
bits -= op; bits -= op;
} }
@ -136,7 +136,7 @@ dodist:
bits += 8; bits += 8;
} }
} }
dist += (unsigned)hold & ((1U << op) - 1); dist += (unsigned)hold & ((UINT32_C(1) << op) - 1);
hold >>= op; hold >>= op;
bits -= op; bits -= op;
op = (unsigned)(out - beg); /* max distance in output */ op = (unsigned)(out - beg); /* max distance in output */
@ -236,7 +236,7 @@ dodist:
} }
else if ((op & 64) == 0) /* 2nd level distance code */ else if ((op & 64) == 0) /* 2nd level distance code */
{ {
here = dcode + here->val + (hold & ((1U << op) - 1)); here = dcode + here->val + (hold & ((UINT32_C(1) << op) - 1));
goto dodist; goto dodist;
} }
else else
@ -248,7 +248,7 @@ dodist:
} }
else if ((op & 64) == 0) /* 2nd level length code */ else if ((op & 64) == 0) /* 2nd level length code */
{ {
here = lcode + here->val + (hold & ((1U << op) - 1)); here = lcode + here->val + (hold & ((UINT32_C(1) << op) - 1));
goto dolen; goto dolen;
} }
else if (op & 32) /* end-of-block */ else if (op & 32) /* end-of-block */
@ -268,7 +268,7 @@ dodist:
len = bits >> 3; len = bits >> 3;
in -= len; in -= len;
bits -= len << 3; bits -= len << 3;
hold &= (1U << bits) - 1; hold &= (UINT32_C(1) << bits) - 1;
/* update state and return */ /* update state and return */
strm->next_in = in; strm->next_in = in;

8
deps/libz/inflate.c vendored
View File

@ -379,7 +379,7 @@ void makefixed(void)
puts(" subject to change. Applications should only use zlib.h."); puts(" subject to change. Applications should only use zlib.h.");
puts(" */"); puts(" */");
puts(""); puts("");
size = 1U << 9; size = UINT32_C(1) << 9;
printf(" static const code lenfix[%u] = {", size); printf(" static const code lenfix[%u] = {", size);
low = 0; low = 0;
for (;;) { for (;;) {
@ -390,7 +390,7 @@ void makefixed(void)
putchar(','); putchar(',');
} }
puts("\n };"); puts("\n };");
size = 1U << 5; size = UINT32_C(1) << 5;
printf("\n static const code distfix[%u] = {", size); printf("\n static const code distfix[%u] = {", size);
low = 0; low = 0;
for (;;) { for (;;) {
@ -550,7 +550,7 @@ static int updatewindow(z_streamp strm, const Bytef *end, unsigned copy)
/* Return the low n bits of the bit accumulator (n < 16) */ /* Return the low n bits of the bit accumulator (n < 16) */
#define BITS(n) \ #define BITS(n) \
((unsigned)hold & ((1U << (n)) - 1)) ((unsigned)hold & ((UINT32_C(1) << (n)) - 1))
/* Remove n bits from the bit accumulator */ /* Remove n bits from the bit accumulator */
#define DROPBITS(n) \ #define DROPBITS(n) \
@ -1469,7 +1469,7 @@ int inflateCopy(z_streamp dest, z_streamp source)
if (window != Z_NULL) if (window != Z_NULL)
{ {
wsize = 1U << state->wbits; wsize = UINT32_C(1) << state->wbits;
memcpy(window, state->window, wsize); memcpy(window, state->window, wsize);
} }
copy->window = window; copy->window = window;

12
deps/libz/inftrees.c vendored
View File

@ -198,7 +198,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne
curr = root; /* current table index bits */ curr = root; /* current table index bits */
drop = 0; /* current bits to drop from code for index */ drop = 0; /* current bits to drop from code for index */
low = (unsigned)(-1); /* trigger new sub-table when len > root */ low = (unsigned)(-1); /* trigger new sub-table when len > root */
used = 1U << root; /* use root table entries */ used = UINT32_C(1) << root; /* use root table entries */
mask = used - 1; /* mask for comparing low */ mask = used - 1; /* mask for comparing low */
/* check available table space */ /* check available table space */
@ -224,16 +224,16 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne
} }
/* replicate for those indices with low len bits equal to huff */ /* replicate for those indices with low len bits equal to huff */
incr = 1U << (len - drop); incr = UINT32_C(1) << (len - drop);
fill = 1U << curr; fill = UINT32_C(1) << curr;
min = fill; /* save offset to next table */ min = fill; /* save offset to next table */
do { do {
fill -= incr; fill -= incr;
next[(huff >> drop) + fill] = here; next[(huff >> drop) + fill] = here;
} while (fill != 0); } while (fill != 0);
/* backwards increment the len-bit code huff */ /* backwards increment the len-bit code huff */
incr = 1U << (len - 1); incr = UINT32_C(1) << (len - 1);
while (huff & incr) while (huff & incr)
incr >>= 1; incr >>= 1;
if (incr != 0) { if (incr != 0) {
@ -270,7 +270,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne
} }
/* check for enough space */ /* check for enough space */
used += 1U << curr; used += UINT32_C(1) << curr;
if ((type == LENS && used > ENOUGH_LENS) || if ((type == LENS && used > ENOUGH_LENS) ||
(type == DISTS && used > ENOUGH_DISTS)) (type == DISTS && used > ENOUGH_DISTS))
return 1; return 1;

View File

@ -442,7 +442,7 @@ static void cpulist_parse(CpuList* list, char **buf, ssize_t length)
for (val = start_value; val <= end_value; val++) for (val = start_value; val <= end_value; val++)
{ {
if ((unsigned)val < 32) if ((unsigned)val < 32)
list->mask |= (uint32_t)(1U << val); list->mask |= (uint32_t)(UINT32_C(1) << val);
} }
/* Jump to next item */ /* Jump to next item */

View File

@ -95,7 +95,7 @@ typedef uint32_t Codepoint;
#define IS_TRAILING_SURROGATE(c) (((c) & 0xFFFFFC00) == 0xDC00) #define IS_TRAILING_SURROGATE(c) (((c) & 0xFFFFFC00) == 0xDC00)
#define CODEPOINT_FROM_SURROGATES(hi_lo) ((((hi_lo) >> 16) << 10) + ((hi_lo) & 0xFFFF) + 0xFCA02400) #define CODEPOINT_FROM_SURROGATES(hi_lo) ((((hi_lo) >> 16) << 10) + ((hi_lo) & 0xFFFF) + 0xFCA02400)
#define SURROGATES_FROM_CODEPOINT(c) ((((c) << 6) & 0x7FF0000) + ((c) & 0x3FF) + 0xD7C0DC00) #define SURROGATES_FROM_CODEPOINT(c) ((((c) << 6) & 0x7FF0000) + ((c) & 0x3FF) + 0xD7C0DC00)
#define SHORTEST_ENCODING_SEQUENCE(enc) (1U << ((enc) >> 1)) #define SHORTEST_ENCODING_SEQUENCE(enc) (UINT32_C(1) << ((enc) >> 1))
#define LONGEST_ENCODING_SEQUENCE 4 #define LONGEST_ENCODING_SEQUENCE 4
/* Internal types that alias enum types in the public API. /* Internal types that alias enum types in the public API.

View File

@ -413,10 +413,10 @@ bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim)
* wavefronts. * wavefronts.
*/ */
const uint32_t keep = const uint32_t keep =
(1U << RETRO_DEVICE_ID_JOYPAD_UP) | (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) |
(1U << RETRO_DEVICE_ID_JOYPAD_DOWN) | (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) |
(1U << RETRO_DEVICE_ID_JOYPAD_LEFT) | (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) |
(1U << RETRO_DEVICE_ID_JOYPAD_RIGHT); (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT);
simstate->data[0] &= keep; simstate->data[0] &= keep;
simstate->data[0] |= pstate->data[0] & ~keep; simstate->data[0] |= pstate->data[0] & ~keep;
} }

View File

@ -9015,7 +9015,7 @@ static bool get_self_input_state(
{ {
state[word] |= state[word] |=
cb(local_device, RETRO_DEVICE_KEYBOARD, 0, netplay_key_ntoh(key)) ? cb(local_device, RETRO_DEVICE_KEYBOARD, 0, netplay_key_ntoh(key)) ?
(1U << bit) : 0; (UINT32_C(1) << bit) : 0;
bit++; bit++;
if (bit >= 32) if (bit >= 32)
{ {
@ -9433,7 +9433,7 @@ static int16_t netplay_input_state(netplay_t *netplay,
word = key / 32; word = key / 32;
bit = key % 32; bit = key % 32;
if (word <= istate->size) if (word <= istate->size)
return ((1U<<bit) & curr_input_state[word]) ? 1 : 0; return ((UINT32_C(1) << bit) & curr_input_state[word]) ? 1 : 0;
return 0; return 0;
} }
default: default: