]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Replace {u}int_fast{16|32} with {u}int32_t
authorNoah Goldstein <goldstein.w.n@gmail.com>
Thu, 14 Apr 2022 00:46:03 +0000 (19:46 -0500)
committerNoah Goldstein <goldstein.w.n@gmail.com>
Thu, 14 Apr 2022 02:23:04 +0000 (21:23 -0500)
On 32-bit machines this has no affect. On 64-bit machines
{u}int_fast{16|32} are set as {u}int64_t which is often not
ideal. Particularly x86_64 this change both saves code size and
may save instruction cost.

Full xcheck passes on x86_64.

19 files changed:
elf/dl-load.c
elf/dl-lookup.c
elf/dl-machine-reject-phdr.h
elf/dl-profile.c
elf/setup-vdso.h
hurd/hurdselect.c
iconv/gconv_simple.c
iconv/gconv_trans.c
iconvdata/cp932.c
iconvdata/johab.c
iconvdata/sjis.c
locale/elem-hash.h
locale/weight.h
posix/regex_internal.h
resolv/nss_dns/dns-canon.c
string/strcoll_l.c
string/strxfrm_l.c
sysdeps/mips/dl-machine-reject-phdr.h
sysdeps/unix/sysv/linux/dl-sysdep.c

index 892e8ef2f6a168d47143a1d33f8d13e05d558f2e..2fdd61299784215e9ca9892cb562f9661015e562 100644 (file)
@@ -1093,7 +1093,7 @@ _dl_map_object_from_fd (const char *name, const char *origname, int fd,
    /* On most platforms presume that PT_GNU_STACK is absent and the stack is
     * executable.  Other platforms default to a nonexecutable stack and don't
     * need PT_GNU_STACK to do so.  */
-   uint_fast16_t stack_flags = DEFAULT_STACK_PERMS;
+   unsigned int stack_flags = DEFAULT_STACK_PERMS;
 
   {
     /* Scan the program header table, collecting its load commands.  */
index 7b2a6622be6a494e38d181168fd1f7153e2a0189..989b073e4f74d2dad53387b64aeaea9022ff5dad 100644 (file)
@@ -208,7 +208,7 @@ is_nodelete (struct link_map *map, int flags)
    in the unique symbol table, creating a new entry if necessary.
    Return the matching symbol in RESULT.  */
 static void
-do_lookup_unique (const char *undef_name, uint_fast32_t new_hash,
+do_lookup_unique (const char *undef_name, unsigned int new_hash,
                  struct link_map *map, struct sym_val *result,
                  int type_class, const ElfW(Sym) *sym, const char *strtab,
                  const ElfW(Sym) *ref, const struct link_map *undef_map,
@@ -339,7 +339,7 @@ marking %s [%lu] as NODELETE due to unique symbol\n",
    something bad happened.  */
 static int
 __attribute_noinline__
-do_lookup_x (const char *undef_name, uint_fast32_t new_hash,
+do_lookup_x (const char *undef_name, unsigned int new_hash,
             unsigned long int *old_hash, const ElfW(Sym) *ref,
             struct sym_val *result, struct r_scope_elem *scope, size_t i,
             const struct r_found_version *const version, int flags,
@@ -558,13 +558,13 @@ skip:
 }
 
 
-static uint_fast32_t
+static uint32_t
 dl_new_hash (const char *s)
 {
-  uint_fast32_t h = 5381;
+  uint32_t h = 5381;
   for (unsigned char c = *s; c != '\0'; c = *++s)
     h = h * 33 + c;
-  return h & 0xffffffff;
+  return h;
 }
 
 
@@ -816,7 +816,7 @@ _dl_lookup_symbol_x (const char *undef_name, struct link_map *undef_map,
                     const struct r_found_version *version,
                     int type_class, int flags, struct link_map *skip_map)
 {
-  const uint_fast32_t new_hash = dl_new_hash (undef_name);
+  const unsigned int new_hash = dl_new_hash (undef_name);
   unsigned long int old_hash = 0xffffffff;
   struct sym_val current_value = { NULL, NULL };
   struct r_scope_elem **scope = symbol_scope;
index ea18289fdab88e390045a9c8a6f262b5c5d469a6..ad64cf40eadd1de47db507bc58c0d1cbb11a5b8c 100644 (file)
@@ -24,7 +24,7 @@
 /* Return true iff ELF program headers are incompatible with the running
    host.  */
 static inline bool
-elf_machine_reject_phdr_p (const ElfW(Phdr) *phdr, uint_fast16_t phnum,
+elf_machine_reject_phdr_p (const ElfW(Phdr) *phdr, unsigned int phnum,
                           const char *buf, size_t len, struct link_map *map,
                           int fd)
 {
index 9359be7c33ec95c7caa26187de85cb862648cd34..ec57e3a96552ae6460c22a0fcc819b85d486c0da 100644 (file)
@@ -558,7 +558,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc)
          /* If we still have no entry stop searching and insert.  */
          if (*topcindex == 0)
            {
-             uint_fast32_t newarc = catomic_exchange_and_add (narcsp, 1);
+             unsigned int newarc = catomic_exchange_and_add (narcsp, 1);
 
              /* In rare cases it could happen that all entries in FROMS are
                 occupied.  So we cannot count this anymore.  */
index db639b0d4f0fdaeb647a1de4e4f19b4e7278d9b4..c0807ea82b48e79a8e82de78013adb1e6eb99298 100644 (file)
@@ -36,7 +36,7 @@ setup_vdso (struct link_map *main_map __attribute__ ((unused)),
       l->l_phdr = ((const void *) GLRO(dl_sysinfo_dso)
                   + GLRO(dl_sysinfo_dso)->e_phoff);
       l->l_phnum = GLRO(dl_sysinfo_dso)->e_phnum;
-      for (uint_fast16_t i = 0; i < l->l_phnum; ++i)
+      for (unsigned int i = 0; i < l->l_phnum; ++i)
        {
          const ElfW(Phdr) *const ph = &l->l_phdr[i];
          if (ph->p_type == PT_DYNAMIC)
index e9d5c64bf352396f55a76a71824fbdc7ef1fb4c0..ddeaf6c0c74ba8c17bf6b94a79e5d7b672f6a6d9 100644 (file)
@@ -575,7 +575,7 @@ _hurd_select (int nfds,
     for (i = 0; i < nfds; ++i)
       {
        int type = d[i].type;
-       int_fast16_t revents = 0;
+       int revents = 0;
 
        if (type & SELECT_ERROR)
          switch (d[i].error)
index be8504791b7835fb583efe2b54dd191f9da45057..640068d9badcdd8693d850ccadf54becbb4d3382 100644 (file)
@@ -959,8 +959,8 @@ ucs4le_internal_loop_single (struct __gconv_step *step,
       }                                                                              \
     else                                                                     \
       {                                                                              \
-       uint_fast32_t cnt;                                                    \
-       uint_fast32_t i;                                                      \
+       unsigned int cnt;                                                     \
+       unsigned int i;                                               \
                                                                              \
        if (ch >= 0xc2 && ch < 0xe0)                                          \
          {                                                                   \
index 0101332d617255fa2b24312521fa0b82334e87fd..1ebbbfd51b14c59180fd236073321397351f0cee 100644 (file)
@@ -37,15 +37,15 @@ __gconv_transliterate (struct __gconv_step *step,
                       unsigned char **outbufstart, size_t *irreversible)
 {
   /* Find out about the locale's transliteration.  */
-  uint_fast32_t size;
+  uint32_t size;
   const uint32_t *from_idx;
   const uint32_t *from_tbl;
   const uint32_t *to_idx;
   const uint32_t *to_tbl;
   const uint32_t *winbuf;
   const uint32_t *winbufend;
-  uint_fast32_t low;
-  uint_fast32_t high;
+  uint32_t low;
+  uint32_t high;
 
   /* The input buffer.  There are actually 4-byte values.  */
   winbuf = (const uint32_t *) *inbufp;
@@ -85,7 +85,7 @@ __gconv_transliterate (struct __gconv_step *step,
   high = size;
   while (low < high)
     {
-      uint_fast32_t med = (low + high) / 2;
+      uint32_t med = (low + high) / 2;
       uint32_t idx;
       int cnt;
 
@@ -111,7 +111,7 @@ __gconv_transliterate (struct __gconv_step *step,
          do
            {
              /* Determine length of replacement.  */
-             uint_fast32_t len = 0;
+             unsigned int len = 0;
              int res;
              const unsigned char *toinptr;
              unsigned char *outptr;
index 91487fa34c697a1122140ece9861c45e0af22238..f40f8e2a9db29cd7028ca7b1b10655a999bf4ca0 100644 (file)
@@ -4572,7 +4572,7 @@ static const char from_ucs4_extra[229][2] =
        /* Two-byte character.  First test whether the next character         \
           is also available.  */                                             \
        uint32_t ch2;                                                         \
-       uint_fast32_t idx;                                                    \
+       uint32_t idx;                                                 \
                                                                              \
        if (__glibc_unlikely (inptr + 1 >= inend))                            \
          {                                                                   \
index 33ec7b9a62bb8d0fde9941c36c551b2453c5df47..8dd5eba4a1b51f81074a5799ae5ba5d9f489fe82 100644 (file)
@@ -130,7 +130,7 @@ static const uint16_t jamo_from_ucs_table[51] =
 
 
 static uint32_t
-johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
+johab_sym_hanja_to_ucs (uint32_t idx, uint32_t c1, uint32_t c2)
 {
   if (idx <= 0xdefe)
     return (uint32_t) __ksc5601_sym_to_ucs[(c1 - 0xd9) * 188 + c2
@@ -189,7 +189,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
            /* Two-byte character.  First test whether the next               \
               character is also available.  */                               \
            uint32_t ch2;                                                     \
-           uint_fast32_t idx;                                                \
+           uint32_t idx;                                                     \
                                                                              \
            if (__glibc_unlikely (inptr + 1 >= inend))                        \
              {                                                               \
@@ -204,7 +204,7 @@ johab_sym_hanja_to_ucs (uint_fast32_t idx, uint_fast32_t c1, uint_fast32_t c2)
            if (__glibc_likely (ch <= 0xd3))                                  \
              {                                                               \
                /* Hangul */                                                  \
-               int_fast32_t i, m, f;                                         \
+               int i, m, f;                                          \
                                                                              \
                i = init[(idx & 0x7c00) >> 10];                               \
                m = mid[(idx & 0x03e0) >> 5];                                 \
index e1bdb3025ca6695ac2f8fbbb426629f77edf06dd..5aea18b314c9e57c5eabce7770ba16da78fcc8af 100644 (file)
@@ -4359,7 +4359,7 @@ static const char from_ucs4_extra[0x100][2] =
        /* Two-byte character.  First test whether the next byte              \
           is also available.  */                                             \
        uint32_t ch2;                                                         \
-       uint_fast32_t idx;                                                    \
+       uint32_t idx;                                                 \
                                                                              \
        if (__glibc_unlikely (inptr + 1 >= inend))                            \
          {                                                                   \
index 8bccfcb6d0c5f1435e410b4c85e1f820f9d78f1f..08dc3da77a44723de086068874188f4533c0ee96 100644 (file)
@@ -18,7 +18,7 @@
 
 /* The hashing function used for the table with collation symbols.  */
 static int32_t __attribute__ ((pure, unused))
-elem_hash (const char *str, int_fast32_t n)
+elem_hash (const char *str, int32_t n)
 {
   int32_t result = n;
 
index c49f4e6d9089ca24fec0cc0058be5ef5bb6022e1..8be2d220f814fbbcb85c506a0911d4215324203c 100644 (file)
@@ -27,7 +27,7 @@ findidx (const int32_t *table,
         const unsigned char *extra,
         const unsigned char **cpp, size_t len)
 {
-  int_fast32_t i = table[*(*cpp)++];
+  int32_t i = table[*(*cpp)++];
   const unsigned char *cp;
   const unsigned char *usrc;
 
index 5827597d2c41e89b4e3d4362b15bf3ffb29afebc..cb079b16f71ead57ca816c9ff80182f12c13784b 100644 (file)
@@ -814,7 +814,7 @@ re_string_elem_size_at (const re_string_t *pstr, Idx idx)
 # ifdef _LIBC
   const unsigned char *p, *extra;
   const int32_t *table, *indirect;
-  uint_fast32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
+  uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
 
   if (nrules != 0)
     {
index 3151e50ae1c7bf3d59feba1ed5f467b3c6a87d7e..9aaa2c45bca68b409f25ded920fe4a1ef51bebc4 100644 (file)
@@ -118,7 +118,7 @@ _nss_dns_getcanonname_r (const char *name, char *buffer, size_t buflen,
                goto unavail;
 
              /* Check whether type and class match.  */
-             uint_fast16_t type;
+             short int type;
              NS_GET16 (type, ptr);
              if (type == qtypes[i])
                {
index 1b08f11b9947a4a11b6ac12468aa70abeb2d6e14..b366020fc709f3eea02418aae4b434f84dc77adc 100644 (file)
@@ -257,7 +257,7 @@ int
 STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, locale_t l)
 {
   struct __locale_data *current = l->__locales[LC_COLLATE];
-  uint_fast32_t nrules = current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].word;
+  uint32_t nrules = current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].word;
   /* We don't assign the following values right away since it might be
      unnecessary in case there are no rules.  */
   const unsigned char *rulesets;
index 5519c3cf8f775f6f9e19b2f97e5e0de0293a70a3..188a3d826a67615634634a260d815e3a6bd4638a 100644 (file)
@@ -49,7 +49,7 @@
 /* Group locale data for shorter parameter lists.  */
 typedef struct
 {
-  uint_fast32_t nrules;
+  uint32_t nrules;
   unsigned char *rulesets;
   USTRING_TYPE *weights;
   int32_t *table;
@@ -135,7 +135,7 @@ do_xfrm (const USTRING_TYPE *usrc, STRING_TYPE *dest, size_t n,
 {
   int32_t weight_idx;
   unsigned char rule_idx;
-  uint_fast32_t pass;
+  uint32_t pass;
   size_t needed = 0;
   size_t last_needed;
 
@@ -404,10 +404,10 @@ static size_t
 do_xfrm_cached (STRING_TYPE *dest, size_t n, const locale_data_t *l_data,
                size_t idxmax, int32_t *idxarr, const unsigned char *rulearr)
 {
-  uint_fast32_t nrules = l_data->nrules;
+  uint32_t nrules = l_data->nrules;
   unsigned char *rulesets = l_data->rulesets;
   USTRING_TYPE *weights = l_data->weights;
-  uint_fast32_t pass;
+  uint32_t pass;
   size_t needed = 0;
   size_t last_needed;
   size_t idxcnt;
index e784320234646a8a42100ad1755371f894cebfe8..45b6bcaeac57aa3e6e0510276dd3d561aa864111 100644 (file)
@@ -152,7 +152,7 @@ static const struct abi_req none_req = { true, true, true, false, true };
    impact of dlclose.  */
 
 static bool __attribute_used__
-elf_machine_reject_phdr_p (const ElfW(Phdr) *phdr, uint_fast16_t phnum,
+elf_machine_reject_phdr_p (const ElfW(Phdr) *phdr, unsigned int phnum,
                           const char *buf, size_t len, struct link_map *map,
                           int fd)
 {
index c90f109b119c2393dda3b902d409234b55cf4c38..a67c45467335794e55ca14a69982d6216447ac8c 100644 (file)
@@ -269,7 +269,7 @@ _dl_discover_osversion (void)
       } expected_note = { { sizeof "Linux", sizeof (ElfW(Word)), 0 }, "Linux" };
       const ElfW(Phdr) *const phdr = GLRO(dl_sysinfo_map)->l_phdr;
       const ElfW(Word) phnum = GLRO(dl_sysinfo_map)->l_phnum;
-      for (uint_fast16_t i = 0; i < phnum; ++i)
+      for (unsigned int i = 0; i < phnum; ++i)
        if (phdr[i].p_type == PT_NOTE)
          {
            const ElfW(Addr) start = (phdr[i].p_vaddr