Commit Graph

1269 Commits

Author SHA1 Message Date
H.J. Lu 4a306ef1c8 ld.so: Add architecture specific fields
To support Intel Control-flow Enforcement Technology (CET) run-time
control:

1. An architecture specific field in the writable ld.so namespace is
needed to indicate if CET features are enabled at run-time.
2. An architecture specific field in struct link_map is needed if
CET features are enabled in an ELF module.

This patch adds dl-procruntime.c to the writable ld.so namespace and
link_map.h to struct link_map.

Tested with build-many-glibcs.py.

	* elf/dl-support.c: Include <dl-procruntime.c>.
	* include/link.h: Include <link_map.h>.
	* sysdeps/generic/dl-procruntime.c: New file.
	* sysdeps/generic/link_map.h: Likewise.
	* sysdeps/generic/ldsodefs.h: Include <dl-procruntime.c> in
	the writable ld.so namespace.
2017-11-13 08:02:52 -08:00
H.J. Lu 8cb5295d3f Add jmp_buf-macros.h
Verify that sizes, alignments and field offsets of jmp_buf as well as
sigjmp_buf are unchanged regardless how struct __jmp_buf_tag is defined.
Since jmp_buf is target specific, jmp_buf-macros.h is added for each
Linux target.  A new target must provides its own jmp_buf-macros.h.

TODO: Hurd needs to provide a jmp_buf-macros.h.

Tested with build-many-glibcs.py.

	* include/setjmp.h [!_ISOMAC]: Include <stddef.h> and
	<jmp_buf-macros.h>.
	[!_ISOMAC] (STR_HELPER): New.
	[!_ISOMAC] (STR): Likewise.
	[!_ISOMAC] (TEST_SIZE): Likewise.
	[!_ISOMAC] (TEST_ALIGN): Likewise.
	[!_ISOMAC] (TEST_OFFSET): Likewise.
	[!_ISOMAC] Add _Static_assert to check sizes, alignments and
	field offsets of jmp_buf as well as sigjmp_buf.
	* sysdeps/unix/sysv/linux/aarch64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/jmp_buf-macros.h:
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/jmp_buf-macros.h: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/jmp_buf-macros.h: Likewise.
2017-11-09 05:10:03 -08:00
Joseph Myers 3683b423a4 Handle more _FloatN, _FloatNx types in include/float.h.
Continuing the preparation for additional _FloatN / _FloatNx type
support, this patch adds support in include/float.h.  This header
defines macros for _Float128 properties when using compilers before
GCC 7 that lack those macros in <float.h>.  For testing _Float32 /
_Float64 / _Float32x / _Float64x functions with older compilers, such
macros need to be defined for those types as well; for the older
compilers, those types will always be typedefs for another type, so
the definitions can be in terms of the macros for that other type.

Tested for x86_64.

	* include/float.h
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MANT_DIG): New macro.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32] (FLT32_TRUE_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MANT_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64] (FLT64_TRUE_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MANT_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT32X] (FLT32X_TRUE_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MANT_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_DECIMAL_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_DIG): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MIN_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MIN_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MAX_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MAX_10_EXP): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MAX): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __GLIBC_USE (IEC_60559_TYPES_EXT)
	&& __HAVE_FLOAT64X] (FLT64X_TRUE_MIN): Likewise.
2017-11-07 23:49:04 +00:00
Florian Weimer c94a5688fb <array_length.h>: New array_length and array_end macros 2017-11-02 12:45:20 +01:00
Joseph Myers eda162dd8a Remove _Mlong_double_ etc. macros.
math.h has a macro _Mlong_double_ for the type to use when declaring
long double functions, and similar macros for other types.
math/Makefile uses -D_Mlong_double_=double in the case of long double
having the same ABI as double.

This originates with:

Mon Jul  8 13:37:40 1996  Roland McGrath  <roland@delasyd.gnu.ai.mit.edu>

        * math/math.h (_Mfloat_, _Mlong_double_): New macros, defined iff not
        already defined to float, long double.  Use those macros for _Mdouble_
        defns when including mathcalls.h.
        * math/Makefile [$(long-double-fcts) != yes] (CPPFLAGS): Append
        -D_Mlong_double_=double.

However, math.h stopped declaring long double functions in the case of
long double having the same ABI as double (and thus probably stopped
actually needing the Makefile definition of _Mlong_double_) with:

1998-11-05  Ulrich Drepper  <drepper@cygnus.com>

        * math/math.h: Unconditionally include bits/mathdef.h.  Declare
        long double functions only if __NO_LONG_DOUBLE_MATH is not
        defined.
        * sysdeps/generic/bits/mathdef.h: Define only if __USE_ISOC9X.
        Define __NO_LONG_DOUBLE_MATH.
        * sysdeps/m68k/fpu/bits/mathdef.h: Define only if __USE_ISOC9X.
        * sysdeps/i386/fpu/bits/mathdef.h: Likewise.

The declarations were since restored for compiling user code, but
remain absent when _LIBC is defined, which is sufficient to avoid
problems declaring function aliases of incompatible types.  Thus the
indirection through the _Mlong_double_ macro is not needed (probably
since that 1998 patch), and this patch removes _Mlong_double_ and
associated macros for other types, leaving only the macro _Mdouble_
which is actually used as the type for which a given inclusion of
<bits/mathcalls.h> should declared functions.

Tested for x86_64, and tested with build-many-glibcs.py that installed
stripped shared libraries are unchanged by this patch.

	* math/math.h [!_Mfloat_] (_Mfloat_): Do not define.
	[!_Mlong_double_] (_Mlong_double_): Likewise.
	[!_Mfloat16_] (_Mfloat16_): Likewise.
	[!_Mfloat32_] (_Mfloat32_): Likewise.
	[!_Mfloat64_] (_Mfloat64_): Likewise.
	[!_Mfloat128_] (_Mfloat128_): Likewise.
	[!_Mfloat32x_] (_Mfloat32x_): Likewise.
	[!_Mfloat64x_] (_Mfloat64x_): Likewise.
	[!_Mfloat128x_] (_Mfloat128x_): Likewise.
	(_Mdouble_): Define without indirection through those macros.
	* math/complex.h [!_Mfloat_] (_Mfloat_): Do not define.
	[!_Mfloat128_] (_Mfloat128_): Likewise.
	[_Mlong_double_] (_Mlong_double_): Likewise.
	(_Mdouble_): Define without indirection through those macros.
	* math/Makefile [$(long-double-fcts) != yes] (math-CPPFLAGS): Do
	not add -D_Mlong_double_=double.
	* include/math.h [_ISOMAC] (_Mlong_double_): Do not undefine.
	* math/test-signgam-finite-c99.c (_Mlong_double_): Likewise.
2017-10-30 20:58:51 +00:00
H.J. Lu a122dbfb2e Replace "if if " with "if " in comments
* include/alloc_buffer.h: Replace "if if " with "if " in
	comments.
	* sysdeps/mips/memcpy.S: Likkewise.
	* sysdeps/mips/memset.S: Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_sincosf16_core_avx512.S:
	Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_sincosf4_core_sse4.S:
	Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_sincosf8_core_avx2.S:
	Likewise.
2017-10-25 08:05:51 -07:00
Joseph Myers 13c92696d2 Use __f128 to define FLT128_* constants in include/float.h for old GCC.
When using compilers before GCC 7, include/float.h provides fallback
definitions of FLT128_* constants.  These definitions use 'Q' constant
suffixes, which works for configurations with _Float128 ABI-distinct
from long double, but not where it has the same ABI as long double.
This patch changes the definitions to use the __f128 macro from
<bits/floatn.h>, so allowing them to work in the non-distinct
_Float128 case (where they are used in building glibc tests, not for
building glibc itself) as well.

