From 4f931f2729527d3d417d5ec9483aea2ba508b7ca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 29 Jul 2020 04:48:11 +0200 Subject: [PATCH] Use UINT32_C / UINT64_C throughout the codebase --- deps/libz/inffast.c | 14 +++++++------- deps/libz/inflate.c | 8 ++++---- deps/libz/inftrees.c | 12 ++++++------ libretro-common/features/features_cpu.c | 2 +- libretro-common/formats/json/jsonsax_full.c | 2 +- network/netplay/netplay_sync.c | 8 ++++---- retroarch.c | 4 ++-- 7 files changed, 25 insertions(+), 25 deletions(-) diff --git a/deps/libz/inffast.c b/deps/libz/inffast.c index 74c893eac8..ff170667c7 100644 --- a/deps/libz/inffast.c +++ b/deps/libz/inffast.c @@ -69,8 +69,8 @@ void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) unsigned bits = state->bits; code const FAR *lcode = state->lencode; code const FAR *dcode = state->distcode; - unsigned lmask = (1U << state->lenbits) - 1; - unsigned dmask = (1U << state->distbits) - 1; + unsigned lmask = (UINT32_C(1) << state->lenbits) - 1; + unsigned dmask = (UINT32_C(1) << state->distbits) - 1; /* decode literals and length/distances until end-of-block or not enough input data or output space */ @@ -102,7 +102,7 @@ dolen: hold += (unsigned long)(*in++) << bits; bits += 8; } - len += (unsigned)hold & ((1U << op) - 1); + len += (unsigned)hold & ((UINT32_C(1) << op) - 1); hold >>= op; bits -= op; } @@ -136,7 +136,7 @@ dodist: bits += 8; } } - dist += (unsigned)hold & ((1U << op) - 1); + dist += (unsigned)hold & ((UINT32_C(1) << op) - 1); hold >>= op; bits -= op; op = (unsigned)(out - beg); /* max distance in output */ @@ -236,7 +236,7 @@ dodist: } 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; } else @@ -248,7 +248,7 @@ dodist: } 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; } else if (op & 32) /* end-of-block */ @@ -268,7 +268,7 @@ dodist: len = bits >> 3; in -= len; bits -= len << 3; - hold &= (1U << bits) - 1; + hold &= (UINT32_C(1) << bits) - 1; /* update state and return */ strm->next_in = in; diff --git a/deps/libz/inflate.c b/deps/libz/inflate.c index 268d75969f..dac12e0790 100644 --- a/deps/libz/inflate.c +++ b/deps/libz/inflate.c @@ -379,7 +379,7 @@ void makefixed(void) puts(" subject to change. Applications should only use zlib.h."); puts(" */"); puts(""); - size = 1U << 9; + size = UINT32_C(1) << 9; printf(" static const code lenfix[%u] = {", size); low = 0; for (;;) { @@ -390,7 +390,7 @@ void makefixed(void) putchar(','); } puts("\n };"); - size = 1U << 5; + size = UINT32_C(1) << 5; printf("\n static const code distfix[%u] = {", size); low = 0; 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) */ #define BITS(n) \ - ((unsigned)hold & ((1U << (n)) - 1)) + ((unsigned)hold & ((UINT32_C(1) << (n)) - 1)) /* Remove n bits from the bit accumulator */ #define DROPBITS(n) \ @@ -1469,7 +1469,7 @@ int inflateCopy(z_streamp dest, z_streamp source) if (window != Z_NULL) { - wsize = 1U << state->wbits; + wsize = UINT32_C(1) << state->wbits; memcpy(window, state->window, wsize); } copy->window = window; diff --git a/deps/libz/inftrees.c b/deps/libz/inftrees.c index 8b8a9648f1..8d0bfc788d 100644 --- a/deps/libz/inftrees.c +++ b/deps/libz/inftrees.c @@ -198,7 +198,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne curr = root; /* current table index bits */ drop = 0; /* current bits to drop from code for index */ 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 */ /* 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 */ - incr = 1U << (len - drop); - fill = 1U << curr; - min = fill; /* save offset to next table */ + incr = UINT32_C(1) << (len - drop); + fill = UINT32_C(1) << curr; + min = fill; /* save offset to next table */ do { fill -= incr; next[(huff >> drop) + fill] = here; } while (fill != 0); /* backwards increment the len-bit code huff */ - incr = 1U << (len - 1); + incr = UINT32_C(1) << (len - 1); while (huff & incr) incr >>= 1; if (incr != 0) { @@ -270,7 +270,7 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, unsigne } /* check for enough space */ - used += 1U << curr; + used += UINT32_C(1) << curr; if ((type == LENS && used > ENOUGH_LENS) || (type == DISTS && used > ENOUGH_DISTS)) return 1; diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index a3d42cdcc9..a0dda815d2 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -442,7 +442,7 @@ static void cpulist_parse(CpuList* list, char **buf, ssize_t length) for (val = start_value; val <= end_value; val++) { if ((unsigned)val < 32) - list->mask |= (uint32_t)(1U << val); + list->mask |= (uint32_t)(UINT32_C(1) << val); } /* Jump to next item */ diff --git a/libretro-common/formats/json/jsonsax_full.c b/libretro-common/formats/json/jsonsax_full.c index e5cefaf785..71de6bd1aa 100644 --- a/libretro-common/formats/json/jsonsax_full.c +++ b/libretro-common/formats/json/jsonsax_full.c @@ -95,7 +95,7 @@ typedef uint32_t Codepoint; #define IS_TRAILING_SURROGATE(c) (((c) & 0xFFFFFC00) == 0xDC00) #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 SHORTEST_ENCODING_SEQUENCE(enc) (1U << ((enc) >> 1)) +#define SHORTEST_ENCODING_SEQUENCE(enc) (UINT32_C(1) << ((enc) >> 1)) #define LONGEST_ENCODING_SEQUENCE 4 /* Internal types that alias enum types in the public API. diff --git a/network/netplay/netplay_sync.c b/network/netplay/netplay_sync.c index f956da5510..a23d4186d7 100644 --- a/network/netplay/netplay_sync.c +++ b/network/netplay/netplay_sync.c @@ -413,10 +413,10 @@ bool netplay_resolve_input(netplay_t *netplay, size_t sim_ptr, bool resim) * wavefronts. */ const uint32_t keep = - (1U << RETRO_DEVICE_ID_JOYPAD_UP) | - (1U << RETRO_DEVICE_ID_JOYPAD_DOWN) | - (1U << RETRO_DEVICE_ID_JOYPAD_LEFT) | - (1U << RETRO_DEVICE_ID_JOYPAD_RIGHT); + (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) | + (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) | + (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) | + (UINT32_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT); simstate->data[0] &= keep; simstate->data[0] |= pstate->data[0] & ~keep; } diff --git a/retroarch.c b/retroarch.c index efc7a92d7b..8c2c5870ac 100644 --- a/retroarch.c +++ b/retroarch.c @@ -9015,7 +9015,7 @@ static bool get_self_input_state( { state[word] |= cb(local_device, RETRO_DEVICE_KEYBOARD, 0, netplay_key_ntoh(key)) ? - (1U << bit) : 0; + (UINT32_C(1) << bit) : 0; bit++; if (bit >= 32) { @@ -9433,7 +9433,7 @@ static int16_t netplay_input_state(netplay_t *netplay, word = key / 32; bit = key % 32; if (word <= istate->size) - return ((1U<