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] Deconditionalize use of LLL_LOCK_INITIALIZER in bits/libc-lock.h.


This was an old attempt at microoptimization that has been superfluous for
some years (i.e. GCC versions).  -Wundef warned us that it was in fact
working by luck (LLL_LOCK_INITIALIZER was not defined at the time of its
use in #if, but it so happens that in all configurations its actual correct
value was zero anyway).  I had thought that deconditionalizing it would
reveal a real compile error with LLL_LOCK_INITIALIZER not being defined.
But it did not, so evidently all the users were including lowlevellock.h
afterwards by some other means.  (I have not investigated further.)

Build-tested on x86_64-linux-gnu, i686-linux-gnu, arm-linux-gnueabihf.


Thanks,
Roland


2014-05-01  Roland McGrath  <roland@hack.frob.com>

	* nptl/sysdeps/pthread/bits/libc-lock.h
	[_LIBC && (!NOT_IN_libc || IS_IN_libpthread)]
	(__libc_lock_define_initialized_recursive): Always define using
	initializer.  Modern compilers treat uninitialized (implicit zero) and
	explicit zero initializers the same (i.e. put the datum in bss).

--- a/nptl/sysdeps/pthread/bits/libc-lock.h
+++ b/nptl/sysdeps/pthread/bits/libc-lock.h
@@ -48,13 +48,8 @@ typedef struct __libc_lock_recursive_opaque__ __libc_lock_recursive_t;
 /* Define an initialized recursive lock variable NAME with storage
    class CLASS.  */
 #if defined _LIBC && (!defined NOT_IN_libc || defined IS_IN_libpthread)
-# if LLL_LOCK_INITIALIZER == 0
-#  define __libc_lock_define_initialized_recursive(CLASS,NAME) \
-  CLASS __libc_lock_recursive_t NAME;
-# else
-#  define __libc_lock_define_initialized_recursive(CLASS,NAME) \
+# define __libc_lock_define_initialized_recursive(CLASS, NAME) \
   CLASS __libc_lock_recursive_t NAME = _LIBC_LOCK_RECURSIVE_INITIALIZER;
-# endif
 # define _LIBC_LOCK_RECURSIVE_INITIALIZER \
   { LLL_LOCK_INITIALIZER, 0, NULL }
 #else


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