Tested (a) with build-many-glibcs.py with GCC 6 (installed stripped
shared libraries unchanged by the patch); (b) with
build-many-glibcs.py with GCC 6 together with the main patch to enable
float128 aliases; (c) for x86_64 with both GCC 6 and GCC 7.

	* include/float.h [!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 &&
	__GLIBC_USE (IEC_60559_TYPES_EXT)] (FLT128_MAX): Define using
	__f128.
	[!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (FLT128_EPSILON): Likewise.
	[!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (FLT128_MIN): Likewise.
	[!__GNUC_PREREQ (7, 0) && __HAVE_FLOAT128 && __GLIBC_USE
	(IEC_60559_TYPES_EXT)] (FLT128_TRUE_MIN): Likewise.
2017-10-17 20:16:01 +00:00
Carlos O'Donell 3480ddc40b shlib-compat: Update documentation of the compat_symbol_reference macro 2017-10-16 20:43:28 +02:00
Jonathan Wakely d6c064e914 Ensure C99 and C11 interfaces are available for C++ [BZ #21326]
This patch ensures that the C99 and C11 features required by C++ are
defined according to the value of the __cplusplus macro, and not just
because G++ always defines _GNU_SOURCE.  This will allow G++ to stop
defining _GNU_SOURCE some day, without causing the C99 and C11
interfaces to disappear for C++ programs.

	[BZ #21326]
	* include/features.h [__cplusplus >= 201103] (__USE_ISOC99): Define.
	[__cplusplus >= 201703] (__USE_ISOCXX17, __USE_ISOC11): Define.
	* math/Makefile (test-math-cxx11): New test.
	* math/test-math-cxx11.cc: New file.
2017-10-09 16:18:11 +02:00
H.J. Lu ee417882e0 Don't use hidden visibility in libc.a with PIE on i386
On i386, when multi-arch is enabled, all external functions must be
called via PIC PLT in PIE, which requires setting up EBX register,
since they may be IFUNC functions.

	* config.h.in (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New.
	* include/libc-symbols.h (__hidden_proto_hiddenattr): Add check
	for PIC and NO_HIDDEN_EXTERN_FUNC_IN_PIE.
	* sysdeps/i386/configure.ac (NO_HIDDEN_EXTERN_FUNC_IN_PIE): New
	AC_DEFINE if multi-arch is enabled.
	* sysdeps/i386/configure: Regenerated.
2017-10-04 17:18:42 -07:00
Samuel Thibault 3d1870fa33 Introduce NO_RTLD_HIDDEN, make hurd use it instead of NO_HIDDEN
On the Hurd, the rtld needs to see its own dumb versions of a few functions
(defined in sysdeps/mach/hurd/dl-sysdep.c) overridden by libc's versions once
loaded. rtld should thus not have hidden attribute for these.  To achieve this,
the Hurd port used to just define NO_HIDDEN, which disables it completely. For
now, this changes that to disabling it for all rtld functions, for simplicity.

See Roland's comment on https://sourceware.org/bugzilla/show_bug.cgi?id=15605#c5

The ld.so numbers remain at

  8 .rel.plt      000000c8  00000c24  00000c24  00000c24  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  9 .plt          000001a0  00000cf0  00000cf0  00000cf0  2**4
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 10 .plt.got      00000010  00000e90  00000e90  00000e90  2**3
                  CONTENTS, ALLOC, LOAD, READONLY, CODE
 18 .got.plt      00000070  0002d000  0002d000  0002c000  2**2
                  CONTENTS, ALLOC, LOAD, DATA

which is about 3 times as much as on Linux.

The libc.so numbers get divided by 3 (the remainings are mostly RPC stub calls)

	* include/libc-symbols.h [NO_RTLD_HIDDEN] (rtld_hidden_proto,
	rtld_hidden_tls_proto, rtld_hidden_def, rtld_hidden_weak,
	rtld_hidden_rtld_hidden_ver, data_def, rtld_hidden_data_weak,
	rtld_hidden_data_ver): Define to empty.
	* include/assert.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__assert_fail,
	__assert_perror_fail): Likewise.
	* include/dirent.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(__rewinddir): Likewise.
	* include/libc-internal.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(__profile_frequency): Likewise.
	* include/setjmp.h (__sigsetjmp): Likewise.
	* include/signal.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__sigaction,
	__libc_sigaction): Likewise.
	* include/stdlib.h [NO_RTLD_HIDDEN] (unsetenv, __strtoul_internal): Do
	not set hidden attribute.
	* include/string.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__stpcpy, __strdup,
	__strerror_t, __strsep_g, memchr, memcmp, memcpy, memmove, memset,
	rawmemchr, stpcpy, strchr, strcmp, strlen, strnlen, strsep): Likewise.
	* include/sys/stat.h [IS_IN(rtld) && NO_RTLD_HIDDEN] (__fxstat,
	__fxstat64, __lxstat, __lxstat64, __xstat, __xstat64,
	__fxstatat64): Likewise.
	* include/sys/utsname.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(__uname): Likewise.
	* include/sysdeps/generic/_itoa.h [IS_IN(rtld) && NO_RTLD_HIDDEN]
	(_itoa_upper_digits, _itoa_lower_digits): Likewise.
	* sysdeps/mach/hurd/configure.ac (NO_HIDDEN): Do not set.
	(NO_RTLD_HIDDEN): Set.
	* sysdeps/mach/hurd/configure: Refresh.
	* config.h.in: Refresh.
2017-10-03 01:33:38 +02:00
H.J. Lu c0769f7031 Hide internal __glob64 function [BZ #18822]
Hide internal __glob64 function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/glob.h (__glob64): Add libc_hidden_proto.
	* sysdeps/unix/sysv/linux/glob64.c (__glob64): Add
	libc_hidden_def.
2017-10-01 18:02:10 -07:00
H.J. Lu 7bfd08ac5b Hide internal __init_misc function [BZ #18822]
Hide internal __init_misc function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/libc-internal.h (__init_misc): Add attribute_hidden.
2017-10-01 17:53:55 -07:00
H.J. Lu 0e1fd06cde Hide internal __setfpucw function [BZ #18822]
Hide internal __setfpucw function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/fpu_control.h (__setfpucw): Add attribute_hidden.
2017-10-01 17:52:15 -07:00
H.J. Lu 87078544f2 Hide internal __tcgetattr function [BZ #18822]
Hide internal __tcgetattr function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/termios.h (__tcgetattr): Add libc_hidden_proto.
	* sysdeps/unix/bsd/tcgetattr.c (__tcgetattr): Add
	libc_hidden_def.
	* sysdeps/unix/sysv/linux/tcgetattr.c (__tcgetattr): Likewise.
	* termios/tcgetattr.c (__tcgetattr): Likewise.
2017-10-01 17:48:24 -07:00
H.J. Lu dd3121df08 Hide internal __setrlimit function [BZ #18822]
Hide internal __setrlimit function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/sys/resource.h (__setrlimit): Add libc_hidden_proto.
	* resource/setrlimit.c (__setrlimit): Add libc_hidden_def.
	* sysdeps/mach/hurd/setrlimit.c (__setrlimit): Likewise.
	* sysdeps/unix/sysv/linux/setrlimit.c (__setrlimit): Likewise.
	* sysdeps/unix/sysv/linux/setrlimit64.c (__GI___setrlimit): New.
2017-10-01 17:46:54 -07:00
H.J. Lu 047d1a81fd Hide internal __vstrfmon_l function [BZ #18822]
Hide internal __vstrfmon_l function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/monetary.h (__vstrfmon_l): Add attribute_hidden.
2017-10-01 17:45:07 -07:00
H.J. Lu fd331b1179 Hide internal __sched_setparam function [BZ #18822]
Hide internal __sched_setparam function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

__GI___sched_setparam is defined when sysdeps/unix/syscalls.list is
used to generate sched_setparam.  Otherwise libc_hidden_def is needed
explicitly.

	[BZ #18822]
	* include/sched.h (__sched_setparam): Add libc_hidden_proto.
	* posix/sched_setp.c (__sched_setparam): Add libc_hidden_def.
2017-10-01 17:43:25 -07:00
H.J. Lu d19033298f Hide internal __hasmntopt function [BZ #18822]
Hide internal __hasmntopt function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/mntent.h (__hasmntopt): Add libc_hidden_proto.
	* misc/mntent_r.c (__hasmntopt): Add libc_hidden_def.
2017-10-01 17:37:42 -07:00
H.J. Lu b4744101f3 Hide internal __ifreq function [BZ #18822]
Hide internal __ifreq function to allow direct access within libc.so and
libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/ifreq.h: New file.
	* sysdeps/generic/ifreq.h (__if_nextreq): Removed.
	(__ifreq): Likewise.
	* sysdeps/mach/hurd/ifreq.h (__if_nextreq): Removed.
	(__ifreq): Likewise.
2017-10-01 17:35:46 -07:00
H.J. Lu 43b7dfd1b6 Hide internal idna functions [BZ #18822]
Hide internal idna functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/idna.h: New file.
	* inet/getnameinfo.c: Include <idna.h> instead of
	<libidn/idna.h>.
	(__idna_to_unicode_lzlz): Removed.
	* sysdeps/posix/getaddrinfo.c: Include <idna.h> instead of
	<libidn/idna.h>.
	(__idna_to_ascii_lz): Removed.
	(__idna_to_unicode_lzlz): Likewise.
2017-10-01 17:33:22 -07:00
H.J. Lu 2c0cd8f81f Hide internal __gettextparse function [BZ #18822]
Hide internal __gettextparse function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/plural-exp.h: New file.
	* intl/plural-exp.c: Include <plural-exp.h> instead of
	"plural-exp.h".
2017-10-01 17:31:05 -07:00
H.J. Lu a0aef7830e Move hidden_proto (__dl_iterate_phdr) to include/link.h [BZ #18822]
__dl_iterate_phdr is hidden and should be accessed directly within
libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* elf/dl-iteratephdr.c (hidden_proto (__dl_iterate_phdr)): Moved
	to ...
	* include/link.h (hidden_proto (__dl_iterate_phdr)): Here.
2017-10-01 16:09:38 -07:00
H.J. Lu fe84fed048 Hide internal __tdestroy function [BZ #18822]
Hide internal __tdestroy function to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/search.h (__tdestroy): Add libc_hidden_proto.
	* misc/tsearch.c (__tdestroy): Add libc_hidden_def.
2017-10-01 16:06:58 -07:00
H.J. Lu 048dd6813f Hide internal __assert_fail_base function [BZ #18822]
Hide internal __assert_fail_base function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/assert.h (__assert_fail_base): Add attribute_hidden.
2017-10-01 16:06:13 -07:00
H.J. Lu 6a088436d4 Hide internal signal functions [BZ #18822]
Hide internal signal functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.

__GI___kill and __GI___sigaltstack are defined when syscalls.list is
used to generate them.  Otherwise libc_hidden_def is needed explicitly.

	[BZ #18822]
	* include/signal.h (__kill): Add libc_hidden_proto.
	(__sigblock): Likewise.
	(__sigprocmask): Likewise.
	(__sigaltstack): Likewise.
	* signal/kill.c (__kill): Add libc_hidden_def.
	* signal/sigblock.c (__sigblock): Likewise.
	* signal/sigprocmask.c (__sigprocmask): Likewise.
	* sysdeps/mach/hurd/kill.c (__kill): Likewise.
	* sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise.
	* sysdeps/mach/hurd/sigprocmask.c (__sigprocmask): Likewise.
	* sysdeps/posix/sigblock.c (__sigblock): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sigprocmask.c (__sigprocmask):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sigprocmask.c (__sigprocmask):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/sigprocmask.c
	(__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/sigprocmask.c (__sigprocmask):
	Likewise.
	* /sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c
	(__sigprocmask): Likewise.
	* sysdeps/unix/sysv/linux/x86_64/sigprocmask.c (__sigprocmask):
	Likewise.
2017-10-01 16:04:41 -07:00
H.J. Lu 78cf1d74d2 Hide internal __strsep function [BZ #18822]
Hide internal __strsep function to allow direct access within libc.so and
libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/string.h (__strsep): Add libc_hidden_proto.
	* string/strsep.c (__strsep): Add libc_hidden_def.
2017-10-01 16:03:41 -07:00
H.J. Lu 225f7eec85 Hide internal __mremap function [BZ #18822]
Hide internal __mremap function to allow direct access within libc.so and
libc.a without using GOT nor PLT.

__GI___mremap is defined when sysdeps/unix/syscalls.list is used to
generate mremap.  Otherwise libc_hidden_def is needed explicitly.

	[BZ #18822]
	* include/sys/mman.h (__mremap): Add libc_hidden_proto.
	* sysdeps/unix/sysv/linux/m68k/mremap.S (__mremap): Add
	libc_hidden_def.
2017-10-01 16:02:04 -07:00
H.J. Lu 372fe247b1 Hide internal __malloc_check_init function [BZ #18822]
Hide internal __malloc_check_init function to allow direct access within
libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/malloc.h (__malloc_check_init): Add attribute_hidden.
2017-10-01 16:00:36 -07:00
H.J. Lu 9e5ee8b839 Hide internal __ioctl function [BZ #18822]
Hide internal __ioctl function to allow direct access within libc.so and
libc.a without using GOT nor PLT.

__GI___ioctl is defined when sysdeps/unix/syscalls.list is used to
generate ioctl.  Otherwise libc_hidden_def is needed explicitly.

	[BZ #18822]
	* include/sys/ioctl.h (__ioctl): Add libc_hidden_proto.
	* misc/ioctl.c (__ioctl): Add libc_hidden_def.
	* sysdeps/mach/hurd/ioctl.c (__ioctl): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/ioctl.S (__ioctl): Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/ioctl.S (__ioctl):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ioctl.c (__ioctl): Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/ioctl.S (__ioctl): Likewise.
2017-10-01 15:59:06 -07:00
H.J. Lu b5648377d9 Hide internal sysinfo functions [BZ #18822]
Hide internal sysinfo functions to allow direct access within libc.so
and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/sys/sysinfo.h (__get_nprocs_conf): Add
	libc_hidden_proto.
	(__get_nprocs): Likewise.
	(__get_phys_pages): Likewise.
	(__get_avphys_pages): Likewise.
	(__get_child_max): Add attribute_hidden.
	* misc/getsysstats.c (__get_nprocs_conf): Add libc_hidden_def.
	(__get_nprocs): Likewise.
	(__get_phys_pages): Likewise.
	(__get_avphys_pages): Likewise.
	* sysdeps/mach/getsysstats.c (__get_nprocs_conf): Add
	libc_hidden_def.
	(__get_nprocs): Likewise.
	(__get_phys_pages): Likewise.
	(__get_avphys_pages): Likewise.
	* sysdeps/unix/sysv/linux/getsysstats.c (__get_nprocs): Add
	libc_hidden_def.
	(__get_nprocs_conf): Likewise.
	(__get_phys_pages): Likewise.
	(__get_avphys_pages): Likewise.
2017-10-01 15:57:21 -07:00
H.J. Lu d48354d860 Mark internal rpc functions with attribute_hidden [BZ #18822]
Mark internal rpc functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/rpc/rpc.h (__rpc_thread_variables): Add
	attribute_hidden.
	(__rpc_thread_svc_cleanup): Likewise.
	(__rpc_thread_clnt_cleanup): Likewise.
	(__rpc_thread_key_cleanup): Likewise.
2017-10-01 15:55:15 -07:00
H.J. Lu d6daff1261 Hide __readv and __writev [BZ #18822]
Hide internal __readv and __writev functions to allow direct access
within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/sys/uio.h (__readv): Add libc_hidden_proto.
	(__writev): Likewise.
	* misc/readv.c (__readv): Add libc_hidden_def.
	* misc/writev.c (__writev): Likewise.
	* sysdeps/posix/readv.c (__readv): Likewise.
	* sysdeps/posix/writev.c (__writev): Likewise.
	* sysdeps/unix/sysv/linux/readv.c: Include <sys/uio.h>.
	(__readv): Likewise.
	* sysdeps/unix/sysv/linux/writev.c: Include <sys/uio.h>.
	(__writev): Likewise.
2017-10-01 15:54:10 -07:00
H.J. Lu b68f862056 Hide internal regex functions [BZ #18822]
Hide internal regex functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/regex.h (__re_compile_fastmap): Add attribute_hidden.
	(__regcomp): Add libc_hidden_proto.
	(__regexec): Likewise.
	(__regfree): Likewise.
	* posix/regcomp.c (__regcomp): Add libc_hidden_def.
	(__regfree): Likewise.
	* posix/regexec.c (__regexec): Likewise.
2017-10-01 15:53:15 -07:00
H.J. Lu 59c04e6763 Mark internal utmp functions with attribute_hidden [BZ #18822]
Mark internal utmp functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/utmp.h (__updwtmp): Add libc_hidden_proto.
	(__getutent): Likewise.
	(__getutid): Likewise.
	(__getutline): Likewise.
	(__pututline): Likewise.
	(__getutent_r): Likewise.
	(__getutid_r): Likewise.
	(__getutline_r): Likewise.
	(__utmpname): Add attribute_hidden.
	(__setutent): Likewise.
	(__endutent): Likewise.
	* login/getutent.c (__getutent): Add libc_hidden_def.
	* login/getutent_r.c (__getutent_r): Likewise.
	(__pututline): Likewise.
	* login/getutid.c (__getutid): Likewise.
	* login/getutid_r.c (__getutid_r): Likewise.
	* login/getutline.c (__getutline): Likewise.
	* login/getutline_r.c (__getutline_r): Likewise.
	* login/updwtmp.c (__updwtmp): Likewise.
2017-10-01 15:51:56 -07:00
H.J. Lu 4587a421c5 Mark internal dirent functions with attribute_hidden [BZ #18822]
Mark internal dirent functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.  __readdir64
is hidden with libc_hidden_proto and libc_hidden_def since the exported
readdir64 is an alias of __readdir64.

	[BZ #18822]
	* include/dirent.h (__opendir): Always add attribute_hidden.
	(__fdopendir): Likewise.
	(__closedir): Likewise.
	(__readdir): Likewise.
	(__readdir64): Add libc_hidden_proto.
	* sysdeps/mach/hurd/readdir64.c (__readdir64): Add libc_hidden_def.
	* sysdeps/unix/sysv/linux/i386/readdir64.c (__readdir64): Likewise.
	* sysdeps/unix/sysv/linux/readdir64.c (__readdir64): Likewise.
	* sysdeps/unix/sysv/linux/wordsize-64/readdir.c (__GI___readdir64):
	New alias.
2017-10-01 15:51:11 -07:00
H.J. Lu 9635ce6962 Mark internal getXXXbyYYY functions with attribute_hidden [BZ #18822]
Mark internal getXXXbyYYY functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/aliases.h (__getaliasbyname_r): Add attribute_hidden.
	* include/netdb.h (__gethostbyaddr_r): Likewise.
	(__gethostbyname_r): Likewise.
	(__gethostbyname2_r): Likewise.
	(__getnetbyaddr_r): Likewise.
	(__getnetbyname_r): Likewise.
	(__getservbyname_r): Likewise.
	(__getservbyport_r): Likewise.
	(__getprotobyname_r): Likewise.
	(__getprotobynumber_r): Likewise.
	(__getnetgrent_r): Likewise.
	* include/rpc/netdb.h (__getrpcbyname_r): Likewise.
	(__getrpcbynumber_r): Likewise.
	* nss/getXXbyYY.c (INTERNAL (REENTRANT_NAME)): Likewise.
2017-10-01 15:21:00 -07:00
H.J. Lu 2e0a69097d Mark internal stdio functions with attribute_hidden [BZ #18822]
Mark internal stdio functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/stdio.h (__fcloseall): Add attribute_hidden.
	(__getline): Likewise.
	(__path_search): Likewise.
	(__gen_tempname): Likewise.
	(__libc_message): Likewise.
	(__flockfile): Likewise.
	(__funlockfile): Likewise.
	(__fxprintf): Likewise.
	(__fxprintf_nocancel): Likewise.
2017-10-01 15:20:13 -07:00
H.J. Lu 94fd682c9b Mark internal gshadow functions with attribute_hidden [BZ #18822]
Mark internal gshadow functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/gshadow.h (__fgetsgent_r): Add attribute_hidden.
	(__sgetsgent_r): Likewise.
2017-10-01 15:19:17 -07:00
H.J. Lu e1b33bba7c Mark internal statfs functions with attribute_hidden [BZ #18822]
Mark internal statfs functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/sys/statfs.h (__fstatfs): Add attribute_hidden.
	(__statfs64): Likewise.
	(__fstatfs64): Likewise.
	* include/sys/statvfs.h (__statvfs64): Likewise.
	(__fstatvfs64): Likewise.
	* sysdeps/unix/sysv/linux/pathconf.h (__statfs_link_max): Likewise.
	(__statfs_filesize_max): Likewise.
	(__statfs_symlinks): Likewise.
	(__statfs_chown_restricted): Likewise.
2017-10-01 15:18:25 -07:00
H.J. Lu b0f5678494 Mark internal time functions with attribute_hidden [BZ #18822]
Mark internal time functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/time.h (__tzstring): Add attribute_hidden.
	(__tzfile_read): Likewise.
	(__tzfile_compute): Likewise.
	(__tzfile_default): Likewise.
	(__tzset_parse_tz): Likewise.
	(__offtime): Likewise.
	(__asctime_r): Likewise.
	(__tzset): Likewise.
	(__tz_convert): Likewise.
	(__getdate_r): Likewise.
	(__getclktck): Likewise.
2017-10-01 15:17:32 -07:00
H.J. Lu a2ca165230 Mark internal gmp functions with attribute_hidden [BZ #18822]
Mark internal gmp functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/gmp.h: Declare internal functions only if _ISOMAC is
	undefined.
	(__mpn_extract_double): Add attribute_hidden.
	(__mpn_extract_long_double): Likewise.
	(__mpn_extract_float128): Likewise.
	(__mpn_construct_float): Likewise.
	(__mpn_construct_double): Likewise.
	(__mpn_construct_long_double): Likewise.
	(__mpn_construct_float128): Likewise.
	(mpn_add_1): Likewise.
	(mpn_addmul_1): Likewise.
	(mpn_add_n): Likewise.
	(mpn_cmp): Likewise.
	(mpn_divrem): Likewise.
	(mpn_lshift): Likewise.
	(mpn_mul): Likewise.
	(mpn_mul_1): Likewise.
	(mpn_rshift): Likewise.
	(mpn_sub_1): Likewise.
	(mpn_submul_1): Likewise.
	(mpn_sub_n): Likewise.
2017-10-01 15:15:30 -07:00
H.J. Lu 44af8a32c3 Mark internal wchar functions with attribute_hidden [BZ #18822]
Mark internal wchar functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/wchar.h (__wcsnlen): Add attribute_hidden.
	(__wcscat): Likewise.
	(__btowc): Likewise.
	(__wcrtomb): Likewise.
	(__mbsrtowcs): Likewise.
	(__wcsrtombs): Likewise.
	(__mbsnrtowcs): Likewise.
	(__wcsnrtombs): Likewise.
	(__wcsncpy): Likewise.
	(__wcpncpy): Likewise.
	(__wmemcpy): Likewise.
	(__wmempcpy): Likewise.
	(__wmemmove): Likewise.
	(__wcschrnul): Likewise.
	(__vfwscanf): Likewise.
	(__vswprintf): Likewise.
	(__fwprintf): Likewise.
	(__vfwprintf): Likewise.
2017-10-01 15:14:33 -07:00
H.J. Lu 783cd767af Mark internal grp/pwd/shadow functions with attribute_hidden [BZ #18822]
Mark internal grp/pwd/shadow functions with attribute_hidden to allow
direct access within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/grp.h (__fgetgrent_r): Add attribute_hidden.
	(__getgrgid_r): Likewise.
	(__getgrnam_r): Likewise.
	* include/pwd.h (__getpwuid_r): Likewise.
	(__getpwnam_r): Likewise.
	(__fgetpwent_r): Likewise.
	* include/shadow.h (__getspnam_r): Likewise.
	(__sgetspent_r): Likewise.
	(__fgetspent_r): Likewise.
2017-10-01 15:13:13 -07:00
H.J. Lu 7ec4b39ac4 Mark internal unistd functions with attribute_hidden [BZ #18822]
Mark internal unistd functions with attribute_hidden to allow direct
access to them within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/unistd.h (__access): Add attribute_hidden.
	(__lseek64): Likewise.
	(__libc_pread64): Likewise.
	(__pipe2): Likewise.
	(__sleep): Likewise.
	(__chdir): Likewise.
	(__fchdir): Likewise.
	(__getcwd): Likewise.
	(__rmdir): Likewise.
	(__execvpe): Likewise.
	(__execve): Likewise.
	(__setsid): Likewise.
	(__getuid): Likewise.
	(__geteuid): Likewise.
	(__getgid): Likewise.
	(__getegid): Likewise.
	(__getgroups): Likewise.
	(__group_member): Likewise.
	(__ttyname_r): Likewise.
	(__isatty): Likewise.
	(__readlink): Likewise.
	(__unlink): Likewise.
	(__gethostname): Likewise.
	(__profil): Likewise.
	(__getdtablesize): Likewise.
	(__brk): Likewise.
	(__ftruncate): Likewise.
	(__ftruncate64): Likewise.
2017-10-01 15:12:04 -07:00
H.J. Lu 8345a76018 Mark internal argp functions with attribute_hidden [BZ #18822]
Mark internal argp functions with attribute_hidden to allow direct
access to them within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* argp/argp-fmtstream.c: Include <argp-fmtstream.h>.
	* argp/argp-fs-xinl.c: Likewise.
	* argp/argp-help.c: Include <argp.h> and <argp-fmtstream.h>.
	* argp/argp-parse.c: Include <argp.h>.
	* argp/argp-xinl.c: Likewise.
	* include/argp-fmtstream.h: New file.
	* include/argp.h (__argp_error): Add attribute_hidden.
	(__argp_failure): Likewise.
	(__argp_input): Likewise.
	(__argp_state_help): Likewise.
2017-10-01 15:10:27 -07:00
H.J. Lu c26dd7c600 Mark ____wcsto*_l_internal functions with attribute_hidden [BZ #18822]
Mark ____wcsto*_l_internal functions with attribute_hidden to allow
direct access to them within libc.so and libc.a without using GOT nor
PLT.

	[BZ #18822]
	* include/wchar.h (____wcstof_l_internal): New prototype.
	(____wcstod_l_internal): Likewise.
	(____wcstold_l_internal): Likewise.
	(____wcstol_l_internal): Likewise.
	(____wcstoul_l_internal): Likewise.
	(____wcstoll_l_internal): Likewise.
	(____wcstoull_l_internal): Likewise.
	(____wcstof128_l_internal): Likewise.
	* sysdeps/ieee754/float128/wcstof128.c
	(____wcstof128_l_internal): Removed.
	* sysdeps/ieee754/float128/wcstof128_l.c
	(____wcstof128_l_internal): Likewise.
	* wcsmbs/wcstod.c (____wcstod_l_internal): Likewise.
	* wcsmbs/wcstod_l.c (____wcstod_l_internal): Likewise.
	* wcsmbs/wcstof.c (____wcstof_l_internal): Likewise.
	* wcsmbs/wcstof_l.c (____wcstof_l_internal): Likewise.
	* wcsmbs/wcstol_l.c (____wcstol_l_internal): Likewise.
	* wcsmbs/wcstold.c (____wcstold_l_internal): Likewise.
	* wcsmbs/wcstold_l.c (____wcstold_l_internal): Likewise.
	* wcsmbs/wcstoll_l.c (____wcstoll_l_internal): Likewise.
	* wcsmbs/wcstoul_l.c (____wcstoul_l_internal): Likewise.
	* wcsmbs/wcstoull_l.c (____wcstoull_l_internal): Likewise.
2017-10-01 15:09:28 -07:00
H.J. Lu 8bcdb7e0c5 Mark internal functions with attribute_hidden [BZ #18822]
Mark internal functions with attribute_hidden to allow direct access to
internal functions within libc.so and libc.a without using GOT nor PLT.

Size comparison of libc.so:

On x86-64:
        text	   data	    bss	    dec	    hex
Before: 1728577	  20584	  17088	1766249	 1af369
After : 1728593	  20584	  17088	1766265	 1af379

The only change is __gconv_release_shlib in iconv/gconv_dl.c is inlined
since it is hidden, which increases the code size of gconv_dl.os by 18
bytes.

On i686:
        text	   data	    bss	    dec	    hex
Before: 1869039	  11444	  11112	1891595	 1cdd0b
After : 1868635	  11444	  11112	1891191	 1cdb77

The code size is decreased by avoiding GOT/PLT for hidden functions.

	[BZ #18822]
	* iconv/gconv_int.h (__gconv_open): Add attribute_hidden.
	(__gconv_close): Likewise.
	(__gconv): Likewise.
	(__gconv_find_transform): Likewise.
	(__gconv_lookup_cache): Likewise.
	(__gconv_compare_alias_cache): Likewise.
	(__gconv_load_cache): Likewise.
	(__gconv_get_path): Likewise.
	(__gconv_close_transform): Likewise.
	(__gconv_release_cache): Likewise.
	(__gconv_find_shlib): Likewise.
	(__gconv_release_shlib): Likewise.
	(__gconv_get_builtin_trans): Likewise.
	(__gconv_compare_alias): Likewise.
	* include/dlfcn.h (_dlerror_run): Likewise.
	* include/stdio.h (__fortify_fail_abort): Likewise.
	* include/time.h (__tz_compute): Likewise.
	(__strptime_internal): Likewise.
	* intl/gettextP.h (_nl_find_domain): Likewise.
	(_nl_load_domain): Likewise.
	(_nl_find_msg): Likewise.
	* intl/plural-exp.h (FREE_EXPRESSION): Likewise.
	(EXTRACT_PLURAL_EXPRESSION): Likewise.
	* locale/coll-lookup.h (__collidx_table_lookup): Likewise.
	* resolv/gai_misc.h (__gai_enqueue_request): Likewise.
	(__gai_find_request): Likewise.
	(__gai_remove_request): Likewise.
	(__gai_notify): Likewise.
	(__gai_notify_only): Likewise.
	* sysdeps/generic/aio_misc.h (__aio_sigqueue): Likewise.
	* sysdeps/generic/ldsodefs.h (_dl_fini): Likewise.
	(_dl_non_dynamic_init): Likewise.
	(_dl_aux_init): Likewise.
	* sysdeps/i386/machine-gmon.h (mcount_internal): Likewise.
	* sysdeps/unix/sysv/linux/i386/olddirent.h (__old_getdents64):
	Likewise.
	* wcsmbs/wcsmbsload.h (__wcsmbs_load_conv): Likewise.
	(__wcsmbs_clone_conv): Likewise.
	(__wcsmbs_named_conv): Likewise.
2017-10-01 15:07:23 -07:00
H.J. Lu 8ed3b64330 Mark internal stdlib functions with attribute_hidden [BZ #18822]
Mark internal stdlib functions with attribute_hidden to allow direct
access within libc.so and libc.a without using GOT nor PLT.  __realpath
is hidden with libc_hidden_proto and libc_hidden_def since the exported
realpath is an alias of __realpath.

	[BZ #18822]
	* include/stdlib.h (__random): Add attribute_hidden.
	(__random_r): Likewise.
	(__srandom_r): Likewise.
	(__initstate_r): Likewise.
	(__setstate_r): Likewise.
	(__erand48_r): Likewise.
	(__nrand48_r): Likewise.
	(__jrand48_r): Likewise.
	(__srand48_r): Likewise.
	(__seed48_r): Likewise.
	(__lcong48_r): Likewise.
	(__drand48_iterate): Likewise.
	(__setenv): Likewise.
	(__unsetenv): Likewise.
	(__clearenv): Likewise.
	(__ptsname_r): Likewise.
	(__posix_openpt): Likewise.
	(__add_to_environ): Likewise.
	(__realpath): Add libc_hidden_proto.
	(__ecvt_r): Likewise.
	(__fcvt_r): Likewise.
	(__qecvt_r): Likewise.
	(__qfcvt_r): Likewise.
	* misc/efgcvt_r.c (cvt_symbol_1): Add libc_hidden_def (local).
	* stdlib/canonicalize.c (__realpath): Add libc_hidden_def.
2017-10-01 14:34:54 -07:00
H.J. Lu ef9b6f73f4 Mark 3 *_internal functions with attribute_hidden [BZ #18822]
Mark __ptsname_internal, __mktime_internal and __fopen_internal with
attribute_hidden to allow direct access to them within libc.so and
libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/stdlib.h (__ptsname_internal): Add attribute_hidden.
	* include/time.h (__mktime_internal): Likewise.
	* libio/iolibio.h (__fopen_internal): Likewise.
2017-10-01 14:34:40 -07:00
Samuel Thibault 4009ddc692 hurd: Fix `getifaddrs' and `freeifaddrs' symbol exposition
from `freeaddrinfo'.

`getifaddrs' and `freeifaddrs' are not in POSIX, they should not be
exposed along `freeaddrinfo' (through `__check_pf') which is POSIX.

	* include/ifaddrs.h (__getifaddrs, __freeifaddrs): New declarations,
	and use libc_hidden_def on them.
	* inet/ifaddrs.c (__getifaddrs, __freeifaddrs): Use libc_hidden_def on
	them.
	* sysdeps/gnu/ifaddrs.c (__getifaddrs, __freeifaddrs): Likewise.
	* inet/check_pf.c (__check_pf): Use __getifaddrs and __freeifaddrs
	instead of getifaddrs and freeifaddrs.
2017-09-28 01:05:18 +02:00
Samuel Thibault 64a4af28a6 hurd: Fix `seekdir' symbol exposition from `rewinddir'
`seekdir' is MISC || XOPEN, it should not be exposed along `rewinddir' which
is POSIX.

	* include/dirent.h (__seekdir): New declaration.
	* sysdeps/mach/hurd/seekdir.c (seekdir): Rename to __seekdir and
	redefine as weak alias.
	* sysdeps/mach/hurd/rewinddir.c (__rewinddir): Use __seekdir instead
	of seekdir.
2017-09-28 00:49:59 +02:00
Samuel Thibault 52a1f1814e hurd: Fix `revoke' symbol exposition from `unlockpt'
`revoke' is MISC only, it should not be exposed along `unlockpt' which is
XOPEN.

	* include/unistd.h (__revoke): New declaration.
	* misc/revoke.c (revoke): Rename to __revoke, and redefine as weak
	alias.
	* sysdeps/mach/hurd/revoke.c (revoke): Likewise.
	* sysdeps/unix/bsd/unlockpt.c (unlockpt): Use __revoke instead of
	revoke.
2017-09-28 00:49:05 +02:00
Samuel Thibault 2c7bbfaf4e hurd: Fix dirfd symbol exposition from ftw
dirfd is XOPEN2K8 only, it should not be exposed along ftw which is earlier.

	* include/dirent.h (__dirfd): New declaration.
	* dirent/dirfd.c (dirfd): Rename to __dirfd, and redefine as weak
	alias.
	* sysdeps/posix/dirfd/dirfd.c (dirfd): Likewise.
	* sysdeps/mach/hurd/dirfd.c (dirfd): Likewise.
	* io/ftw.c (open_dir_stream, ftw_dir): Use __dirfd instead of dirfd.
2017-09-28 00:49:05 +02:00
H.J. Lu 825adeeed1 Mark __dso_handle as hidden [BZ #18822]
Since __dso_handle is always defined by either crtbegin.o from GCC or
dso_handle.c, it should be marked as hidden and be passed directly.

	[BZ #18822]
	* dlfcn/modatexit.c (foo): Remove __dso_handle check.
	* dlfcn/modcxaatexit.c: Include <dso_handle.h>.
	(__dso_handle): Remove declaration.
	* dlfcn/tstatexit.c (__dso_handle): Removed.
	(main): Don't check __dso_handle.
	* dlfcn/tstcxaatexit.c (__dso_handle): Removed.
	(main): Don't check __dso_handle.
	* include/dso_handle.h: New file.
	* malloc/mtrace.c: Include <dso_handle.h>.
	(mtrace): Pass __dso_handle directly.
	* nptl/pthread_atfork.c: Include <dso_handle.h>.
	(__dso_handle): Remove declaration.
	(__pthread_atfork): Pass __dso_handle directly.
	* nptl/tst-atfork2mod.c: Include <dso_handle.h>.
	(__dso_handle): Removed.
	* posix/wordexp-test.c: Include <dso_handle.h>.
	(__dso_handle): Remove declaration.
	(__app_register_atfork): Pass __dso_handle directly.
	* stdlib/at_quick_exit.c: Include <dso_handle.h>.
	(__dso_handle): Remove declaration.
	(at_quick_exit): Pass __dso_handle directly.
	* stdlib/atexit.c: Include <dso_handle.h>.
	(__dso_handle): Remove declaration.
	(atexit): Pass __dso_handle directly.
	* stdlib/tst-tls-atexit-lib.c: Include <dso_handle.h>.
	(__dso_handle): Removed.
2017-09-26 16:53:44 -07:00
Adhemerval Zanella 5f9f31ad12 scratch_buffer: use union for internal buffer
Problem reported by Florian Weimer [1] and solution suggested by
Andreas Schwab [2].  It also set the same buffer size independent
of architecture max_align_t size.

Checked on x86_64-linux-gnu and i686-linux-gnu.

	* lib/malloc/scratch_buffer.h (struct scratch_buffer):
	Use an union instead of a max_align_t array for __space,
	so that __space is the same size on all platforms.
	* malloc/scratch_buffer_grow_preserve.c
	(__libc_scratch_buffer_grow_preserve): Likewise.

[1] https://sourceware.org/ml/libc-alpha/2017-09/msg00693.html
[2] https://sourceware.org/ml/libc-alpha/2017-09/msg00695.html
2017-09-25 18:04:22 -07:00
Adhemerval Zanella ccf970c7a7 posix: Add compat glob symbol to not follow dangling symbols
This patch follows commit 5554304f0 (posix: Allow glob to match dangling
symlinks [BZ #866]) by adding a compat symbol that follow previous
semantic of not following dangling symlinks and thus avoiding call
gl_lstat with GLOB_ALTDIRFUNC.

It avoids failure with old binaries that not set the alternate function
pointer for lstat (GNUmake for instance).  The following scenario, for
instance, fails with current GNUmake because glibc will access unitialized
memory when calling gl_lstat:

  $ cat src/t/t.c
  int main ()
  {
    return 0;
  }
  $ cat Makefile
  SRC = $(wildcard src/*/t.c)
  OBJ = $(patsubst src/%.c, obj/%.o, $(SRC))

  prog:           $(OBJ)
                  $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) $(OBJ) -o prog

  obj/%.o:        src/%.c
                  $(CC) $(CFLAGS) -c $< -o $@
  $ make

This works as expected with the patch applied.  Since it is for generic
ABI, default compat symbols are added with override for Linux due LFS.
Now we have two compat symbols for glob on Linux:

  1. sysdeps/unix/sysv/linux/oldglob.c which implements glob64 with
     the old dirent layout.  For this implementation I also set it to
     not follow dangling symlinks (which is the safest path).

  2. sysdeps/unix/sysv/linux/glob{64}-lstat-compat.c which implements
     the compat symbol for dangling symlinks.  As for generic glob,
     the implementation uses XSTAT_IS_XSTAT64 to define whether
     both __glob_lstat_compat and __glob64_lstat_compat should be
     different implementations.  For archictures that define
     XSTAT_IS_XSTAT64, __glob_lstat_compat is aliased to
     __glob64_lstat_compat.

  3. sysdeps/unix/sysv/linux/alpha/oldglob.c with a different glob_t
     layout.  As for 1. this patch changes it to not follow dangling
     symlinks.

The patch also bumps _GNU_GLOB_INTERFACE_VERSION to 2 to advertise the
new semantic.  On GNUmake, for instance, it will force to it use its
internal glob implementation instead and avoiding triggering the same
failure on builds against newer GLIBCs.

Checked on x86_64-linux-gnu and i686-linux-gnu.  I also checked
with a build against the major ABIs required to check for the abilist.

The changes should also work on gnulib (I run gnulib-tool.py check glob
and it shown no regressions).

	[BZ #22183]
	* include/gnu-versions.h (_GNU_GLOB_INTERFACE_VERSION): Increase
	version to 2.
	* posix/Makefile (routines): Add glob-lstat-compat and
	glob64-lstat-compat.
	* posix/Versions (GLIBC_2.27, glob, glob64): Add symbol version.
	* posix/glob-lstat-compat.c: New file.
	* posix/glob64-lstat-compat.c: Likewise.
	* posix/tst-glob_lstat_compat.c: Likewise.
	* sysdeps/unix/sysv/linux/glob-lstat-compat.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/glob-lstat-compat.c: Likewise.
	* sysdeps/unix/sysv/linux/glob64-lstat-compat.c: Likewise.
	* sysdeps/unix/sysv/linux/alpha/glob.c: Remove file.
	* posix/glob.c (glob_lstat): New function.
	(glob): Rename to __glob and add versioned symbol to 2.27.
	(glob_in_dir): Use glob_lstat.
	* posix/glob64.c (glob64): Add GLOB_ATTRIBUTE.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/glob.c (glob): Add versioned symbol for
	2.27.
	* sysdeps/unix/sysv/linux/glob64.c (glob64): Likewise.
	* sysdeps/unix/sysv/linux/oldglob.c (GLOB_NO_LSTAT): Define.
	* sysdeps/unix/sysv/linux/alpha/oldglob.c (__old_glob): Do not use
	gl_lstat on glob call.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add GLIBC_2.27 glob
	and glob64 symbols.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
2017-09-25 18:04:16 -07:00
Joseph Myers 01f2881245 Make more libm functions into weak aliases.
Many libm functions define the function as __<func> and then define
<func> as a weak alias.  This is not at all limited to cases where
there is an internal call that has namespace reasons to need to call
__<func> instead of <func>.

The common macros for creating libm function aliases work on the basis
of public function names all being aliases; that is, they define
aliases for functions using the above pattern.  Thus, where a function
just defines the public name <func> directly, changing that to be a
weak alias enables a subsequent conversion to the common macros to
retain the exact existing symbols (and so be testable by comparison of
stripped binaries).

This patch converts many existing functions to use the weak alias
pattern, as preparation for subsequent conversions to common macros.
I do expect that _FloatN/_FloatNx function aliases will end up needing
new variants of the common macros that do *not* create the original
float / double / long double name of a function - for cases where that
name is created specially to give it a particular symbol version, for
example - but for functions that can use the most common macros to
create all the public names as aliases, it makes sense for them to do
so.

Regarding the Bessel function wrappers in this patch: only float and
double wrappers are changed because the long double wrappers already
used the weak alias pattern.

Tested for x86_64, and with build-many-glibcs.py.

	* include/math.h (roundeven): Change hidden_proto call to
	__roundeven.
	* math/w_j0_compat.c (j0): Rename to __j0 and define as weak
	alias.
	[NO_LONG_DOUBLE] (__j0l): New strong alias.
	(y0): Rename to __y0 and define as weak alias.
	[NO_LONG_DOUBLE] (__y0l): New strong alias.
	* math/w_j0f_compat.c (j0f): Rename to __j0f and define as weak
	alias.
	(y0f): Rename to __y0f and define as weak alias.
	* math/w_j1_compat.c (j1): Rename to __j1 and define as weak
	alias.
	[NO_LONG_DOUBLE] (__j1l): New strong alias.
	(y1): Rename to __y1 and define as weak alias.
	[NO_LONG_DOUBLE] (__y1l): New strong alias.
	* math/w_j1f_compat.c (j1f): Rename to __j1f and define as weak
	alias.
	(y1f): Rename to __y1f and define as weak alias.
	* math/w_jn_compat.c (jn): Rename to __jn and define as weak
	alias.
	[NO_LONG_DOUBLE] (__jnl): New strong alias.
	(yn): Rename to __yn and define as weak alias.
	[NO_LONG_DOUBLE] (__ynl): New strong alias.
	* math/w_jnf_compat.c (jnf): Rename to __jnf and define as weak
	alias.
	(ynf): Rename to __ynf and define as weak alias.
	* sysdeps/ieee754/dbl-64/s_fromfp.c (FUNC): Define to __fromfp.
	(fromfp): Define as weak alias.
	[NO_LONG_DOUBLE] (__fromfpl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_fromfpx.c (FUNC): Define to __fromfpx.
	(fromfpx): Define as weak alias.
	[NO_LONG_DOUBLE] (__fromfpxl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_getpayload.c (getpayload): Rename to
	__getpayload and define as weak alias.
	[NO_LONG_DOUBLE] (__getpayloadl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_roundeven.c (roundeven): Rename to
	__roundeven and define as weak alias.
	[NO_LONG_DOUBLE] (__roundevenl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_setpayload.c (FUNC): Define to
	__setpayload.
	(setpayload): Define as weak alias.
	[NO_LONG_DOUBLE] (__setpayloadl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_setpayloadsig.c (FUNC): Define to
	__setpayloadsig.
	(setpayloadsig): Define as weak alias.
	[NO_LONG_DOUBLE] (__setpayloadsigl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_totalorder.c (totalorder): Rename to
	__totalorder and define as weak alias.
	[NO_LONG_DOUBLE] (__totalorderl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_totalordermag.c (totalordermag): Rename
	to __totalordermag and define as weak alias.
	[NO_LONG_DOUBLE] (__totalordermagl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_ufromfp.c (FUNC): Define to __ufromfp.
	(ufromfp): Define as weak alias.
	[NO_LONG_DOUBLE] (__ufromfpl): New strong alias.
	* sysdeps/ieee754/dbl-64/s_ufromfpx.c (FUNC): Define to
	__ufromfpx.
	(ufromfpx): Define as weak alias.
	[NO_LONG_DOUBLE] (__ufromfpxl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_getpayload.c (getpayload):
	Rename to __getpayload and define as weak alias.
	[NO_LONG_DOUBLE] (__getpayloadl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_roundeven.c (roundeven):
	Rename to __roundeven and define as weak alias.
	[NO_LONG_DOUBLE] (__roundevenl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_totalorder.c (totalorder):
	Rename to __totalorder and define as weak alias.
	[NO_LONG_DOUBLE] (__totalorderl): New strong alias.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_totalordermag.c
	(totalordermag): Rename to __totalordermag and define as weak
	alias.
	[NO_LONG_DOUBLE] (__totalordermagl): New strong alias.
	* sysdeps/ieee754/float128/float128_private.h (__getpayloadl): New
	macro.
	(__roundevenl): Likewise.
	(__totalorderl): Likewise.
	(__totalordermagl): Likewise
	* sysdeps/ieee754/float128/s_fromfpf128.c (FUNC): Define to
	__fromfpf128.
	(fromfpf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_fromfpxf128.c (FUNC): Define to
	__fromfpxf128.
	(fromfpxf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_setpayloadf128.c (FUNC): Define to
	__setpayloadf128.
	(setpayloadf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_setpayloadsigf128.c (FUNC): Define to
	__setpayloadsigf128.
	(setpayloadsigf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_ufromfpf128.c (FUNC): Define to
	__ufromfpf128.
	(ufromfpf128): Define as weak alias.
	* sysdeps/ieee754/float128/s_ufromfpxf128.c (FUNC): Define to
	__ufromfpxf128.
	(ufromfpxf128): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_fromfpf.c (FUNC): Define to __fromfpf.
	(fromfpf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_fromfpxf.c (FUNC): Define to
	__fromfpxf.
	(fromfpxf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_getpayloadf.c (getpayloadf): Rename to
	__getpayloadf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_roundevenf.c (roundevenf): Rename to
	__roundevenf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_setpayloadf.c (FUNC): Define to
	__setpayloadf.
	(setpayloadf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_setpayloadsigf.c (FUNC): Define to
	__setpayloadsigf.
	(setpayloadsigf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_totalorderf.c (totalorderf): Rename to
	__totalorderf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_totalordermagf.c (totalordermagf):
	Rename to __totalordermagf and define as weak alias.
	* sysdeps/ieee754/flt-32/s_ufromfpf.c (FUNC): Define to
	__ufromfpf.
	(ufromfpf): Define as weak alias.
	* sysdeps/ieee754/flt-32/s_ufromfpxf.c (FUNC): Define to
	__ufromfpxf.
	(ufromfpxf): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_fromfpl.c (FUNC): Define to
	__fromfpl.
	(fromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_fromfpxl.c (FUNC): Define to
	__fromfpxl.
	(fromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_getpayloadl.c (getpayloadl): Rename
	to __getpayloadl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_roundevenl.c (roundevenl): Rename to
	__roundevenl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_setpayloadl.c (FUNC): Define to
	__setpayloadl.
	(setpayloadl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_setpayloadsigl.c (FUNC): Define to
	__setpayloadsigl.
	(setpayloadsigl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_totalorderl.c (totalorderl): Rename
	to __totalorderl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_totalordermagl.c (totalordermagl):
	Rename to __totalordermagl and define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_ufromfpl.c (FUNC): Define to
	__ufromfpl.
	(ufromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128/s_ufromfpxl.c (FUNC): Define to
	__ufromfpxl.
	(ufromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_fromfpl.c (FUNC): Define to
	__fromfpl.
	(fromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_fromfpxl.c (FUNC): Define to
	__fromfpxl.
	(fromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_getpayloadl.c (getpayloadl):
	Rename to __getpayloadl and define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_roundevenl.c (roundevenl): Rename
	to __roundevenl and define as weak alias.  Call __roundeven
	instead of roundeven.
	* sysdeps/ieee754/ldbl-128ibm/s_setpayloadl.c (FUNC): Define to
	__setpayloadl.
	(setpayloadl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_setpayloadsigl.c (FUNC): Define to
	__setpayloadsigl.
	(setpayloadsigl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_totalorderl.c (totalorderl):
	Rename to __totalorderl and define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_totalordermagl.c (totalordermagl):
	Rename to __totalordermagl and define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_ufromfpl.c (FUNC): Define to
	__ufromfpl.
	(ufromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-128ibm/s_ufromfpxl.c (FUNC): Define to
	__ufromfpxl.
	(ufromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_fromfpl.c (FUNC): Define to
	__fromfpl.
	(fromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_fromfpxl.c (FUNC): Define to
	__fromfpxl.
	(fromfpxl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_getpayloadl.c (getpayloadl): Rename to
	__getpayloadl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_roundevenl.c (roundevenl): Rename to
	__roundevenl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_setpayloadl.c (FUNC): Define to
	__setpayloadl.
	(setpayloadl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_setpayloadsigl.c (FUNC): Define to
	__setpayloadsigl.
	(setpayloadsigl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_totalorderl.c (totalorderl): Rename to
	__totalorderl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_totalordermagl.c (totalordermagl):
	Rename to __totalordermagl and define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_ufromfpl.c (FUNC): Define to
	__ufromfpl.
	(ufromfpl): Define as weak alias.
	* sysdeps/ieee754/ldbl-96/s_ufromfpxl.c (FUNC): Define to
	__ufromfpxl.
	(ufromfpxl): Define as weak alias.
2017-09-14 22:28:53 +00:00
Adhemerval Zanella e00f242599 Sync scratch_buffer with gnulib
This patch syncs the scratch_buffer grom gnulib commit 3866ef6 with
GLIBC code.

Checked on x86_64-linux-gnu and on a build using build-many-glibcs.py
for all major architectures.

	* include/scratch_buffer.h (scratch_buffer): Use a C99 align method
	instead of GCC extension.
	* malloc/scratch_buffer_grow.c [!_LIBC]: Include libc-config.h.
	* malloc/scratch_buffer_grow_preserve.c [!_LIBC]: Likewise.
	* malloc/scratch_buffer_set_array_size.c [!_LIBC]: Likewise.
2017-09-08 15:51:34 +02:00
Steve Ellcey 05b38d64b1 Fix tests that are testing obsoleted functionality
* include/shlib-compat.h (TEST_COMPAT): New Macro.
	* malloc/tst-mallocstate.c: Convert from test-skeleton
	to test-driver.  Ifdef code using TEST_COMPAT macro.
	* math/test-matherr-2.c: Ifdef test using TEST_COMPAT macro.
	* math/test-matherr.c: Likewise.
2017-09-05 12:24:00 -07:00
H.J. Lu 0a587a8a98 Hide __chmod and __mkdir [BZ #18822]
Hide internal __chmod and __mkdir functions to allow direct access
within libc.so and libc.a without using GOT nor PLT.

	[BZ #18822]
	* include/sys/stat.h (__chmod): Add libc_hidden_proto.
	(__mkdir): Likewise.
	* io/chmod.c (__chmod): Add libc_hidden_def.
	* io/mkdir.c (__mkdir): Likewise.
	* sysdeps/mach/hurd/chmod.c (__chmod): Likewise.
	* sysdeps/mach/hurd/mkdir.c (__mkdir): Likewise.
	* sysdeps/unix/sysv/linux/generic/chmod.c (__chmod): Likewise.
	* sysdeps/unix/sysv/linux/generic/mkdir.c (__mkdir): Likewise.
2017-09-04 13:38:51 -07:00
Adhemerval Zanella e0d2eb5a79 linux: Implement tmpfile with O_TMPFILE (BZ#21530)
This patch adds O_TMPFILE support to tmpfile on Linux.  This is
similar to the previous suggestion by Andreas Schwab [1] with the
difference the file descriptor creation is parameterized to
compartmentalize Linux only open flags (O_TMPFILE) on sysdeps.

Checked on x86_64-linux-gnu.

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Andreas Schwab  <schwab@suse.de>

	[BZ #21530]
	* include/stdio.h (__gen_tempfd): New function.
	* stdio-common/Makefile (routines): Add gentempfd.
	* stdio-common/gentempfd.c: New file.
	* sysdeps/unix/sysv/linux/gentempfd.c: Likewise.
	* stdio-common/tmpfile.c (tmpfile): First try to use a system specific
	unnamed file first.

[1] https://sourceware.org/ml/libc-alpha/2017-06/msg01293.html
2017-09-01 09:52:47 -03:00
Florian Weimer 65284eb7a8 libc-symbols.h: Remove definition of internal_function 2017-08-31 18:52:00 +02:00
Florian Weimer 86e4919f57 dlfcn: Remove internal_function attribute 2017-08-31 16:12:03 +02:00
Florian Weimer fc3d94979e dirent: Remove internal_function attribute 2017-08-31 16:02:40 +02:00
Florian Weimer 7e01f080e8 time: Remove the internal_function attribute 2017-08-31 15:59:07 +02:00
Florian Weimer 75b3047eac NSS: Remove internal_function function attribute 2017-08-31 15:59:06 +02:00
Florian Weimer ca4ec80396 sunrpc: Remove internal_function attribute 2017-08-31 15:59:02 +02:00
Adhemerval Zanella 2b0b9a1c85 Consolidate remaning non cancellable definitions
This patch consolidate the remaning non cancellable syscall definitions
on not-cancel.h header.  They are:

  * __fcntl_nocancel: Moved from fcntl.h to not-cancel.h.
  * __sigsuspend_nocancel: Removed since 988f991b50 it is not used or
    defined anymore.
  * __nanosleep_nocancel: Removed since 6f33fd046b it is defined on
    not-cancel.h.

Now all non-cancellable syscall definition are defined on not-cancel
(the only exceptions is the stdio symbol __fxprintf_nocancel which
uses non cancellable open and it is used on getopt implementation).

Checked on x86_64-linux-gnu and with build-many-glibc.py.

	* include/fcntl.h (__fcntl_nocancel): Remove definition.
	* include/signal.h (__sigsuspend_nocancel): Likewise.
	* include/time.h (__nanosleep_nocancel): Likewise.
	* sysdeps/generic/not-cancel.h (__fcntl_nocancel): New macro.
	* login/utmp_file.c: Include non cancellable syscall header.
	* sysdeps/unix/sysv/linux/not-cancel.h (__fcntl_nocancel): New
	prototype.
2017-08-23 10:47:03 -03:00
Gabriel F. T. Gomes b513da7e80 Fix remaining return type of ifunc resolver declaration
Since Martin Sebor's commit

commit ee4e992ebe
Author: Martin Sebor <msebor@redhat.com>
Date:   Tue Aug 22 09:35:23 2017 -0600

    Declare ifunc resolver to return a pointer to the same type as the target
    function to help GCC detect incompatibilities between the two when it's
    enhanced to do so.

builds for powerpc64le fail in the declaration of some ifunc resolvers,
because the ifunc is declared with unmatching return types.  One of the
declarations comes from the __ifunc_resolver macro, which was patched by
the aforementioned commit:

    /* Helper / base  macros for indirect function symbols.  */
    #define __ifunc_resolver(type_name, name, expr, arg, init, classifier) \
      classifier inhibit_stack_protector                                   \
      __typeof (type_name) *name##_ifunc (arg)                             \

whereas the other comes from the unpatched __ifunc macro when
HAVE_GCC_IFUNC is not defined:

    # define __ifunc(type_name, name, expr, arg, init)                     \
      extern __typeof (type_name) name;                                    \
      void *name##_ifunc (arg) __asm__ (#name);                            \

This patch changes the return type of the ifunc resolver in the __ifunc
macro, so that it matches the return type of the target function,
similarly to what the aforementioned commit does.

Tested for powerpc64le and s390x with unpatched GCC.

	* include/libc-symbols.h: [!defined HAVE_GCC_IFUNC] (__ifunc):
	Change the return type of the ifunc resolver to match the return
	type of the target function.
2017-08-22 19:08:27 -03:00
Adhemerval Zanella 08d6eb46ca Consolidate non cancellable pause call
This patch consolidates all the non cancellable pause calls to use
the __pause_nocancel identifier.  For non cancellable targets it will
be just a macro to call the default respective symbol while on Linux
will be a internal one.

Checked on x86_64-linux-gnu, x86_64-linux-gnu-x32, and i686-linux-gnu.

	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock_full): Replace
	pause_not_cancel with __pause_nocancel.
	* sysdeps/generic/not-cancel.h (pause_not_cancel): Remove macro.
	(__pause_nocancel): New macro.
	* sysdeps/unix/sysv/linux/not-cancel.h (pause_not_cancel): Remove
	macro.
	(__pause_nocancel): New prototype.
	* sysdeps/unix/sysv/linux/pause.c (__pause_nocancel): New function.
2017-08-22 14:25:03 -03:00
Martin Sebor ee4e992ebe Declare ifunc resolver to return a pointer to the same type as the target
function to help GCC detect incompatibilities between the two when it's
enhanced to do so.
2017-08-22 09:35:23 -06:00
H.J. Lu 20962acbea Hide internal printf functions [BZ #18822/21986]
Hide internal printf functions to allow direct access within libc.so and
libc.a without using GOT nor PLT.

Since __guess_grouping has been changed to take 2 arguments by

commit a1d84548c8
Author: Ulrich Drepper <drepper@redhat.com>
Date:   Fri Feb 11 18:50:36 2000 +0000

the third argument passed to __guess_grouping is removed.

	[BZ #18822]
	[BZ #21986]
	* include/printf.h (__printf_fphex): Add attribute_hidden.
	(__guess_grouping): New prototype.
	* stdio-common/printf_fp.c (__guess_grouping): Removed.
	* stdio-common/reg-printf.c (__register_printf_specifier): Add
	libc_hidden_proto and libc_hidden_def.
	* stdlib/strfmon_l.c (__guess_grouping): Removed.
	(__vstrfmon_l): Remove the third argument passed to
	__guess_grouping.
2017-08-22 07:50:57 -07:00
H.J. Lu 8d2ec55329 Add hidden visibility to internal function prototypes
Add hidden visibility to internal function prototypes to allow direct
access to internal functions within libc.a without using GOT when the
compiler defaults to -fPIE.

Size comparison of elf/ldconfig when the compiler defaults to -fPIE:

On x86-64:
        text	   data	    bss	    dec	    hex
Before: 619646	  20132	   5488	 645266	  9d892
After : 619502	  20132	   5488	 645122	  9d802
On i686:
        text	   data	    bss	    dec	    hex
Before: 550333	  10748	   3060	 564141	  89bad
After : 546453	  10732	   3060	 560245	  88c75

	* include/libc-symbols.h (__hidden_proto_hiddenattr): New for
	building libc.a.
	(hidden_proto): Likewise.
	(hidden_tls_proto): Likewise.
	(__hidden_proto): Likewise.

(Reapplied after the revert in df1deda60050cc8a68156cf6c81ad42363647a29.)
2017-08-22 13:50:28 +02:00
Joseph Myers df1deda600 Revert "Add hidden visibility to internal function prototypes".
The commit

commit 568ff4296c
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Mon Aug 21 05:50:38 2017 -0700

    Add hidden visibility to internal function prototypes

breaks the build of the testsuite for many platforms:

https://sourceware.org/ml/libc-testresults/2017-q3/msg00300.html

The errors are of the following form, building math/atest-exp:

[...]
/scratch/jmyers/glibc-bot/build/glibcs/aarch64-linux-gnu/glibc/stdlib/rshift.o: In function `__mpn_rshift':
/scratch/jmyers/glibc-bot/build/glibcs/aarch64-linux-gnu/glibc-src/stdlib/rshift.c:45: undefined reference to `__assert_fail'
/scratch/jmyers/glibc-bot/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/7.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: /scratch/jmyers/glibc-bot/build/glibcs/aarch64-linux-gnu/glibc/math/atest-exp: hidden symbol `__assert_fail' isn't defined
/scratch/jmyers/glibc-bot/install/compilers/aarch64-linux-gnu/lib/gcc/aarch64-glibc-linux-gnu/7.2.1/../../../../aarch64-glibc-linux-gnu/bin/ld: final link failed: Bad value

This test is using various objects from the build of libc.  Some of
those objects contain references to __assert_fail.  Because those
references are hidden, they cannot refer to __assert_fail from
libc.so.  Given the tests using internal objects those symbols in
libc.a can't safely be made hidden, so this patch reverts the problem
commit until any alternative approach that doesn't break the build can
be found.
2017-08-21 17:52:05 +00:00
Joseph Myers 813378e9fe Obsolete matherr, _LIB_VERSION, libieee.a.
This patch obsoletes support for SVID libm error handling (the system
where a user-defined function matherr is called on a libm function
error; only enabled if you also set _LIB_VERSION = _SVID_ or
_LIB_VERSION = _XOPEN_) and the use of the _LIB_VERSION global
variable to control libm error handling.  matherr and _LIB_VERSION are
made into compat symbols, not supported for new ports or for static
linking.  The libieee.a object file (which sets _LIB_VERSION = _IEEE_,
so disabling errno setting for some functions) is also removed, and
all the related definitions are removed from math.h.

The manual already recommends against using matherr, and it's already
not supported for _Float128 functions (those use new wrappers that
don't support matherr, only errno) - this patch means that it becomes
possible to e.g. add sinf32 as an alias to sinf without that resulting
in undesired matherr support in sinf32 for existing glibc ports.
matherr support is not part of any standard supported by glibc (it was
removed in XPG4).

Because matherr is a function to be defined by the user, of course
user programs defining such a function will still continue to link; it
just quietly won't be used.  If they try to write to the library's
copy of _LIB_VERSION to enable SVID error handling, however, they will
get a link error (but if they define their own _LIB_VERSION variable,
they won't).

I expect the most likely case of build failures from this patch to be
programs with unconditional cargo-culted uses of -lieee (based on a
notion of "I want IEEE floating point", not any actual requirement for
that library).

Ideally, the new-port-or-static-linking case would use the new
wrappers used for _Float128.  This is not implemented in this patch,
because of the complication of architecture-specific (powerpc32 and
sparc) sqrt wrappers that use _LIB_VERSION and __kernel_standard
directly.  Thus, the old wrappers and __kernel_standard are still
built unconditionally, and _LIB_VERSION still exists in static libm.
But when the old wrappers and __kernel_standard are built in the
non-compat case, _LIB_VERSION and matherr are defined as macros so
code to support those features isn't actually built into static libm
or new ports' shared libm after this patch.

I intend to move to the new wrappers for static libm and new ports in
followup patches.  I believe the sqrt wrappers for powerpc32 and sparc
can reasonably be removed.  GCC already optimizes the normal case of
sqrt by generating code that uses a hardware instruction and only
calls the sqrt function if the argument was negative (if
-fno-math-errno, of course, it just uses the hardware instruction
without any check for negative argument being needed).  Thus those
wrappers will only actually get called in the case of negative
arguments, which is not a case it makes sense to optimize for.  But
even without removing the powerpc32 and sparc wrappers it should still
be possible to move to the new wrappers for static libm and new ports,
just without having those dubious architecture-specific optimizations
in static libm.

Everything said about matherr equally applies to matherrf and matherrl
(IA64-specific, undocumented), except that the structure of IA64 libm
means it won't be converted to using the new wrappers (it doesn't use
the old ones either, but its own error-handling code instead).

As with other tests of compat symbols, I expect test-matherr and
test-matherr-2 to need to become appropriately conditional once we
have a system for disabling such tests for ports too new to have the
relevant symbols.

Tested for x86_64 and x86, and with build-many-glibcs.py.

	* math/math.h [__USE_MISC] (_LIB_VERSION_TYPE): Remove.
	[__USE_MISC] (_LIB_VERSION): Likewise.
	[__USE_MISC] (struct exception): Likewise.
	[__USE_MISC] (matherr): Likewise.
	[__USE_MISC] (DOMAIN): Likewise.
	[__USE_MISC] (SING): Likewise.
	[__USE_MISC] (OVERFLOW): Likewise.
	[__USE_MISC] (UNDERFLOW): Likewise.
	[__USE_MISC] (TLOSS): Likewise.
	[__USE_MISC] (PLOSS): Likewise.
	[__USE_MISC] (HUGE): Likewise.
	[__USE_XOPEN] (MAXFLOAT): Define even if [__USE_MISC].
	* math/math-svid-compat.h: New file.
	* conform/linknamespace.pl (@whitelist): Remove matherr, matherrf
	and matherrl.
	* include/math.h [!_ISOMAC] (__matherr): Remove.
	* manual/arith.texi (FP Exceptions): Do not document matherr.
	* math/Makefile (tests): Change test-matherr to test-matherr-3.
	(tests-internal): New variable.
	(install-lib): Do not add libieee.a.
	(non-lib.a): Likewise.
	(extra-objs): Do not add libieee.a and ieee-math.o.
	(CPPFLAGS-s_lib_version.c): Remove variable.
	($(objpfx)libieee.a): Remove rule.
	($(addprefix $(objpfx), $(tests-internal)): Depend on $(libm).
	* math/ieee-math.c: Remove.
	* math/libm-test-support.c (matherr): Remove.
	* math/test-matherr.c: Use <support/test-driver.c>.  Add copyright
	and license notices.  Include <math-svid-compat.h> and
	<shlib-compat.h>.
	(matherr): Undefine as macro.  Use compat_symbol_reference.
	(_LIB_VERSION): Likewise.
	* math/test-matherr-2.c: New file.
	* math/test-matherr-3.c: Likewise.
	* sysdeps/generic/math_private.h (__kernel_standard): Remove
	declaration.
	(__kernel_standard_f): Likewise.
	(__kernel_standard_l): Likewise.
	* sysdeps/ieee754/s_lib_version.c: Do not include <math.h> or
	<math_private.h>.  Include <math-svid-compat.h>.
	(_LIB_VERSION): Undefine as macro.
	(_LIB_VERSION_INTERNAL): Always initialize to _POSIX_.  Define
	only if [LIBM_SVID_COMPAT || !defined SHARED].  If
	[LIBM_SVID_COMPAT], use compat_symbol.
	* sysdeps/ieee754/s_matherr.c: Do not include <math.h> or
	<math_private.h>.  Include <math-svid-compat.h>.
	(matherr): Undefine as macro.
	(__matherr): Define only if [LIBM_SVID_COMPAT].  Use
	compat_symbol.
	* sysdeps/ia64/fpu/libm_error.c: Include <math-svid-compat.h>.
	[_LIBC && LIBM_SVID_COMPAT] (matherrf): Use
	compat_symbol_reference.
	[_LIBC && LIBM_SVID_COMPAT] (matherrl): Likewise.
	[_LIBC && !LIBM_SVID_COMPAT] (matherrf): Define as macro.
	[_LIBC && !LIBM_SVID_COMPAT] (matherrl): Likewise.
	* sysdeps/ia64/fpu/libm_support.h: Include <math-svid-compat.h>.
	(MATHERR_D): Remove declaration.
	[!_LIBC] (_LIB_VERSION_TYPE): Likewise
	[!LIBM_BUILD] (_LIB_VERSIONIMF): Likewise.
	[LIBM_BUILD] (pmatherrf): Likewise.
	[LIBM_BUILD] (pmatherr): Likewise.
	[LIBM_BUILD] (pmatherrl): Likewise.
	(DOMAIN): Likewise.
	(SING): Likewise.
	(OVERFLOW): Likewise.
	(UNDERFLOW): Likewise.
	(TLOSS): Likewise.
	(PLOSS): Likewise.
	* sysdeps/ia64/fpu/s_matherrf.c: Include <math-svid-compat.h>.
	(__matherrf): Define only if [LIBM_SVID_COMPAT].  Use
	compat_symbol.
	* sysdeps/ia64/fpu/s_matherrl.c: Include <math-svid-compat.h>.
	(__matherrl): Define only if [LIBM_SVID_COMPAT].  Use
	compat_symbol.
	* math/lgamma-compat.h: Include <math-svid-compat.h>.
	* math/w_acos_compat.c: Likewise.
	* math/w_acosf_compat.c: Likewise.
	* math/w_acosh_compat.c: Likewise.
	* math/w_acoshf_compat.c: Likewise.
	* math/w_acoshl_compat.c: Likewise.
	* math/w_acosl_compat.c: Likewise.
	* math/w_asin_compat.c: Likewise.
	* math/w_asinf_compat.c: Likewise.
	* math/w_asinl_compat.c: Likewise.
	* math/w_atan2_compat.c: Likewise.
	* math/w_atan2f_compat.c: Likewise.
	* math/w_atan2l_compat.c: Likewise.
	* math/w_atanh_compat.c: Likewise.
	* math/w_atanhf_compat.c: Likewise.
	* math/w_atanhl_compat.c: Likewise.
	* math/w_cosh_compat.c: Likewise.
	* math/w_coshf_compat.c: Likewise.
	* math/w_coshl_compat.c: Likewise.
	* math/w_exp10_compat.c: Likewise.
	* math/w_exp10f_compat.c: Likewise.
	* math/w_exp10l_compat.c: Likewise.
	* math/w_exp2_compat.c: Likewise.
	* math/w_exp2f_compat.c: Likewise.
	* math/w_exp2l_compat.c: Likewise.
	* math/w_fmod_compat.c: Likewise.
	* math/w_fmodf_compat.c: Likewise.
	* math/w_fmodl_compat.c: Likewise.
	* math/w_hypot_compat.c: Likewise.
	* math/w_hypotf_compat.c: Likewise.
	* math/w_hypotl_compat.c: Likewise.
	* math/w_j0_compat.c: Likewise.
	* math/w_j0f_compat.c: Likewise.
	* math/w_j0l_compat.c: Likewise.
	* math/w_j1_compat.c: Likewise.
	* math/w_j1f_compat.c: Likewise.
	* math/w_j1l_compat.c: Likewise.
	* math/w_jn_compat.c: Likewise.
	* math/w_jnf_compat.c: Likewise.
	* math/w_jnl_compat.c: Likewise.
	* math/w_lgamma_main.c: Likewise.
	* math/w_lgamma_r_compat.c: Likewise.
	* math/w_lgammaf_main.c: Likewise.
	* math/w_lgammaf_r_compat.c: Likewise.
	* math/w_lgammal_main.c: Likewise.
	* math/w_lgammal_r_compat.c: Likewise.
	* math/w_log10_compat.c: Likewise.
	* math/w_log10f_compat.c: Likewise.
	* math/w_log10l_compat.c: Likewise.
	* math/w_log2_compat.c: Likewise.
	* math/w_log2f_compat.c: Likewise.
	* math/w_log2l_compat.c: Likewise.
	* math/w_log_compat.c: Likewise.
	* math/w_logf_compat.c: Likewise.
	* math/w_logl_compat.c: Likewise.
	* math/w_pow_compat.c: Likewise.
	* math/w_powf_compat.c: Likewise.
	* math/w_powl_compat.c: Likewise.
	* math/w_remainder_compat.c: Likewise.
	* math/w_remainderf_compat.c: Likewise.
	* math/w_remainderl_compat.c: Likewise.
	* math/w_scalb_compat.c: Likewise.
	* math/w_scalbf_compat.c: Likewise.
	* math/w_scalbl_compat.c: Likewise.
	* math/w_sinh_compat.c: Likewise.
	* math/w_sinhf_compat.c: Likewise.
	* math/w_sinhl_compat.c: Likewise.
	* math/w_sqrt_compat.c: Likewise.
	* math/w_sqrtf_compat.c: Likewise.
	* math/w_sqrtl_compat.c: Likewise.
	* math/w_tgamma_compat.c: Likewise.
	* math/w_tgammaf_compat.c: Likewise.
	* math/w_tgammal_compat.c: Likewise.
	* sysdeps/ieee754/dbl-64/w_exp_compat.c: Likewise.
	* sysdeps/ieee754/flt-32/w_expf_compat.c: Likewise.
	* sysdeps/ieee754/k_standard.c: Likewise.
	* sysdeps/ieee754/k_standardf.c: Likewise.
	* sysdeps/ieee754/k_standardl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/w_expl_compat.c: Likewise.
	* sysdeps/ieee754/ldbl-96/w_expl_compat.c: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/powerpc/powerpc32/power4/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/powerpc/powerpc32/power5/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/sparc/sparc32/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/sparc/sparc32/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrt_compat-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/multiarch/w_sqrtf_compat-vis3.S:
	Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/fpu/w_sqrtf_compat.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/w_sqrt_compat.S: Likewise.
	* sysdeps/sparc/sparc64/fpu/w_sqrtf_compat.S: Likewise.
2017-08-21 17:45:10 +00:00
H.J. Lu 568ff4296c Add hidden visibility to internal function prototypes
Add hidden visibility to internal function prototypes to allow direct
access to internal functions within libc.a without using GOT when the
compiler defaults to -fPIE.

Size comparison of elf/ldconfig when the compiler defaults to -fPIE:

On x86-64:
        text	   data	    bss	    dec	    hex
Before: 619646	  20132	   5488	 645266	  9d892
After : 619502	  20132	   5488	 645122	  9d802
On i686:
        text	   data	    bss	    dec	    hex
Before: 550333	  10748	   3060	 564141	  89bad
After : 546453	  10732	   3060	 560245	  88c75

	* include/libc-symbols.h (__hidden_proto_hiddenattr): New for
	building libc.a.
	(hidden_proto): Likewise.
	(hidden_tls_proto): Likewise.
	(__hidden_proto): Likewise.
2017-08-21 05:50:52 -07:00
H.J. Lu 7c41b4a131 Enable hidden visibility in libc.a compiled with PIE
When building libc.a with PIE, enable hidden visibility to allow direct
access to definitions within libc.a without using GOT.

Size comparison of elf/ldconfig when the compiler defaults to -fPIE:

On x86-64:
        text	   data	    bss	    dec	    hex
Before: 619206	  20132	   5488	 644826	  9d6da
After : 619062	  20132	   5488	 644682	  9d64a
On i686:
        text	   data	    bss	    dec	    hex
Before: 556305	  10816	   3056	 570177	  8b341
After : 553688	  10756	   3056	 567500	  8a8cc

	* include/libc-symbols.h (attribute_hidden): Enable hidden
	visibility in libc.a compiled with PIE.
2017-08-21 05:47:27 -07:00
H.J. Lu 54e4b8f215 Mark __libc_multiple_libcs with attribute_hidden [BZ #18822]
Since __libc_multiple_libcs is defined as hidden symbol in init-first.c,
it should be always marked with attribute_hidden.

	[BZ #18822]
	* csu/libc-start.c (__libc_multiple_libcs): Removed.
	* elf/dl-open.c: Include <libc-internal.h>.
	(__libc_multiple_libcs): Removed.
	* elf/dl-sysdep.c: Include <libc-internal.h> instead of
	<hp-timing.h>.
	* include/libc-internal.h (__libc_multiple_libcs): New.
	* misc/sbrk.c: Include <libc-internal.h>.
	(__libc_multiple_libcs): Removed.
2017-08-21 05:32:39 -07:00
H.J. Lu 7ed87317c7 Remove __bb_init_func and __bb_exit_func [BZ #21974]
__bb_init_func and __bb_exit_func have been removed from GCC 3.3 in
2002 by

https://gcc.gnu.org/ml/gcc-patches/2002-09/msg00499.html

which also recommended that they should also be removed from glibc. These
functions exist only in libc.a and are used for gcov from versions of GCC
older than GCC 3.3.

	[BZ #21974]
	* gmon/Makefile (routines): Remove bb_init_func and
	bb_exit_func.
	(elide-routines.os): Removed.
	* include/sys/gmon.h (__bb): Likewise.
	(__bb_init_func): Likewise.
	(__bb_exit_func): Likewise.
2017-08-20 06:39:31 -07:00
H.J. Lu 94e6ba153b Move ____longjmp_chk prototype to include/setjmp.h
Move ____longjmp_chk prototype to include/setjmp.h and add
attribute_hidden.

	* debug/longjmp_chk.c (____longjmp_chk): Moved to ...
	* include/setjmp.h (____longjmp_chk): Here.  Add
	attribute_hidden.
2017-08-20 06:30:46 -07:00
H.J. Lu 65a086db91 Mark internal argz functions with attribute_hidden [BZ #18822]
Move internal argz function prototypes to include/argz.h and mark them
with attribute_hidden to allow direct access within libc.so and libc.a
without using GOT nor PLT.  This also brings string/argz.h closer to the
gnulib version.

	[BZ #18822]
	* include/argz.h (__argz_create_sep): New function prototype.
	(__argz_append): Likewise.
	(__argz_add): Likewise.
	(__argz_add_sep): Likewise.
	(__argz_delete): Likewise.
	(__argz_insert): Likewise.
	(__argz_replace): Likewise.
	* string/argz.h (__argz_create_sep): Removed.
	(__argz_append): Likewise.
	(__argz_add): Likewise.
	(__argz_add_sep): Likewise.
	(__argz_delete): Likewise.
	(__argz_insert): Likewise.
	(__argz_replace): Likewise.
2017-08-18 09:31:33 -07:00
Florian Weimer 038d1cafaf __opensock: Remove internal_function attribute 2017-08-17 10:18:15 +02:00
Joseph Myers 67f0aff0c6 Fix sigval namespace (bug 21944).
XPG4.2 defines the siginfo_t type, but not union sigval or its
contents (which were added in the 1993 edition of POSIX.1), resulting
in namespace violations for sigval, sival_int and sival_ptr for
signal.h and sys/wait.h for that standard because those headers
incorrectly expose those names in that case.

This patch fixes this problem.  The public type in this case is union
sigval, but various places in the headers use the sigval_t name for
it; direct uses of union sigval are already properly guarded or in
headers not in XPG4.2.  Now, sigval_t, although not a standard name,
does seem to be widely used outside glibc.  The approach taken by this
patch is to make installed headers use the name __sigval_t instead.
__sigval_t is then defined to either union sigval or union __sigval
(where union __sigval has __-prefixed member names as well), depending
on whether there are any namespace issues with the union sigval name
and its members.  In the case where union __sigval is used, sigval_t
is not defined at all, to avoid the problem of sigval_t having a C++
mangled name that depends on feature test macros.  sigval_t is still
defined by signal.h if __USE_MISC (reflecting the nonstandard nature
of that name).

Tested for x86_64.

	[BZ #21944]
	* signal/bits/types/__sigval_t.h: New file.
	* signal/Makefile (headers): Add bits/types/__sigval_t.h.
	* signal/bits/types/sigval_t.h: Include <bits/types/__sigval_t.h>
	and define sigval_t using __sigval_t.
	* include/bits/types/__sigval_t.h: New file.
	* bits/types/sigevent_t.h: Include <bits/types/__sigval_t.h>
	instead of <bits/types/__sigval_t.h>.
	(struct sigevent): Use __sigval_t instead of sigval_t.
	* bits/types/siginfo_t.h: Include <bits/types/__sigval_t.h>
	instead of <bits/types/__sigval_t.h>.
	(siginfo_t): Use __sigval_t instead of sigval_t.
	* sysdeps/unix/sysv/linux/bits/types/sigevent_t.h: Include
	<bits/types/__sigval_t.h> instead of <bits/types/__sigval_t.h>.
	(struct sigevent): Use __sigval_t instead of sigval_t.
	* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h: Include
	<bits/types/__sigval_t.h> instead of <bits/types/__sigval_t.h>.
	(siginfo_t): Use __sigval_t instead of sigval_t.
	* signal/signal.h [__USE_MISC]: Include <bits/types/sigval_t.h>.
2017-08-16 20:33:59 +00:00
Florian Weimer 3012cfb0d2 ld.so: Remove internal_function attribute from various functions
These functions are invoked from other DSOs and should therefore
use the standard calling convention.
2017-08-13 21:11:54 +02:00
Florian Weimer 52bcdf267b Remove internal_function attribute from string-to-float functions
These are called across DSO boundaries and should therefore use
the standard calling convention.
2017-08-13 21:11:47 +02:00
Florian Weimer c4d767f7f3 __libc_rpc_getport: Remove internal_function attribute
This function has a hidden alias and is therefore expected to be
called across DSO boundaries.
2017-08-13 21:11:06 +02:00
Florian Weimer 1b0bfc6946 __fortify_fail: Remove internal_function attribute
__fortify_fail is called across DSO boundaries, so it should not
use a non-standard calling convention.
2017-08-13 21:10:44 +02:00
H.J. Lu 086df229ee i386: Add <startup.h> [BZ #21913]
On Linux/i386, there are 3 ways to make a system call:

1. call *%gs:SYSINFO_OFFSET.  This requires TLS initialization.
2. call *_dl_sysinfo.  This requires relocation of _dl_sysinfo.
3. int $0x80.  This is slower than #2 and #3, but works everywhere.

When an object file is compiled with PIC, #1 is prefered since it is
faster than #3 and doesn't require relocation of _dl_sysinfo.  For
dynamic executables, ld.so initializes TLS.  However, for static
executables, before TLS is initialized by __libc_setup_tls, #3 should
be used for system calls.

This patch adds <startup.h> which defines _startup_fatal and defaults
it to __libc_fatal.  It replaces __libc_fatal with _startup_fatal in
static executables where it is called before __libc_setup_tls is called.
This header file is included in all files containing functions which are
called before __libc_setup_tls is called.  On Linux/i386, when PIE is
enabled by default, _startup_fatal is turned into ABORT_INSTRUCTION and
I386_USE_SYSENTER is defined to 0 so that "int $0x80" is used for system
calls before __libc_setup_tls is called.

Tested on i686 and x86-64.  Without this patch, all statically-linked
tests will fail on i686 when the compiler defaults to -fPIE.

	[BZ #21913]
	* csu/libc-tls.c: Include <startup.h> first.
	(__libc_setup_tls): Call _startup_fatal instead of __libc_fatal.
	* elf/dl-tunables.c: Include <startup.h> first.
	* include/libc-symbols.h (BUILD_PIE_DEFAULT): New.
	* sysdeps/generic/startup.h: New file.
	* sysdeps/unix/sysv/linux/i386/startup.h: Likewise.
	* sysdeps/unix/sysv/linux/i386/brk.c [BUILD_PIE_DEFAULT != 0]
	(I386_USE_SYSENTER): New.  Defined to 0.
2017-08-08 08:43:15 -07:00
Siddhesh Poyarekar 1c9a5c270d Update for 2.26 release 2017-08-02 18:27:16 +05:30
Adhemerval Zanella 95a7339258 tunables: Use direct syscall for access (BZ#21744)
The function maybe_enable_malloc_check, which is called by
__tunables_init, calls __access_noerrno.  It isn't problem when
symbol is is in ld.so, which has a special version of __access_noerrno
without stack protector.  But when glibc is built with stack protector,
maybe_enable_malloc_check in libc.a can't call the regular version of
__access_noerrno with stack protector.

This patch changes how Linux defines the __access_noerrno to be an
inline call instead and thus preventing defining different build
rules for ld/static and shared.

	H.J. Lu  <hongjiu.lu@intel.com>
	Adhemerval Zanella  <adhemerval.zanella@linaro.org>

	[BZ #21744]
	* elf/dl-tunables.c: Include not-errno.h header.
	* include/unistd.h (__access_noerrno): Remove definition.
	* sysdeps/unix/sysv/linux/access.c (__access_noerrno): Likewise.
	* sysdeps/generic/not-errno.h: New file.
	* sysdeps/unix/sysv/linux/not-errno.h: Likewise.
2017-07-24 11:21:07 -03:00
H.J. Lu ed421fca42 Avoid backtrace from __stack_chk_fail [BZ #12189]
__stack_chk_fail is called on corrupted stack.  Stack backtrace is very
unreliable against corrupted stack.  __libc_message is changed to accept
enum __libc_message_action and call BEFORE_ABORT only if action includes
do_backtrace.  __fortify_fail_abort is added to avoid backtrace from
__stack_chk_fail.

	[BZ #12189]
	* debug/Makefile (CFLAGS-tst-ssp-1.c): New.
	(tests): Add tst-ssp-1 if -fstack-protector works.
	* debug/fortify_fail.c: Include <stdbool.h>.
	(_fortify_fail_abort): New function.
	(__fortify_fail): Call _fortify_fail_abort.
	(__fortify_fail_abort): Add a hidden definition.
	* debug/stack_chk_fail.c: Include <stdbool.h>.
	(__stack_chk_fail): Call __fortify_fail_abort, instead of
	__fortify_fail.
	* debug/tst-ssp-1.c: New file.
	* include/stdio.h (__libc_message_action): New enum.
	(__libc_message): Replace int with enum __libc_message_action.
	(__fortify_fail_abort): New hidden prototype.
	* malloc/malloc.c (malloc_printerr): Update __libc_message calls.
	* sysdeps/posix/libc_fatal.c (__libc_message): Replace int
	with enum __libc_message_action.  Call BEFORE_ABORT only if
	action includes do_backtrace.
	(__libc_fatal): Update __libc_message call.
2017-07-11 07:44:14 -07:00
Florian Weimer 352f4ff9a2 resolv: Introduce struct resolv_context [BZ #21668]
struct resolv_context objects provide a temporary resolver context
which does not change during a name lookup operation.  Only when the
outmost context is created, the stub resolver configuration is
verified to be current (at present, only against previous res_init
calls).  Subsequent attempts to obtain the context will reuse the
result of the initial verification operation.

struct resolv_context can also be extended in the future to store
data which needs to be deallocated during thread cancellation.
2017-07-03 20:52:59 +02:00
Gabriel F. T. Gomes 8466ee1cb7 float128: Add signbit alternative for old compilers
In math/math.h, __MATH_TG will expand signbit to __builtin_signbit*,
e.g.: __builtin_signbitf128, before GCC 6.  However, there has never
been a __builtin_signbitf128 in GCC and the type-generic builtin is
only available since GCC 6.  For older GCC, this patch defines
__builtin_signbitf128 to __signbitf128, so that the internal function
is used instead of the non-existent builtin.

This patch also changes the implementation of __signbitf128, because
it was reusing the implementation of __signbitl from ldbl-128, which
calls __builtin_signbitl.  Using the long double version of the
builtin is not correct on machines where _Float128 is ABI-distinct
from long double (i.e.: ia64, powerpc64le, x86, x86_84).  The new
implementation does not rely on builtins when being built with GCC
versions older than 6.0.

The new code does not currently affect powerpc64le builds, because
only GCC 6.2 fulfills the requirements from configure.  It might
affect powerpc64le builds if those requirements are backported to
older versions of the compiler.  The new code affects x86_64 builds,
since glibc is supposed to build correctly with older versions of GCC.

Tested for powerpc64le and x86_64.

	* include/math.h (__signbitf128): Define as hidden.
	* sysdeps/ieee754/float128/s_signbitf128.c (__signbitf128):
	Reimplement without builtins.
	* sysdeps/ia64/bits/floatn.h [!__GNUC_PREREQ (6, 0)]
	(__builtin_signbitf128): Define to __signbitf128.
	* sysdeps/powerpc/bits/floatn.h: Likewise.
	* sysdeps/x86/bits/floatn.h: Likewise.
2017-06-30 18:34:29 -03:00
Florian Weimer 6781d8e693 resolv: Turn _res_opcodes into a compatibility symbol 2017-06-30 11:31:41 +02:00
Florian Weimer d85f99679d resolv: Move fp_nquery, fp_query, p_query, _res_opcodes
From res_data.c to res_debug.c.

Also drop the unnecessary _res initialization from fp_nquery.
2017-06-30 11:31:35 +02:00
Adhemerval Zanella fa872e1b62 Clean pthread functions namespaces for C11 threads
This patch adds internal definition (through {libc_}hidden_{proto,def}) and
also change some strong to weak alias for symbols that might be used by C11
threads implementations.

The patchset should not change libc/libpthread functional, although object
changes are expected (since now internal symbols are used instead) and final
exported symbols through GLIBC_PRIVATE is also expanded (to cover libpthread
usage of __mmap{64}, __munmap, __mprotect).

Checked with a build for all major ABI (aarch64-linux-gnu, alpha-linux-gnu,
arm-linux-gnueabi, i386-linux-gnu, ia64-linux-gnu, m68k-linux-gnu,
microblaze-linux-gnu [1], mips{64}-linux-gnu, nios2-linux-gnu,
powerpc{64le}-linux-gnu, s390{x}-linux-gnu, sparc{64}-linux-gnu,
tile{pro,gx}-linux-gnu, and x86_64-linux-gnu).

	* include/sched.h (__sched_get_priority_max): Add libc hidden proto.
	(__sched_get_prioriry_min): Likewise.
	* include/sys/mman.h (__mmap): Likewise.
	(__mmap64): Likewise.
	(__munmap): Likewise.
	(__mprotect): Likewise.
	* include/termios.h (__tcsetattr): Likewise.
	* include/time.h (__nanosleep): Use hidden_proto instead of
	libc_hidden_proto.
	* posix/nanosleep.c (__nanosleep): Likewise.
	* misc/Versions (libc): Export __mmap, __munmap, __mprotect,
	__sched_get_priority_min, and __sched_get_priority_max under
	GLIBC_PRIVATE.
	* nptl/allocatestack.c (__free_stacks): Use internal definition for
	libc symbols.
	(change_stack_perm): Likewise.
	(allocate_stack): Likewise.
	* sysdeps/posix/gethostname.c: Likewise.
	* nptl/tpp.c (__init_sched_fifo_prio): Likewise.
	* sysdeps/unix/sysv/linux/i386/smp.h (is_smp_system): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/ioctl.c (__ioctl): Likewise.
	* nptl/pthreadP.h (__pthread_mutex_timedlock): Add definition.
	(__pthread_key_delete): Likewise.
	(__pthread_detach): Likewise.
	(__pthread_cancel): Likewise.
	(__pthread_mutex_trylock): Likewise.
	(__pthread_mutexattr_init): Likewise.
	(__pthread_mutexattr_settype): Likewise.
	* nptl/pthread_cancel.c (pthread_cancel): Change to internal name and
	create alias for exported one.
	* nptl/pthread_join.c (pthread_join): Likewise.
	* nptl/pthread_detach.c (pthread_detach): Likewise.
	* nptl/pthread_key_delete.c (pthread_key_delete): Likewise.
	* nptl/pthread_mutex_timedlock.c (pthread_mutex_timedlock): Likewise.
	* nptl/pthread_create.c: Change static requirements for pthread
	symbols.
	* nptl/pthread_equal.c (__pthread_equal): Change strong alias to weak
	for internal definition.
	* nptl/pthread_exit.c (__pthread_exit): Likewise.
	* nptl/pthread_getspecific.c (__pthread_getspecific): Likewise.
	* nptl/pthread_key_create.c (__pthread_key_create): Likewise.
	* nptl/pthread_mutex_destroy.c (__pthread_mutex_destroy): Likewise.
	* nptl/pthread_mutex_init.c (__pthread_mutex_init): Likewise.
	* nptl/pthread_mutex_lock.c (__pthread_mutex_lock): Likewise.
	* nptl/pthread_mutex_trylock.c (__pthread_mutex_trylock): Likewise.
	* nptl/pthread_mutex_unlock.c (__pthread_mutex_unlock): Likewise.
	* nptl/pthread_mutexattr_init.c (__pthread_mutexattr_init): Likwise.
	* nptl/pthread_mutexattr_settype.c (__pthread_mutexattr_settype):
	Likewise.
	* nptl/pthread_self.c (__pthread_self): Likewise.
	* nptl/pthread_setspecific.c (__pthread_setspecific): Likewise.
	* sysdeps/unix/sysv/linux/tcsetattr.c (tcsetattr): Likewise.
	* misc/mmap.c (__mmap): Add internal symbol definition.
	* misc/mmap.c (__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/mmap.c (__mmap): Likewise.
	* sysdeps/unix/sysv/linux/mmap64.c (__mmap): Likewise.
	(__mmap64): Likewise.
	* sysdeps/unix/sysv/linux/i386/Versions (libc) [GLIBC_PRIVATE):
	Add __uname.
2017-06-23 17:38:17 -03:00
Gabriel F. T. Gomes 9f0170af26 Include libc-header-start.h in include/float.h
The file include/float.h uses the macro __GLIBC_USE to test for TS 18661-3
support.  Such macro is provided by bits/libc-header-start.h, so include it
to get the definition.

Tested for powerpc64le and s390x.

	* include/float.h: Include libc-header-start.h to get the
	definition of __GLIBC_USE.
2017-06-23 10:30:04 -03:00
Mike FABIAN 925fac7793 Bug 21533: Update to Unicode 10.0.0
* Unicode 10.0.0 Support: Character encoding, character type info, and
  transliteration tables are all updated to Unicode 10.0.0, using
  generator scripts contributed by Mike FABIAN (Red Hat).
2017-06-22 17:02:55 +02:00
Florian Weimer 4dd8e7c0ce Implement allocation buffers for internal use
This commit adds fixed-size allocation buffers.  The primary use
case is in NSS modules, where dynamically sized data is stored
in a fixed-size buffer provided by the caller.

Other uses include a replacement of mempcpy cascades (which is
safer due to the size checking inherent to allocation buffers).
2017-06-21 22:43:57 +02:00
Zack Weinberg af85385f31 Use locale_t, not __locale_t, throughout glibc
<locale.h> is specified to define locale_t in POSIX.1-2008, and so are
all of the headers that define functions that take locale_t arguments.
Under _GNU_SOURCE, the additional headers that define such functions
have also always defined locale_t.  Therefore, there is no need to use
__locale_t in public function prototypes, nor in any internal code.

	* ctype/ctype-c99_l.c, ctype/ctype.h, ctype/ctype_l.c
	* include/monetary.h, include/stdlib.h, include/time.h
	* include/wchar.h, locale/duplocale.c, locale/freelocale.c
	* locale/global-locale.c, locale/langinfo.h, locale/locale.h
	* locale/localeinfo.h, locale/newlocale.c
	* locale/nl_langinfo_l.c, locale/uselocale.c
	* localedata/bug-usesetlocale.c, localedata/tst-xlocale2.c
	* stdio-common/vfscanf.c, stdlib/monetary.h, stdlib/stdlib.h
	* stdlib/strfmon_l.c, stdlib/strtod_l.c, stdlib/strtof_l.c
	* stdlib/strtol.c, stdlib/strtol_l.c, stdlib/strtold_l.c
	* stdlib/strtoll_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
	* string/strcasecmp.c, string/strcoll_l.c, string/string.h
	* string/strings.h, string/strncase.c, string/strxfrm_l.c
	* sysdeps/ieee754/float128/strtof128_l.c
	* sysdeps/ieee754/float128/wcstof128.c
	* sysdeps/ieee754/float128/wcstof128_l.c
	* sysdeps/ieee754/ldbl-128ibm/strtold_l.c
	* sysdeps/ieee754/ldbl-64-128/strtold_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c
	* sysdeps/ieee754/ldbl-opt/nldbl-strfmon_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-strtold_l.c
	* sysdeps/ieee754/ldbl-opt/nldbl-wcstold_l.c
	* sysdeps/powerpc/powerpc32/power7/strcasecmp.S
	* sysdeps/powerpc/powerpc64/power7/strcasecmp.S
	* sysdeps/x86_64/strcasecmp_l-nonascii.c
	* sysdeps/x86_64/strncase_l-nonascii.c, time/strftime_l.c
	* time/strptime_l.c, time/time.h, wcsmbs/mbsrtowcs_l.c
	* wcsmbs/wchar.h, wcsmbs/wcscasecmp.c, wcsmbs/wcsncase.c
	* wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
	* wcsmbs/wcstof_l.c, wcsmbs/wcstol_l.c, wcsmbs/wcstold.c
	* wcsmbs/wcstold_l.c, wcsmbs/wcstoll_l.c, wcsmbs/wcstoul_l.c
	* wcsmbs/wcstoull_l.c, wctype/iswctype_l.c
	* wctype/towctrans_l.c, wctype/wcfuncs_l.c
	* wctype/wctrans_l.c, wctype/wctype.h, wctype/wctype_l.c:
	Change all uses of __locale_t to locale_t.
2017-06-20 20:30:06 -04:00
Zack Weinberg f0be25b633 Rename xlocale.h to bits/types/__locale_t.h.
xlocale.h is already a single-type micro-header, defining struct
__locale_struct and the typedefs __locale_t and locale_t.  This patch
brings it into the bits/types/ scheme: there are now
bits/types/__locale_t.h which defines only __locale_struct and
__locale_t, and bits/types/locale_t.h which defines locale_t as well
as the other two.  None of *our* headers need __locale_t.h, but it
appears to me that libstdc++ could make use of it.

There are a lot of external uses of xlocale.h, but all the uses I
checked had an autoconf test or equivalent for its existence.  It has
never been available from other C libraries, and it has always
contained a comment reading "This file is not standardized, don't rely
on it, it can go away without warning" so I think dropping it is
pretty safe.

I also took the opportunity to clean up comments in various public
header files that still talk about the *_l interfaces as though they
were completely nonstandard.  There are a few of them, notably the
strtoX_l and wcstoX_l families, that haven't been standardized, but
the bulk are in POSIX.1-2008.

        * locale/xlocale.h: Rename to...
	* locale/bits/types/__locale_t.h: ...here.  Adjust commentary.
	Only define struct __locale_struct and __locale_t, not locale_t.
        * locale/bits/types/locale_t.h: New file; define locale_t here.
        * locale/Makefile (headers): Update to match.

        * include/xlocale.h: Delete wrapper.
        * include/bits/types/__locale_t.h: New wrapper.
        * include/bits/types/locale_t.h: New wrapper.

        * ctype/ctype.h, include/printf.h, include/time.h
        * locale/langinfo.h, locale/locale.h, stdlib/monetary.h
        * stdlib/stdlib.h, string/string.h, string/strings.h, time/time.h
        * wcsmbs/wchar.h, wctype/wctype.h: Use bits/types/locale_t.h.
        Correct outdated comments regarding the standardization status of
        the functions that take locale_t arguments.

        * stdlib/strtod_l.c, stdlib/strtof_l.c, stdlib/strtol_l.c
        * stdlib/strtold_l.c, stdlib/strtoul_l.c, stdlib/strtoull_l.c
        * sysdeps/ieee754/ldbl-128ibm/strtold_l.c
        * sysdeps/ieee754/ldbl-64-128/strtold_l.c
        * wcsmbs/wcstod.c, wcsmbs/wcstod_l.c, wcsmbs/wcstof.c
        * wcsmbs/wcstof_l.c, wcsmbs/wcstold.c, wcsmbs/wcstold_l.c:
        Don't include xlocale.h. If necessary, include locale.h instead.

        * stdlib/strtold_l.c: Unconditionally include wchar.h.
2017-06-20 20:28:11 -04:00
Zack Weinberg 09a596cc2c Remove bits/string.h.
These machine-dependent inline string functions have never been on by
default, and even if they were a good idea at the time they were
introduced, they haven't really been touched in ten to fifteen years
and probably aren't a good idea on current-gen processors.  Current
thinking is that this class of optimization is best left to the
compiler.

	* bits/string.h, string/bits/string.h
	* sysdeps/aarch64/bits/string.h
	* sysdeps/m68k/m680x0/m68020/bits/string.h
	* sysdeps/s390/bits/string.h, sysdeps/sparc/bits/string.h
	* sysdeps/x86/bits/string.h: Delete file.

	* string/string.h: Don't include bits/string.h.
	* string/bits/string3.h: Rename to bits/string_fortified.h.
	No need to undef various symbols that the removed headers
	might have defined as macros.
	* string/Makefile (headers): Remove bits/string.h, change
	bits/string3.h to bits/string_fortified.h.
	* string/string-inlines.c: Update commentary.  Remove definitions
	of various macros that nothing looks at anymore.  Don't directly
	include bits/string.h. Set _STRING_INLINE_unaligned here, based on
	compiler-predefined macros.
	* string/strncat.c: If STRNCAT is not defined, or STRNCAT_PRIMARY
	_is_ defined, provide internal hidden alias __strncat.
	* include/string.h: Declare internal hidden alias __strncat.
	Only forward __stpcpy to __builtin_stpcpy if __NO_STRING_INLINES is
	not defined.
	* include/bits/string3.h: Rename to bits/string_fortified.h,
	update to match above.

	* sysdeps/i386/string-inlines.c: Define compat symbols for
	everything formerly defined by sysdeps/x86/bits/string.h.
	Make existing definitions into compat symbols as well.
	Remove some no-longer-necessary messing around with macros.

	* sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c
	* sysdeps/powerpc/powerpc64/multiarch/mempcpy.c
	* sysdeps/powerpc/powerpc64/multiarch/stpcpy.c
	* sysdeps/s390/multiarch/mempcpy.c
	No need to define _HAVE_STRING_ARCH_mempcpy.
	Do define __NO_STRING_INLINES and NO_MEMPCPY_STPCPY_REDIRECT.

	* sysdeps/i386/i686/multiarch/strncat-c.c
	* sysdeps/s390/multiarch/strncat-c.c
	* sysdeps/x86_64/multiarch/strncat-c.c
	Define STRNCAT_PRIMARY.  Don't change definition of libc_hidden_def.
2017-06-20 08:21:24 -04:00
Florian Weimer ca3d65ff69 resolv: Make __res_vinit hidden
And remove unnecessary separate declarations.
2017-06-19 14:24:23 +02:00
Joseph Myers a66bc30d6b Define struct rusage in sys/wait.h when required (bug 21575).
Some older standards (XPG4.2 through POSIX.1:2001, XSI only) require
sys/wait.h to include the definition of struct rusage.  This is
missing in glibc.

This patch adds the required definition.  struct rusage is moved to a
new header bits/types/struct_rusage.h to avoid bringing in the whole
of sys/resource.h (although the standards in question do allow the
whole of sys/resource.h to be brought in).  In the five
bits/resource.h headers, the only variation between the definitions of
struct rusage is that the sysdeps/unix/sysv/linux version is prepared
for x32 (by having anonymous unions with __syscall_slong_t fields) and
the others are not.  Thus, this version is suitable for use
generically (everything other than x32 simply has __syscall_slong_t
the same as long int, so there are no API or ABI changes involved, and
anonymous unions are already a required language feature for glibc
headers elsewhere), and this patch uses it as a base for the single
implementation of bits/types/struct_rusage.h.

Tested for x86_64, and with build-many-glibcs.py.

	[BZ #21575]
	* resource/bits/types/struct_rusage.h: New file.
	* include/bits/types/struct_rusage.h: Likewise.
	* bits/resource.h (struct rusage): Include
	<bits/types/struct_rusage.h> instead of defining here.
	* sysdeps/unix/sysv/linux/bits/resource.h (struct rusage):
	Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/resource.h (struct rusage):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/resource.h (struct rusage):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/resource.h (struct rusage):
	Likewise.
	* resource/Makefile (headers): Add bits/types/struct_rusage.h.
	* posix/sys/wait.h [__USE_XOPEN_EXTENDED && !__USE_XOPEN2K8]:
	Include <bits/types/struct_rusage.h>
2017-06-19 11:59:19 +00:00
Zack Weinberg fd860eaaa8 Remove __need macros from errno.h (__need_Emath, __need_error_t).
This is fairly complicated, not because the users of __need_Emath and
__need_error_t have complicated requirements, but because the core
changes had a lot of fallout.

__need_error_t exists for gnulib compatibility in argz.h and argp.h.
error_t itself is a Hurdism, an enum containing all the E-constants,
so you can do 'p (error_t) errno' in gdb and get a symbolic value.
argz.h and argp.h use it for function return values, and they want to
fall back to 'int' when that's not available.  There is no reason why
these nonstandard headers cannot just go ahead and include all of
errno.h; so we do that.

__need_Emath is defined only by .S files; what they _really_ need is
for errno.h to avoid declaring anything other than the E-constants
(e.g. 'extern int __errno_location(void);' is a syntax error in
assembly language). This is replaced with a check for __ASSEMBLER__ in
errno.h, plus a carefully documented requirement for bits/errno.h not
to define anything other than macros.  That in turn has the
consequence that bits/errno.h must not define errno - fortunately, all
live ports use the same definition of errno, so I've moved it to
errno.h.  The Hurd bits/errno.h must also take care not to define
error_t when __ASSEMBLER__ is defined, which involves repeating all of
the definitions twice, but it's a generated file so that's okay.

	* stdlib/errno.h: Remove __need_Emath and __need_error_t logic.
	Reorganize file.  Declare errno here.  When __ASSEMBLER__ is
	defined, don't declare anything other than the E-constants.

	* include/errno.h: Change conditional for exposing internal
	declarations to (not _ISOMAC and not __ASSEMBLER__).
	* bits/errno.h: Remove logic for __need_Emath.  Document
	requirements for a port-specific bits/errno.h.

	* sysdeps/unix/sysv/linux/bits/errno.h
	* sysdeps/unix/sysv/linux/alpha/bits/errno.h
	* sysdeps/unix/sysv/linux/hppa/bits/errno.h
	* sysdeps/unix/sysv/linux/mips/bits/errno.h
	* sysdeps/unix/sysv/linux/sparc/bits/errno.h:
	Add multiple-include guard and check against improper inclusion.
	Remove __need_Emath logic.  Don't declare errno here.  Ensure all
	constants are defined as simple integer literals.  Consistent
	formatting.
	* sysdeps/mach/hurd/errnos.awk: Likewise.  Only define error_t and
	enum __error_t_codes if __ASSEMBLER__ is not defined.
	* sysdeps/mach/hurd/bits/errno.h: Regenerate.

	* argp/argp.h, string/argz.h: Don't define __need_error_t before
	including errno.h.
	* sysdeps/i386/i686/fpu/multiarch/s_cosf-sse2.S
	* sysdeps/i386/i686/fpu/multiarch/s_sincosf-sse2.S
	* sysdeps/i386/i686/fpu/multiarch/s_sinf-sse2.S
	* sysdeps/x86_64/fpu/s_cosf.S
	* sysdeps/x86_64/fpu/s_sincosf.S
	* sysdeps/x86_64/fpu/s_sinf.S:
	Just include errno.h; don't define __need_Emath or include
	bits/errno.h directly.
2017-06-14 08:14:34 -04:00
Zack Weinberg 37f802f864 Remove __need_IOV_MAX and __need_FOPEN_MAX.
__need_FOPEN_MAX wasn't being used anywhere.  __need_IOV_MAX was more
complicated; the basic deal is that sys/uio.h wants to define a
constant named UIO_MAXIOV and bits/xopen_lim.h wants to define a
constant named IOV_MAX, with the same meaning.  For no apparent reason
this was being handled via bits/stdio_lim.h -- stdio.h is NOT supposed
to define IOV_MAX -- and some mess in Makerules.  Also, bits/uio.h on
Linux was being used as a dumping ground for extension functions.

So now we have bits/uio_lim.h, which defines __IOV_MAX.
bits/xopen_lim.h and sys/uio.h use that to define their respective
constants.  We also now have bits/uio-ext.h, which is the official
Proper Home for extensions to sys/uio.h.  bits/uio.h is removed, and
stdio_lim.h doesn't define IOV_MAX at all.

	* bits/uio_lim.h, sysdeps/unix/sysv/linux/bits/uio_lim.h
	* bits/uio-ext.h, sysdeps/unix/sysv/linux/bits/uio-ext.h: New file.
	* bits/uio.h, sysdeps/unix/sysv/linux/bits/uio.h: Delete file.

	* include/bits/xopen_lim.h: Use bits/uio_lim.h to get the value
	for IOV_MAX.
	* misc/Makefile: Install bits/uio-ext.h and bits/uio_lim.h.
	Don't install bits/uio.h.
	* misc/sys/uio.h: Don't include bits/uio.h.  Do include
	bits/types/struct_iovec.h and bits/uio_lim.h.  Set UIO_MAXIOV
	based on __IOV_MAX. Under __USE_GNU, also include bits/uio-ext.h.

	* stdio-common/stdio_lim.h.in: Remove logic for __need_FOPEN_MAX
	and __need_IOV_MAX.  Don't define IOV_MAX at all.
	* Makerules (stdio_lim.h): Remove logic for setting IOV_MAX.

	* sysdeps/unix/sysv/linux/bits/fcntl-linux.h:
	Include bits/types/struct_iovec.h, not bits/uio.h.
	Use __ssize_t, not ssize_t, in function prototypes.
	Don't use hard TAB for double space after period in comments.
2017-06-14 07:51:30 -04:00
Zack Weinberg 46ee3da55e Remove __need_schedparam and __cpu_set_t_defined.
bits/sched.h has logic to expose only an impl-namespace variant of
struct sched_param (i.e. struct __sched_param), but nothing uses it,
and the only header that includes bits/sched.h is sched.h.  The
__need_schedparam logic can therefore be removed.

bits/sched.h also has a great deal of code relating to cpu_set_t
objects that was *almost* the same between the two versions of
bits/sched.h in the tree; a little spelunking indicated that this is
because some bug fixes got applied to the Linux-specific bits/sched.h
but not the generic one.  Introduce a new header, bits/cpu-set.h,
containing the version of that code with the bugfixes, have sched.h
include it directly, and delete all of the code from both versions of
bits/sched.h.

Also remove the unnecessary name mangling in the definition of struct
sched_param -- POSIX specifies a field 'sched_priority', so there is
no reason to define it as '__sched_priority' and then paper over that
with a macro.  (Just in case someone was using the internal name,
'sched_priority' remains a macro defined to expand to itself, and
'__sched_priority' now expands to 'sched_priority'.)

Finally, as long as I'm touching these files anyway, merge new
constants from linux/sched.h into the Linux bits/sched.h.

	* bits/sched.h: Remove __need_schedparam logic and replace with a
	normal multiple-include guard.  Change field name in struct
	sched_param from __sched_priority to sched_priority.  Delete
	everything under #ifndef __cpu_set_t_defined.
	* sysdeps/unix/sysv/linux/bits/sched.h: Likewise.  Also sync with
	kernel sched.h, adding SCHED_ISO and SCHED_DEADLINE constants.

	* posix/sched.h: Include bits/cpu-set.h as well as bits/sched.h.
	For compatibility, #define sched_priority to itself, and #define
	__sched_priority as sched_priority.
	* posix/bits/cpu-set.h: New file containing, verbatim, the code
	that was under #ifndef __cpu_set_t_defined in
	sysdeps/unix/sysv/linux/bits/sched.h.
	* include/bits/cpu-set.h: New wrapper.
	* posix/Makefile: Install bits/cpu-set.h.
2017-06-12 17:11:36 -04:00
Gabriel F. T. Gomes 8fd3101431 Allow macros prefixed with FLT128 in include/float.h
TS 18661-3 specifies that macros prefixed with FLTN_ can be defined in
float.h, only if __STDC_WANT_IEC_60559_TYPES_EXT__ is defined as a macro
before the inclusion of float.h.  Since GCC 7.0, these macros are provided
under this condition, however, for older versions of GCC, these macros are
not provided at all.  This patch allows the definitions of such macros in
include/float.h for older compilers, if the condition above is met, and
even if _ISOMAC is defined.

	* include/float.h: Allow the definition of macros prefixed with
	FLT128 even if _ISOMAC is defined, but provided that
	__STDC_WANT_IEC_60559_TYPES_EXT__ is defined as a macro.
2017-06-12 14:48:53 -03:00
Paul E. Murphy 45f39d4588 float128: Add strtof128, wcstof128, and related functions.
The implementations are contained with sysdeps/ieee754/float128 as
they are only built when _Float128 is enabled within libc/m.

	* include/gmp.h (__mpn_construct_float128): New declaration.
	* include/stdlib.h: Include bits/floatn.h for _Float128 tests.
	(__strtof128_l): New declaration.
	(__strtof128_nan): Likewise.
	(__wcstof128_nan): Likewise.
	(__strtof128_internal): Likewise.
	(____strtof128_l_internal): Likewise.
	* include/wchar.h: Include bits/floatn.h for _Float128 tests.
	(__wcstof128_l): New declaration.
	(__wcstof128_internal): Likewise.

	* stdlib/Makefile (bug-strtod2): Link libm too.

	* stdlib/stdlib.h (strtof128): New declaration.
	(strtof128_l): Likewise.

	* stdlib/tst-strtod-nan-locale-main.c: Updated to use
	tst-strtod.h macros to ensure float128 gets tested too.

	* stdlib/tst-strtod-round-skeleton.c (CHOOSE_f128): New macro.

	* stdlib/tst-strtod.h: Include bits/floatn.h for _Float128
	tests.
	(IF_FLOAT128): New macro.
	(GEN_TEST_STRTOD): Update to optionally include _Float128 in
	the tests.
	(STRTOD_TEST_FOREACH): Likewise.

	* sysdeps/ieee754/float128/Makefile: Insert new strtof128 and
	wcstof128 functions into libc.

	* sysdeps/ieee754/float128/Versions: Add exports for the above
	new functions.

	* sysdeps/ieee754/float128/mpn2float128.c: New file.
	* sysdeps/ieee754/float128/strtod_nan_float128.h: New file.
	* sysdeps/ieee754/float128/strtof128.c: New file.
	* sysdeps/ieee754/float128/strtof128_l.c: New file.
	* sysdeps/ieee754/float128/strtof128_nan.c: New file.
	* sysdeps/ieee754/float128/wcstof128.c: New file.
	* sysdeps/ieee754/float128/wcstof128_l.c: New file.
	* sysdeps/ieee754/float128/wcstof128_nan.c: New fike.
	* wcsmbs/Makefile: (CFLAGS-wcstof128.c): Append strtox-CFLAGS.
	(CFLAGS-wcstof128_l): Likewise.

	* wcsmbs/wchar.h: Include bits/floatn.h for _Float128 tests.
	(wcstof128): New declaration.
	(wcstof128_l): Likewise.
2017-06-12 14:48:53 -03:00
Wilco Dijkstra 18b10de7ce 2017-06-12 Wilco Dijkstra <wdijkstr@arm.com>
There is no longer a need for string2.h, so remove it and all mention of it.
Move the redirect for __stpcpy to include/string.h since it is still required
until all internal uses have been renamed.
This fixes several linknamespace/localplt failures when building with -Os.

	[BZ #15105]
	[BZ #19463]
	* include/string.h: Add internal redirect for __stpcpy.
	* string/Makefile: Remove bits/string2.h.
	* string/string.h: Update comment.
	* string/string-inlines.c: Remove bits/string2.h include and comment.
	* string/bits/string2.h: Remove file.
2017-06-12 15:22:17 +01:00
Tulio Magno Quites Machado Filho d6bd839b9a Add a way to bypass the PLT when calling getauxval
* include/sys/auxv.h (__getauxval): Add a prototype and its
	libc_hidden_proto.
	* misc/getauxval.c (__getauxval): Use libc_hidden_def.
2017-06-09 14:36:22 -03:00
Zack Weinberg b4971123e9 Remove bare use of __attribute__ in include/errno.h.
This is just a style fix; we always prefer the shorthand macros over
bare uses of __attribute__, even in private headers.

	* include/errno.h (__errno_location): Use __attribute_const__
	instead of bare __attribute__.
2017-06-09 09:37:55 -04:00
Zack Weinberg 199fc19d3a Remove __need macros from stdio.h and wchar.h.
wint_t is a little finicky because it might be defined by stddef.h, which
belongs to the compiler.

In addition to the _types_, a bunch of other declarations shared between
wctype.h and wchar.h are factored out to their own header.

	* libio/bits/types/FILE.h, libio/bits/types/__FILE.h
	* wcsmbs/bits/types/mbstate_t.h, wcsmbs/bits/types/__mbstate_t.h
	* wcsmbs/bits/types/wint_t.h: New single-type definition files.
	* wctype/bits/wctype-wchar.h: New file holding declarations shared
	between wctype.h and wchar.h.

	* libio/Makefile, wcsmbs/Makefile, wctype/Makefile:
	Install them.

	* include/bits/types/FILE.h, include/bits/types/__FILE.h
	* include/bits/types/mbstate_t.h, include/bits/types/__mbstate_t.h
	* include/bits/types/wint_t.h, include/bits/wcsmbs-wchar.h:
	New wrappers.
	* include/stdio.h, include/wchar.h, include/wctype.h:
	No need to handle __need macros.

	* grp/grp.h, gshadow/gshadow.h, hurd/hurd.h, iconv/gconv.h
	* libio/stdio.h, mach/mach.h, misc/mntent.h, pwd/pwd.h
	* shadow/shadow.h, stdio-common/printf.h, wcsmbs/uchar.h
	* wcsmbs/wchar.h, wctype/wctype.h
	* sysdeps/generic/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h
	Use the new files instead of __need macros.
2017-06-08 13:58:17 -04:00
Gabriel F. T. Gomes 32bf1d09da float128: Add conversion from float128 to mpn
Reuse the code for __mpn_extract_long_double to implement
__mpn_extract_float128.

	* include/gmp.h: Include bits/floatn.h
	(__mpn_extract_float128): Declare when __HAVE_DISTINCT_FLOAT128 is 1.
	* stdlib/gmp-impl.h: Also check if alloca is not defined before
	including stack-alloc.h.  It could have been defined by other header
	which not necessarily defines HAVE_ALLOCA.
	* sysdeps/ieee754/float128/Makefile: New file.
	* sysdeps/ieee754/float128/float1282mpn.c: New file.
	* sysdeps/ieee754/float128/float128_private.h: Include gmp.h before
	redefining __mpn_extract_long_double to __mpn_extract_float128, then
	redefine __mpn_extract_long_double to __mpn_extract_float128.
	* sysdeps/ieee754/ldbl-128/ldbl2mpn.c: Replace long double with
	_Float128 to allow float128_private.h overrides.
2017-06-07 17:03:43 -03:00
Joseph Myers 81df4d253d Fix include paths in include/bits/types/*.h.
Various include/bits/types/*.h files do

where the path specified is relative to the toplevel glibc source
directory.

That has the wrong number of ../ components to achieve the desired
effect; it actually searches relative to include/ for a file that does
not exist there, then goes on to search the #include <> paths
specified with -I, eventually finding the desired file via such a path
(e.g. sysdeps/nptl/) with the right number of directory components.
Before that it searches include/../.. because of the -Iinclude,
meaning that an appropriately named file outside the glibc source tree
can affect the build.

This patch changes all those files to do #include <path> without the
../../, as some such files already do.

Tested for x86_64.

	* include/bits/types/clock_t.h: Use #include <path> instead of
	#include "../../path".
	* include/bits/types/clockid_t.h: Likewise.
	* include/bits/types/struct_iovec.h: Likewise.
	* include/bits/types/struct_itimerspec.h: Likewise.
	* include/bits/types/struct_osockaddr.h: Likewise.
	* include/bits/types/struct_sigstack.h: Likewise.
	* include/bits/types/struct_timespec.h: Likewise.
	* include/bits/types/struct_timeval.h: Likewise.
	* include/bits/types/struct_tm.h: Likewise.
	* include/bits/types/time_t.h: Likewise.
	* include/bits/types/timer_t.h: Likewise.
2017-06-07 17:59:50 +00:00
Stefan Liebler 12d2dd7060 Optimize generic spinlock code and use C11 like atomic macros.
This patch optimizes the generic spinlock code.

The type pthread_spinlock_t is a typedef to volatile int on all archs.
Passing a volatile pointer to the atomic macros which are not mapped to the
C11 atomic builtins can lead to extra stores and loads to stack if such
a macro creates a temporary variable by using "__typeof (*(mem)) tmp;".
Thus, those macros which are used by spinlock code - atomic_exchange_acquire,
atomic_load_relaxed, atomic_compare_exchange_weak - have to be adjusted.
According to the comment from  Szabolcs Nagy, the type of a cast expression is
unqualified (see http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_423.htm):
__typeof ((__typeof (*(mem)) *(mem)) tmp;
Thus from spinlock perspective the variable tmp is of type int instead of
type volatile int.  This patch adjusts those macros in include/atomic.h.
With this construct GCC >= 5 omits the extra stores and loads.

The atomic macros are replaced by the C11 like atomic macros and thus
the code is aligned to it.  The pthread_spin_unlock implementation is now
using release memory order instead of sequentially consistent memory order.
The issue with passed volatile int pointers applies to the C11 like atomic
macros as well as the ones used before.

I've added a glibc_likely hint to the first atomic exchange in
pthread_spin_lock in order to return immediately to the caller if the lock is
free.  Without the hint, there is an additional jump if the lock is free.

I've added the atomic_spin_nop macro within the loop of plain reads.
The plain reads are also realized by C11 like atomic_load_relaxed macro.

The new define ATOMIC_EXCHANGE_USES_CAS determines if the first try to acquire
the spinlock in pthread_spin_lock or pthread_spin_trylock is an exchange
or a CAS.  This is defined in atomic-machine.h for all architectures.

The define SPIN_LOCK_READS_BETWEEN_CMPXCHG is now removed.
There is no technical reason for throwing in a CAS every now and then,
and so far we have no evidence that it can improve performance.
If that would be the case, we have to adjust other spin-waiting loops
elsewhere, too!  Using a CAS loop without plain reads is not a good idea
on many targets and wasn't used by one.  Thus there is now no option to
do so.

Architectures are now using the generic spinlock automatically if they
do not provide an own implementation.  Thus the pthread_spin_lock.c files
in sysdeps folder are deleted.

ChangeLog:

	* NEWS: Mention new spinlock implementation.
	* include/atomic.h:
	(__atomic_val_bysize): Cast type to omit volatile qualifier.
	(atomic_exchange_acq): Likewise.
	(atomic_load_relaxed): Likewise.
	(ATOMIC_EXCHANGE_USES_CAS): Check definition.
	* nptl/pthread_spin_init.c (pthread_spin_init):
	Use atomic_store_relaxed.
	* nptl/pthread_spin_lock.c (pthread_spin_lock):
	Use C11-like atomic macros.
	* nptl/pthread_spin_trylock.c (pthread_spin_trylock):
	Likewise.
	* nptl/pthread_spin_unlock.c (pthread_spin_unlock):
	Use atomic_store_release.
	* sysdeps/aarch64/nptl/pthread_spin_lock.c: Delete File.
	* sysdeps/arm/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/hppa/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/m68k/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/microblaze/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/mips/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/nios2/nptl/pthread_spin_lock.c: Likewise.
	* sysdeps/aarch64/atomic-machine.h (ATOMIC_EXCHANGE_USES_CAS): Define.
	* sysdeps/alpha/atomic-machine.h: Likewise.
	* sysdeps/arm/atomic-machine.h: Likewise.
	* sysdeps/i386/atomic-machine.h: Likewise.
	* sysdeps/ia64/atomic-machine.h: Likewise.
	* sysdeps/m68k/coldfire/atomic-machine.h: Likewise.
	* sysdeps/m68k/m680x0/m68020/atomic-machine.h: Likewise.
	* sysdeps/microblaze/atomic-machine.h: Likewise.
	* sysdeps/mips/atomic-machine.h: Likewise.
	* sysdeps/powerpc/powerpc32/atomic-machine.h: Likewise.
	* sysdeps/powerpc/powerpc64/atomic-machine.h: Likewise.
	* sysdeps/s390/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc32/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc32/sparcv9/atomic-machine.h: Likewise.
	* sysdeps/sparc/sparc64/atomic-machine.h: Likewise.
	* sysdeps/tile/tilegx/atomic-machine.h: Likewise.
	* sysdeps/tile/tilepro/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/atomic-machine.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/atomic-machine.h: Likewise.
	* sysdeps/x86_64/atomic-machine.h: Likewise.
2017-06-06 09:41:56 +02:00
H.J. Lu ef9c4cb6c7 x86-64: Optimize wmemset with SSE2/AVX2/AVX512
The difference between memset and wmemset is byte vs int.  Add stubs
to SSE2/AVX2/AVX512 memset for wmemset with updated constant and size:

SSE2 wmemset:
	shl    $0x2,%rdx
	movd   %esi,%xmm0
	mov    %rdi,%rax
	pshufd $0x0,%xmm0,%xmm0
	jmp	entry_from_wmemset

SSE2 memset:
	movd   %esi,%xmm0
	mov    %rdi,%rax
	punpcklbw %xmm0,%xmm0
	punpcklwd %xmm0,%xmm0
	pshufd $0x0,%xmm0,%xmm0
entry_from_wmemset:

Since the ERMS versions of wmemset requires "rep stosl" instead of
"rep stosb", only the vector store stubs of SSE2/AVX2/AVX512 wmemset
are added.  The SSE2 wmemset is about 3X faster and the AVX2 wmemset
is about 6X faster on Haswell.

	* include/wchar.h (__wmemset_chk): New.
	* sysdeps/x86_64/memset.S (VDUP_TO_VEC0_AND_SET_RETURN): Renamed
	to MEMSET_VDUP_TO_VEC0_AND_SET_RETURN.
	(WMEMSET_VDUP_TO_VEC0_AND_SET_RETURN): New.
	(WMEMSET_CHK_SYMBOL): Likewise.
	(WMEMSET_SYMBOL): Likewise.
	(__wmemset): Add hidden definition.
	(wmemset): Add weak hidden definition.
	* sysdeps/x86_64/multiarch/Makefile (sysdep_routines): Add
	wmemset_chk-nonshared.
	* sysdeps/x86_64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add __wmemset_sse2_unaligned,
	__wmemset_avx2_unaligned, __wmemset_avx512_unaligned,
	__wmemset_chk_sse2_unaligned, __wmemset_chk_avx2_unaligned
	and __wmemset_chk_avx512_unaligned.
	* sysdeps/x86_64/multiarch/memset-avx2-unaligned-erms.S
	(VDUP_TO_VEC0_AND_SET_RETURN): Renamed to ...
	(MEMSET_VDUP_TO_VEC0_AND_SET_RETURN): This.
	(WMEMSET_VDUP_TO_VEC0_AND_SET_RETURN): New.
	(WMEMSET_SYMBOL): Likewise.
	* sysdeps/x86_64/multiarch/memset-avx512-unaligned-erms.S
	(VDUP_TO_VEC0_AND_SET_RETURN): Renamed to ...
	(MEMSET_VDUP_TO_VEC0_AND_SET_RETURN): This.
	(WMEMSET_VDUP_TO_VEC0_AND_SET_RETURN): New.
	(WMEMSET_SYMBOL): Likewise.
	* sysdeps/x86_64/multiarch/memset-vec-unaligned-erms.S: Updated.
	(WMEMSET_CHK_SYMBOL): New.
	(WMEMSET_CHK_SYMBOL (__wmemset_chk, unaligned)): Likewise.
	(WMEMSET_SYMBOL (__wmemset, unaligned)): Likewise.
	* sysdeps/x86_64/multiarch/memset.S (WMEMSET_SYMBOL): New.
	(libc_hidden_builtin_def): Also define __GI_wmemset and
	__GI___wmemset.
	(weak_alias): New.
	* sysdeps/x86_64/multiarch/wmemset.c: New file.
	* sysdeps/x86_64/multiarch/wmemset.h: Likewise.
	* sysdeps/x86_64/multiarch/wmemset_chk-nonshared.S: Likewise.
	* sysdeps/x86_64/multiarch/wmemset_chk.c: Likewise.
	* sysdeps/x86_64/wmemset.c: Likewise.
	* sysdeps/x86_64/wmemset_chk.c: Likewise.
2017-06-05 11:09:59 -07:00
Joseph Myers 7553131847 Fix struct sigaltstack namespace (bug 21517).
glibc defines the stack_t type with the tag struct sigaltstack.  This
is not permitted by POSIX; sigaltstack is only reserved with file
scope in the namespace of ordinary identifiers, not the tag namespace,
and in the case where stack_t is obtained from ucontext.h rather than
signal.h, it's not reserved with file scope at all.

This patch removes the tag accordingly and updates uses in glibc of
struct sigaltstack.  This is similar to the removal of the "struct
siginfo" tag a few years ago: C++ name mangling changes are an
unavoidable consequence.  A NEWS item is added to note the changed
mangling.  There is inevitably some risk of breaking builds of
anything that relies on the struct sigaltstack name (though the first
few hits I looked at from codesearch.debian.net generally seemed to
involve code that could use the stack_t name conditionally, so
depending on how they determine the conditionals they may work with
glibc not defining the struct tag anyway).

Tested for x86_64 and x86, and with build-many-glibcs.py.

	[BZ #21517]
	* bits/types/stack_t.h (stack_t): Remove struct tag.
	* sysdeps/unix/sysv/linux/bits/types/stack_t.h (stack_t):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h (stack_t):
	Likewise.
	* debug/segfault.c (install_handler): Use stack_t instead of
	struct sigaltstack.
	* hurd/hurd/signal.h (struct hurd_sigstate): Likewise.
	* hurd/trampoline.c (_hurd_setup_sighandler): Likewise.
	* include/signal.h (__sigaltstack): Likwise.
	* signal/sigaltstack.c (__sigaltstack): Likewise.
	* signal/signal.h (sigaltstack): Likewise.
	* sysdeps/mach/hurd/i386/signal-defines.sym
	(SIGALTSTACK__SS_SP__OFFSET): Likewise.
	(SIGALTSTACK__SS_SIZE__OFFSET): Likewise.
	(SIGALTSTACK__SS_FLAGS__OFFSET): Likewise.
	* sysdeps/mach/hurd/sigaltstack.c (__sigaltstack): Likewise.
	* sysdeps/mach/hurd/sigstack.c (sigstack): Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/procfs.h (struct
	elf_prstatus): Likewise.
	* sysdeps/unix/sysv/linux/hppa/____longjmp_chk.c (CHECK_SP):
	Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/procfs.h (struct elf_prstatus):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/____longjmp_chk.c (CHECK_SP):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/procfs.h (struct
	elf_prstatus): Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/procfs.h (struct elf_prstatus):
	Likewise.
	* sysdeps/unix/sysv/linux/sys/procfs.h (struct elf_prstatus):
	Likewise.
2017-06-05 10:17:46 +00:00
Adhemerval Zanella 52bd938169 posix: Implement preadv2 and pwritev2
This patch adds support of preadv2 and pwritev2 which are similar to
preadv/pwritev but with an extra flag argument.  As for preadv/pwritev
both interfaces are added a non-standard GNU API.

For default 'posix' implementation trying to emulate the Linux supported
flags is troublesome:

   * We can not temporary change the file state of the O_DSYNC and O_SYNC
     flags to emulate RWF_{D}SYNC (attempts to change the state of using
     fcntl are silently ignored).

   * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
     semantic not provided by any other flag (O_NONBLOCK for instance).

So default sysdeps/posix implementations fails with EOPNOTSUPP for any non
supported flag (which are none currently) calls generic preadv/pwritev.
Basically this implementation supports only preadv2 called as preadv (with
flags sets to 0).

The Linux one uses the preadv2/pwritev2 syscall if defined, otherwise it
call preadv/writev.  Instead of using the previous __ASSUME_* to
unconditionally issue the syscall (and avoid building the fallback routine),
it call pread/write if the preadv2/pwritev2 syscalls fails.  The idea
is just avoid adding another __ASSUME_* and checking each architecture
on every kernel bump and simplify code conditionals.

Checked on x86_64-linux-gnu and on i686-linux-gnu and a check with
run-built-tests=no on aarch64-linux-gnu, alpha-linux-gnu, arm-linux-gnueabihf,
ia64-linux-gnu, m68k-linux-gnu, microblaze-linux-gnu, mips{64,64n32}-linux-gnu,
nios2-linux-gnu, powerpc{64,64le}-linux-gnu, s390{x}-linux-gnu,
sparc{64,v9}-linux-gnu, tile{gx,pro}-linux-gnu, and sh4-linux-gnu (all using
gcc 6.3).

	* NEWS: Add note about pwritev2 and preadv2 inclusion.
	* misc/Makefile (routines): Add preadv2, preadv64v2, pwritev2, and
	pwritev64v2.
	(tests): Add tst-preadvwritev2 and tst-preadvwritev64v2.
	* misc/Versions (GLIBC_2.26): Add preadv2, preadv64v2, pwritev2, and
	pwritev64v2.
	* misc/preadv2.c: New file.
	* misc/preadv64v2.c: Likewise.
	* misc/pwritev2.c: Likewise.
	* misc/pwritev64v2.c: Likewise.
	* misc/tst-preadvwritev2.c: Likewise.
	* misc/tst-preadvwritev64v2.c: Likewise.
	* manual/llio.texi: Add preadv2 and pwritev2 documentation.
	* misc/sys/uio.h [__USE_GNU && !__USE_FILE_OFFSET64] (preadv2): New
	prototype.
	[__USE_GNU && !__USE_FILE_OFFSET64] (pwritev2):	Likewise.
	[__USE_GNU && __USE_FILE_OFFSET64] (preadv64v2): Likewise.
	[__USE_GNU && __USE_FILE_OFFSET64] (pwritev64v2): Likewise.
	* misc/tst-preadvwritev-common.c (PREADV): Define if not defined.
	(PWRITEV): Likewise.
	(do_test_with_offset): Use PREADV and PWRITEV macros and check for
	ENOSYS.
	* nptl/tst-cancel4.c (tf_pwritev2): New test.
	(tf_preadv2): Likewise.
	(tf_fsync): Add tf_pwritev2 and tf_preadv2.
	* sysdeps/posix/preadv2.c: Likewise.
	* sysdeps/posix/preadv64v2.c: Likewise.
	* sysdeps/posix/pwritev2.c: Likewise.
	* sysdeps/posix/pwritev64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/kernel-features.h: Add comment for syscall
	support in kernel.
	* sysdeps/unix/sysv/linux/preadv2.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev2.c: Likewise.
	* sysdeps/unix/sysv/linux/pwritev64v2.c: Likewise.
	* sysdeps/unix/sysv/linux/preadv.c (preadv): Add libc_hidden_def.
	* sysdeps/unix/sysv/linux/preadv64.c (preadv64): Likewise.
	* sysdeps/unix/sysv/linux/pwritev.c (pwritev): Likewise.
	* sysdeps/unix/sysv/linux/pwritev64.c (pwritev64): Likewise.
	* sysdeps/unix/sysv/linux/bits/uio.h: Add supported preadv2/pwritev2
	support flags on Linux.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist (GLIBC_2.26): Add
	preadv2, preadv64v2, pwritev2, pwritev64v2.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
	(GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist (GLIBC_2.26): Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/sysv/linux/tile/tilegx/tilegx32/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/sysv/linux/tile/tilegx/tilegx64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist (GLIBC_2.26):
	Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist (GLIBC_2.26):
	Likewise.
2017-05-31 17:35:46 -03:00
Dennis Wölfing 2e0bbbfbf9 Add reallocarray function
The reallocarray function is an extension from OpenBSD.  It is an
integer-overflow-safe replacement for realloc(p, X*Y) and
malloc(X*Y) (realloc(NULL, X*Y)).  It can therefore help in preventing
certain security issues in code.

This is an updated version of a patch originally submitted by Rüdiger
Sonderfeld in May 2014 [1].

Checked on i686-linux-gnu and x86_64-linux-gnu.

[1] <https://sourceware.org/ml/libc-alpha/2014-05/msg00481.html>.

2017-05-30  Dennis Wölfing  <denniswoelfing@gmx.de>
            Rüdiger Sonderfeld  <ruediger@c-plusplus.de>

	* include/stdlib.h (__libc_reallocarray): New declaration.
	* malloc/Makefile (routines): Add reallocarray.
	(tests): Add tst-reallocarray.c.
	* malloc/Versions: Add reallocarray and __libc_reallocarray.
	* malloc/malloc-internal.h (check_mul_overflow_size_t): New inline
	function.
	* malloc/malloc.h (reallocarray): New declaration.
	* stdlib/stdlib.h (reallocarray): Likewise.
	* malloc/reallocarray.c: New file.
	* malloc/tst-reallocarray.c: New test file.
	* manual/memory.texi: Document reallocarray.
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add reallocarray.
	* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/tilepro/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
2017-05-30 18:27:57 -03:00
Zack Weinberg a992f506ff Remove __need macros from signal.h.
The types affected are __sig_atomic_t, sig_atomic_t, __sigset_t,
sigset_t, sigval_t, sigevent_t, and siginfo_t. __sig_atomic_t is a
scalar, so it's now directly available from bits/types.h.  The others
get bits/types/ headers.

Side effects include: There have been small changes to which
non-signal headers expose which subset of the signal-related types.
A couple of architectures' nested siginfo_t fields had to be renamed
to prevent undesired macro expansion.  Internal code that wants to
manipulate signal masks must now include <sigsetops.h> (which is not
installed) and should be aware that __sigaddset, __sigandset,
__sigdelset, __sigemptyset, and __sigorset no longer return a value
(unlike the public API).  Relatedly, the public signal.h no longer
declares any of those functions.  The obsolete sigmask() macro no
longer has a system-specific definition -- in the cases where it
matters, it didn't work anyway.

New Linux architectures should create bits/siginfo-arch.h and/or
bits/siginfo-consts-arch.h to customize their siginfo_t, rather than
duplicating everything in bits/siginfo.h (which no longer exists).
Add new __SI_* macros if necessary.  Ports to other operating systems
are strongly encouraged to generalize this scheme further.

	* bits/sigevent-consts.h
	* bits/siginfo-consts.h
	* bits/types/__sigset_t.h
	* bits/types/sigevent_t.h
	* bits/types/siginfo_t.h
	* sysdeps/unix/sysv/linux/bits/sigevent-consts.h
	* sysdeps/unix/sysv/linux/bits/siginfo-consts.h
	* sysdeps/unix/sysv/linux/bits/types/__sigset_t.h
	* sysdeps/unix/sysv/linux/bits/types/sigevent_t.h
	* sysdeps/unix/sysv/linux/bits/types/siginfo_t.h:
	New system-dependent bits headers.

	* sysdeps/unix/sysv/linux/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/bits/siginfo-consts-arch.h
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo-consts-arch.h
	* sysdeps/unix/sysv/linux/mips/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/sparc/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/tile/bits/siginfo-arch.h
	* sysdeps/unix/sysv/linux/tile/bits/siginfo-consts-arch.h
	* sysdeps/unix/sysv/linux/x86/bits/siginfo-arch.h:
	New Linux-only system-dependent bits headers.

	* signal/bits/types/sig_atomic_t.h
	* signal/bits/types/sigset_t.h
	* signal/bits/types/sigval_t.h:
	New non-system-dependent bits headers.

	* sysdeps/generic/sigsetops.h
	* sysdeps/unix/sysv/linux/sigsetops.h:
	New internal headers.

	* include/bits/types/sig_atomic_t.h
	* include/bits/types/sigset_t.h
	* include/bits/types/sigval_t.h:
	New wrappers.

	* signal/sigsetops.h
	* bits/siginfo.h
	* bits/sigset.h
	* sysdeps/unix/sysv/linux/bits/siginfo.h
	* sysdeps/unix/sysv/linux/bits/sigset.h
	* sysdeps/unix/sysv/linux/ia64/bits/siginfo.h
	* sysdeps/unix/sysv/linux/mips/bits/siginfo.h
	* sysdeps/unix/sysv/linux/s390/bits/siginfo.h
	* sysdeps/unix/sysv/linux/sparc/bits/siginfo.h
	* sysdeps/unix/sysv/linux/tile/bits/siginfo.h
	* sysdeps/unix/sysv/linux/x86/bits/siginfo.h:
	Deleted.

	* signal/Makefile, sysdeps/unix/sysv/linux/Makefile:
	Update lists of installed headers.

	* posix/bits/types.h: Define __sig_atomic_t here.
	* signal/signal.h: Use the new bits headers; no need to handle
	__need_sig_atomic_t nor __need_sigset_t.  Don't use __sigmask
	to define sigmask.
	* include/signal.h: No need to handle __need_sig_atomic_t
	nor __need_sigset_t.  Don't define __sigemptyset.

	* io/sys/poll.h, setjmp/setjmp.h
	* sysdeps/arm/sys/ucontext.h, sysdeps/generic/sys/ucontext.h
	* sysdeps/i386/sys/ucontext.h, sysdeps/m68k/sys/ucontext.h
	* sysdeps/mach/hurd/i386/bits/sigcontext.h
	* sysdeps/mips/sys/ucontext.h, sysdeps/powerpc/novmxsetjmp.h
	* sysdeps/pthread/bits/sigthread.h
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h:
	Use bits/types/__sigset_t.h.

	* misc/sys/select.h, posix/spawn.h
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h
	* sysdeps/unix/sysv/linux/sys/epoll.h
	* sysdeps/unix/sysv/linux/sys/signalfd.h:
	Use bits/types/sigset_t.h.

	* resolv/netdb.h, rt/mqueue.h: Use bits/types/sigevent_t.h.
	* rt/aio.h: Use bits/types/sigevent_t.h and bits/sigevent-consts.h.
	* socket/sys/socket.h: Don't include bits/sigset.h.

	* login/utmp_file.c, shadow/lckpwdf.c, signal/sigandset.c
	* signal/sigisempty.c, stdlib/abort.c, sysdeps/posix/profil.c
	* sysdeps/posix/sigignore.c, sysdeps/posix/sigintr.c
	* sysdeps/posix/signal.c, sysdeps/posix/sigset.c
	* sysdeps/posix/sprofil.c, sysdeps/posix/sysv_signal.c
	* sysdeps/unix/sysv/linux/nptl-signals.h:
	Include sigsetops.h.

	* signal/sigaddset.c, signal/sigandset.c, signal/sigdelset.c
	* signal/sigorset.c, stdlib/abort.c, sysdeps/posix/sigignore.c
	* sysdeps/posix/signal.c, sysdeps/posix/sigset.c:
	__sigaddset, __sigandset, __sigdelset, __sigemptyset, __sigorset
	now return no value.

	* signal/sigaddset.c, signal/sigdelset.c, signal/sigismem.c
	Include <errno.h>, <signal.h>, and <sigsetops.h> instead of
	"sigsetops.h".

	* signal/sigsetops.c: Explicitly define __sigismember,
	__sigaddset, and __sigdelset as compatibility symbols.

	* signal/Versions: Correct commentary on __sigpause,
	__sigaddset, __sigdelset, __sigismember.

	* inet/rcmd.c: Include sigsetops.h.  Convert old code using
	__sigblock/__sigsetmask to use __sigprocmask and friends.
2017-05-20 19:04:43 -04:00
Zack Weinberg 500b3a499f Remove __need_list_t and __need_res_state.
These __need macros are only used internally, by nptl/descr.h.
However, including all of resolv.h from descr.h causes build failures
due to resolv.h's dozens of pseudo-struct-field macros, some of which
collide with struct fields in NPTL internal data structures.
Similarly, including all of list.h from descr.h produces an include
cycle, atomic.h -> atomic-machine.h -> tls.h -> descr.h -> list.h ->
atomic.h, and then list.h tries to use atomic.h macros that haven't
been defined yet.  So we do need mini-headers for these.  In the
list.h case I called it include/list_t.h since it isn't going to be
installed.

	* resolv/resolv.h: Remove __need_res_state logic.
	Move definition of res_state and related constants to ...
	* resolv/bits/types/res_state.h: ...this new file.
	* resolv/Makefile: Install bits/types/res_state.h.
	* include/bits/types/res_state.h: New wrapper.
	* include/list.h: Remove __need_list_t logic.
	Move definition of list_t to ...
	* include/list_t.h: ...this new file.

	* nptl/descr.h: Include list_t.h and bits/types/res_state.h
	instead of list.h and resolv.h.
2017-05-20 19:01:46 -04:00
Joseph Myers 0bcec5321f Split up bits/sigstack.h.
bits/sigstack.h contains four things: the legacy struct sigstack type,
the preferred stack_t type, the SS_* enum values and macros for signal
stack sizes.

These vary in different ways between glibc configurations; in
particular, the stack sizes vary much more than any of the other
pieces.  Furthermore, these pieces have different standard namespace
rules for when they should be visible (not currently visible in
conform/ results both because the relevant tests are XFAILed for
sys/ucontext.h namespace issues, and because some of the expectations
are incorrect in the same way as the headers, e.g. neither
expectations nor headers reflect that current POSIX no longer has
either the sigstack function or the sigstack structure).

To reduce duplication of identical definitions, and facilitate
namespace fixes without requiring the same feature test macro
conditions to be repeated in many versions of the same header, this
patch splits bits/sigstack.h up into four headers.  It keeps the stack
size macros, while new bits/types/struct_sigstack.h,
bits/types/stack_t.h and bits/ss_flags.h are added for the other
pieces.  bits/types/struct_sigstack.h is the same everywhere,
bits/types/stack_t.h has three variants different in the order of the
structure elements (generic = MIPS Linux, and other Linux), and
bits/ss_flags.h has generic and Linux variants.

This patch includes the new headers everywhere that included
<bits/sigstack.h>, so should cause no difference to what any public
header defines.  Subsequent namespace fixes would then remove or
condition some of those includes.

There should be no conflicts with Zack's changes to signal.h types,
beyond the trivial conflict of both making additions to
signal/Makefile's headers list; the two patches affect disjoint sets
of types and other definitions.

Tested for x86_64 and x86, and with build-many-glibcs.py.

	* bits/ss_flags.h: New file.
	* bits/types/stack_t.h: Likewise.
	* include/bits/types/struct_sigstack.h: Likewise.
	* signal/bits/types/struct_sigstack.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/ss_flags.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/types/stack_t.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/types/stack_t.h: Likewise.
	* signal/Makefile (headers): Add bits/types/struct_sigstack.h,
	bits/types/stack_t.h and bits/ss_flags.h.
	* signal/signal.h [__USE_XOPEN_EXTENDED || __USE_XOPEN2K8]:
	Include <bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
	<bits/ss_flags.h>.
	* bits/sigstack.h (struct sigstack): Remove.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/aarch64/bits/sigstack.h
	(struct sigstack): Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/sigstack.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/sigstack.h
	(struct sigstack): Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/sigstack.h (struct sigstack):
	Likewise.
	(stack_t): Likewise.
	(SS_ONSTACK): Likewise.
	(SS_DISABLE): Likewise.
	* sysdeps/arm/sys/ucontext.h: Include
	<bits/types/struct_sigstack.h>, <bits/types/stack_t.h> and
	<bits/ss_flags.h>.
	* sysdeps/generic/sys/ucontext.h: Likewise.
	* sysdeps/i386/sys/ucontext.h: Likewise.
	* sysdeps/m68k/sys/ucontext.h: Likewise.
	* sysdeps/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/arm/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/hppa/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/bits/sigcontext.h: Likewise.
	* sysdeps/unix/sysv/linux/ia64/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/m68k/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/nios2/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/s390/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/sh/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/tile/sys/ucontext.h: Likewise.
	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h: Likewise.
2017-05-19 20:35:07 +00:00
Paul E. Murphy 81f26b53b5 float128: Add private _Float128 declarations for libm.
Add the necessary bits to the private headers to support
building the _Float128 libm functions.

A local override for float.h is provided to include the
missing *FLT128 macros implied by TS 18661-3 for this
type when compiling prior to GCC 7.

	* include/complex.h (__kernel_casinhf128): New declaration.
	* include/float.h: New file.
	* include/math.h (__finitef128): Add a hidden def.
	(__isinff128): Likewise.
	(__isnanf128): Likewise.
	(__fpclassify): Likewise.
	(__issignalling): Likewise.
	(__expf128): Likewise.
	(__expm1f128): Likewise.

	* sysdeps/generic/fix-fp-int-convert-overflow.h:
	(FIX_FLT128_LONG_CONVERT_OVERFLOW): New macro.
	(FIX_FLT128_LLONG_CONVERT_OVERFLOW): Likewise.

	* sysdeps/generic/math-type-macros-float128.h: New file.

	* sysdeps/generic/math_private.h: Include bits/floatn.h and
	math_private_calls.h for _Float128.
	(__isinff128): New inline implementation used when GCC < 7.0,
	since in this case __builtin_isinf_sign is broken.
	(fabsf128): New inline implementation that calls the builtin.
	(__EXPR_FLT128): New macro.
	(min_of_type): Optionally include _Float128 types too.

	* sysdeps/generic/math_private_calls.h (__kernel_sincos):
	Declare for _Float128.
	(__kernel_rem_pio2): Likewise.

	* sysdeps/ieee754/ldbl-opt/s_sin.c:
	(__DECL_SIMD_sincos_disablef128): New macro.
2017-05-15 10:23:28 -03:00
Zack Weinberg 7c3018f9e4 Suppress internal declarations for most of the testsuite.
This patch adds a new build module called 'testsuite'.
IS_IN (testsuite) implies _ISOMAC, as do IS_IN_build and __cplusplus
(which means several ad-hoc tests for __cplusplus can go away).
libc-symbols.h now suppresses almost all of *itself* when _ISOMAC is
defined; in particular, _ISOMAC mode does not get config.h
automatically anymore.

There are still quite a few tests that need to see internal gunk of
one variety or another.  For them, we now have 'tests-internal' and
'test-internal-extras'; files in this category will still be compiled
with MODULE_NAME=nonlib, and everything proceeds as it always has.
The bulk of this patch is moving tests from 'tests' to
'tests-internal'.  There is also 'tests-static-internal', which has
the same effect on files in 'tests-static', and 'modules-names-tests',
which has the *inverse* effect on files in 'modules-names' (it's
inverted because most of the things in modules-names are *not* tests).
For both of these, the file must appear in *both* the new variable and
the old one.

There is also now a special case for when libc-symbols.h is included
without MODULE_NAME being defined at all.  (This happens during the
creation of libc-modules.h, and also when preprocessing Versions
files.)  When this happens, IS_IN is set to be always false and
_ISOMAC is *not* defined, which was the status quo, but now it's
explicit.

The remaining changes to C source files in this patch seemed likely to
cause problems in the absence of the main change.  They should be
relatively self-explanatory.  In a few cases I duplicated a definition
from an internal header rather than move the test to tests-internal;
this was a judgement call each time and I'm happy to change those
however reviewers feel is more appropriate.

	* Makerules: New subdir configuration variables 'tests-internal'
	and 'test-internal-extras'.  Test files in these categories will
	still be compiled with MODULE_NAME=nonlib.  Test files in the
	existing categories (tests, xtests, test-srcs, test-extras) are
	now compiled with MODULE_NAME=testsuite.
	New subdir configuration variable 'modules-names-tests'.  Files
	which are in both 'modules-names' and 'modules-names-tests' will
	be compiled with MODULE_NAME=testsuite instead of
	MODULE_NAME=extramodules.
	(gen-as-const-headers): Move to tests-internal.
	(do-tests-clean, common-mostlyclean): Support tests-internal.
	* Makeconfig (built-modules): Add testsuite.
	* Makefile: Change libof-check-installed-headers-c and
	libof-check-installed-headers-cxx to 'testsuite'.
	* Rules: Likewise.  Support tests-internal.
	* benchtests/strcoll-inputs/filelist#en_US.UTF-8:
	Remove extra-modules.mk.

	* config.h.in: Don't check for __OPTIMIZE__ or __FAST_MATH__ here.
	* include/libc-symbols.h: Move definitions of _GNU_SOURCE,
	PASTE_NAME, PASTE_NAME1, IN_MODULE, IS_IN, and IS_IN_LIB to the
	very top of the file and rationalize their order.
	If MODULE_NAME is not defined at all, define IS_IN to always be
	false, and don't define _ISOMAC.
	If any of IS_IN (testsuite), IS_IN_build, or __cplusplus are
	true, define _ISOMAC and suppress everything else in this file,
	starting with the inclusion of config.h.
	Do check for inappropriate definitions of __OPTIMIZE__ and
	__FAST_MATH__ here, but only if _ISOMAC is not defined.
        Correct some out-of-date commentary.

	* include/math.h: If _ISOMAC is defined, undefine NO_LONG_DOUBLE
	and _Mlong_double_ before including math.h.
	* include/string.h: If _ISOMAC is defined, don't expose
	_STRING_ARCH_unaligned. Move a comment to a more appropriate
	location.

	* include/errno.h, include/stdio.h, include/stdlib.h, include/string.h
	* include/time.h, include/unistd.h, include/wchar.h: No need to
	check __cplusplus nor use __BEGIN_DECLS/__END_DECLS.

	* misc/sys/cdefs.h (__NTHNL): New macro.
	* sysdeps/m68k/m680x0/fpu/bits/mathinline.h
	(__m81_defun): Use __NTHNL to avoid errors with GCC 6.

	* elf/tst-env-setuid-tunables.c: Include config.h with _LIBC
	defined, for HAVE_TUNABLES.
	* inet/tst-checks-posix.c: No need to define _ISOMAC.
	* intl/tst-gettext2.c: Provide own definition of N_.
	* math/test-signgam-finite-c99.c: No need to define _ISOMAC.
	* math/test-signgam-main.c: No need to define _ISOMAC.
	* stdlib/tst-strtod.c: Convert to test-driver. Split locale_test to...
	* stdlib/tst-strtod1i.c: ...this new file.
	* stdlib/tst-strtod5.c: Convert to test-driver and add copyright notice.
        Split tests of __strtod_internal to...
	* stdlib/tst-strtod5i.c: ...this new file.
	* string/test-string.h: Include stdint.h. Duplicate definition of
	inhibit_loop_to_libcall here (from libc-symbols.h).
	* string/test-strstr.c: Provide dummy definition of
	libc_hidden_builtin_def when including strstr.c.
	* sysdeps/ia64/fpu/libm-symbols.h: Suppress entire file in _ISOMAC
	mode; no need to test __STRICT_ANSI__ nor __cplusplus as well.
	* sysdeps/x86_64/fpu/math-tests-arch.h: Include cpu-features.h.
	Don't include init-arch.h.
	* sysdeps/x86_64/multiarch/test-multiarch.h: Include cpu-features.h.
	Don't include init-arch.h.

	* elf/Makefile: Move tst-ptrguard1-static, tst-stackguard1-static,
	tst-tls1-static, tst-tls2-static, tst-tls3-static, loadtest,
	unload, unload2, circleload1, neededtest, neededtest2,
	neededtest3, neededtest4, tst-tls1, tst-tls2, tst-tls3,
	tst-tls6, tst-tls7, tst-tls8, tst-dlmopen2, tst-ptrguard1,
	tst-stackguard1, tst-_dl_addr_inside_object, and all of the
	ifunc tests to tests-internal.
	Don't add $(modules-names) to test-extras.
	* inet/Makefile: Move tst-inet6_scopeid_pton to tests-internal.
	Add tst-deadline to tests-static-internal.
	* malloc/Makefile: Move tst-mallocstate and tst-scratch_buffer to
	tests-internal.
	* misc/Makefile: Move tst-atomic and tst-atomic-long to tests-internal.
	* nptl/Makefile: Move tst-typesizes, tst-rwlock19, tst-sem11,
	tst-sem12, tst-sem13, tst-barrier5, tst-signal7, tst-tls3,
	tst-tls3-malloc, tst-tls5, tst-stackguard1, tst-sem11-static,
	tst-sem12-static, and tst-stackguard1-static to tests-internal.
        Link tests-internal with libpthread also.
	Don't add $(modules-names) to test-extras.
	* nss/Makefile: Move tst-field to tests-internal.
	* posix/Makefile: Move bug-regex5, bug-regex20, bug-regex33,
	tst-rfc3484, tst-rfc3484-2, and tst-rfc3484-3 to tests-internal.
	* stdlib/Makefile: Move tst-strtod1i, tst-strtod3, tst-strtod4,
	tst-strtod5i, tst-tls-atexit, and tst-tls-atexit-nodelete to
	tests-internal.
        * sunrpc/Makefile: Move tst-svc_register to tests-internal.
	* sysdeps/powerpc/Makefile: Move test-get_hwcap and
	test-get_hwcap-static to tests-internal.
	* sysdeps/unix/sysv/linux/Makefile: Move tst-setgetname to
	tests-internal.
	* sysdeps/x86_64/fpu/Makefile: Add all libmvec test modules to
	modules-names-tests.
2017-05-11 19:27:59 -04:00
Zack Weinberg 1711991592 Remove _IO_MTSAFE_IO from public headers.
_IO_MTSAFE_IO controls whether stdio is *built* with support for
multithreading.  In the distant past it might also have worked as a
feature selection macro, allowing library *users* to select
thread-safe or lock-free stdio at application build time, I haven't
done the archaeology.  Nowadays, defining _IO_MTSAFE_IO while using
the installed headers, or in _ISOMAC mode, will cause libio.h to throw
syntax errors.

This patch removes _IO_MTSAFE_IO from the public headers
(specifically, from libio/libio.h).  The most important thing it
controlled in there was whether libio.h defines _IO_lock_t itself or
expects stdio-lock.h to have done it, and we do still need a
inter-header communication macro for that, because stdio-lock.h can
only define _IO_lock_t as a typedef.  I've invented
_IO_lock_t_defined, which is defined by both versions of stdio-lock.h.

_IO_MTSAFE_IO also controlled the definitions of a handful of macros
that _might_ count as part of the public libio.h interface.  They are
now unconditionally given their non-_IO_MTSAFE_IO definition in
libio/libio.h, and include/libio.h redefines them with the
_IO_MTSAFE_IO definition.  This should minimize the odds of breaking
old software that actually uses those macros.

I suspect that this entire mechanism is vestigial, and that glibc
won't build anymore if you *don't* define _IO_MTSAFE_IO, but that's
another patchset.  The bulk of libio.h is internal-use-only stuff that
no longer makes sense to expose (libstdc++ gave up on making a FILE
the same object as a C++ filebuf *decades* ago) but that, too, is
another patchset.

	* libio/libio.h: Condition dummy definition of _IO_lock_t on
	_IO_lock_t_defined, not _IO_MTSAFE_IO. Unconditionally use the
	non-_IO_MTSAFE_IO definitions for _IO_peekc, _IO_flockfile,
	_IO_funlockfile, and _IO_ftrylockfile.  Only define
	_IO_cleanup_region_start and _IO_cleanup_region_end if not
	already defined.
	* include/libio.h: If _IO_MTSAFE_IO is defined, redefine
        _IO_peekc, _IO_flockfile, _IO_funlockfile, and _IO_ftrylockfile
        appropriately.
	* sysdeps/generic/stdio-lock.h, sysdeps/nptl/stdio-lock.h:
	Define _IO_lock_t_defined after defining _IO_lock_t.
2017-05-11 19:14:11 -04:00
Adhemerval Zanella dfaaee33ba Consolidate Linux write syscall
This patch consolidates the write Linux syscall implementation on
sysdeps/unix/sysv/linux/write.c.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	* include/unistd.h (write): Add hidden proto.
	* io/Makefile (CFLAGS-write.c): New rule.
	* nptl/Makefile (CFLAGS-write.c): Likewise.
	* sysdeps/unix/sysv/linux/write.c: New file.
2017-05-11 17:27:30 -03:00
Adhemerval Zanella f6a191a6ee Consolidate Linux read syscall
This patch consolidates the read Linux syscall implementation on
sysdeps/unix/sysv/linux/read.c.  This leads to a different frame
pointer creation on some architectures:

  * It fixes BZ#21428 on aarch64, since now the returned address
    for the read syscall can be correctly found out by
    backtrace_symbols.

  * It makes tst-backtrace{5,6} fails on powerpc due an issue on
    its custom backtrace implementation.  It is fixed on subsequent
    patch from this set.

Checked on i686-linux-gnu, x86_64-linux-gnu, x86_64-linux-gnux32,
arch64-linux-gnu, arm-linux-gnueabihf, and powerpc64le-linux-gnu.

	[BZ #21428]
	* include/unistd.h (read): Add hidden proto.
	* io/Makefile (CFLAGS-read.c): New rule.
	* nptl/Makefile (CFLAGS-read.c): New rule.
	* sysdeps/unix/sysv/linux/read.c: New file.
2017-05-11 17:27:30 -03:00
Paul E. Murphy 4fc12f0eda Add support for testing __STDC_WANT_IEC_60559_TYPES_EXT__
This macro is defined by TS 18661-3 for supporting the _FloatN and
_FloatNx types, as well as the functions suffixed with fN.

	* bits/libc-header-start.h:
	(__GLIBC_USE_IEC_60559_TYPES_EXT): New macro.
	* include/features.h: Describe __STDC_WANT_IEC_60559_TYPES_EXT__.
	* manual/creature.texi: Likewise.
2017-05-09 11:40:28 -03:00
Joseph Myers 176804300b Fix network headers stdint.h namespace (bug 21455).
conform/ namespace tests of arpa/inet.h, netdb.h and netinet/in.h fail
for UNIX98 and XPG42 because of inclusion of stdint.h, which defines
macros not permitted in those headers for those standards.  UNIX98
allows them to include inttypes.h, but (predating C99) has restricted
inttypes.h contents (not yet tested in the conform/ tests) not
including those macros; XPG4.2 has no such permission and no
inttypes.h / stdint.h at all.

This patch rearranges the headers to avoid this issue.  intN_t
definitions move to bits/stdint-intn.h, and uintN_t definitions to
bits/stdint-uintn.h.  (These are not bits/types/ headers because they
each define four types.  They are separate rather than just a single
header because sys/types.h defines intN_t but u_intN_t rather than
uintN_t - and while sys/types.h could define uintN_t because of the
POSIX reservation of *_t, existing practice there is largely to
condition types on appropriate feature test macros, and indeed there
is at least one open bug report (14553) about a type that's not
so-conditioned, so maybe types there should actually have conditions
added where appropriate.)  The affected network headers are then made
to include bits/stdint-uintn.h instead of stdint.h.  This allows six
XFAILs to be removed.

This doesn't do anything about inttypes.h defining more than it should
for UNIX98, but we don't have conformtest expectations for that case
at present (and my inclination is that a fix for that should be as
local as possible - affecting only inttypes.h, not stdint.h, only for
the case of __USE_UNIX98 && !__USE_ISOC99).

Tested for x86_64.

	[BZ #21455]
	* bits/stdint-intn.h: New file.
	* bits/stdint-uintn.h: Likewise.
	* stdlib/Makefile (headers): Add bits/stdint-intn.h and
	bits/stdint-uintn.h.
	* inet/netinet/in.h: Include <bits/stdint-uintn.h> instead of
	<stdint.h>.
	* posix/sys/types.h: Include <bits/stdint-intn.h>.
	(__int8_t_defined): Do not define here.
	(int8_t): Likewise.
	(int16_t): Likewise.
	(int32_t): Likewise.
	(int64_t): Likewise.
	[__GNUC_PREREQ (2, 7)] (__intN_t): Likewise.
	* resolv/netdb.h: Include <bits/stdint-uintn.h> instead of
	<stdint.h>.
	* include/netdb.h [_ISOMAC]: Do not include <stdint.h>.
	* sysdeps/generic/stdint.h: Include <bits/stdint-intn.h> and
	<bits/stdint-uintn.h>.
	(int8_t): Do not define here.
	(int16_t): Likewise.
	(int32_t): Likewise.
	(int64_t): Likewise.
	(uint8_t): Likewise.
	(uint16_t): Likewise.
	(uint32_t): Likewise.
	(uint64_t): Likewise.
	* conform/Makefile (test-xfail-XPG42/arpa/inet.h/conform): Remove
	variable.
	(test-xfail-XPG42/netdb.h/conform): Likewise.
	(test-xfail-XPG42/netinet/in.h/conform): Likewise.
	(test-xfail-UNIX98/arpa/inet.h/conform): Likewise.
	(test-xfail-UNIX98/netdb.h/conform): Likewise.
	(test-xfail-UNIX98/netinet/in.h/conform): Likewise.
2017-05-04 20:36:42 +00:00
Adhemerval Zanella 827b823783 posix: Fix internal p{read,write} plt usage
This patch adds internal alias for __pread, __pread64, and __pwrite
following the already in place one for __pwrite64.  This is not used
in any implementation but on microblaze on preadv/pwritev fallback
(since it does not define __ASSUME_PREADV).

In fact it was signaled by commit c35db50ff5 which update the expected
localptl.data for the architecture based on resulted value.  This patch
updates the plt for microblaze now that p{read,write}{64} are correctly
routed to use internal alias.

Checked on x86_64-linux-gnu and a build for all supported architectures
(no all variants although).

	* include/unistd.h (__pread): Add libc_hidden_proto.
	(__pread64): Likewise.
	(__pwrite): Likewise.
	* sysdeps/unix/sysv/linux/microblaze/localplt.data [libc.so]
	(__pread64): Remove.
	* sysdeps/unix/sysv/linux/pread.c (__pread64): Add libc_hidden_weak.
	* sysdeps/unix/sysv/linux/pread64.c (__pread64): Likewise.
	* sysdeps/unix/sysv/linux/pwrite.c (__pwrite): Likewise.
2017-05-02 14:57:40 -03:00
Joseph Myers 9fe3c80c7c Fix sys/socket.h namespace issues from sys/uio.h inclusion (bug 21426).
sys/socket.h includes sys/uio.h to get the definition of the iovec
structure.

POSIX allows sys/socket.h to make all sys/uio.h symbols visible.
However, all of sys/uio.h is XSI-shaded, so for non-XSI POSIX this
results in conformtest failures (for sys/socket.h and other headers
that include it):

    Namespace violation: "UIO_MAXIOV"
    Namespace violation: "readv"
    Namespace violation: "writev"

Now, there is some ambiguity in POSIX about what namespace
reservations apply in this case - see
http://austingroupbugs.net/view.php?id=1127 - but glibc convention
would still avoid declaring readv and writev, for example, for feature
test macros that don't include them (if only headers from the relevant
standard are included), even if such declarations are permitted, so
there is a bug here according to glibc conventions.

This patch moves the struct iovec definition to a new
bits/types/struct_iovec.h header and includes that from sys/socket.h
instead of including the whole of sys/uio.h.  This fixes the namespace
issue; however, three files in glibc that were relying on the implicit
inclusion needed to be updated to include sys/uio.h explicitly.  So
there is a question of whether sys/socket.h should continue to include
sys/uio.h under some conditions, such as __USE_XOPEN or __USE_MISC or
__USE_XOPEN || __USE_MISC, for greater compatibility with code that
(wrongly) expects this optional inclusion to be present there.  (I
think the three affected files in glibc should still have explicit
sys/uio.h inclusions added in any case, however.)

Tested for x86_64.

	[BZ #21426]
	* misc/bits/types/struct_iovec.h: New file.
	* misc/Makefile (headers): Add bits/types/struct_iovec.h.
	* include/bits/types/struct_iovec.h: New file.
	* bits/uio.h (struct iovec): Replace by inclusion of
	<bits/types/struct_iovec.h>.
	* sysdeps/unix/sysv/linux/bits/uio.h (struct iovec): Likewise.
	* socket/sys/socket.h: Include <bits/types/struct_iovec.h> instead
	of <sys/uio.h>.
	* nptl/tst-cancel4.c: Include <sys/uio.h>
	* posix/test-errno.c: Likewise.
	* support/resolv_test.c: Likewise.
	* conform/Makefile (test-xfail-POSIX2008/arpa/inet.h/conform):
	Remove.
	(test-xfail-POSIX2008/netdb.h/conform): Likewise.
	(test-xfail-POSIX2008/netinet/in.h/conform): Likewise.
	(test-xfail-POSIX2008/sys/socket.h/conform): Likewise.
2017-04-25 17:52:47 +00:00
Florian Weimer cef9b65376 Assume that O_CLOEXEC is always defined and works 2017-04-18 14:56:51 +02:00
Florian Weimer b48061e1a5 Assume that dup3 is available 2017-04-18 14:42:19 +02:00
Florian Weimer 46d8874d5b Assume that pipe2 is always available
The Debian patches for Hurd (which are already required to build
glibc before this commit) contain an implementation of pipe2.
2017-04-18 14:09:01 +02:00
Florian Weimer e14a27723c resolv: Reduce EDNS payload size to 1200 bytes [BZ #21361]
This hardens the stub resolver against fragmentation-based attacks.
2017-04-13 13:09:38 +02:00
Zack Weinberg 10a33cf8b4 getopt: eliminate __need_getopt by splitting up getopt.h.
__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions".  Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers.  getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.

	* posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
	New files, intended to be shared with gnulib.
	* posix/bits/getopt_posix.h:
	New file, not intended to be shared with gnulib.
	* posix/getopt.h: Now just includes features.h,
	bits/getopt_core.h, and bits/getopt_ext.h.  Will
	no longer be shared with gnulib.
	* include/bits/getopt_core.h, include/bits/getopt_ext.h
	* include/bits/getopt_posix.h: New wrappers.
	* posix/Makefile: Install new headers.
	* posix/unistd.h, libio/stdio.h:
	Include bits/getopt_posix.h instead of getopt.h.
2017-04-07 07:53:03 -04:00
Zack Weinberg 0f3be8721a getopt: merge _GL_UNUSED annotations from gnulib
gnulib now has annotations on at least some functions to cater to
compilation with -Wunused-parameter.  In order to follow suit cleanly,
I've added to libc-symbols.h some of the _GL_* macros that
gnulib-common.m4 puts into config.h.  (I don't think they belong in
sys/cdefs.h, at least not without further thought.)

At this point all gnulib-side changes to getopt.c have been merged.

	* include/libc-symbols.h: For gnulib compatibility, define
	_GL_UNUSED, _GL_UNUSED_LABEL, _GL_ATTRIBUTE_PURE, and
	_GL_ATTRIBUTE_CONST.
	* posix/getopt.c (_getopt_initialize): Mark argc and argv
	parameters with _GL_UNUSED.
2017-04-07 07:52:29 -04:00
Zack Weinberg 544ce845de getopt: clean up error reporting
getopt can print a whole bunch of error messages, and when used
standalone (from gnulib) it uses fprintf to do that.  But fprintf is a
cancellation point and getopt isn't, and also applying fprintf to a
stream in wide-character mode is not allowed.

glibc has an internal function called __fxprintf that writes a narrow
format string to a stream regardless of mode, but it only handles
ASCII format strings, and it's still a cancellation point.  getopt's
messages are translated, so they might not be ASCII.  So getopt has an
error message to an asprintf buffer, monkeys with internal flag bits
on stderr to disable cancellation, and then calls
__fxprintf(stderr, "%s", buffer).  There isn't even a helper function,
the code is duplicated every time.

This patch fixes __fxprintf to handle arbitrary multibyte format
strings, and adds a variant __fxprintf_nocancel that does the same
thing but also isn't a cancellation point.  (It still _works_ by
monkeying with internal flag bits on the FILE, but that's not really a
layering violation for code in stdio-common.)  All of the #ifdef _LIBC
blocks can then be reduced to their standalone versions with a little
help from some macros at the top of the file.

I also wrote a test case to verify that getopt really isn't a
cancellation point, and I'm glad I did, because it found two bugs, one
of which wasn't even to do with cancellation (see previous patch).

	* stdio-common/fxprintf.c (__fxprintf_nocancel): New function.
	(locked_vfxprintf): New helper function. Handle arbitrary
	multibyte strings, not just ASCII.
	* include/stdio.h: Declare __fxprintf_nocancel.

	* posix/getopt.c: When _LIBC is defined, define fprintf to
	__fxprintf_nocancel, flockfile to _IO_flockfile, and
	funlockfile to _IO_funlockfile.  When neither _LIBC nor
	_POSIX_THREAD_SAFE_FUNCTIONS is defined, define flockfile and
	funlockfile as no-ops.  (_getopt_internal_r): Remove all
	internal #ifdef _LIBC blocks; the standalone error-printing
	code can now be used for libc as well.  Add an
	flockfile/funlockfile pair around one case where the error
	message is printed in several chunks.  Don't use fputc.

	* posix/tst-getopt-cancel.c: New test.
	* posix/Makefile: Run it.
2017-04-07 07:48:57 -04:00
Zack Weinberg bf079e19f5 getopt: remove USE_NONOPTION_FLAGS
glibc's implementation of getopt includes code to parse an environment
variable named _XXX_GNU_nonoption_argv_flags_ (where XXX is the
current process's PID in decimal); but all of it has been #ifdefed out
since 2001, with no official way to turn it back on.

According to commentary in our config.h.in, bash version 2.0 set this
environment variable to indicate argv elements that were the result of
glob expansion and therefore should not be treated as options, but the
feature was "disabled later" because "it caused problems".  According
to bash's CHANGES file, "later" was release 2.01; it gives no more
detail about what the problems were.

Version 2.0 of bash was released on the last day of 1996, and version
2.01 in June of 1997.  Twenty years later, I think it is safe to
assume that this environment variable isn't coming back.

	* config.h.in (USE_NONOPTION_FLAGS): Remove.
	* csu/init-first.c: Remove all #ifdef USE_NONOPTION_FLAGS blocks.
	* sysdeps/mach/hurd/i386/init-first.c: Likewise.
	* posix/getopt_int.h: Likewise.
	* posix/getopt.c: Likewise. Also remove SWAP_FLAGS and the
	__libc_argc and __libc_argv externs, which were only used by
	#ifdef USE_NONOPTION_FLAGS blocks.
	* posix/getopt_init.c: Remove file.
	* posix/Makefile (routines): Remove getopt_init.
	* include/getopt.h: Don't declare __getopt_initialize_environment.
	* manual/getopt.texi: Remove mention of USE_NONOPTION_FLAGS in
	a comment.
2017-04-07 07:45:53 -04:00
Florian Weimer 44f28da7ca nss_dns: Replace local declarations with declarations from a header file 2017-04-04 20:56:23 +02:00
Thorsten Kukuk 1e4d83f6fe Deprecate libnsl by default (only shared library will be
build for backward compatibility, no linking possible) and disable building
of libnss_compat, libnss_nis and libnss_nisplus, except --enable-obsolete-nsl
option is given to configure.

        * config.h.in: Add LINK_OBSOLETE_NSL.
        * config.make.in: Add build-obsolete-nsl.
        * configure.ac: Add obsolete-nsl option.
        * include/libc-symbols.h: Define libnsl_hidden_nolink_def.
        * include/rpcsvc/yp.h: Add missing functions as libnsl_hidden_proto.
        * include/rpcsvc/nislib.h: Likewise.
        * include/rpcsvc/ypclnt.h: Likewise.
        * manual/install.texi: Document --enable-obsolete-nsl.
        * nis/Makefile: Build only libnsl by default (add build-obsolete-nsl).
        * nis/nis_add.c: Replace libnsl_hidden_def with
        libnsl_hidden_nolink_def.
        * nis/nis_addmember.c: Likewise.
        * nis/nis_call.c: Likewise.
        * nis/nis_clone_obj.c: Likewise.
        * nis/nis_defaults.c: Likeise.
        * nis/nis_domain_of_r.c: Likewise.
        * nis/nis_error.c: Likewise.
        * nis/nis_file.c: Likewise.
        * nis/nis_free.c: Likewise.
        * nis_local_names.c: Likewise.
        * nis/nis_lookup.c: Likewise.
        * nis/nis_modify.c: Likewise.
        * nis/nis_print.c: Likewise.
        * nis/nis_remove.c: Likewise.
        * nis/nis_table.c: Likewise.
        * nis/nis_util.c: Likewise.
        * nis/nis_xdr.c: Likewise.
        * nis/yp_xdr.c: Likewise.
        * nis/ypclnt.c: Likewise.
        * nis/ypupdate_xdr.c: Likewise.
        * nis/nis_checkpoint.c: Add libnsl_hidden_nolink_def to all functions.
        * nis/nis_clone_dir.c: Likewise.
        * nis/nis_clone_res.c: Likewise.
        * nis/nis_creategroup.c: Likewise.
        * nis/nis_destroygroup.c: Likewise.
        * nis/nis_domain_of.c: Likewise.
        * nis/nis_getservlist.c: Likewise.
        * nis/nis_ismember.c: Likewise.
        * nis/nis_mkdir.c: Likewise.
        * nis/nis_ping.c: Likewise.
        * nis/nis_print_group_entry.c: Likewise.
        * nis/nis_removemember.c: Likewise.
        * nis/nis_rmdir.c: Likewise.
        * nis/nis_server.c: Likewise.
        * nis/nis_subr.c: Likewise.
        * nis/nis_verifygroup.c: Likewise.

Signed-off-by: Thorsten Kukuk <kukuk@suse.com>
2017-03-21 15:14:27 +01:00
Gabriel F. T. Gomes ff80ec4283 Split helper classification macros from mathcalls.h
The classification macros: finite, fpclassify, iseqsig, isinf, isnan,
issignaling, and signbit are defined by ISO C11 and declared in
mathcalls.h for each of the floating-point types: float, double, and
long double.

TS 18661-3 does not mention these macros for float128, however support
for them must be present when _Float128 is present.  This is true,
even when the feature test macro __STDC_WANT_IEC_60559_TYPES_EXT__ is
false.  Other function declarations in mathcalls.h, on the other hand,
depend on __STDC_WANT_IEC_60559_TYPES_EXT__.

This patch splits the helper functions (__finite, __fpclassify,
__iseqsig, __isinf, __isnan, __issignaling, and __signbit) from
mathcalls.h, so that these helper functions can be declared for
_Float128, even when __STDC_WANT_IEC_60559_TYPES_EXT__ is false.

Tested for powerpc64le, s390x, and x86_64.

	* include/bits/mathcalls-helper-functions.h: New file.
	* math/Makefile (headers): Add bits/mathcalls-helper-functions.h.
	* math/bits/mathcalls.h (__finite, __fpclassify, __iseqsig)
	(__isinf, __isnan, __issignaling, __signbit): Move declarations to
	math/bits/mathcalls-helper-functions.h.
	* math/bits/mathcalls-helper-functions.h: New file.
	* math/math.h: Include bits/mathcalls-helper-functions.h for
	float, double, and long double.
2017-03-15 09:39:16 -03:00
Wilco Dijkstra ae65d4f3c3 Remove the str(n)dup inlines from string/bits/string2.h. Although inlining
calls with constant strings shows a small (~10%) performance gain, strdup is
typically used in error reporting code, so not performance critical.
Remove the now unused __need_malloc_and_calloc related defines from stdlib.h.

Rename existing uses of str(n)dup to __str(n)dup so it no longer needs to be
redirected to a builtin.  Also building GLIBC with -Os now no longer shows
localplt or linkname space failures (partial fix for BZ #15105 and BZ #19463).

        [BZ #15105]
        [BZ #19463]
        * elf/dl-cache.c (_dl_load_cache_lookup): Use __strdup.
        * inet/rcmd.c (rcmd_af): Likewise.
        * inet/rexec.c   (rexec_af): Likewise.
        * intl/dcigettext.c (_LIBC): Likewise.
        * intl/finddomain.c (_nl_find_domain): Use strdup expansion.
        * locale/loadarchive.c (_nl_load_locale_from_archive): Use __strdup.
        * locale/setlocale.c (setlocale): Likewise.
        * posix/spawn_faction_addopen.c
        (posix_spawn_file_actions_addopen): Likewise.
        * stdlib/putenv.c (putenv): Use __strndup.
        * sunrpc/svc_simple.c (__registerrpc): Use __strdup.
        * sysdeps/posix/getaddrinfo.c (gaih_inet): Use __strdup/__strndup.
        * include/stdlib.h (__need_malloc_and_calloc): Remove uses.
        (__Need_M_And_C) Remove define/undef.
        * stdlib/stdlib.h (__need_malloc_and_calloc): Remove uses.
        (__malloc_and_calloc_defined): Remove define.
        * string/bits/string2.h (__strdup): Remove define.
        (strdup): Likewise.
        (__strndup): Likewise.
        (strndup): Likewise.
2017-03-13 18:45:42 +00:00
Florian Weimer 8492c4dd69 timezone: Remove TZNAME_MAX limit from sysconf [BZ #15576]
glibc does not impose a limit, and POSIX does not allow a
sysconf limit which changes during the lifetime of a process.
2017-03-07 17:45:38 +01:00
Zack Weinberg 9090848d06 Narrowing the visibility of libc-internal.h even further.
posix/wordexp-test.c used libc-internal.h for PTR_ALIGN_DOWN; similar
to what was done with libc-diag.h, I have split the definitions of
cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and PTR_ALIGN_DOWN
to a new header, libc-pointer-arith.h.

It then occurred to me that the remaining declarations in libc-internal.h
are mostly to do with early initialization, and probably most of the
files including it, even in the core code, don't need it anymore.  Indeed,
only 19 files actually need what remains of libc-internal.h.  23 others
need libc-diag.h instead, and 12 need libc-pointer-arith.h instead.
No file needs more than one of them, and 16 don't need any of them!

So, with this patch, libc-internal.h stops including libc-diag.h as
well as losing the pointer arithmetic macros, and all including files
are adjusted.

        * include/libc-pointer-arith.h: New file.  Define
	cast_to_integer, ALIGN_UP, ALIGN_DOWN, PTR_ALIGN_UP, and
        PTR_ALIGN_DOWN here.
        * include/libc-internal.h: Definitions of above macros
	moved from here.  Don't include libc-diag.h anymore either.
	* posix/wordexp-test.c: Include stdint.h and libc-pointer-arith.h.
        Don't include libc-internal.h.

	* debug/pcprofile.c, elf/dl-tunables.c, elf/soinit.c, io/openat.c
	* io/openat64.c, misc/ptrace.c, nptl/pthread_clock_gettime.c
	* nptl/pthread_clock_settime.c, nptl/pthread_cond_common.c
	* string/strcoll_l.c, sysdeps/nacl/brk.c
	* sysdeps/unix/clock_settime.c
	* sysdeps/unix/sysv/linux/i386/get_clockfreq.c
	* sysdeps/unix/sysv/linux/ia64/get_clockfreq.c
	* sysdeps/unix/sysv/linux/powerpc/get_clockfreq.c
	* sysdeps/unix/sysv/linux/sparc/sparc64/get_clockfreq.c:
	Don't include libc-internal.h.

	* elf/get-dynamic-info.h, iconv/loop.c
	* iconvdata/iso-2022-cn-ext.c, locale/weight.h, locale/weightwc.h
	* misc/reboot.c, nis/nis_table.c, nptl_db/thread_dbP.h
	* nscd/connections.c, resolv/res_send.c, soft-fp/fmadf4.c
	* soft-fp/fmasf4.c, soft-fp/fmatf4.c, stdio-common/vfscanf.c
	* sysdeps/ieee754/dbl-64/e_lgamma_r.c
	* sysdeps/ieee754/dbl-64/k_rem_pio2.c
	* sysdeps/ieee754/flt-32/e_lgammaf_r.c
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c
	* sysdeps/ieee754/ldbl-128/k_tanl.c
	* sysdeps/ieee754/ldbl-128ibm/k_tanl.c
	* sysdeps/ieee754/ldbl-96/e_lgammal_r.c
	* sysdeps/ieee754/ldbl-96/k_tanl.c, sysdeps/nptl/futex-internal.h:
	Include libc-diag.h instead of libc-internal.h.

        * elf/dl-load.c, elf/dl-reloc.c, locale/programs/locarchive.c
        * nptl/nptl-init.c, string/strcspn.c, string/strspn.c
	* malloc/malloc.c, sysdeps/i386/nptl/tls.h
	* sysdeps/nacl/dl-map-segments.h, sysdeps/x86_64/atomic-machine.h
	* sysdeps/unix/sysv/linux/spawni.c
        * sysdeps/x86_64/nptl/tls.h:
        Include libc-pointer-arith.h instead of libc-internal.h.

	* elf/get-dynamic-info.h, sysdeps/nacl/dl-map-segments.h
	* sysdeps/x86_64/atomic-machine.h:
        Add multiple include guard.
2017-03-01 20:33:46 -05:00
Zack Weinberg e15f7de60c Split DIAG_* macros to new header libc-diag.h.
Quite a few tests include libc-internal.h just for the DIAG_* macros.
Split those macros to their own file, which can be included safely in
_ISOMAC mode.  I also moved ignore_value, since it seems logically
related, even though I didn't notice any tests needing it.

Also add -Wnonnull suppressions to two tests that _should_ have them,
but the error is masked when compiling against internal headers.

	* include/libc-diag.h: New file.  Define ignore_value,
	DIAG_PUSH_NEEDS_COMMENT, DIAG_POP_NEEDS_COMMENT,
	DIAG_IGNORE_NEEDS_COMMENT, and DIAG_IGNORE_Os_NEEDS_COMMENT here.

	* include/libc-internal.h: Definitions of above macros moved from
	here.  Include libc-diag.h.  Add copyright notice.

	* malloc/tst-malloc.c, malloc/tst-memcheck.c, malloc/tst-realloc.c
	* misc/tst-error1.c, posix/tst-dir.c, stdio-common/bug21.c
	* stdio-common/scanf14.c, stdio-common/scanf4.c, stdio-common/scanf7.c
	* stdio-common/test-vfprintf.c, stdio-common/tst-printf.c
	* stdio-common/tst-printfsz.c, stdio-common/tst-sprintf.c
	* stdio-common/tst-unlockedio.c, stdio-common/tstdiomisc.c
	* stdlib/bug-getcontext.c, string/tester.c, string/tst-endian.c
	* time/tst-strptime2.c, wcsmbs/tst-wcstof.c:
	Include libc-diag.h instead of libc-internal.h.

	* stdlib/tst-environ.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to unsetenv (NULL).
	* nptl/tst-mutex1.c: Include libc-diag.h.  Suppress -Wnonnull for
	call to pthread_mutexattr_destroy (NULL).
2017-02-25 09:59:46 -05:00
Zack Weinberg 7caa5054af Clean up conditionals for declaration of gets.
gets has the dubious honor of being the only C89 library feature that
has been completely removed from the current C and C++ standards.
glibc follows suit by not declaring it in _GNU_SOURCE mode either,
but it remains present in older compatibility modes.  Internally,
two test cases need to see stdio.h make the declaration, but all our
internal code is of course compiled under _GNU_SOURCE.  This is currently
kludged by duplicating the gets declaration, fortify wrapper and all,
in include/stdio.h.  Also, the conditional in the public headers for
deciding when to declare gets is complicated and repeated in two places.

This patch adds a new macro to features.h that encapsulates the
complicated rule for when to declare gets.  stdio.h and bits/stdio2.h
then simply test __GLIBC_USE (DEPRECATED_GETS), and instead of having
a duplicate gets declaration in include/stdio.h, debug/tst-chk1.c and
stdio-common/tst-gets.c can force gets to be declared.

        * include/features.h (__GLIBC_USE_DEPRECATED_GETS): New macro.
        * libio/stdio.h, libio/bits/stdio2.h: Condition gets on
        __GLIBC_USE (DEPRECATED_GETS).  Update comments to indicate
        gets was removed from C++ in C++14.
        * include/stdio.h: Remove redundant declaration of gets.
        * debug/tst-chk1.c, stdio-common/tst-gets.c: Force gets to
        be declared, since we are testing it.
        * stdio-common/Makefile (tst-gets.c): Compile with
        -Wno-deprecated-declarations.
	* debug/Makefile (tst-chk1.c, tst-chk2.c, tst-chk3.c, tst-chk4.cc)
	(tst-chk5.cc, tst-chk6.cc, tst-lfschk1.c, tst-lfschk2.c)
	(tst-lfschk3.c, tst-lfschk4.cc, tst-lfschk5.cc, tst-lfschk6.cc):
	Compile with -Wno-deprecated-declarations.
2017-02-25 09:47:51 -05:00
Mike FABIAN 0b38d66a4e Bug 20313: Update to Unicode 9.0.0
* Unicode 9.0.0 Support: Character encoding, character type info, and
  transliteration tables are all updated to Unicode 9.0.0, using
  generator scripts contributed by Mike FABIAN (Red Hat).
2017-02-21 06:30:38 -05:00