Disable elision for PTHREAD_MUTEX_NORMAL mutexes

There was a lot of discussion about the POSIX statement that
PTHREAD_MUTEX_NORMAL "shall" deadlock for mutexes that
get re-acquired by the same thread.

Elided mutexes act like recursive locks and would only deadlock
sometimes (any time an abort happens, e.g. at program startup
or when context switches or syscalls happen), but not guaranteed
every time.

This does not apply to DEFAULT mutexes.  But currently in glibc DEFAULT and
NORMAL is the same number.

The only way NORMAL can be set is through pthread_mutexattr_setkind()
PTHREAD_MUTEX_INITIALIZER initialized mutexes are default.

So what we do here is:
- Add a new numeric value for PTHREAD_MUTEX_NORMAL
- Add a new symbol version for pthread_mutexattr_setkind
(and its aliases pthread_mutexattr_settype_np and __pthread_mutexattr_settype)
that disables elision for the new PTHREAD_MUTEX_NORMAL value
- The compat version for the old symbol version always
disables elision when a 0 type (old ambigious DEFUALT/NORMAL)
is passed.

The result is that old binaries that use pthread_mutexattr_setkind()
for NORMAL/DEFAULT/TIMED_NP will disable elision, and new programs that
use it with PTHREAD_MUTEX_NORMAL only (but not default/timed) will
also disable elision. Any mutex not using pthread_mutexattr_setkind
or setting an ADAPTIVE type uses elision. The use of
pthread_mutexattr_setkind() for the default type is expected to be
rare, so this should not affect many programs.

Note an alternative would be to just disable nesting for these
normal mutexes (so always _xabort() before starting a transaction).
This would require additional checks in the fast path, and
since this case should be rare we just disable elision instead.

This adds new symbol versions to pthread, so the ABI test
reference files for libpthread in all other ports have to be
updated. I only updated x86_64 and i386 so far.

Thanks to Torvald Riegel, Roland McGrath, Richard Henderson, Rich Felker
for input on the discussion. This patch is based on the proposal from
Rich Felker, with some help from H.J. on the aliases.

XXX add i386 abi files

/:
2013-06-21  Andi Kleen  <ak@linux.intel.com>

	* Versions.def (GLIBC_2.18): Add new 2.18 version for libpthread.

nptl/:
2013-06-21  Andi Kleen  <ak@linux.intel.com>
            H.J. Lu  <hongjiu.lu@intel.com>
            Rich Felker <dalias@aerifal.cx>

	* Versions (pthread_mutexattr_settype,
	  pthread_mutexattr_setkind_np, __pthread_mutexattr_settype): Add
	  new version for GLIBC_2.18.
	* pthreadP.h: Use PTHREAD_MUTEX_DEFAULT to define derived
	  NORMAL mutexes. These disable elision in any case.
	* pthread_mutexattr_init.c (pthread_mutexattr_init):
	  Use PTHREAD_MUTEX_DEFAULT instead of PTHREAD_MUTEX_NORMAL.
	* pthread_mutex_init.c (default_mutexattr): Use
	  PTHREAD_MUTEX_DEFAULT as base value.
	  (__pthread_mutex_init): Disable elision flags for
	  prio/robust.
	* pthread_mutexattr_settype.c
	  (pthread_mutexattr_settype_worker): Rename from
	  __pthread_mutexattr_settype.
	  (__pthread_mutexattr_settype_new):
          Add new symbol version. Disable lock elision for NORMAL type.
	  (__pthread_mutexattr_settype_old): New function to disable lock
	  elision for old DEFAULT/NORMAL/TIMED type.
	* sysdeps/pthread/pthread.h (PTHREAD_MUTEX_NORMAL): Redefine
	  as new value.
	* tst-mutex5.c: Use PTHREAD_MUTEX_DEFAULT.
	* sysdeps/unix/sysv/linux/x86_64/64/nptl/libpthread.abilist:
	  Update.
improve fast path for lock