This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[COMMITTED PATCH] Remove a lot of inline keywords


I tried the -Os build and fixed a lot of "inlining failed" warnings with
this.  It did affect the code generation on the -O2 build for
x86_64-linux-gnu too (making libc.so text about 2k smaller).  I didn't
analyze this in detail, but I don't see any reason off hand to think our
optimization choices are better than the compiler's for these miscellanea.
No 'make check' regressions on x86_64-linux-gnu (-O2).

In general, I think we should eschew the inline keyword entirely when used
alone.  If it really matters that something be inlined, it needs
always_inline.  Otherwise we should leave optimization decisions to the
compiler unless there is a particular strong reason in an individual case.
Any such cases should have clear comments saying why the explicit inline
is desireable.


Thanks,
Roland


2013-02-07  Roland McGrath  <roland@hack.frob.com>

	* nscd/nscd-client.h (__nscd_drop_map_ref):
	Add __attribute__ ((unused)).
	* nis/nss-nisplus.h (niserr2nss): Likewise.

	* sysdeps/x86_64/multiarch/strstr.c (__m128i_strloadu): Define it only
	under [!(USE_AS_STRCASESTR && STRCASESTR_NONASCII)].

	* csu/libc-tls.c (init_static_tls, init_slotinfo):
	Remove inline keyword.
	* include/rounding-mode.h (round_away): Likewise.
	* libio/wfileops.c (adjust_wide_data): Likewise.
	* sysdeps/x86_64/multiarch/strstr.c (__m128i_strloadu): Likewise.
	(__m128i_strloadu_tolower): Likewise.
	* sysdeps/x86_64/multiarch/strcasestr-nonascii.c
	(__m128i_strloadu_tolower): Likewise.
	* time/mktime.c (ydhms_diff): Likewise.
	* locale/elem-hash.h (elem_hash): Likewise.
	* locale/setlocale.c (setdata): Likewise.
	* posix/regex_internal.h (re_string_char_size_at): Likewise.
	(re_string_wchar_at): Likewise.
	(bitset_not, bitset_merge, bitset_mask): Likewise.
	[!(__GNUC__ > 3)] (inline): Remove macro.
	* nscd/nscd-client.h (__nscd_drop_map_ref): Remove inline keyword.
	* elf/dl-deps.c (_dl_map_object_deps: preload): Likewise.
	* elf/tlsdeschtab.h (_dl_tlsdesc_resolve_early_return_p): Likewise.
	(_dl_tlsdesc_wake_up_held_fixups): Likewise.
	* string/memcmp.c (memcmp_bytes): Likewise.
	* locale/programs/locarchive.c (compute_hashval): Likewise.
	* sysdeps/ieee754/dbl-64/x2y2m1.c (mul_split): Likewise.
	* sysdeps/unix/sysv/linux/fips-private.h (fips_enabled_p): Likewise.
	* resolv/res_send.c (evNowTime, evCmpTime): Likewise.
	* nss/getent.c (print_rpc, print_protocols): Likewise.
	(print_passwd, print_group, print_aliases): Likewise.
	* nis/nss-nisplus.h (niserr2nss): Likewise.
	* nscd/connections.c (restart_p): Likewise.
	Change return type to bool.

--- a/csu/libc-tls.c
+++ b/csu/libc-tls.c
@@ -75,7 +75,7 @@ size_t _dl_tls_generation;
 TLS_INIT_HELPER
 #endif
 
-static inline void
+static void
 init_slotinfo (void)
 {
   /* Create the slotinfo list.  */
@@ -90,7 +90,7 @@ init_slotinfo (void)
   GL(dl_tls_dtv_slotinfo_list) = &static_slotinfo.si;
 }
 
-static inline void
+static void
 init_static_tls (size_t memsz, size_t align)
 {
   /* That is the size of the TLS memory for this object.  The initialized
--- a/elf/dl-deps.c
+++ b/elf/dl-deps.c
@@ -155,9 +155,7 @@ _dl_map_object_deps (struct link_map *map,
   const char *errstring;
   const char *objname;
 
-  auto inline void preload (struct link_map *map);
-
-  inline void preload (struct link_map *map)
+  void preload (struct link_map *map)
     {
       known[nlist].done = 0;
       known[nlist].map = map;
--- a/elf/tlsdeschtab.h
+++ b/elf/tlsdeschtab.h
@@ -129,7 +129,7 @@ _dl_make_tlsdesc_dynamic (struct link_map *map, size_t ti_offset)
    or a futex wake to wake up any waiting threads, but let's try to
    avoid introducing such dependencies.  */
 
-inline static int
+static int
 _dl_tlsdesc_resolve_early_return_p (struct tlsdesc volatile *td, void *caller)
 {
   if (caller != td->entry)
@@ -147,7 +147,7 @@ _dl_tlsdesc_resolve_early_return_p (struct tlsdesc volatile *td, void *caller)
   return 0;
 }
 
-inline static void
+static void
 _dl_tlsdesc_wake_up_held_fixups (void)
 {
   __rtld_lock_unlock_recursive (GL(dl_load_lock));
--- a/include/rounding-mode.h
+++ b/include/rounding-mode.h
@@ -39,7 +39,7 @@
    MORE_BITS is true if the number is not exactly equal to the
    truncated value or the half-way value, false otherwise.  */
 
-static inline bool
+static bool
 round_away (bool negative, bool last_digit_odd, bool half_bit, bool more_bits,
 	    int mode)
 {
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -551,7 +551,7 @@ libc_hidden_def (_IO_wfile_sync)
    fp->_wide_data->_IO_read_base and fp->_wide_data->_IO_read_end.
 
    Returns 0 on success and -1 on error with the _IO_ERR_SEEN flag set.  */
-static inline int
+static int
 adjust_wide_data (_IO_FILE *fp, bool do_convert)
 {
   struct _IO_codecvt *cv = fp->_codecvt;
--- a/locale/elem-hash.h
+++ b/locale/elem-hash.h
@@ -18,7 +18,7 @@
 
 
 /* The hashing function used for the table with collation symbols.  */
-static inline int32_t
+static int32_t
 elem_hash (const char *str, int_fast32_t n)
 {
   int32_t result = n;
--- a/locale/programs/locarchive.c
+++ b/locale/programs/locarchive.c
@@ -45,7 +45,7 @@
 
 /* Define the hash function.  We define the function as static inline.
    We must change the name so as not to conflict with simple-hash.h.  */
-#define compute_hashval static inline archive_hashval
+#define compute_hashval static archive_hashval
 #define hashval_t uint32_t
 #include "hashval.h"
 #undef compute_hashval
--- a/locale/setlocale.c
+++ b/locale/setlocale.c
@@ -204,7 +204,7 @@ setname (int category, const char *name)
 }
 
 /* Put DATA in *_nl_current[CATEGORY].  */
-static inline void
+static void
 setdata (int category, struct __locale_data *data)
 {
   if (CATEGORY_USED (category))
--- a/nis/nss-nisplus.h
+++ b/nis/nss-nisplus.h
@@ -28,7 +28,8 @@
 extern const enum nss_status __niserr2nss_tab[] attribute_hidden;
 extern const unsigned int __niserr2nss_count attribute_hidden;
 
-static inline enum nss_status
+static enum nss_status
+__attribute__ ((unused))
 niserr2nss (int errval)
 {
   if ((unsigned int) errval >= __niserr2nss_count)
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -1859,7 +1859,7 @@ fd_ready (int fd)
 
 
 /* Check whether restarting should happen.  */
-static inline int
+static bool
 restart_p (time_t now)
 {
   return (paranoia && readylist == NULL && nready == nthreads
--- a/nscd/nscd-client.h
+++ b/nscd/nscd-client.h
@@ -362,8 +362,9 @@ extern struct mapped_database *__nscd_get_map_ref (request_type type,
 extern void __nscd_unmap (struct mapped_database *mapped);
 
 /* Drop reference of mapping.  */
-static inline int __nscd_drop_map_ref (struct mapped_database *map,
-				       int *gc_cycle)
+static int
+__attribute__ ((unused))
+__nscd_drop_map_ref (struct mapped_database *map, int *gc_cycle)
 {
   if (map != NO_MAPPING)
     {
--- a/nss/getent.c
+++ b/nss/getent.c
@@ -92,7 +92,7 @@ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\
 }
 
 /* This is for aliases */
-static inline void
+static void
 print_aliases (struct aliasent *alias)
 {
   unsigned int i = 0;
@@ -181,7 +181,7 @@ ethers_keys (int number, char *key[])
 }
 
 /* This is for group */
-static inline void
+static void
 print_group (struct group *grp)
 {
   unsigned int i = 0;
@@ -600,7 +600,7 @@ networks_keys (int number, char *key[])
 }
 
 /* Now is all for passwd */
-static inline void
+static void
 print_passwd (struct passwd *pwd)
 {
   printf ("%s:%s:%lu:%lu:%s:%s:%s\n",
@@ -651,7 +651,7 @@ passwd_keys (int number, char *key[])
 }
 
 /* This is for protocols */
-static inline void
+static void
 print_protocols (struct protoent *proto)
 {
   unsigned int i;
@@ -701,7 +701,7 @@ protocols_keys (int number, char *key[])
 }
 
 /* Now is all for rpc */
-static inline void
+static void
 print_rpc (struct rpcent *rpc)
 {
   int i;
--- a/posix/regex_internal.h
+++ b/posix/regex_internal.h
@@ -98,7 +98,6 @@
 # define BE(expr, val) __builtin_expect (expr, val)
 #else
 # define BE(expr, val) (expr)
-# define inline
 #endif
 
 /* Number of single byte character.  */
@@ -687,7 +686,7 @@ typedef struct
 
 
 /* Inline functions for bitset operation.  */
-static inline void
+static void
 bitset_not (bitset_t set)
 {
   int bitset_i;
@@ -695,7 +694,7 @@ bitset_not (bitset_t set)
     set[bitset_i] = ~set[bitset_i];
 }
 
-static inline void
+static void
 bitset_merge (bitset_t dest, const bitset_t src)
 {
   int bitset_i;
@@ -703,7 +702,7 @@ bitset_merge (bitset_t dest, const bitset_t src)
     dest[bitset_i] |= src[bitset_i];
 }
 
-static inline void
+static void
 bitset_mask (bitset_t dest, const bitset_t src)
 {
   int bitset_i;
@@ -713,7 +712,7 @@ bitset_mask (bitset_t dest, const bitset_t src)
 
 #ifdef RE_ENABLE_I18N
 /* Inline functions for re_string.  */
-static inline int
+static int
 internal_function __attribute ((pure))
 re_string_char_size_at (const re_string_t *pstr, int idx)
 {
@@ -726,7 +725,7 @@ re_string_char_size_at (const re_string_t *pstr, int idx)
   return byte_idx;
 }
 
-static inline wint_t
+static wint_t
 internal_function __attribute ((pure))
 re_string_wchar_at (const re_string_t *pstr, int idx)
 {
--- a/resolv/res_send.c
+++ b/resolv/res_send.c
@@ -155,7 +155,7 @@ evSubTime(struct timespec *res, const struct timespec *minuend,
 	}
 }
 
-static inline int
+static int
 evCmpTime(struct timespec a, struct timespec b) {
 	long x = a.tv_sec - b.tv_sec;
 
@@ -164,7 +164,7 @@ evCmpTime(struct timespec a, struct timespec b) {
 	return (x < 0L ? (-1) : x > 0L ? (1) : (0));
 }
 
-static inline void
+static void
 evNowTime(struct timespec *res) {
 	struct timeval now;
 
--- a/string/memcmp.c
+++ b/string/memcmp.c
@@ -88,9 +88,6 @@ typedef unsigned char byte;
 
 static int memcmp_bytes (op_t, op_t) __THROW;
 
-# ifdef  __GNUC__
-__inline
-# endif
 static int
 memcmp_bytes (a, b)
      op_t a, b;
--- a/sysdeps/ieee754/dbl-64/x2y2m1.c
+++ b/sysdeps/ieee754/dbl-64/x2y2m1.c
@@ -37,7 +37,7 @@ add_split (double *hi, double *lo, double x, double y)
    given that the values are small enough that no overflow occurs and
    large enough (or zero) that no underflow occurs.  */
 
-static inline void
+static void
 mul_split (double *hi, double *lo, double x, double y)
 {
 #ifdef __FP_FAST_FMA
--- a/sysdeps/unix/sysv/linux/fips-private.h
+++ b/sysdeps/unix/sysv/linux/fips-private.h
@@ -29,7 +29,7 @@
 /* Return true if FIPS mode is enabled.  See
    sysdeps/generic/fips-private.h for more information.  */
 
-static inline bool
+static bool
 fips_enabled_p (void)
 {
   static enum
--- a/sysdeps/x86_64/multiarch/strcasestr-nonascii.c
+++ b/sysdeps/x86_64/multiarch/strcasestr-nonascii.c
@@ -22,7 +22,7 @@
 
 /* Similar to __m128i_strloadu.  Convert to lower case for none-POSIX/C
    locale.  */
-static inline __m128i
+static __m128i
 __m128i_strloadu_tolower (const unsigned char *p)
 {
   union
--- a/sysdeps/x86_64/multiarch/strstr.c
+++ b/sysdeps/x86_64/multiarch/strstr.c
@@ -82,11 +82,11 @@
    5.  failed string compare, go back to scanning
  */
 
+#if !(defined USE_AS_STRCASESTR && defined STRCASESTR_NONASCII)
 /* Simple replacement of movdqu to address 4KB boundary cross issue.
    If EOS occurs within less than 16B before 4KB boundary, we don't
    cross to next page.  */
-
-static inline __m128i
+static __m128i
 __m128i_strloadu (const unsigned char * p, __m128i zero)
 {
   if (__builtin_expect ((int) ((size_t) p & 0xfff) > 0xff0, 0))
@@ -99,13 +99,14 @@ __m128i_strloadu (const unsigned char * p, __m128i zero)
     }
   return _mm_loadu_si128 ((__m128i *) p);
 }
+#endif
 
 #if defined USE_AS_STRCASESTR && !defined STRCASESTR_NONASCII
 
 /* Similar to __m128i_strloadu.  Convert to lower case for POSIX/C
    locale and other which have single-byte letters only in the ASCII
    range.  */
-static inline __m128i
+static __m128i
 __m128i_strloadu_tolower (const unsigned char *p, __m128i zero, __m128i uclow,
 			  __m128i uchigh, __m128i lcqword)
 {
--- a/time/mktime.c
+++ b/time/mktime.c
@@ -196,7 +196,7 @@ isdst_differ (int a, int b)
    The result may overflow.  It is the caller's responsibility to
    detect overflow.  */
 
-static inline time_t
+static time_t
 ydhms_diff (long_int year1, long_int yday1, int hour1, int min1, int sec1,
 	    int year0, int yday0, int hour0, int min0, int sec0)
 {


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]