Commit Graph

22988 Commits

Author SHA1 Message Date
Joseph Myers 4e7fbdd7c2 Remove x86_64 math_private.h asms.
The x86_64 math_private.h has asm versions of the macros to
reinterpret between floating-point and integer types.

This is the sort of thing we now strongly discourage; the expectation
in such cases, where the generic C code gives the compiler all the
information needed about the required semantics, is that you should
get the compiler to do the right thing for the generic C code rather
than writing an asm version.

Trivial tests showed GCC generates the expected single instructions
for reinterpretation from floating point to integer.  In the other
direction, it goes via memory when the asms don't; I asked about this
in GCC bug 87236 and was advised this was deliberate for generic
tuning because it was faster that way on some AMD processors (but
-mtune=intel, and -Os with the latest GCC, avoid going via memory).
The asms don't and can't know about those tuning details, so that's
evidence that they are actually making the code worse.

This patch removes the asms accordingly.  Tested for x86_64.

	* sysdeps/x86_64/fpu/math_private.h (MOVD): Remove macro.
	(MOVQ): Likewise.
	(EXTRACT_WORDS64): Likewise.
	(INSERT_WORDS64): Likewise.
	(GET_FLOAT_WORD): Likewise.
	(SET_FLOAT_WORD): Likewise.
2018-09-11 14:51:40 +00:00
Joseph Myers b1176270de Add build-many-glibcs.py support for building more GCC libraries.
Every so often we get libsanitizer or libgo builds breaking with new
glibc because of some change in the glibc headers.

glibc's build-many-glibcs.py deliberately disables libsanitizer and
GCC languages other than C and C++ because the point is to test glibc
and find glibc problems (including problems shown up by new compiler
warnings in new GCC), not to test libsanitizer or libgo; if the
compiler build fails because of libsanitizer or libgo failing to
build, that could hide the existence of new problems in glibc.
However, it seems reasonable to have a non-default mode where
build-many-glibcs.py does build those additional pieces, which this
patch adds.

Note that I do not intend to run a build-many-glibcs.py bot with this
new option.  If people concerned with libsanitizer, libgo or other
potentially affected GCC libraries wish to find out about such
problems more quickly, they may wish to run such a bot or bots (and to
monitor the results and fix issues found - obviously there will be
some overlap with issues found by my bots not using that option).

Note also that building a non-native Ada compiler requires a
sufficiently recent native (or build-x-host, in general) Ada compiler
to be used, possibly more or less the same version as being built.
That needs to be in the PATH when build-many-glibcs.py --full-gcc is
run; the script does not deal with setting up such a compiler (or any
of the other host tools needed for building GCC and glibc, beyond the
GMP / MPFR / MPC libraries), but perhaps it should, to avoid the need
to keep updating such a compiler manually when running a bot.

Tested by running build-many-glibcs.py with the new option, with
mainline GCC.  There are build failures for various configurations,
which may be of interest to Go / Ada people even if you're not
interested in running such a bot:

* mips64 / mips64el (all configuration): ICE building libstdc++, as
  seen without using the new option
  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87156>.

* aarch64_be: error building libgo (little-endian aarch64 works fine):

version.go:67:13: error: expected ';' or ')' or newline
67 |   BigEndian =
   |             ^
version.go:67:3: error: reference to undefined name 'BigEndian'
67 |   BigEndian =
   |   ^

* arm (all configurations): error building libgo:

/scratch/jmyers/glibc/many9/src/gcc/libgo/go/internal/syscall/unix/getrandom_linux.go:29:5: error: reference to undefined name 'randomTrap'
29 |  if randomTrap == 0 {
   |     ^
/scratch/jmyers/glibc/many9/src/gcc/libgo/go/internal/syscall/unix/getrandom_linux.go:38:34: error: reference to undefined name 'randomTrap'
38 |  r1, _, errno := syscall.Syscall(randomTrap,
   |                                  ^

What's happening there is, I think, that the arm*b*-*-* case in
libgo/configure.ac is wrongly matching arm-glibc-linux-gnueabi with
the 'b' in the vendor part, and then something else is failing to
handle GOARCH=armbe.  Given that you can have configurations with
multilibs of both endiannesses, endianness should always be detected
by configure.ac, for all architectures, using a compile test of
whether __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__, not based on textual
matches to the host (= target at top-level) triplet.

* armeb (all configurations): error building libada (for some reason
  the Arm libada configuration seems to do different things for EH for
  big-endian, which makes no sense to me and doesn't actually work):

a-exexpr.adb:87:06: "System.Exceptions.Machine" is not a predefined library unit
a-exexpr.adb:87:06: "Ada.Exceptions (body)" depends on "Ada.Exceptions.Exception_Propagation (body)"
a-exexpr.adb:87:06: "Ada.Exceptions.Exception_Propagation (body)" depends on "System.Exceptions.Machine (spec)"

* hppa: error building libgo (same error as for aarch64_be).

* ia64: ICE building libgo.  I've filed
  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87281> for this.

* m68k: ICE in the Go front end building libgo
  <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84948>.

* microblaze, microblazeel, nios2, sh3, sh3eb: build failure in libada
  for lack of a libada port to those systems (I'm not sure sh3 would
  actually need anything different from sh4):

a-cbdlli.ads:38:14: violation of restriction "No_Finalization" at system.ads:47

* i686-gnu: build failure in libada, might be fixed by the patch
  attached to <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81103>
  (not tested):

terminals.c:1115:13: fatal error: termio.h: No such file or directory

	* scripts/build-many-glibcs.py (Context.__init__): Add full_gcc
	argument.
	(Config.build_gcc): Use --disable-libsanitizer for first GCC
	build, but not for second build if --full-gcc.  Use
	--enable-languages=all for second build if --full-gcc.
	(get_parser): Add --full-gcc option.
	(main): Update call to Context.
2018-09-11 12:02:28 +00:00
Rafal Luzynski 527f355e5e Italian and Swiss locales: Use the correct separators (bug 10797).
CLDR and many other sources say that it_IT (Italian) should use a dot
(".") as a thousands separator and a comma (",") as a decimal separator.

For it_CH and de_CH CLDR says that they should use the Right Single
Quotation Mark ("’") as a thousands separator and a dot (".") as a
decimal separator.  Consequently, the same rules are copied to all other
locales in Switzerland.

These rules apply to both LC_MONETARY and LC_NUMERIC.

	[BZ #10797]
	* localedata/locales/de_CH (mon_thousands_sep): Use "<U2019>" (Right
	Single Quotation Mark).
	(thousands_sep): Likewise.
	* localedata/locales/it_CH (LC_NUMERIC): Use “copy "de_CH"”.
	* localedata/locales/it_IT (thousands_sep): Use ".".
	(grouping): Use "3;3".
2018-09-10 23:56:53 +02:00
Joseph Myers 7244f13ded Add build-many-glibcs.py --enable-obsolete-* configs.
We've had issues before with build failures (with new GCC) in code
only built with --enable-obsolete-rpc or --enable-obsolete-nsl not
being reported for a while because build-many-glibcs.py does not test
those configure options.  This patch adds configurations (32-bit and
64-bit) using those options so that in future we can notice quickly if
they start failing to build.

Tested the new configurations do build with GCC 8.

	* scripts/build-many-glibcs.py (Context.add_all_configs): Add
	x86_64 and i686 configs using --enable-obsolete-rpc
	--enable-obsolete-nsl.
2018-09-10 16:54:34 +00:00
Stefan Liebler 38245425a9 S390: Regenerate ULPs.
Regenerated ulps from scratch after recent changes.

ChangeLog:

	* sysdeps/s390/fpu/libm-test-ulps: Regenerated.
2018-09-06 14:29:01 +02:00
Stefan Liebler 28669f86f6 Fix segfault in maybe_script_execute.
If glibc is built with gcc 8 and -march=z900,
the testcase posix/tst-spawn4-compat crashes with a segfault.

In function maybe_script_execute, the new_argv array is dynamically
initialized on stack with (argc + 1) elements.
The function wants to add _PATH_BSHELL as the first argument
and writes out of bounds of new_argv.
There is an off-by-one because maybe_script_execute fails to count
the terminating NULL when sizing new_argv.

ChangeLog:

	* sysdeps/unix/sysv/linux/spawni.c (maybe_script_execute):
	Increment size of new_argv by one.
2018-09-06 14:27:03 +02:00
Rafal Luzynski a33650d1a6 Indian and similar locales: Set the correct date format (bug 17426).
This commit also fixes d_fmt in bn_BD which is identical to bn_IN,
in ne_NP which is identical to ne_IN (not supported by Glibc but supported
by CLDR), and in ta_LK which is identical to ta_IN.

For those locales which are supported by CLDR data is imported from
CLDR v33.  For others it is copied from those locales which were identical
before this commit.

	[BZ #17426]
	* localedata/locales/anp_IN (d_fmt): Use "%-d//%-m//%y".
	* localedata/locales/ar_IN (d_fmt): Likewise.
	* localedata/locales/bhb_IN (d_fmt): Likewise.
	* localedata/locales/bho_IN (d_fmt): Likewise.
	* localedata/locales/bn_BD (d_fmt): Likewise.
	* localedata/locales/bn_IN (d_fmt): Likewise.
	* localedata/locales/doi_IN (d_fmt): Likewise.
	* localedata/locales/gu_IN (d_fmt): Likewise.
	* localedata/locales/hi_IN (d_fmt): Likewise.
	* localedata/locales/hne_IN (d_fmt): Likewise.
	* localedata/locales/kn_IN (d_fmt): Likewise.
	* localedata/locales/mag_IN (d_fmt): Likewise.
	* localedata/locales/mai_IN (d_fmt): Likewise.
	* localedata/locales/mjw_IN (d_fmt): Likewise.
	* localedata/locales/ml_IN (d_fmt): Likewise.
	* localedata/locales/mni_IN (d_fmt): Likewise.
	* localedata/locales/mr_IN (d_fmt): Likewise.
	* localedata/locales/pa_IN (d_fmt): Likewise.
	* localedata/locales/raj_IN (d_fmt): Likewise.
	* localedata/locales/sat_IN (d_fmt): Likewise.
	* localedata/locales/sd_IN (d_fmt): Likewise.
	* localedata/locales/sd_IN@devanagari (d_fmt): Likewise.
	* localedata/locales/ta_IN (d_fmt): Likewise.
	* localedata/locales/ta_LK (d_fmt): Likewise.
	* localedata/locales/tcy_IN (d_fmt): Likewise.
	* localedata/locales/ur_IN (d_fmt): Likewise.

	* localedata/locales/brx_IN (d_fmt): Use "%-m//%-d//%y".
	* localedata/locales/ks_IN (d_fmt): Likewise.
	* localedata/locales/ks_IN@devanagari (d_fmt): Likewise.

	* localedata/locales/kok_IN (d_fmt): Use "%-d-%-m-%y".
	* localedata/locales/ne_NP (d_fmt): Use "%y//%-m//%-d".
	* localedata/locales/sa_IN (d_fmt): Use "%-d-%m-%y".
	* localedata/locales/te_IN (d_fmt): Use "%d-%m-%y".
2018-09-05 23:57:11 +02:00
Szabolcs Nagy d114e6a722 Missed ChangeLog 2018-09-05 16:30:17 +01:00
Joseph Myers b7cdc2aeb1 Remove alpha math_private.h.
After some math_private.h cleanups (in particulat math-barriers.h
being split out), the only thing left in the alpha math_private.h was
macro definitions of __isnan and __isnanf, apparently (based on the
comments) intended to avoid problems with inline definitions in other
math_private.h files.  Those inline definitions were removed in commit
fe8c2b33ae, and the alpha math_private.h
is no longer needed; this patch removes it.

Tested with build-many-glibcs.py that installed stripped shared
libraries for alpha are unchanged by the patch.

	* sysdeps/alpha/fpu/math_private.h: Remove.
2018-09-05 12:42:51 +00:00
Joseph Myers b9d8c47472 Move float128 inlines from sysdeps/generic/math_private.h to include/math.h.
Continuing the cleanup of math_private.h, with a view to it becoming
the header for the APIs defined therein and not also a header with
inline variants of math.h APIs, this patch moves inline definitions of
__isinff128 and fabsf128 to include/math.h, so that any users of
math.h in glibc automatically get the optimized functions rather than
quietly missing them if they do not also include math_private.h.

Tested for x86_64 and x86, and with build-many-glibcs.py with GCC 6.
There are changes to installed stripped libc.so on configurations with
distinct _Float128, because of __printf_fp_l code that now gets the
__isinff128 inline where previously it called the out-of-line
function because of the lack of a math_private.h call.  It seems
appropriate that this code does get the inline (as it would
automatically with GCC 7 and later when the built-in function is used)
rather than being the only place in glibc that does not.

	* sysdeps/generic/math_private.h
	[__HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7, 0)] (__isinff128):
	Move this inline function ....
	[__HAVE_DISTINCT_FLOAT128] (fabsf128): And this one ....
	* include/math.h [!_ISOMAC]: To here....
2018-09-05 11:53:35 +00:00
Joseph Myers 418d99e622 Move fenv.h soft-float inlines from fenv_private.h to include/fenv.h.
<fenv_private.h> has inline versions of various <fenv.h> functions,
and their __fe* variants, for systems (generally soft-float) without
support for floating-point exceptions, rounding modes or both.

Having these inlines in a separate header introduces a risk of a
source file including <fenv.h> and compiling OK on x86_64, but failing
to compile (because the feraiseexcept inline is actually a macro that
discards its argument, to avoid the need for #ifdef FE_INVALID
conditionals), or not being properly optimized, on systems without the
exceptions and rounding modes support (when these inlines were in
math_private.h, we had a few cases where this broke the build because
there was no obvious reason for a file to need math_private.h and it
didn't need that header on x86_64).  By moving those inlines to
include/fenv.h, this risk can be avoided, and fenv_private.h becomes
more clearly defined as specifically the header for the internal
libc_fe* and SET_RESTORE_ROUND* interfaces.

This patch makes that move, removing fenv_private.h includes that are
no longer needed (or replacing them by fenv.h includes in a few cases
that didn't already have such an include).

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

	* sysdeps/generic/fenv_private.h [FE_ALL_EXCEPT == 0]: Move this
	code ....
	[!FE_HAVE_ROUNDING_MODES]: And this code ....
	* include/fenv.h [!_ISOMAC]: ... to here.
	* math/fraiseexcpt.c (__feraiseexcept): Undefine as macro.
	(feraiseexcept): Likewise.
	* math/fromfp.h: Do not include <fenv_private.h>.
	* math/s_cexp_template.c: Likewise.
	* math/s_csin_template.c: Likewise.
	* math/s_csinh_template.c: Likewise.
	* math/s_ctan_template.c: Likewise.
	* math/s_ctanh_template.c: Likewise.
	* math/s_iseqsig_template.c: Likewise.
	* math/w_acos_compat.c: Likewise.
	* math/w_acosf_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_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_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.
	* sysdeps/ieee754/dbl-64/s_llrint.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_llround.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_lrint.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_lround.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Likewise.
	* sysdeps/ieee754/flt-32/s_llrintf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_llroundf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_lrintf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_lroundf.c: Likewise.
	* sysdeps/ieee754/k_standardl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/e_expl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_lroundl.c: Likewise.
	* math/w_ilogb_template.c: Include <fenv.h> instead of
	<fenv_private.h>.
	* math/w_llogb_template.c: Likewise.
	* sysdeps/powerpc/fpu/e_sqrt.c: Likewise.
	* sysdeps/powerpc/fpu/e_sqrtf.c: Likewise.
2018-09-04 19:52:06 +00:00
Joseph Myers 70e2ba332f Do not include fenv_private.h in math_private.h.
Continuing the clean-up related to the catch-all math_private.h
header, this patch stops math_private.h from including fenv_private.h.
Instead, fenv_private.h is included directly from those users of
math_private.h that also used interfaces from fenv_private.h.  No
attempt is made to remove unused includes of math_private.h, but that
is a natural followup.

(However, since math_private.h sometimes defines optimized versions of
math.h interfaces or __* variants thereof, as well as defining its own
interfaces, I think it might make sense to get all those optimized
versions included from include/math.h, not requiring a separate header
at all, before eliminating unused math_private.h includes - that
avoids a file quietly becoming less-optimized if someone adds a call
to one of those interfaces without restoring a math_private.h include
to that file.)

There is still a pitfall that if code uses plain fe* and __fe*
interfaces, but only includes fenv.h and not fenv_private.h or (before
this patch) math_private.h, it will compile on platforms with
exceptions and rounding modes but not get the optimized versions (and
possibly not compile) on platforms without exception and rounding mode
support, so making it easy to break the build for such platforms
accidentally.

I think it would be most natural to move the inlines / macros for fe*
and __fe* in the case of no exceptions and rounding modes into
include/fenv.h, so that all code including fenv.h with _ISOMAC not
defined automatically gets them.  Then fenv_private.h would be purely
the header for the libc_fe*, SET_RESTORE_ROUND etc. internal
interfaces and the risk of breaking the build on other platforms than
the one you tested on because of a missing fenv_private.h include
would be much reduced (and there would be some unused fenv_private.h
includes to remove along with unused math_private.h includes).

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

	* sysdeps/generic/math_private.h: Do not include <fenv_private.h>.
	* math/fromfp.h: Include <fenv_private.h>.
	* math/math-narrow.h: Likewise.
	* math/s_cexp_template.c: Likewise.
	* math/s_csin_template.c: Likewise.
	* math/s_csinh_template.c: Likewise.
	* math/s_ctan_template.c: Likewise.
	* math/s_ctanh_template.c: Likewise.
	* math/s_iseqsig_template.c: Likewise.
	* math/w_acos_compat.c: Likewise.
	* math/w_acosf_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_ilogb_template.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_llogb_template.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.
	* sysdeps/aarch64/fpu/feholdexcpt.c: Likewise.
	* sysdeps/aarch64/fpu/fesetround.c: Likewise.
	* sysdeps/aarch64/fpu/fgetexcptflg.c: Likewise.
	* sysdeps/aarch64/fpu/ftestexcept.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_atan2.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_exp2.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_gamma_r.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_jn.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_pow.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_remainder.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_sqrt.c: Likewise.
	* sysdeps/ieee754/dbl-64/gamma_product.c: Likewise.
	* sysdeps/ieee754/dbl-64/lgamma_neg.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_atan.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fma.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_fmaf.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_llrint.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_llround.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_lrint.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_lround.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_nearbyint.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_sin.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_sincos.c: Likewise.
	* sysdeps/ieee754/dbl-64/s_tan.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_lround.c: Likewise.
	* sysdeps/ieee754/dbl-64/wordsize-64/s_nearbyint.c: Likewise.
	* sysdeps/ieee754/dbl-64/x2y2m1.c: Likewise.
	* sysdeps/ieee754/float128/float128_private.h: Likewise.
	* sysdeps/ieee754/flt-32/e_gammaf_r.c: Likewise.
	* sysdeps/ieee754/flt-32/e_j1f.c: Likewise.
	* sysdeps/ieee754/flt-32/e_jnf.c: Likewise.
	* sysdeps/ieee754/flt-32/lgamma_negf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_llrintf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_llroundf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_lrintf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_lroundf.c: Likewise.
	* sysdeps/ieee754/flt-32/s_nearbyintf.c: Likewise.
	* sysdeps/ieee754/k_standardl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/e_expl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/e_gammal_r.c: Likewise.
	* sysdeps/ieee754/ldbl-128/e_j1l.c: Likewise.
	* sysdeps/ieee754/ldbl-128/e_jnl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/gamma_productl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/lgamma_negl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_fmal.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_lroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/s_nearbyintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128/x2y2m1l.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_expl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_gammal_r.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_j1l.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/e_jnl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/lgamma_negl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_fmal.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_lroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/s_rintl.c: Likewise.
	* sysdeps/ieee754/ldbl-128ibm/x2y2m1l.c: Likewise.
	* sysdeps/ieee754/ldbl-96/e_gammal_r.c: Likewise.
	* sysdeps/ieee754/ldbl-96/e_jnl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/gamma_productl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/lgamma_negl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fma.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_fmal.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_llrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_llroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_lrintl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/s_lroundl.c: Likewise.
	* sysdeps/ieee754/ldbl-96/x2y2m1l.c: Likewise.
	* sysdeps/powerpc/fpu/e_sqrt.c: Likewise.
	* sysdeps/powerpc/fpu/e_sqrtf.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_ceil.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_floor.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_nearbyint.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_round.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_roundeven.c: Likewise.
	* sysdeps/riscv/rv64/rvd/s_trunc.c: Likewise.
	* sysdeps/riscv/rvd/s_finite.c: Likewise.
	* sysdeps/riscv/rvd/s_fmax.c: Likewise.
	* sysdeps/riscv/rvd/s_fmin.c: Likewise.
	* sysdeps/riscv/rvd/s_fpclassify.c: Likewise.
	* sysdeps/riscv/rvd/s_isinf.c: Likewise.
	* sysdeps/riscv/rvd/s_isnan.c: Likewise.
	* sysdeps/riscv/rvd/s_issignaling.c: Likewise.
	* sysdeps/riscv/rvf/fegetround.c: Likewise.
	* sysdeps/riscv/rvf/feholdexcpt.c: Likewise.
	* sysdeps/riscv/rvf/fesetenv.c: Likewise.
	* sysdeps/riscv/rvf/fesetround.c: Likewise.
	* sysdeps/riscv/rvf/feupdateenv.c: Likewise.
	* sysdeps/riscv/rvf/fgetexcptflg.c: Likewise.
	* sysdeps/riscv/rvf/ftestexcept.c: Likewise.
	* sysdeps/riscv/rvf/s_ceilf.c: Likewise.
	* sysdeps/riscv/rvf/s_finitef.c: Likewise.
	* sysdeps/riscv/rvf/s_floorf.c: Likewise.
	* sysdeps/riscv/rvf/s_fmaxf.c: Likewise.
	* sysdeps/riscv/rvf/s_fminf.c: Likewise.
	* sysdeps/riscv/rvf/s_fpclassifyf.c: Likewise.
	* sysdeps/riscv/rvf/s_isinff.c: Likewise.
	* sysdeps/riscv/rvf/s_isnanf.c: Likewise.
	* sysdeps/riscv/rvf/s_issignalingf.c: Likewise.
	* sysdeps/riscv/rvf/s_nearbyintf.c: Likewise.
	* sysdeps/riscv/rvf/s_roundevenf.c: Likewise.
	* sysdeps/riscv/rvf/s_roundf.c: Likewise.
	* sysdeps/riscv/rvf/s_truncf.c: Likewise.
2018-09-03 21:09:04 +00:00
Paul Pluzhnikov a6e8926f8d [BZ #20271] Add newlines in __libc_fatal calls. 2018-08-31 18:04:32 -07:00
Joseph Myers 2bbd06bcee Replace conform/list-header-symbols.pl with a Python script.
Continuing the move of test code from Perl to Python (which seems
uncontroversial, unlike dependencies on Python in the actual build of
glibc), this patch replaces conform/list-header-symbols.pl with a
Python script, as a first step in converting the conform/ tests.
(conform/glibcconform.py is an equivalent to GlibcConform.pm,
containing code that will be relevant to move than one of the conform/
scripts.)

Tested for x86_64, including verifying that the symbol lists generated
are identical to those generated by the Perl version.

	* conform/glibcconform.py: New file.
	* conform/list-header-symbols.py: Likewise.
	* conform/list-header-symbols.pl: Remove.
	* conform/Makefile (tests-special): Only add linknamespace tests
	if [PYTHON].
	($(linknamespace-symlists-tests)): Use list-header-symbols.py.
2018-08-31 21:19:51 +00:00
H.J. Lu 81b9d87bae test-container: Use xcopy_file_range for cross-device copy [BZ #23597]
copy_file_range can't be used to copy a file from glibc source directory
to glibc build directory since they may be on different filesystems.
This patch adds xcopy_file_range for cross-device copy.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #23597]
	* support/Makefile (libsupport-routines): Add
	support_copy_file_range and xcopy_file_range.
	* support/support.h: Include <sys/types.h>.
	(support_copy_file_range): New prototype.
	* support/support_copy_file_range.c: New file.  Copied and
	modified from io/copy_file_range-compat.c.
	* support/test-container.c (copy_one_file): Call xcopy_file_rang
	instead of copy_file_range.
	* support/xcopy_file_range.c: New file.
	* support/xunistd.h (xcopy_file_range): New prototype.
2018-08-31 13:08:02 -07:00
Carlos O'Donell d330f31af6 Fix test failure with -DNDEBUG.
The elf/tst-dlopen-aout.c test uses asserts to verify properties of the
test execution.  Instead of using assert it should use xpthread_create
and xpthread_join to catch errors starting the threads and fail the
test.  This shows up in Fedora 28 when building for i686-pc-linux-gnu
and using gcc 8.1.1.

Tested on i686, and fixes a check failure with -DNDEBUG.

Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-08-30 12:33:22 -04:00
Florian Weimer 2bda273aa3 reallocarray: Declare under _DEFAULT_SOURCE
Initially, this function was restricted to _GNU_SOURCE, but experience
shows that compatibility with existing build systems is improved if we
declare it under _DEFAULT_SOURCE as well.
2018-08-30 14:14:53 +02:00
Stefan Liebler 3bad2358d6 Test stdlib/test-bz22786 exits now with unsupported if malloc fails.
The test tries to allocate more than 2^31 bytes which will always fail on s390
as it has maximum 2^31bit of memory.
Before commit 6c3a8a9d86, this test returned
unsupported if malloc fails.  This patch re enables this behaviour.

Furthermore support_delete_temp_files() failed to remove the temp directory
in this case as it is not empty due to the created symlink.
Thus the creation of the symlink is moved behind malloc.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

ChangeLog:

	* stdlib/test-bz22786.c (do_test): Return EXIT_UNSUPPORTED
	if malloc fails.
2018-08-30 08:44:32 +02:00
Joseph Myers 09c12efcaf Make gen-libm-test.py treat plus_oflow and minus_oflow as non-finite.
When converting gen-libm-test to Python, in one place I noted a bug in
the old Perl version that I preserved in the Python version so that
the generated output files were the same with both versions, as such
comparisons help give confidence in the correctness of such a rewrite
of a script.  Now that the conversion has been done, this patch fixes
that bug, by arranging for tests with plus_oflow or minus_oflow
results (manually written tests in libm-test-*.inc that have
overflowing results that thus depend on the rounding mode) to be
properly treated as having non-finite results, and thus not run for
the __FINITE_MATH_ONLY__ tests.  (As the affected tests in fact did
pass for __FINITE_MATH_ONLY__ testing, this is just a matter of
logical correctness in the choice of which tests run for that case,
rather than fixing any actual test failures.)

Tested for x86_64.

	* math/gen-libm-test.py (gen_test_args_res): Also treat plus_oflow
	and minus_oflow as non-finite.
2018-08-29 20:01:57 +00:00
Joseph Myers ff6b24501f Split fenv_private.h out of math_private.h more consistently.
On some architectures, the parts of math_private.h relating to the
floating-point environment are in a separate file fenv_private.h
included from math_private.h.  As this is purely an
architecture-specific convention used by several architectures,
however, all such architectures still need their own math_private.h,
even if it has nothing to do beyond #include <fenv_private.h> and
peculiarity of including the i386 file directly instead of having a
shared file in sysdeps/x86.

This patch makes the fenv_private.h name an architecture-independent
convention in glibc.  The include of fenv_private.h from
math_private.h becomes architecture-independent (until callers are
updated to include fenv_private.h directly so the include from
math_private.h is no longer needed).  Some architecture math_private.h
headers are removed if no longer needed, or renamed to fenv_private.h
if all they define belongs in that header; architecture fenv_private.h
headers now do require #include_next <fenv_private.h>.  The i386
fenv_private.h file moves to sysdeps/x86/fpu/ to reflect how it is
actually shared with x86_64.  The generic math_private.h gets a new
include of <stdbool.h>, as needed for bool in some prototypes in that
header (previously that was indirectly included via include/fenv.h,
which now only gets included too late in math_private.h, after those
prototypes).

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

	* sysdeps/aarch64/fpu/fenv_private.h: New file.  Based on ....
	* sysdeps/aarch64/fpu/math_private.h: ... this file.  All contents
	moved to fenv_private.h except for ...
	(TOINT_INTRINSICS): Kept in math_private.h.
	(roundtoint): Likewise.
	(converttoint): Likewise.
	* sysdeps/arm/fenv_private.h: Change multiple-include guard to
	[ARM_FENV_PRIVATE_H].  Include next <fenv_private.h>.
	* sysdeps/arm/math_private.h: Remove.
	* sysdeps/generic/fenv_private.h: New file.  Contents moved from
	....
	* sysdeps/generic/math_private.h: ... this file.  Include
	<stdbool.h>.  Do not include <fenv.h> or <get-rounding-mode.h>.
	Include <fenv_private.h>.  Remove functions and macros moved to
	fenv_private.h.
	* sysdeps/i386/fpu/math_private.h: Remove.
	* sysdeps/mips/math_private.h: Move to ....
	* sysdeps/mips/fpu/fenv_private.h: ... here.  Change
	multiple-include guard to [MIPS_FENV_PRIVATE_H].  Remove
	[__mips_hard_float] conditional.  Include next <fenv_private.h>.
	* sysdeps/powerpc/fpu/fenv_private.h: Change multiple-include
	guard to [POWERPC_FENV_PRIVATE_H].  Include next <fenv_private.h>.
	* sysdeps/powerpc/fpu/math_private.h: Do not include
	<fenv_private.h>.
	* sysdeps/riscv/rvf/math_private.h: Move to ....
	* sysdeps/riscv/rvf/fenv_private.h: ... here.  Change
	multiple-include guard to [RISCV_FENV_PRIVATE_H].  Include next
	<fenv_private.h>.
	* sysdeps/sparc/fpu/fenv_private.h: Change multiple-include guard
	to [SPARC_FENV_PRIVATE_H].  Include next <fenv_private.h>.
	* sysdeps/sparc/fpu/math_private.h: Remove.
	* sysdeps/i386/fpu/fenv_private.h: Move to ....
	* sysdeps/x86/fpu/fenv_private.h: ... here.  Change
	multiple-include guard to [X86_FENV_PRIVATE_H].  Include next
	<fenv_private.h>.
	* sysdeps/x86_64/fpu/math_private.h: Do not include
	<sysdeps/i386/fpu/fenv_private.h>.
2018-08-28 20:48:49 +00:00
Florian Weimer 761404b74d regex: Add test tst-regcomp-truncated [BZ #23578] 2018-08-28 19:43:12 +02:00
Florian Weimer d6c44c3d0c test-container: EPERM from unshare is UNSUPPORTED
For example, the security policy on the Fedora build daemons results in
this EPERM error.
2018-08-28 14:02:47 +02:00
Florian Weimer 745664bd79 nscd: Fix use-after-free in addgetnetgrentX [BZ #23520]
addinnetgrX may use the heap-allocated buffer, so free the buffer
in this function.
2018-08-28 13:19:27 +02:00
Rajalakshmi Srinivasaraghavan c8dd67e7c9 Speedup first memmem match
As done in commit 284f42bc77, memcmp
can be used after memchr to avoid the initialization overhead of the
two-way algorithm for the first match.  This has shown improvement
>40% for first match.
2018-08-28 12:42:19 +05:30
Rafal Luzynski 5abedf97a3 en_IN: Set the correct date format for "%x" (bug 17426).
[BZ #17426]
	* localedata/locales/en_IN (d_fmt): Use "%d/%m/%y".
2018-08-28 00:21:52 +02:00
DJ Delorie 86de0499c3 links-dso-program: Fix build-programs=no build case.
* support/Makefile (others): Don't list programs explicitly as a
dependency of "others".
2018-08-27 16:31:33 -04:00
Joseph Myers c3ab211099 Move EXCEPTION_SET_FORCES_TRAP out of math-tests.h.
Completing the move of macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_SET_FORCES_TRAP macro out to its own
math-tests-trap-force.h header.

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-trap-force.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-trap-force.h>.
	(EXCEPTION_SET_FORCES_TRAP): Do not define here.
	* sysdeps/powerpc/math-tests.h: Remove file.
	* sysdeps/powerpc/fpu/math-tests-trap-force.h: New file.
2018-08-27 18:52:41 +00:00
Martin Kuchta 99ea93ca31 pthread_cond_broadcast: Fix waiters-after-spinning case [BZ #23538] 2018-08-27 17:03:35 +02:00
Joseph Myers 4061791fcc Update netinet/udp.h from Linux 4.18.
This patch adds the UDP_SEGMENT constant from Linux 4.18 to
netinet/udp.h.

Tested for x86_64.

	* sysdeps/gnu/netinet/udp.h (UDP_SEGMENT): New macro.
2018-08-27 13:43:05 +00:00
Paul Eggert bc680b3369 regex: fix uninitialized memory access
I introduced this bug into gnulib in commit
8335a4d6c7b4448cd0bcb6d0bebf1d456bcfdb17 dated 2006-04-10;
eventually it was merged into glibc.  The bug was found by
project-repo <bugs@feusi.co> and reported here:
https://lists.gnu.org/r/sed-devel/2018-08/msg00017.html
Diagnosis and draft fix reported by Assaf Gordon here:
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00071.html
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00142.html
* posix/regex_internal.c (build_wcs_upper_buffer):
Fix bug when mbrtowc returns 0.
2018-08-25 20:34:34 -07:00
Carlos O'Donell 02458a5236 Update translations for be. 2018-08-24 22:26:41 -04:00
DJ Delorie acc2842ace Fix IA64 links-dso-program link.
* support/Makefile (LDLIBS-links-dso-program): Add -lgcc and
$(libunwind).
2018-08-24 22:10:00 -04:00
Paul Pluzhnikov 6c3a8a9d86 Fix BZ#23400 (creating temporary files in source tree), and undefined behavior in test. 2018-08-24 18:08:51 -07:00
Joseph Myers 895ef79e04 Move EXCEPTION_ENABLE_SUPPORTED out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_ENABLE_SUPPORTED macro out to its own
math-tests-trap.h header.

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-trap.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-trap.h>.
	(EXCEPTION_ENABLE_SUPPORTED): Do not define here.
	* sysdeps/aarch64/math-tests.h: Remove file.
	* sysdeps/arm/math-tests.h: Likewise.
	* sysdeps/riscv/math-tests.h: Likewise.
	* sysdeps/aarch64/math-tests-trap.h: New file.
	* sysdeps/arm/math-tests-trap.h: Likewise.
	* sysdeps/riscv/math-tests-trap.h: Likewise.
2018-08-24 19:18:16 +00:00
Wilco Dijkstra ca3aac57ef Remove unused math files
Remove empty files due to the sin/cos improvements: k_sinf.c, k_cosf.c,
k_cos.c, k_sin.c.  After the tanf change s_rem_pio2f.c and k_rem_pio2f.c
(and the ia64, m68k and powerpc equivalents) are no longer used,
so remove them.  All e_rem_pio2.c files were already empty or commented
out, so remove them too.  Passes build-many-glibcs.

	* math/Makefile: Remove empty files k_sin(f).c, k_cos(f).c.
	Remove unused files e_rem_pio2(f).c, k_rem_pio2f.c.
	* sysdeps/i386/fpu/e_rem_pio2.c: Delete file.
	* sysdeps/ia64/fpu/e_rem_pio2.c: Likewise.
	* sysdeps/ia64/fpu/e_rem_pio2f.c: Likewise.
	* sysdeps/ia64/fpu/k_rem_pio2f.c: Likewise.
	* sysdeps/ieee754/dbl-64/e_rem_pio2.c: Likewise.
	* sysdeps/ieee754/dbl-64/k_cos.c: Likewise.
	* sysdeps/ieee754/dbl-64/k_sin.c: Likewise.
	* sysdeps/ieee754/flt-32/e_rem_pio2f.c: Likewise.
	* sysdeps/ieee754/flt-32/k_cosf.c: Likewise.
	* sysdeps/ieee754/flt-32/k_rem_pio2f.c: Likewise.
	* sysdeps/ieee754/flt-32/k_sinf.c: Likewise.
	* sysdeps/m68k/m680x0/fpu/e_rem_pio2.c: Likewise
	* sysdeps/m68k/m680x0/fpu/e_rem_pio2f.c: Likewise
	* sysdeps/m68k/m680x0/fpu/k_rem_pio2f.c: Likewise
	* sysdeps/powerpc/fpu/e_rem_pio2f.c: Likewise.
	* sysdeps/powerpc/fpu/k_rem_pio2f.c: Likewise.
2018-08-24 15:34:54 +01:00
Joseph Myers 60bcac09c0 Move EXCEPTION_TESTS_* out of math-tests.h
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the EXCEPTION_TESTS_* macros for individual types out to their
own sysdeps header.

As with ROUNDING_TESTS_*, there is no need to define these macros if
FE_ALL_EXCEPT == 0 and the individual exception macros are undefined;
thus, math-tests-exceptions.h headers are only needed for soft-float
ARM and RISC-V, while the other cases that defined these macros do not
need to do so (and the associated math-tests.h headers are thus
removed without needing replacement by math-tests-exceptions.h
headers).

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-exceptions.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-exceptions.h>.
	(EXCEPTION_TESTS_float): Do not define here.
	(EXCEPTION_TESTS_double): Likewise.
	(EXCEPTION_TESTS_long_double): Likewise.
	(EXCEPTION_TESTS_float128): Likewise.
	* sysdeps/arm/math-tests.h [__SOFTFP__] (EXCEPTION_TESTS_float):
	Likewise.
	[__SOFTFP__] (EXCEPTION_TESTS_double): Likewise.
	[__SOFTFP__] (EXCEPTION_TESTS_long_double): Likewise.
	* sysdeps/arm/nofpu/math-tests-exceptions.h: New file.
	* sysdeps/m68k/coldfire/math-tests.h: Remove file.
	* sysdeps/mips/math-tests.h: Likewise.
	* sysdeps/nios2/math-tests.h: Likewise.
	* sysdeps/riscv/math-tests.h [!__riscv_flen]
	(EXCEPTION_TESTS_float): Do not define here.
	[!__riscv_flen] (EXCEPTION_TESTS_double): Likewise.
	[!__riscv_flen] (EXCEPTION_TESTS_long_double): Likewise.
	* sysdeps/riscv/nofpu/math-tests-exceptions.h: New file.
2018-08-23 23:41:13 +00:00
Wilco Dijkstra 3bded567a7 Update NEWS for sinf improvements
The NEWS entry for sinf improvements is listed for 2.28, while it was
committed in 2.29, so move it there and mention tanf.

Committed as obvious.

	* NEWS: Move optimized sinf entry to 2.29.
2018-08-23 12:55:28 +01:00
Wilco Dijkstra 900fb446eb Speedup tanf range reduction
Speedup tanf range reduction by using the new sincosf range
reduction algorithm.  Overall code quality is improved due to
inlining, so there is a speedup even if no range reduction is
required.

tanf throughput gains on Cortex-A72:
* |x| < M_PI_4  : 1.1x
* |x| < M_PI_2  : 1.2x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.6x
* |x| < Inf     : 12.1x

	* sysdeps/ieee754/flt-32/s_tanf.c (__tanf): Use fast range reduction.
2018-08-23 12:38:16 +01:00
DJ Delorie 561b0bec44 Add test-in-container infrastructure.
* Makefile (testroot.pristine): New rules to initialize the
test-in-container "testroot".
* Makerules (all-testsuite): Add tests-container.
* Rules (tests-expected): Add tests-container.
(binaries-all-tests): Likewise.
(tests-container): New, run these tests in the testroot container.
* support/Makefile (others): Add *-container, support_paths.c,
xmkdirp, and links-dso-program.
* support/links-dso-program-c.c: New.
* support/links-dso-program.cc: New.
* support/test-container.c: New.
* support/shell-container.c: New.
* support/echo-container.c: New.
* support/true-container.c: New.
* support/xmkdirp.c: New.
* support/xsymlink.c: New.
* support/support_paths.c: New.
* support/support.h: Add support paths prototypes.
* support/xunistd.h: Add xmkdirp () and xsymlink ().

* nss/tst-nss-test3.c: Convert to test-in-container.
* nss/tst-nss-test3.root/: New.
2018-08-22 21:20:37 -04:00
Paul Eggert b35d3509ca regex: port Gnulib code to z/OS POSIX environment
Problem reported by Arnold Robbins in:
https://lists.gnu.org/r/bug-gnulib/2018-08/msg00129.html
* posix/regex_internal.h (__iswalnum, __towlower, __towupper) [!_LIBC]:
Undef.
2018-08-22 17:46:32 -07:00
Joseph Myers debc4c9870 Don't redefine ROUNDING_TESTS_* in math/test-*-vlen*.h.
This patch completes the move of ROUNDING_TESTS_* macros to typo-proof
conventions by stopping redefining them in test-*-vlen*.h.  Instead,
libm-test-driver.c is made to check TEST_MATHVEC when setting
non-to-nearest rounding modes.

Tested for x86_64.

	* math/test-double-vlen2.h: Don't include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Remove.
	* math/test-double-vlen4.h: Don't include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Remove.
	* math/test-double-vlen8.h: Don't include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Remove.
	* math/test-float-vlen16.h: Don't include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Remove.
	* math/test-float-vlen4.h: Don't include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Remove.
	* math/test-float-vlen8.h: Don't include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Remove.
	* math/libm-test-driver.c (IF_ROUND_INIT_FE_DOWNWARD): Check
	!TEST_MATHVEC here.
	(IF_ROUND_INIT_FE_TOWARDZERO): Likewise.
	(IF_ROUND_INIT_FE_UPWARD): Likewise.
2018-08-22 15:22:06 +00:00
Joseph Myers 16a25138c1 Move ROUNDING_TESTS_* out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the ROUNDING_TESTS_* macros for individual types out to their
own sysdeps header.

In the soft-float case where FE_TONEAREST is the only rounding mode
macro defined, there is no need to define ROUNDING_TESTS_*; it is only
necessary when rounding modes macros are defined that may not be
supported at runtime.  Thus, the ROUNDING_TESTS_* definitions for some
configurations are just removed, not moved to new
math-tests-rounding.h headers; the only architectures needing
math-tests-rounding.h are those where the macros are defined in
bits/fenv.h because of the possibility of a soft-float compilation
using a hard-float glibc with the same ABI (i.e., ARM and RISC-V).

The test-*-vlen*.h headers, by using #undef, do not yet follow
typo-proof conventions (but they no longer implicitly rely on being
included before math-tests.h, and this area can always be cleaned up
further in future).

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-rounding.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Do not define here.
	(ROUNDING_TESTS_double): Likewise.
	(ROUNDING_TESTS_long_double): Likewise.
	(ROUNDING_TESTS_float128): Likewise.
	* math/test-double-vlen2.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Undefine before defining.
	* math/test-double-vlen4.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Undefine before defining.
	* math/test-double-vlen8.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_double): Undefine before defining.
	* math/test-float-vlen16.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Undefine before defining.
	* math/test-float-vlen4.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Undefine before defining.
	* math/test-float-vlen8.h: Include <math-tests-rounding.h>.
	(ROUNDING_TESTS_float): Undefine before defining.
	* sysdeps/arm/nofpu/math-tests-rounding.h: New file.
	* sysdeps/arm/math-tests.h [__SOFTFP__] (ROUNDING_TESTS_float): Do
	not define here.
	[__SOFTFP__] (ROUNDING_TESTS_double): Likewise.
	[__SOFTFP__] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/riscv/nofpu/math-tests-rounding.h: New file.
	* sysdeps/riscv/math-tests.h [!__riscv_flen]
	(ROUNDING_TESTS_float): Do not define here.
	[!__riscv_flen] (ROUNDING_TESTS_double): Likewise.
	[!__risv_flen] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/m68k/coldfire/math-tests.h [!__mcffpu__]
	(ROUNDING_TESTS_float): Likewise.
	[!__mcffpu__] (ROUNDING_TESTS_double): Likewise.
	[!__mcffpu__] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/mips/math-tests.h [__mips_soft_float]
	(ROUNDING_TESTS_float): Likewise.
	[__mips_soft_float] (ROUNDING_TESTS_double): Likewise.
	[__mips_soft_float] (ROUNDING_TESTS_long_double): Likewise.
	* sysdeps/nios2/math-tests.h (ROUNDING_TESTS_float): Likewise.
	(ROUNDING_TESTS_double): Likewise.
	(ROUNDING_TESTS_long_double): Likewise.
2018-08-22 12:25:50 +00:00
Tobias Klauser 38b0593e9a Add PF_XDP, AF_XDP and SOL_XDP from Linux 4.18 to bits/socket.h.
This patch adds the PF_XDP, AF_XDP and SOL_XDP macros from Linux 4.18 to
sysdeps/unix/sysv/linux/bits/socket.h.

	* sysdeps/unix/sysv/linux/bits/socket.h (PF_MAX): Set to 45.
	(PF_XDP): New macro.
	(AF_XDP): New macro.
	(SOL_XDP): New macro.
2018-08-21 17:22:53 +00:00
Joseph Myers 5cd7dbdea1 Update netinet/tcp.h from Linux 4.18.
This patch adds constants from netinet/tcp.h in Linux 4.18, and an
associated struct tcp_zerocopy_receive, to sysdeps/gnu/netinet/tcp.h.
The new TCP_REPAIR_* constants seemed sufficiently related to those
already present to include them.

Note that this patch does not include additions to struct tcp_info;
there are many other elements in this structure in the Linux kernel
that are not included in the glibc version (which was last extended in
2007, it seems).  Such additions to the end of the structure may be OK
with the expected way it is used (size passed explicitly to the kernel
with getsockopt), but in principle any change to the size of a type
provided by glibc is an ABI change for external applications /
libraries using that type in their ABIs, and has the associated risks
of such a change.

Tested for x86_64.

	* sysdeps/gnu/netinet/tcp.h (TCP_ZEROCOPY_RECEIVE): New macro.
	(TCP_INQ): Likewise.
	(TCP_CM_INQ): Likewise.
	(TCP_REPAIR_ON): Likewise.
	(TCP_REPAIR_OFF): Likewise.
	(TCP_REPAIR_OFF_NO_WP): Likewise.
	(struct tcp_zerocopy_receive): New type.
2018-08-21 15:57:22 +00:00
Florian Weimer aa42b3dbcb Avoid running some tests if the file system does not support holes
Otherwise, these tests fills up the entire disk (or just run very
slowly and eventually time out).
2018-08-21 12:56:53 +02:00
Florian Weimer c7627f41ba Makeconfig: Do not sort and deduplicate +cflags [BZ # 17248]
The original intent behind this is unclear.  It interferes with flags
that has to be ordered in a particular way.
2018-08-21 11:43:35 +02:00
Florian Weimer ef939d928a __readlink_chk: Remove micro-optimization 2018-08-21 11:24:12 +02:00
Florian Weimer 88ffb39dc6 __readlink_chk: Assume HAVE_INLINED_SYSCALLS
HAVE_INLINED_SYSCALLS is always defined on Linux.
Switch to INLINE_SYSCALL_CALL as well.
2018-08-20 18:24:09 +02:00
Joseph Myers e6edd40d61 Update struct signalfd_siginfo from Linux 4.18.
This patch updates struct signalfd_siginfo in sys/signalfd.h with new
members from Linux 4.18 (plus ssi_addr_lsb, added to the kernel in
2.6.37 without being added to sys/signalfd.h at that time).  The
__pad2 member name follows the kernel and the existing __pad name.

Tested for x86_64.

	* sysdeps/unix/sysv/linux/sys/signalfd.h (struct
	signalfd_siginfo): Add ssi_addr_lsb, ssi_syscall, ssi_call_addr
	and ssi_arch members.
2018-08-20 15:48:16 +00:00
Joseph Myers 174195409d Add NT_VMCOREDD, AT_MINSIGSTKSZ from Linux 4.18 to elf.h.
This patch adds two new constants from Linux 4.18 to elf.h,
NT_VMCOREDD and AT_MINSIGSTKSZ.

Tested for x86_64.

	* elf/elf.c (NT_VMCOREDD): New macro.
	(AT_MINSIGSTKSZ): Likewise.
2018-08-20 15:46:26 +00:00
Florian Weimer 35cfefd960 malloc: Add ChangeLog for accidentally committed change
Commit b90ddd08f6 ("malloc: Additional
checks for unsorted bin integrity I.") was committed without a
whitespace fix, so it is adjusted here as well.
2018-08-20 14:57:13 +02:00
Rajalakshmi Srinivasaraghavan fa78896b1f powerpc: Remove powerpc specific sinf and cosf optimization
New generic optimization of sinf and cosf introduced by commit
599cf39766 shows improvement
compared to powerpc specific assembly version.  Hence removing
the powerpc assembly versions to make use of generic code.
2018-08-20 08:47:43 +05:30
Florian Weimer 86a6c75a29 math: Regenerate s390 ulps
Based on results on a s390x 2964 machine, with -march=z196 and
-mtune=zEC12, and separately with -march=z13 and -mtune=z14.
2018-08-17 16:39:13 +02:00
Florian Weimer 6413fcde4f Add --with-nonshared-cflags option to configure 2018-08-17 11:44:39 +02:00
Florian Weimer 93a2584cd2 Makeconfig (ASFLAGS): Always append required assembler flags
Otherwise, it is impossible to set ASFLAGS differently from CFLAGS
without also overriding essential flags such as -Wa,--noexecstack.
2018-08-17 11:35:42 +02:00
Florian Weimer f6f275d2d9 Fix attribution of previous change in ChangeLog 2018-08-17 11:33:29 +02:00
Moritz Eckert d6db68e66d malloc: Mitigate null-byte overflow attacks
* malloc/malloc.c (_int_free): Check for corrupt prev_size vs size.
(malloc_consolidate): Likewise.
2018-08-16 21:26:16 -04:00
Pochang Chen 30a17d8c95 malloc: Verify size of top chunk.
The House of Force is a well-known technique to exploit heap
overflow. In essence, this exploit takes three steps:
1. Overwrite the size of top chunk with very large value (e.g. -1).
2. Request x bytes from top chunk. As the size of top chunk
   is corrupted, x can be arbitrarily large and top chunk will
   still be offset by x.
3. The next allocation from top chunk will thus be controllable.

If we verify the size of top chunk at step 2, we can stop such attack.
2018-08-16 15:24:24 -04:00
Siddhesh Poyarekar 34f86d6168 Reallocate buffers for every run in strlen
Try and avoid influencing performance of neighbouring functions.
2018-08-16 14:11:57 +05:30
Siddhesh Poyarekar 953a5a4a59 Print strlen benchmark output in json
Allow reading the benchmark using the compare_strings.py script.
2018-08-16 14:11:56 +05:30
Rajalakshmi Srinivasaraghavan 7793ad7a2c powerpc: Rearrange little endian specific files
This patch moves little endian specific POWER9 optimization files to
sysdeps/powerpc/powerpc64/le and creates POWER9 ifunc functions
only for little endian.
2018-08-16 12:12:02 +05:30
Siddhesh Poyarekar 436e4d5b96 [aarch64] Add an ASIMD variant of strlen for falkor
This variant of strlen uses vector loads and operations to reduce the
size of the code and also eliminate the non-ascii fallback.  This
works very well for falkor because of its two vector units and
efficient vector ops.  In the best case it reduces latency of cases in
bench-strlen by 48%, with gains throughout the benchmark.
strlen-walk also sees uniform gains in the 5%-15% range.

Overall the routine appears to work better than the stock one for falkor
regardless of the benchmark, length of string or cache state.

The same cannot be said of a53 and a72 though.  a53 performance was
greatly reduced and for a72 it was a bit of a mixed bag, slightly on the
negative side but I reckon it might be fast in some situations.

	* sysdeps/aarch64/strlen.S (__strlen): Rename to STRLEN.
	[!STRLEN](STRLEN): Set to __strlen.
	* sysdeps/aarch64/multiarch/strlen.c: New file.
	* sysdeps/aarch64/multiarch/strlen_generic.S: Likewise.
	* sysdeps/aarch64/multiarch/strlen_asimd.S: Likewise.
	* sysdeps/aarch64/multiarch/ifunc-impl-list.c
	(__libc_ifunc_impl_list): Add strlen.
	* sysdeps/aarch64/multiarch/Makefile (sysdep_routines): Add
	strlen_generic and strlen_asimd.

Reviewed-By: szabolcs.nagy@arm.com
CC: pinskia@gmail.com
2018-08-15 23:01:33 +05:30
Wilco Dijkstra 126c4e3f80 Use generic sinf/cosf in lgammaf_r
The internal functions __kernel_sinf and __kernel_cosf are used only by
lgammaf_r.  Removing the internal functions and using the generic sinf
and cosf is better overall.  Benchmarking on Cortex-A72 shows the generic
sinf and cosf are 1.4x and 2.3x faster in the range |x| < PI/4, and 0.66x
and 1.1x for |x| < PI/2, so it should make lgammaf_r faster on average.

GLIBC regression tests pass on AArch64.

	* sysdeps/ieee754/flt-32/e_lgammaf_r.c (sin_pif): Use __sinf/__cosf.
	* sysdeps/ieee754/flt-32/k_cosf.c (__kernel_cosf): Remove all code.
	* sysdeps/ieee754/flt-32/k_sinf.c (__kernel_sinf): Likewise.
2018-08-15 16:01:21 +01:00
Wilco Dijkstra 49acec179c Fix spaces in x86_64 ULP file
Fix a few missing spaces, it's now identical to the regenerated version.

Passes GLIBC tests on x64.

	* sysdeps/x86_64/fpu/libm-test-ulps: Regenerate to fix spaces.
2018-08-15 12:56:22 +01:00
Florian Weimer fdb16de387 error, warn, warnx: Use __fxprintf for wide printing [BZ #23519]
Also introduce the __vfxprintf function.
2018-08-14 17:54:49 +02:00
Wilco Dijkstra 599cf39766 Improve performance of sinf and cosf
The second patch improves performance of sinf and cosf using the same
algorithms and polynomials.  The returned values are identical to sincosf
for the same input.  ULP definitions for AArch64 and x64 are updated.

sinf/cosf througput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.2x
* |x| < M_PI_4  : 1.8x
* |x| < 2 * M_PI: 1.7x
* |x| < 120.0   : 2.3x
* |x| < Inf     : 3.0x

	* NEWS: Mention sinf, cosf, sincosf.
	* sysdeps/aarch64/libm-test-ulps: Update ULP for sinf, cosf, sincosf.
	* sysdeps/x86_64/fpu/libm-test-ulps: Update ULP for sinf and cosf.
	* sysdeps/x86_64/fpu/multiarch/s_sincosf-fma.c: Add definitions of
	constants rather than including generic sincosf.h.
	* sysdeps/x86_64/fpu/s_sincosf_data.c: Remove.
	* sysdeps/ieee754/flt-32/s_cosf.c (cosf): Rewrite.
	* sysdeps/ieee754/flt-32/s_sincosf.h (reduced_sin): Remove.
	(reduced_cos): Remove.
	(sinf_poly): New function.
	* sysdeps/ieee754/flt-32/s_sinf.c (sinf): Rewrite.
2018-08-14 10:45:59 +01:00
Florian Weimer e95c6f6192 nss_files: Fix file stream leak in aliases lookup [BZ #23521]
In order to get a clean test case, it was necessary to fix partially
fixed bug 23522 as well.
2018-08-14 10:52:06 +02:00
Florian Weimer 2d7acfac3e nscd: Deallocate existing user names in file parser
This avoids a theoretical memory leak (theoretical because it depends on
multiple server-user/stat-user directives in the configuration file).
2018-08-14 10:51:07 +02:00
Joseph Myers 17b26500f9 Update syscall-names.list for Linux 4.18.
This patch updates sysdeps/unix/sysv/linux/syscall-names.list for
Linux 4.18.  The io_pgetevents and rseq syscalls are added to the
kernel on various architectures, so need to be mentioned in this file.

Tested with build-many-glibcs.py.

	* sysdeps/unix/sysv/linux/syscall-names.list: Update kernel
	version to 4.18.
	(io_pgetevents): New syscall.
	(rseq): Likewise.
2018-08-13 21:35:27 +00:00
Joseph Myers 3c1622eb77 Update install.texi documentation of uses of Perl and Python.
The install.texi documentation of uses of Perl and Python is
substantially out of date.

The description of Perl is "to test the installation" (which I
interpret as referring to test-installation.pl), but it's used for
more tests than that, and to build the manual, and to regenerate one
file in the source tree.

The description of Python is only for pretty-printer tests, but it's
used for other tests / benchmarks as well (and for other internal uses
such as updating Unicode data, for which we already require Python 3,
but I think install.texi only needs to describe uses from the main
glibc Makefiles).

This patch updates the descriptions of what those tools are used for.
The Python information (and information about other tools for testing
pretty printers) was awkwardly in the middle of the general
description of building and testing glibc, rather than with the rest
of information about tools used in glibc build and test; this patch
moves the information about those tools into the main list.

Tested with regeneration of INSTALL as well as "make info" and "make
pdf".

	* manual/install.texi (Configuring and compiling): Do not list
	tools used for testing pretty printers here.
	(Tools for Compilation): List Python, PExpect and GDB here.
	Update descriptions of uses of Perl and Python.
	* INSTALL: Regenerate.
2018-08-13 17:20:46 +00:00
Joseph Myers f3cd0904a4 Use Linux 4.18 in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default Linux
	version to 4.18.
2018-08-13 16:46:13 +00:00
Florian Weimer b7b52b9dec error, error_at_line: Add missing va_end calls 2018-08-13 14:28:07 +02:00
Florian Weimer 017801880b mbstowcs: Remove outdated comment
ISO C requires that there is no effect on any global conversion state,
so the change in commit 9f097308c7 was
correct in princple.
2018-08-13 14:05:01 +02:00
Siddhesh Poyarekar 8cac1f2635 [benchtests] Add workload test properties to schema
Add the workload test properties (max-throughput, latency, etc.) to
the schema to prevent benchmark output validation from failing.

	* benchtests/scripts/benchout.schema.json (properties): Add
	new properties.
2018-08-11 18:55:09 +05:30
Siddhesh Poyarekar 44727aec4f [benchtests] Add mandatory attributes to workload tests
Add the duration and iterations attributes to the workloads tests to
make the json schema parser happy

	* benchtests/bench-skeleton.c (main): Add duration and
	iterations attributes.
2018-08-11 18:55:07 +05:30
Rafal Luzynski 7b7adbd8d4 ChangeLog: Fix an obvious typo.
The typo has been introduced in commit
08a5ee14c6.
2018-08-10 23:57:35 +02:00
Paul Eggert c77bf91b43 regex: Gnulib unibyte RRI uses bytes not chars
Adjust the non-glibc code to agree with what Gawk needs for
rational range interpretation (RRI) for regular expression ranges.
In unibyte locales, Gawk wants ranges to use the underlying byte
rather than the character code point.  This change does not affect
glibc proper.
* posix/regcomp.c (parse_byte) [!LIBC && RE_ENABLE_I18N]:
In unibyte locales, use the byte value rather than
running it through btowc.
2018-08-10 14:27:56 -07:00
Joseph Myers 2ce7ba7d15 Move SNAN_TESTS_* out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves the SNAN_TESTS_* macros for individual types out to their own
sysdeps header (while the type-generic SNAN_TESTS wrapper for those
macros remains in math-tests.h).

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

	* sysdeps/generic/math-tests-snan.h: New file.
	* sysdeps/generic/math-tests.h: Include <math-tests-snan.h>.
	(SNAN_TESTS_float): Do not define here.
	(SNAN_TESTS_double): Likewise.
	(SNAN_TESTS_long_double): Likewise.
	(SNAN_TESTS_float128): Likewise.
	* sysdeps/i386/fpu/math-tests-snan.h: New file.
	* sysdeps/i386/fpu/math-tests.h: Remove file.
	* sysdeps/ia64/math-tests-snan.h: New file.
	* sysdeps/ia64/math-tests.h: Remove file.
	* sysdeps/x86/math-tests.h: Likewise.
	* sysdeps/x86_64/fpu/math-tests-snan.h: New file.
2018-08-10 19:22:01 +00:00
Wilco Dijkstra ea5c662c62 Improve performance of sincosf
This patch is a complete rewrite of sincosf.  The new version is
significantly faster, as well as simple and accurate.
The worst-case ULP is 0.5607, maximum relative error is 0.5303 * 2^-23 over
all 4 billion inputs.  In non-nearest rounding modes the error is 1ULP.

The algorithm uses 3 main cases: small inputs which don't need argument
reduction, small inputs which need a simple range reduction and large inputs
requiring complex range reduction.  The code uses approximate integer
comparisons to quickly decide between these cases.

The small range reducer uses a single reduction step to handle values up to
120.0.  It is fastest on targets which support inlined round instructions.

The large range reducer uses integer arithmetic for simplicity.  It does a
32x96 bit multiply to compute a 64-bit modulo result.  This is more than
accurate enough to handle the worst-case cancellation for values close to
an integer multiple of PI/4.  It could be further optimized, however it is
already much faster than necessary.

sincosf throughput gains on Cortex-A72:
* |x| < 0x1p-12 : 1.6x
* |x| < M_PI_4  : 1.7x
* |x| < 2 * M_PI: 1.5x
* |x| < 120.0   : 1.8x
* |x| < Inf     : 2.3x

	* math/Makefile: Add s_sincosf_data.c.
	* sysdeps/ia64/fpu/s_sincosf_data.c: New file.
	* sysdeps/ieee754/flt-32/s_sincosf.h (abstop12): Add new function.
	(sincosf_poly): Likewise.
	(reduce_small): Likewise.
	(reduce_large): Likewise.
	* sysdeps/ieee754/flt-32/s_sincosf.c (sincosf): Rewrite.
	* sysdeps/ieee754/flt-32/s_sincosf_data.c: New file with sincosf data.
	* sysdeps/m68k/m680x0/fpu/s_sincosf_data.c: New file.
	* sysdeps/x86_64/fpu/s_sincosf_data.c: New file.
2018-08-10 17:34:39 +01:00
Szabolcs Nagy 43cfdf8f48 Clean up converttoint handling and document the semantics
This patch currently only affects aarch64.

The roundtoint and converttoint internal functions are only called with small
values, so 32 bit result is enough for converttoint and it is a signed int
conversion so the return type is changed to int32_t.

The original idea was to help the compiler keeping the result in uint64_t,
then it's clear that no sign extension is needed and there is no accidental
undefined or implementation defined signed int arithmetics.

But it turns out gcc does a good job with inlining so changing the type has
no overhead and the semantics of the conversion is less surprising this way.
Since we want to allow the asuint64 (x + 0x1.8p52) style conversion, the top
bits were never usable and the existing code ensures that only the bottom
32 bits of the conversion result are used.

On aarch64 the neon intrinsics (which round ties to even) are changed to
round and lround (which round ties away from zero) this does not affect the
results in a significant way, but more portable (relies on round and lround
being inlined which works with -fno-math-errno).

The TOINT_SHIFT and TOINT_RINT macros were removed, only keep separate code
paths for TOINT_INTRINSICS and !TOINT_INTRINSICS.

	* sysdeps/aarch64/fpu/math_private.h (roundtoint): Use round.
	(converttoint): Use lround.
	* sysdeps/ieee754/flt-32/math_config.h (roundtoint): Declare and
	document the semantics when TOINT_INTRINSICS is set.
	(converttoint): Likewise.
	(TOINT_RINT): Remove.
	(TOINT_SHIFT): Remove.
	* sysdeps/ieee754/flt-32/e_expf.c (__expf): Remove the TOINT_RINT code
	path.
2018-08-10 17:23:16 +01:00
Florian Weimer 690652882b Linux: Rewrite __old_getdents64 [BZ #23497]
Commit 298d0e3129 ("Consolidate Linux
getdents{64} implementation") broke the implementation because it does
not take into account struct offset differences.

The new implementation is close to the old one, before the
consolidation, but has been cleaned up slightly.
2018-08-10 10:20:13 +02:00
Ilya Leoshkevich 8f135efcad S390: Fix unwind in 32-bit _mcount
* Fix CFI offset for %r14.
* Fix unwound value of %r15 being off by 128 bytes.

ChangeLog:

	* sysdeps/s390/s390-32/s390-mcount.S (_mcount):
	Fix unwind.
2018-08-10 09:07:44 +02:00
Ilya Leoshkevich 71c01af52f S390: Implement 64-bit __fentry__
* Since __fentry__ is almost the same as _mcount, reuse the code by
  #including it twice with different #defines around.
* Remove LA usages - they are needed in 31-bit mode to clear the top
  bit, but in 64-bit they appear to do nothing.
* Add CFI rule for the nonstandard return register. This rule applies
  to the current function (binutils generates a new CIE - see
  gas/dw2gencfi.c:select_cie_for_fde()), so it is not necessary to put
  __fentry__ into a new file.
* Fix CFI offset for %r14.
* Add CFI rule for %r0.
* Fix unwound value of %r15 being off by 244 bytes.
* Unwinding in __fentry__@plt does not work, no plan to fix it - it
  would require asking linker to generate CFI for return address in
  %r0.  From functional perspective keeping it broken is fine, since
  the callee did not have a chance to do anything yet.  From
  convenience perspective it would be possible to enhance GDB in the
  future to treat __fentry__@plt in a special way.
* Fix whitespace.
* Fix offsets in comments, which were copied from 32-bit code.
* 32-bit version will not be implemented, since it's not compatible
  with the corresponding PLT stubs: they assume %r12 points to GOT,
  which is not the case for gcc-emitted __fentry__ stub, which runs
  before the prolog.

This patch adds the runtime support in glibc for the -mfentry
gcc feature introduced in [1] and [2].

[1] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00784.html
[2] https://gcc.gnu.org/ml/gcc-patches/2018-07/msg00912.html

ChangeLog:

	* sysdeps/s390/s390-64/Versions (__fentry__): Add.
	* sysdeps/s390/s390-64/s390x-mcount.S: Move the common
	code to s390x-mcount.h and #include it.
	* sysdeps/s390/s390-64/s390x-mcount.h: New file.
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
	(__fentry__): Add.
2018-08-10 09:07:44 +02:00
Ilya Leoshkevich 8d997d2253 Move __fentry__ version definition to sysdeps/{i386,x86_64}
__fentry__ symbol is currently not defined for other architectures.
Attempts to introduce it cause abicheck to fail, because it will be
available since 2.29 earliest, and not 2.13, which is the case for
Intel.  With the new code, abicheck passes for i686-linux-gnu,
x86_64-linux-gnu and x86_64-linux-gnu32 triples.

ChangeLog:

	* stdlib/Versions: Remove __fentry__.
	* sysdeps/i386/Versions: Add __fentry__.
	* sysdeps/x86_64/Versions: Add __fentry__.
2018-08-10 09:07:44 +02:00
Ilya Leoshkevich 69e2444ab1 S390: Test that lazy binding does not clobber R0
The following combinations need to be tested:
* 32- (g5, esa and zarch) and 64-bit
  * linux32 glibc/configure CC='gcc -m31 -march=g5'
  * linux32 glibc/configure CC='gcc -m31'
  * linux32 glibc/configure CC='gcc -m31 -mzarch'
* With and without VX:
  * glibc/configure libc_cv_asm_s390_vx=no
* With and without profiling (using LD_PROFILE)
* With and without pltexit (using LD_AUDIT)

ChangeLog:

	* sysdeps/s390/Makefile: Register the new tests.
	* sysdeps/s390/tst-dl-runtime-mod.S: New file.
	* sysdeps/s390/tst-dl-runtime-profile-audit.c: New file.
	* sysdeps/s390/tst-dl-runtime-profile-noaudit.c: New file.
	* sysdeps/s390/tst-dl-runtime-resolve-audit.c: New file.
	* sysdeps/s390/tst-dl-runtime-resolve-noaudit.c: New file.
	* sysdeps/s390/tst-dl-runtime.c: New file.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich bde6320f39 S390: Do not clobber R0 in 64-bit _dl_runtime_profile
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
	Do not clobber R0.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich 5755f5e4cc S390: Do not clobber R0 in 64-bit _dl_runtime_resolve
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
	Do not clobber R0.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich c8ad85225b S390: Do not clobber R0 in 32-bit _dl_runtime_profile
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
	Do not clobber R0.
2018-08-10 09:07:43 +02:00
Ilya Leoshkevich b215eee1e1 S390: Do not clobber R0 in 32-bit _dl_runtime_resolve
Preparation for the usage of R0 by __fentry__.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
	Do not clobber R0.
2018-08-10 09:07:42 +02:00
Ilya Leoshkevich 329c6fec8b S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_profile
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_profile):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:42 +02:00
Ilya Leoshkevich 0fb7afa2f9 S390: Use symbolic offsets for stack variables in 64-bit _dl_runtime_resolve
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-64/dl-trampoline.h (_dl_runtime_resolve):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:42 +02:00
Ilya Leoshkevich 6954059ad6 S390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_profile
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_profile):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:41 +02:00
Ilya Leoshkevich c7099673aa S390: Use symbolic offsets for stack variables in 32-bit _dl_runtime_resolve
Maintainability improvement.

ChangeLog:

	* sysdeps/s390/s390-32/dl-trampoline.h (_dl_runtime_resolve):
	Use symbolic offsets for stack variables.
2018-08-10 09:07:41 +02:00
Joseph Myers 2813e41e90 Replace gen-libm-test.pl with gen-libm-test.py.
Following the recent discussion of using Python instead of Perl and
Awk for glibc build / test, this patch replaces gen-libm-test.pl with
a new gen-libm-test.py script.  This script should work with all
Python versions supported by glibc (tested by hand with Python 2.7,
tested in the build system with Python 3.5; configure prefers Python 3
if available).

This script is designed to give identical output to gen-libm-test.pl
for ease of verification of the change, except for generated comments
referring to .py instead of .pl.  (That is, identical for actual
inputs passed to the script, not necessarily for all possible input;
for example, this version more precisely follows the C standard syntax
for floating-point constants when deciding when to add LIT macro
calls.)  In one place a comment notes that the generation of
NON_FINITE flags is replicating a bug in the Perl script to assist in
such comparisons (with the expectation that this bug can then be
separately fixed in the Python script later).

Tested for x86_64, including comparison of generated files (and hand
testing of the case of generating a sorted libm-test-ulps file, which
isn't covered by normal "make check").

I'd expect to follow this up by extending the new script to produce
the ulps tables for the manual as well (replacing
manual/libm-err-tab.pl, so that then we just have one ulps file
parser) - at which point the manual build would depend on both Perl
and Python (eliminating the Perl dependency would require someone to
rewrite summary.pl in Python, and that would only eliminate the
*direct* Perl dependency; current makeinfo is written in Perl so there
would still be an indirect dependency).

I think install.texi is more or less equally out-of-date regarding
Perl and Python uses before and after this patch, so I don't think
this patch depends on my patch
<https://sourceware.org/ml/libc-alpha/2018-08/msg00133.html> to update
install.texi regarding such uses (pending review).

	* math/gen-libm-test.py: New file.
	* math/gen-libm-test.pl: Remove.
	* math/Makefile [$(PERL) != no]: Change condition to [PYTHON].
	($(objpfx)libm-test-ulps.h): Use gen-libm-test.py instead of
	gen-libm-test.pl.
	($(libm-test-c-noauto-obj)): Likewise.
	($(libm-test-c-auto-obj)): Likewise.
	($(libm-test-c-narrow-obj)): Likewise.
	(regen-ulps): Likewise.
	* math/README.libm-test: Update references to gen-libm-test.pl.
	* math/libm-test-driver.c (struct test_fj_f_data): Update comment
	referencing gen-libm-test.pl.
	* math/libm-test-nexttoward.inc (nexttoward_test_data): Likewise.
	* math/libm-test-support.c: Likewise.
	* math/libm-test-support.h: Likewise.
	* sysdeps/generic/libm-test-ulps: Likewise.
2018-08-09 15:34:12 +00:00
Samuel Thibault 8ac0f9e6f7 hurd: Avoid PLTs for __pthread_get/setspecific
* sysdeps/htl/pthreadP.h [IS_IN (libpthread)] (__pthread_getspecific,
__pthread_setspecific): Add hidden proto.
* sysdeps/htl/pt-getspecific.c (__pthread_getspecific): Add hidden def.
* sysdeps/htl/pt-setspecific.c (__pthread_setspecific): Add hidden def.
2018-08-09 01:28:55 +02:00
Siddhesh Poyarekar be64b1946b [aarch64] Fix value of MIN_PAGE_SIZE for testing
MIN_PAGE_SIZE is normally set to 4096 but for testing it can be set to
16 so that it exercises the page crossing code for every misaligned
access.  The value was set to 15, which is obviously wrong, so fixed
as obvious and tested.

	* sysdeps/aarch64/strlen.S [TEST_PAGE_CROSS](MIN_PAGE_SIZE):
	Fix value.
2018-08-08 22:47:17 +05:30
Joseph Myers 140137fb2d Move comment from libm-test-nextdown.inc to libm-test-nexttoward.inc.
When libm tests were split into separate per-function .inc files, a
comment relating to the nexttoward tests ended up at the end of
libm-test-nextdown.inc (because the split was based on starting each
function's tests with the <function>_test_data definition, which
failed to allow for comments before such definitions).  This patch
moves that comment to the correct location.

Tested for x86_64.

	* math/libm-test-nextdown.inc (do_test): Move comment to ....
	* math/libm-test-nexttoward.inc (nexttoward_test_data): ... here.
2018-08-08 16:16:59 +00:00
Samuel Thibault b5403eca16 hurd: Add missing symbols for proper libc_get/setspecific
* htl/Versions (__pthread_getspecific, __pthread_setspecific): Add
	symbols.
2018-08-08 01:55:04 +02:00
Siddhesh Poyarekar 014efdd7ea benchtests: Clean up the alloc_bufs
Drop realloc_bufs in favour of making alloc_bufs transparently
reallocate the buffers if it had allocated before.  Also consolidate
computation of buffer lengths so that they don't get repeated on every
reallocation.

	* benchtests/bench-string.h (buf1_size, buf2_size): New
	variables.
	(init_sizes): New function.
	(test_init): Use it.
	(alloc_buf, exit_error): New functions.
	(alloc_bufs): Use ALLOC_BUF.
	(realloc_bufs): Remove.
	* benchtests/bench-memcmp.c (do_test): Adjust.
	* benchtests/bench-memset-large.c (do_test): Likewise.
	* benchtests/bench-memset-walk.c (do_test): Likewise.
	* benchtests/bench-memset.c (do_test): Likewise.
	* benchtests/bench-strncmp.c (do_test): Likewise.
2018-08-08 00:44:56 +05:30
Andreas Schwab 92a4cba760
RISC-V: Don't use ps_get_thread_area in libthread_db (bug 23402)
Since RISC-V stores the thread pointer in a general register libthread_db
can just ask the debugger for the register contents instead of trying to
call ps_get_thread_area.  This enables thread debugging in gdb.

	* sysdeps/riscv/nptl/tls.h (DB_THREAD_SELF): Use REGISTER instead
	of CONST_THREAD_AREA.
2018-08-06 12:51:59 -07:00
H.J. Lu fb4c32aef6 x86: Move STATE_SAVE_OFFSET/STATE_SAVE_MASK to sysdep.h
Move STATE_SAVE_OFFSET and STATE_SAVE_MASK to sysdep.h to make
sysdeps/x86/cpu-features.h a C header file.

	* sysdeps/x86/cpu-features.h (STATE_SAVE_OFFSET): Removed.
	(STATE_SAVE_MASK): Likewise.
	Don't check __ASSEMBLER__ to include <cpu-features-offsets.h>.
	* sysdeps/x86/sysdep.h (STATE_SAVE_OFFSET): New.
	(STATE_SAVE_MASK): Likewise.
	* sysdeps/x86_64/dl-trampoline.S: Include <cpu-features-offsets.h>
	instead of <cpu-features.h>.
2018-08-06 06:25:43 -07:00
DJ Delorie e5721f45f6 Improve ChangeLog message. 2018-08-03 19:24:14 -04:00
DJ Delorie bb17621ab8 Regen RISC-V rvd ULPs
* sysdeps/riscv/rv64/rvd/libm-test-ulps: Update.

Note: I regen'd these from scratch, but I'm only committing the
increases, as I only tested on hardware.  There were a few 2->1
decreases that I omitted, possibly "for now".
2018-08-03 13:52:01 -04:00
DJ Delorie bf41818787 RISC-V: Fix rounding save/restore bug.
* sysdeps/riscv/rvf/math_private.h (libc_feholdexcept_setround_riscv):
Fix rounding save-restore bug.

Fixes about a hundred off-by-ULP failures in the math testsuite.
2018-08-03 13:43:31 -04:00
Joseph Myers ea705eb5ec Consistently terminate libm-test-*.inc TEST lines with commas.
Some TEST_* lines in libm-test-*.inc end with semicolons not commas.
This works at present because gen-libm-test.pl ignores whatever comes
after the TEST_* call, but is logically wrong (since the TEST_* calls
generate array elements, not statements) and the Python replacement
for gen-libm-test.pl that I'm working on is stricter about the syntax
here.  This patch fixes the lines in question to use commas like most
such lines already do.

Tested for x86_64.

	* math/libm-test-ilogb.inc (ilogb_test_data): Use ',' not ';'
	after TEST_* calls.
	* math/libm-test-llogb.inc (llogb_test_data): Likewise.
	* math/libm-test-logb.inc (logb_test_data): Likewise.
2018-08-03 16:56:02 +00:00
Wilco Dijkstra 284f42bc77 Simplify and speedup strstr/strcasestr first match
Looking at the benchtests, both strstr and strcasestr spend a lot of time
in a slow initialization loop handling one character per iteration.
This can be simplified and use the much faster strlen/strnlen/strchr/memcmp.
Read ahead a few cachelines to reduce the number of strnlen calls, which
improves performance by ~3-4%.  This patch improves the time taken for the
full strstr benchtest by >40%.

	* string/strcasestr.c (STRCASESTR): Simplify and speedup first match.
	* string/strstr.c (AVAILABLE): Likewise.
2018-08-03 17:24:12 +01:00
H.J. Lu 430388d5dc x86: Don't include <init-arch.h> in assembly codes
There is no need to include <init-arch.h> in assembly codes since all
x86 IFUNC selector functions are written in C.  Tested on i686 and
x86-64.  There is no code change in libc.so, ld.so and libmvec.so.

	* sysdeps/i386/i686/multiarch/bzero-ia32.S: Don't include
	<init-arch.h>.
	* sysdeps/x86_64/fpu/multiarch/svml_d_sin8_core-avx2.S: Likewise.
	* sysdeps/x86_64/fpu/multiarch/svml_s_expf16_core-avx2.S: Likewise.
	* sysdeps/x86_64/multiarch/memset-sse2-unaligned-erms.S: Likewise.
2018-08-03 08:05:00 -07:00
Carlos O'Donell 6b535b8423 Update be translations. 2018-08-03 10:13:47 -04:00
Carlos O'Donell c5760aa902 Update be translations. 2018-08-03 09:57:00 -04:00
H.J. Lu ae67f2e562 x86: Cleanup cpu-features-offsets.sym
Remove the unused macros.  There is no code changes in libc.so nor
ld.so on i686 and x86-64.

	* sysdeps/x86/cpu-features-offsets.sym
	(rtld_global_ro_offsetof): Removed.
	(CPU_FEATURES_SIZE): Likewise.
	(CPUID_OFFSET): Likewise.
	(CPUID_SIZE): Likewise.
	(CPUID_EAX_OFFSET): Likewise.
	(CPUID_EBX_OFFSET): Likewise.
	(CPUID_ECX_OFFSET): Likewise.
	(CPUID_EDX_OFFSET): Likewise.
	(FAMILY_OFFSET): Likewise.
	(MODEL_OFFSET): Likewise.
	(FEATURE_OFFSET): Likewise.
	(FEATURE_SIZ): Likewise.
	(COMMON_CPUID_INDEX_1): Likewise.
	(COMMON_CPUID_INDEX_7): Likewise.
	(FEATURE_INDEX_1): Likewise.
	(RTLD_GLOBAL_RO_DL_X86_CPU_FEATURES_OFFSET): Updated.
2018-08-03 06:42:09 -07:00
Carlos O'Donell cfb0ff932e Fix ChangeLog date. 2018-08-02 15:32:23 -04:00
Carlos O'Donell 08a5ee14c6 Add convenience target 'install-locale-files'.
The convenience install target 'install-locale-files' is created
to allow distributions to install all of the SUPPORTED locales as
files instead of into the locale-archive.

You invoke the new convenience target like this:
make localedata/install-locale-files DESTDIR=<prefix>
2018-08-02 15:31:12 -04:00
Siddhesh Poyarekar d67d634bef [benchtests] Fix compare_strings.py for python2
Python 2 does not have a FileNotFoundError so drop it in favour of
simply printing out the last (and most informative) line of the
exception.

	* benchtests/scripts/compare_strings.py: Import traceback.
	(parse_file): Pretty-print error.
2018-08-03 00:26:45 +05:30
Siddhesh Poyarekar 525691bde3 Add ChangeLog for the last commit 2018-08-02 23:56:18 +05:30
Joseph Myers 506d7fb1d4 Do not define various fenv.h macros for MIPS soft-float (bug 23479).
MIPS soft-float glibc does not support floating-point exceptions and
rounding modes, and uses a different ABI from hard-float so a
soft-float compilation cannot use a glibc that does support
floating-point exceptions and rounding modes.  Thus, bits/fenv.h
should not, when compiling for soft-float, define macros for the
unsupported features.

This patch changes it accordingly to define those macros only for
hard-float.  None of the exception macros are defined for soft-float,
with FE_ALL_EXCEPT defined to 0 in that case, and only FE_TONEAREST is
defined of the rounding-mode macros, and FE_NOMASK_ENV is not defined;
this is consistent with how architectures lacking exception and
rounding mode support generally define things in this header.  As well
as making the header more correct for this case, this also means the
generic math_private.h optimizations for this case automatically apply
(inlining libm-internal fenv.h function calls that are trivial when
exceptions and rounding modes are not supported).

The mips64 sfp-machine.h then needs similar changes to disable more of
the exception and rounding mode handling for soft-float.  (The mips32
sfp-machine.h is already used only for soft-float, has no integration
with hardware exceptions or rounding modes and so needs no changes.)

Existing binaries might use the old FE_NOMASK_ENV value as an argument
to fesetenv / feupdateenv and expect an error for it (given that it
was defined in a header that also defined FE_ALL_EXCEPT to a nonzero
value).  To preserve that error, wrappers for the fallback fesetenv
and feupdateenv are created in sysdeps/mips/nofpu/.

Tested for mips64 (hard-float and soft-float, all three ABIs).

	[BZ #23479]
	* sysdeps/mips/bits/fenv.h (FE_INEXACT): Define only if
	[__mips_hard_float].
	(FE_UNDERFLOW): Likewise.
	(FE_OVERFLOW): Likewise.
	(FE_DIVBYZERO): Likewise.
	(FE_INVALID): Likewise.
	(FE_ALL_EXCEPT): Define to 0 if [!__mips_hard_float].
	(FE_TOWARDZERO): Define only if [__mips_hard_float].
	(FE_UPWARD): Likewise.
	(FE_DOWNWARD): Likewise.
	(__FE_UNDEFINED): Define if [!__mips_hard_float]
	(FE_NOMASK_ENV): Define only if [__mips_hard_float].
	* sysdeps/mips/mips64/sfp-machine.h (_FP_DECL_EX): Define only if
	[__mips_hard_float].
	(FP_ROUNDMODE): Likewise.
	(FP_RND_NEAREST): Likewise.
	(FP_RND_ZERO): Likewise.
	(FP_RND_PINF): Likewise.
	(FP_RND_MINF): Likewise.
	(FP_EX_INVALID): Likewise.
	(FP_EX_OVERFLOW): Likewise.
	(FP_EX_UNDERFLOW): Likewise.
	(FP_EX_DIVZERO): Likewise.
	(FP_EX_INEXACT): Likewise.
	(FP_INIT_ROUNDMODE): Likewise.
	* sysdeps/mips/nofpu/fesetenv.c: New file.
	* sysdeps/mips/nofpu/feupdateenv.c: Likewise.
2018-08-02 15:53:29 +00:00
Joseph Myers f6dcefbe60 Fix math/test-misc.c for undefined fenv.h macros.
math/test-misc.c contains some code that uses fenv.h macros
FE_UNDERFLOW, FE_OVERFLOW and FE_UPWARD without being conditional on
those macros being defined.

That would normally break the build for configurations (typically
soft-float) not defining those macros.  However, the code in question
is inside LDBL_MANT_DIG > DBL_MANT_DIG conditionals.  And, while we
have configurations lacking rounding mode and exception support where
LDBL_MANT_DIG > DBL_MANT_DIG (soft-float MIPS64 and RISC-V), those
configurations currently define the fenv.h macros in question even for
soft-float.

There may be some case for defining those macros in cases where a
soft-float compilation could use a hard-float libm (where both
soft-float and hard-float can use the same ABI, as on ARM and RISC-V,
for example).  But MIPS is not such a case - the hard-float and
soft-float ABIs are incompatible - and thus I am testing a patch to
stop defining those macros for soft-float MIPS (motivated by reducing
the extent to which architectures need their own definitions of
math-tests.h macros - if lack of rounding mode / exception support can
be determined by the lack of macros in fenv.h, that avoids the need
for math-tests.h to declare that lack as well).  Introducing a case of
LDBL_MANT_DIG > DBL_MANT_DIG without these macros defined shows up the
problem with math/test-misc.c.  This patch then fixes that problem by
adding appropriate conditionals.

Tested for MIPS64 in conjunction with changes to stop defining the
macros in question in bits/fenv.h for soft-float.

	* math/test-misc.c (do_test) [LDBL_MANT_DIG > DBL_MANT_DIG]: Make
	code using FE_UNDERFLOW conditional on [FE_UNDERFLOW], code using
	FE_OVERFLOW conditional on [FE_OVERFLOW] and code using FE_UPWARD
	conditional on [FE_UPWARD].
2018-08-01 22:22:00 +00:00
Paul Eggert fa67ba06ee regex: fix memory leak in Gnulib
Problem and fix reported by Assaf Gordon in:
https://lists.gnu.org/r/bug-gnulib/2018-07/txtqLKNwBdefE.txt
* posix/regcomp.c (free_charset) [!_LIBC]: Free range_starts and
range_ends members too, as they are defined in 'struct
re_charset_t' even if not _LIBC.  This affects only Gnulib.
2018-08-01 13:22:58 -07:00
H.J. Lu 82c80ac2eb x86: Rename get_common_indeces to get_common_indices
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86/cpu-features.c (get_common_indeces): Renamed to
	...
	(get_common_indices): This.
	(init_cpu_features): Updated.
2018-08-01 04:57:50 -07:00
Joseph Myers 46f8cf5712 Move SNAN_TESTS_PRESERVE_PAYLOAD out of math-tests.h.
Continuing moving macros out of math-tests.h to smaller headers
following typo-proof conventions instead of using #ifndef, this patch
moves SNAN_TESTS_PRESERVE_PAYLOAD out to its own sysdeps header.

Tested with build-many-glibcs.py.

	* sysdeps/generic/math-tests-snan-payload.h: New file.
	* sysdeps/hppa/math-tests-snan-payload.h: Likewise.
	* sysdeps/mips/math-tests-snan-payload.h: Likewise.
	* sysdeps/riscv/math-tests-snan-payload.h: Likewise.
	* sysdeps/generic/math-tests.h: Include
	<math-tests-snan-payload.h>.
	(SNAN_TESTS_PRESERVE_PAYLOAD): Do not define macro here.
	* sysdeps/hppa/math-tests.h: Remove file.
	* sysdeps/mips/math-tests.h [!__mips_nan2008]
	(SNAN_TESTS_PRESERVE_PAYLOAD): Do not define macro here.
	* sysdeps/riscv/math-tests.h (SNAN_TESTS_PRESERVE_PAYLOAD):
	Likewise.
2018-08-01 11:21:16 +00:00
Joseph Myers c0e7e2c127 Move SNAN_TESTS_TYPE_CAST out of math-tests.h.
The math-tests.h header has many different macros and groups of
macros, defined using #ifndef in the generic version which is included
by architecture versions with #include_next after possibly defining
non-default versions of some of those macros.

This use of #ifndef is contrary to our normal typo-proof conventions
for macro definitions.  This patch moves one of the macros,
SNAN_TESTS_TYPE_CAST, out to its own sysdeps header, to follow those
typo-proof conventions more closely.

Tested with build-many-glibcs.py.

2018-08-01  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/generic/math-tests-snan-cast.h: New file.
	* sysdeps/powerpc/math-tests-snan-cast.h: Likewise.
	* sysdeps/generic/math-tests.h: Include <math-tests-snan-cast.h>.
	(SNAN_TESTS_TYPE_CAST): Do not define macro here.
	* sysdeps/powerpc/math-tests.h (SNAN_TESTS_TYPE_CAST): Likewise.
2018-08-01 11:18:57 +00:00
Carlos O'Donell b029723b80 Add version.h, and NEWS update to ChangeLog. 2018-08-01 01:44:08 -04:00
Carlos O'Donell 3c03baca37 Update NEWS, version.h, and features.h for glibc 2.28. 2018-08-01 01:10:47 -04:00
Carlos O'Donell 74939c83d0 Synchronize translation project PO files. 2018-08-01 01:01:42 -04:00
Samuel Thibault 42fc12ef73 hurd: Fix exec usage of mach_setup_thread
Exec needs that mach_setup_thread does *not* set up TLS since it works on
another task, so we have to split this into mach_setup_tls.

	* mach/mach.h (__mach_setup_tls, mach_setup_tls): Add prototypes.
	* mach/setup-thread.c (__mach_setup_thread): Move TLS setup to...
	(__mach_setup_tls): ... new function.
	(mach_setup_tls): New alias.
	* hurd/hurdsig.c (_hurdsig_init): Call __mach_setup_tls after
	__mach_setup_thread.
	* sysdeps/mach/hurd/profil.c (update_waiter): Likewise.
	* sysdeps/mach/hurd/setitimer.c (setitimer_locked): Likewise.
	* mach/Versions [libc] (mach_setup_tls): Add symbol.
	* sysdeps/mach/hurd/i386/libc.abilist (mach_setup_tls): Likewise.
2018-08-01 00:10:03 +02:00
Samuel Thibault d4b54bdff0 hurd: Add missing ChangeLog entry 2018-08-01 00:07:29 +02:00
Carlos O'Donell f650932b34 Update tooling versions verified to work with glibc. 2018-07-31 16:37:07 -04:00
Carlos O'Donell 6cca855e7e Update contrib.texi contributions. 2018-07-31 15:34:30 -04:00
Carlos O'Donell 07fdea47d8 Update translation for be. 2018-07-31 15:34:30 -04:00
Adhemerval Zanella 63d5fad404 Update SH libm-tests-ulps
* sysdeps/sh/libm-test-ulps: Update.
2018-07-31 10:33:53 -03:00
Carlos O'Donell 1ff712a678 Update translations for bg, de, hr, pt_BR, sv, and vi. 2018-07-31 08:19:08 -04:00
H.J. Lu 98864ed0e0 x86/CET: Fix property note parser [BZ #23467]
GNU_PROPERTY_X86_FEATURE_1_AND may not be the first property item.  We
need to check each property item until we reach the end of the property
or find GNU_PROPERTY_X86_FEATURE_1_AND.

This patch adds 2 tests.  The first test checks if IBT is enabled and
the second test reads the output from the first test to check if IBT
is is enabled.  The second second test fails if IBT isn't enabled
properly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #23467]
	* sysdeps/unix/sysv/linux/x86/Makefile (tests): Add
	tst-cet-property-1 and tst-cet-property-2 if CET is enabled.
	(CFLAGS-tst-cet-property-1.o): New.
	(ASFLAGS-tst-cet-property-dep-2.o): Likewise.
	($(objpfx)tst-cet-property-2): Likewise.
	($(objpfx)tst-cet-property-2.out): Likewise.
	* sysdeps/unix/sysv/linux/x86/tst-cet-property-1.c: New file.
	* sysdeps/unix/sysv/linux/x86/tst-cet-property-2.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/tst-cet-property-dep-2.S: Likewise.
	* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Parse
	each property item until GNU_PROPERTY_X86_FEATURE_1_AND is found.
2018-07-30 16:15:38 -07:00
H.J. Lu c92a00d865 x86: Add tst-get-cpu-features-static to $(tests) [BZ #23458]
All tests should be added to $(tests).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #23458]
	* sysdeps/x86/Makefile (tests): Add tst-get-cpu-features-static.
2018-07-30 16:11:19 -07:00
Samuel Thibault af86087f02 hurd: Fix some ld.so symbol override from libc
ld.so symbols to be overriden by libc need to be extern to really get
overriden.

	* sysdeps/mach/hurd/not-errno.h: New file.
	* sysdeps/mach/hurd/i386/localplt.data: Update accordingly.
2018-07-28 15:12:42 +02:00
Samuel Thibault 99bc624136 hurd: Fix some ld.so symbol override from libc
ld.so symbols to be overriden by libc need to be extern to really get
overriden.

	* sysdeps/mach/hurd/dl-unistd.h (__access, __brk, __lseek, __read,
	__sbrk): Do not set attribute_hidden.
	* sysdeps/mach/hurd/i386/ld.abilist: Update accordingly.
	* sysdeps/mach/hurd/i386/localplt.data: Update accordingly.
2018-07-28 14:57:10 +02:00
Carlos O'Donell bcb1c4afd8 Update translations for cs, pl, and uk. 2018-07-27 20:35:51 -04:00
H.J. Lu 4591b7db23 x86/CET: Don't parse beyond the note end
Simply check if "ptr < ptr_end" since "ptr" is always incremented by 8.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86/dl-prop.h (_dl_process_cet_property_note): Don't
	parse beyond the note end.
2018-07-27 13:23:31 -07:00
Adhemerval Zanella 2c6da2f487 Fix Linux fcntl OFD locks on unsupported kernels
This patch make the OFD tests return unsupported if kernel does not
support OFD locks (it was added on 3.15).

Checked on a ia64-linux-gnu with Linux 3.14.

	* sysdeps/unix/sysv/linux/tst-ofdlocks.c: Return unsupported if
	kernel does not support OFD locks.
	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Likewise.
2018-07-27 14:48:06 -03:00
H.J. Lu da80612d61 Add the missing ChangeLog entry for commit be525a69a6 2018-07-27 10:28:30 -07:00
Samuel Thibault 20365a315b hurd: Fix some ld.so symbol override from libc
ld.so symbols to be overriden by libc need to be extern to really get
overriden.

More fixes are needed to avoid the hidden attribute.

	* sysdeps/mach/hurd/Versions (libc): Make __access and
	__access_noerrno external so they can override the ld symbols.
	(ld): Make __access, __read, __sbrk, __strtoul_internal, __write,
	__writev, __open64, __access_noerrno extern so they can be overrided.
	* sysdeps/mach/hurd/i386/libc.abilist: Update accordingly.
	* sysdeps/mach/hurd/i386/ld.abilist: Update accordingly.
2018-07-27 11:18:29 +02:00
Carlos O'Donell cb1a43db05 Update libc.pot. 2018-07-26 22:21:34 -04:00
Joseph Myers 74759ae5b6 Update powerpc-nofpu ulps.
* sysdeps/powerpc/nofpu/libm-test-ulps: Update.
2018-07-26 22:51:06 +00:00
H.J. Lu 65d87ade1e x86: Correct index_cpu_LZCNT [BZ # 23456]
cpu-features.h has

 #define bit_cpu_LZCNT		(1 << 5)
 #define index_cpu_LZCNT	COMMON_CPUID_INDEX_1
 #define reg_LZCNT

But the LZCNT feature bit is in COMMON_CPUID_INDEX_80000001:

Initial EAX Value: 80000001H
ECX Extended Processor Signature and Feature Bits:
Bit 05: LZCNT available

index_cpu_LZCNT should be COMMON_CPUID_INDEX_80000001, not
COMMON_CPUID_INDEX_1.  The VMX feature bit is in COMMON_CPUID_INDEX_1:

Initial EAX Value: 01H
Feature Information Returned in the ECX Register:
5 VMX

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ # 23456]
	* sysdeps/x86/cpu-features.h (index_cpu_LZCNT): Set to
	COMMON_CPUID_INDEX_80000001.
2018-07-26 11:10:44 -07:00
Stefan Liebler c9dc4d5117 Fix string/tst-xbzero-opt if build with gcc head.
On s390x, the test string/tst-xbzero-opt is failing if build with gcc head:
FAIL: no clear/prepare: expected 32 got 0
FAIL: no clear/test: expected some got 0
FAIL: ordinary clear/prepare: expected 32 got 0
INFO: ordinary clear/test: found 0 patterns (memset not eliminated)
PASS: explicit clear/prepare: expected 32 got 32
PASS: explicit clear/test: expected 0 got 0

In setup_no_clear / setup_ordinary_clear, GCC is omitting the memcpy loop
in prepare_test_buffer. Thus count_test_patterns does not find any of the
test_pattern.

This patch calls use_test_buffer in order to force the compiler to really copy
the pattern to buf.

ChangeLog:

	* string/tst-xbzero-opt.c (use_test_buffer): New function.
	(prepare_test_buffer): Call use_test_buffer as compiler barrier.
2018-07-26 17:09:44 +02:00
Florian Weimer cfba5dbb10 htl: Use weak aliases for public symbols
Strong definitions of flockfile, funlockfile, ftrylockfile can conflict
with application symbols when linking statically.
2018-07-26 08:34:05 +02:00
Carlos O'Donell 7cd7d36f1f Keep expected behaviour for [a-z] and [A-z] (Bug 23393).
In commit 9479b6d5e0 we updated all of
the collation data to harmonize with the new version of ISO 14651
which is derived from Unicode 9.0.0.  This collation update brought
with it some changes to locales which were not desirable by some
users, in particular it altered the meaning of the
locale-dependent-range regular expression, namely [a-z] and [A-Z], and
for en_US it caused uppercase letters to be matched by [a-z] for the
first time.  The matching of uppercase letters by [a-z] is something
which is already known to users of other locales which have this
property, but this change could cause significant problems to en_US
and other similar locales that had never had this change before.
Whether this behaviour is desirable or not is contentious and GNU Awk
has this to say on the topic:
https://www.gnu.org/software/gawk/manual/html_node/Ranges-and-Locales.html
While the POSIX standard also has this further to say: "RE Bracket
Expression":
http://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_xbd_chap09.html
"The current standard leaves unspecified the behavior of a range
expression outside the POSIX locale. ... As noted above, efforts were
made to resolve the differences, but no solution has been found that
would be specific enough to allow for portable software while not
invalidating existing implementations."
In glibc we implement the requirement of ISO POSIX-2:1993 and use
collation element order (CEO) to construct the range expression, the
API internally is __collseq_table_lookup().  The fact that we use CEO
and also have 4-level weights on each collation rule means that we can
in practice reorder the collation rules in iso14651_t1_common (the new
data) to provide consistent range expression resolution *and* the
weights should maintain the expected total order.  Therefore this
patch does three things:

* Reorder the collation rules for the LATIN script in
  iso14651_t1_common to deinterlace uppercase and lowercase letters in
  the collation element orders.

* Adds new test data en_US.UTF-8.in for sort-test.sh which exercises
  strcoll* and strxfrm* and ensures the ISO 14651 collation remains.

* Add back tests to tst-fnmatch.input and tst-regexloc.c which
  exercise that [a-z] does not match A or Z.

The reordering of the ISO 14651 data is done in an entirely mechanical
fashion using the following program attached to the bug:
https://sourceware.org/bugzilla/show_bug.cgi?id=23393#c28

It is up for discussion if the iso14651_t1_common data should be
refined further to have 3 very tight collation element ranges that
include only a-z, A-Z, and 0-9, which would implement the solution
sought after in:
https://sourceware.org/bugzilla/show_bug.cgi?id=23393#c12
and implemented here:
https://www.sourceware.org/ml/libc-alpha/2018-07/msg00854.html

No regressions on x86_64.
Verified that removal of the iso14651_t1_common change causes tst-fnmatch
to regress with:
422: fnmatch ("[a-z]", "A", 0) = 0 (FAIL, expected FNM_NOMATCH) ***
...
425: fnmatch ("[A-Z]", "z", 0) = 0 (FAIL, expected FNM_NOMATCH) ***
2018-07-25 17:00:45 -04:00
H.J. Lu 3fb455b318 ia64: Work around incorrect type of IA64 uc_sigmask
Work around:

https://sourceware.org/bugzilla/show_bug.cgi?id=21634

	* sysdeps/unix/sysv/linux/ia64/tst-setcontext4.c: New file.
2018-07-25 13:55:26 -07:00
Adhemerval Zanella d6499b7039 Fix ISO C threads installed header and HURD assumption
Set installed NPTL header as the expected one (instead of an
internal one for glibc testsuite) and add a hurd specific
stdc-predef with __STDC_NO_THREADS__.

Checked on both i686-linux-gnu and i686-gnu that both threads.h
and stdc-predef.h are the expected ones.

	* nptl/threads.h: Move to ...
	* sysdeps/nptl/threads.h: ... here.
	* sysdeps/hurd/stdc-predef.h: New file.
2018-07-25 17:27:45 -03:00
H.J. Lu 08ac6bed14 x86/CET: Add a setcontext test for CET
Verify that setcontext works with gaps above and below the newly
allocated shadow stack.

	* sysdeps/unix/sysv/linux/x86/Makefile (tests): Add
	tst-cet-setcontext-1 if CET is enabled.
	(CFLAGS-tst-cet-setcontext-1.c): Add -mshstk.
	* sysdeps/unix/sysv/linux/x86/tst-cet-setcontext-1.c: New file.
2018-07-25 08:40:50 -07:00
Adhemerval Zanella 9faaf93850 Fix C11 conformance issues
Remove conformace assumption of NPTL implementation for ISO C threads
and revert wrong libcrypt addition on linknamespace-libs-XPG4.

The i686-gnu target now shows two new conformance failures:

FAIL: conform/ISO11/threads.h/conform
FAIL: conform/ISO11/threads.h/linknamespace

It is expected due missing HTL ISO C threads support and both conformance
.out files indicates the reason ("#error "HTL does not implement ISO C
threads").

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

	* include/threads.h: Move to ...
	* sysdeps/nptl/threads.h: ... here.
	* sysdeps/htl/threads.h: New file.
	* conform/Makefile (linknamespace-libs-ISO11): Use
	static-thread-library instead of linking libpthread.
	(linknamespace-libs-XPG4): Revert wrong libcrypt.a addition.
2018-07-25 12:02:32 -03:00
Florian Weimer d6b8f84709 C11 threads: Fix timeout and locking issues 2018-07-25 16:31:45 +02:00
H.J. Lu 25123a1c5c x86-64/CET: Extend ucontext_t to save shadow stack
This patch adds a field to ucontext_t to save shadow stack:

1. getcontext and swapcontext are updated to save the caller's shadow
stack pointer and return addresses.
2. setcontext and swapcontext are updated to restore shadow stack and
jump to new context directly.
3. makecontext is updated to allocate a new shadow stack and set the
caller's return address to __start_context.

Since makecontext allocates a new shadow stack when making a new
context and kernel allocates a new shadow stack for clone/fork/vfork
syscalls, we track the current shadow stack base.  In setcontext and
swapcontext, if the target shadow stack base is the same as the current
shadow stack base, we unwind the shadow stack.  Otherwise it is a stack
switch and we look for a restore token.

We enable shadow stack at run-time only if program and all used shared
objects, including dlopened ones, are shadow stack enabled, which means
that they must be compiled with GCC 8 or above and glibc 2.28 or above.
We need to save and restore shadow stack only if shadow stack is enabled.
When caller of getcontext, setcontext, swapcontext and makecontext is
compiled with smaller ucontext_t, shadow stack won't be enabled at
run-time.  We check if shadow stack is enabled before accessing the
extended field in ucontext_t.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/x86/sys/ucontext.h (ucontext_t): Add
	__ssp.
	* sysdeps/unix/sysv/linux/x86_64/__start_context.S: Include
	<asm/prctl.h> and "ucontext_i.h" when shadow stack is enabled.
	(__push___start_context): New.
	* sysdeps/unix/sysv/linux/x86_64/getcontext.S: Include
	<asm/prctl.h>.
	(__getcontext): Record the current shadow stack base.  Save the
	caller's shadow stack pointer and base.
	* sysdeps/unix/sysv/linux/x86_64/makecontext.c: Include
	<pthread.h>, <libc-pointer-arith.h> and <sys/prctl.h>.
	(__push___start_context): New prototype.
	(__makecontext): Call __push___start_context to allocate a new
	shadow stack, push __start_context onto the new stack as well
	as the new shadow stack.
	* sysdeps/unix/sysv/linux/x86_64/setcontext.S: Include
	<asm/prctl.h>.
	(__setcontext): Restore the target shadow stack.
	* sysdeps/unix/sysv/linux/x86_64/swapcontext.S: Include
	<asm/prctl.h>.
	(__swapcontext): Record the current shadow stack base.  Save
	the caller's shadow stack pointer and base.  Restore the target
	shadow stack.
	* sysdeps/unix/sysv/linux/x86_64/sysdep.h
	(STACK_SIZE_TO_SHADOW_STACK_SIZE_SHIFT): New.
	* sysdeps/unix/sysv/linux/x86_64/ucontext_i.sym (oSSP): New.
2018-07-25 06:37:31 -07:00
H.J. Lu 375a484459 Add tests for setcontext on the context from makecontext
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* stdlib/Makefile ((tests): Add tst-setcontext6, tst-setcontext7,
	tst-setcontext8 and tst-setcontext9.
	* stdlib/tst-setcontext6.c: New file.
	* stdlib/tst-setcontext7.c: Likewise.
	* stdlib/tst-setcontext8.c: Likewise.
	* stdlib/tst-setcontext9.c: Likewise.
2018-07-25 05:13:16 -07:00
H.J. Lu bd4f7903df Add a test for multiple setcontext calls
Check multiple setcontext calls.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>.

	* stdlib/Makefile ((tests): Add tst-setcontext5.
	* stdlib/tst-setcontext5.c: New file.
2018-07-25 05:00:30 -07:00
H.J. Lu 7e28f20345 Add another test for setcontext
Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* stdlib/Makefile (tests): Add tst-setcontext4.
	* stdlib/tst-setcontext4.c: New file.
2018-07-25 04:57:21 -07:00
H.J. Lu 8516ad2de3 Add a test for multiple makecontext calls
Check multiple makecontext calls.

	* stdlib/Makefile (tests): Add tst-swapcontext1.
	* stdlib/tst-swapcontext1.c: New test.
2018-07-25 04:54:00 -07:00
H.J. Lu fddcd00377 x86/CET: Add tests with legacy non-CET shared objects
Check binary compatibility of CET-enabled executables:

1. When CET-enabled executable is used with legacy non-CET shared object
at run-time, ld.so should disable SHSTK and put legacy non-CET shared
objects in legacy bitmap.
2. When IBT-enabled executable dlopens legacy non-CET shared object,
ld.so should put legacy shared object in legacy bitmap.
3. Use GLIBC_TUNABLES=glibc.tune.x86_shstk=[on|off|permissive] to
control how SHSTK is enabled.

	* sysdeps/x86/Makefile (tests): Add tst-cet-legacy-1,
	tst-cet-legacy-2, tst-cet-legacy-2a, tst-cet-legacy-3,
	tst-cet-legacy-4, tst-cet-legacy-4a, tst-cet-legacy-4b
	and tst-cet-legacy-4c.
	(modules-names): Add tst-cet-legacy-mod-1, tst-cet-legacy-mod-2
	and tst-cet-legacy-mod-4.
	(CFLAGS-tst-cet-legacy-2.c): New.
	(CFLAGS-tst-cet-legacy-mod-1.c): Likewise.
	(CFLAGS-tst-cet-legacy-mod-2.c): Likewise.
	(CFLAGS-tst-cet-legacy-3.c): Likewise.
	(CFLAGS-tst-cet-legacy-4.c): Likewise.
	(CFLAGS-tst-cet-legacy-mod-4.c): Likewise.
	($(objpfx)tst-cet-legacy-1): Likewise.
	($(objpfx)tst-cet-legacy-2): Likewise.
	($(objpfx)tst-cet-legacy-2.out): Likewise.
	($(objpfx)tst-cet-legacy-2a): Likewise.
	($(objpfx)tst-cet-legacy-2a.out): Likewise.
	($(objpfx)tst-cet-legacy-4): Likewise.
	($(objpfx)tst-cet-legacy-4.out): Likewise.
	($(objpfx)tst-cet-legacy-4a): Likewise.
	($(objpfx)tst-cet-legacy-4a.out): Likewise.
	(tst-cet-legacy-4a-ENV): Likewise.
	($(objpfx)tst-cet-legacy-4b): Likewise.
	($(objpfx)tst-cet-legacy-4b.out): Likewise.
	(tst-cet-legacy-4b-ENV): Likewise.
	($(objpfx)tst-cet-legacy-4c): Likewise.
	($(objpfx)tst-cet-legacy-4c.out): Likewise.
	(tst-cet-legacy-4c-ENV): Likewise.
	* sysdeps/x86/tst-cet-legacy-1.c: New file.
	* sysdeps/x86/tst-cet-legacy-2.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-2a.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-3.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4a.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4b.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-4c.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-mod-1.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-mod-2.c: Likewise.
	* sysdeps/x86/tst-cet-legacy-mod-4.c: Likewise.
2018-07-25 04:47:05 -07:00
H.J. Lu 9aa3113a42 x86: Rename __glibc_reserved2 to ssp_base in tcbhead_t
This will be used to record the current shadow stack base for shadow
stack switching by getcontext, makecontext, setcontext and swapcontext.
If the target shadow stack base is the same as the current shadow stack
base, we unwind the shadow stack.  Otherwise it is a stack switch and
we look for a restore token to restore the target shadow stack.

	* sysdeps/i386/nptl/tcb-offsets.sym (SSP_BASE_OFFSET): New.
	* sysdeps/i386/nptl/tls.h (tcbhead_t): Replace __glibc_reserved2
	with ssp_base.
	* sysdeps/x86_64/nptl/tcb-offsets.sym (SSP_BASE_OFFSET): New.
	* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Replace __glibc_reserved2
	with ssp_base.
2018-07-25 04:39:39 -07:00
Andreas Schwab 9c79cec8cd Fix out of bounds access in findidxwc (bug 23442)
If usrc is a prefix of cp but one character shorter an out of bounds
access to usrc was done.
2018-07-25 10:50:03 +02:00
Adhemerval Zanella 969c335506 Mention ISO C threads addition
* NEWS: Add ISO C threads addition.
2018-07-24 19:35:03 -03:00
Florian Weimer e0f9c462d8 alpha: mlock2, copy_file_range syscalls were introduced in kernel 4.13 2018-07-24 22:38:39 +02:00
H.J. Lu 394df3815e x86/CET: Extend arch_prctl syscall for CET control
CET arch_prctl bits should be defined in <asm/prctl.h> from Linux kernel
header files.  Add x86 <include/asm/prctl.h> for pre-CET kernel header
files.

Note: sysdeps/unix/sysv/linux/x86/include/asm/prctl.h should be removed
if <asm/prctl.h> from the required kernel header files contains CET
arch_prctl bits.

 /* CET features:
    IBT:   GNU_PROPERTY_X86_FEATURE_1_IBT
    SHSTK: GNU_PROPERTY_X86_FEATURE_1_SHSTK
  */

 /* Return CET features in unsigned long long *addr:
      features: addr[0].
      shadow stack base address: addr[1].
      shadow stack size: addr[2].
  */
 # define ARCH_CET_STATUS		0x3001
 /* Disable CET features in unsigned int features.  */
 # define ARCH_CET_DISABLE		0x3002
 /* Lock all CET features.  */
 # define ARCH_CET_LOCK			0x3003
 /* Allocate a new shadow stack with unsigned long long *addr:
      IN: requested shadow stack size: *addr.
      OUT: allocated shadow stack address: *addr.
  */
 # define ARCH_CET_ALLOC_SHSTK		0x3004
 /* Return legacy region bitmap info in unsigned long long *addr:
     address: addr[0].
     size: addr[1].
  */
 # define ARCH_CET_LEGACY_BITMAP	0x3005

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/x86/include/asm/prctl.h: New file.
	* sysdeps/unix/sysv/linux/x86/cpu-features.c: Include
	<sys/prctl.h> and <asm/prctl.h>.
	(get_cet_status): Call arch_prctl with ARCH_CET_STATUS.
	* sysdeps/unix/sysv/linux/x86/dl-cet.h: Include <sys/prctl.h>
	and <asm/prctl.h>.
	(dl_cet_allocate_legacy_bitmap): Call arch_prctl with
	ARCH_CET_LEGACY_BITMAP.
	(dl_cet_disable_cet): Call arch_prctl with ARCH_CET_DISABLE.
	(dl_cet_lock_cet): Call arch_prctl with ARCH_CET_LOCK.
	* sysdeps/x86/libc-start.c: Include <startup.h>.
2018-07-24 12:23:17 -07:00
Florian Weimer 465455306f sh: Do not define __ASSUME_STATX 2018-07-24 21:05:07 +02:00
Rical Jasan 9d0a979e5d Add manual documentation for threads.h
This patch updates the manual and adds a new chapter to the manual,
explaining types macros, constants and functions defined by ISO C11
threads.h standard.

	[BZ# 14092]
	* manual/debug.texi: Update adjacent chapter name.
	* manual/probes.texi: Likewise.
	* manual/threads.texi (ISO C Threads): New section.
	(POSIX Threads): Convert to a section.
2018-07-24 14:07:31 -03:00
Adhemerval Zanella 0a07288b13 nptl: Add test cases for ISO C11 threads
This patch adds to testsuite new test cases to test all new introduced
C11 threads functions, types and macros are tested.

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,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	Adhemerval Zanella  <adhemerval.zanella@linaro.org>
	Juan Manuel Torres Palma  <jmtorrespalma@gmail.com>

	[BZ #14092]
	* nptl/Makefile (tests): Add new test files.
	* nptl/tst-call-once.c : New file. Tests C11 functions and types.
	* nptl/tst-cnd-basic.c: Likewise.
	* nptl/tst-cnd-broadcast.c: Likewise.
	* nptl/tst-cnd-timedwait.c: Likewise.
	* nptl/tst-mtx-basic.c: Likewise.
	* nptl/tst-mtx-recursive.c: Likewise.
	* nptl/tst-mtx-timedlock.c: Likewise.
	* nptl/tst-mtx-trylock.c: Likewise.
	* nptl/tst-thrd-basic.c: Likewise.
	* nptl/tst-thrd-detach.c: Likewise.
	* nptl/tst-thrd-sleep.c: Likewise.
	* nptl/tst-tss-basic.c: Likewise.
2018-07-24 14:07:25 -03:00
Adhemerval Zanella c6dd669bed nptl: Add abilist symbols for C11 threads
This patch adds the required abilist symbols for C11 thread support.

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,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist [GLIBC_2.28]
	(thrd_current, thrd_equal, thrd_sleep, thrd_yield): Add C11 thread
	symbols.
	* 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/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/riscv/rv64/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/x86_64/64/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist [[GLIBC_2.28]
	(call_once, cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
	cnd_timedwait, cnd_wait, mtx_destroy, mtx_init, mtx_lock,
	mtx_timedlock, mtx_trylock, mtx_unlokc, thrd_create, thrd_detach,
	thrd_exit, thrd_join, tss_create, tss_delete, tss_get, tss_set):
	Likewise.
	* sysdeps/unix/sysv/linux/aarch64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/alpha/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/arm/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/hppa/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/i386/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/ia64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/coldfire/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/m68k/m680x0/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/microblaze/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/mips/mips64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/nios2/libpthread.abilist: Likewise.
	ikewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/libpthread.abilist:
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread-le.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libpthread.abilist:
	Likewise.
	* sysdeps/unix/sysv/linux/riscv/rv64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/s390/s390-64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sh/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc32/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/sparc/sparc64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/64/libpthread.abilist: Likewise.
	* sysdeps/unix/sysv/linux/x86_64/x32/libpthread.abilist: Likewise.
2018-07-24 14:07:18 -03:00
Adhemerval Zanella 78d401327f nptl: Add C11 threads tss_* functions
This patch adds the tss_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically tss_create, tss_delete, tss_get, tss_set, and required
types.

Mostly of the definitions are composed based on POSIX conterparts, including
tss_t (pthread_key_t).

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,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (thread_local): New macro.
	(TSS_DTOR_ITERATIONS): Likewise.
	(tss_t): New type.
	(tss_dtor_t): Likewise.
	(tss_create): New function.
	(tss_get): Likewise.
	(tss_set): Likewise.
	(tss_delete): Likewise.
	* nptl/Makefile (libpthread-routines): Add tss_create, tss_delete,
	tss_get, and tss_set objects.
	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
	* nptl/tss_create.c: New file.
	* nptl/tss_delete.c: Likewise.
	* nptl/tss_get.c: Likewise.
	* nptl/tss_set.c: Likewise.
	* sysdeps/nptl/threads.h (thread_local): New define.
	(TSS_DTOR_ITERATIONS): Likewise.
	(tss_t): New typedef.
	(tss_dtor_t): Likewise.
	(tss_create): New prototype.
	(tss_get): Likewise.
	(tss_set): Likewise.
	(tss_delete): Likewise.
2018-07-24 14:07:12 -03:00
Adhemerval Zanella 918311a3a3 nptl: Add C11 threads cnd_* functions
This patch adds the cnd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically cnd_broadcast, cnd_destroy, cnd_init, cnd_signal,
cnd_timedwait, cnd_wait, and required types.

Mostly of the definitions are composed based on POSIX conterparts, and
cnd_t is also based on internal pthreads fields, but with distinct internal
layout to avoid possible issues with code interchange (such as trying to pass
POSIX structure on C11 functions and to avoid inclusion of pthread.h).  The
idea is to make it possible to share POSIX internal implementation for mostly
of the code making adjust where only required.

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,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (cnd_t): New type.
	(cnd_init): New function.
	(cnd_signal): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
	* nptl/Makefile (libpthread-routines): Add cnd_broadcast,
	cnd_destroy, cnd_init, cnd_signal, cnd_timedwait, and cnd_wait
	object.
	* nptl/Versions (libpthread) [GLIBC_2.28]: Likewise.
	* nptl/cnd_broadcast.c: New file.
	* nptl/cnd_destroy.c: Likewise.
	* nptl/cnd_init.c: Likewise.
	* nptl/cnd_signal.c: Likewise.
	* nptl/cnd_timedwait.c: Likewise.
	* nptl/cnd_wait.c: Likewise.
	* sysdeps/nptl/threads.h (cnd_t): New type.
	(cnd_init): New prototype.
	(cnd_signa): Likewise.
	(cnd_broadcast): Likewise.
	(cnd_wait): Likewise.
	(cnd_timedwait): Likewise.
	(cnd_destroy): Likewise.
2018-07-24 14:07:07 -03:00
Adhemerval Zanella 3c20a679b6 nptl: Add C11 threads call_once functions
This patch adds the call_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically call_once and required types.

Mostly of the definitions are composed based on POSIX conterparts,including
once_flag (pthread_once_t).  The idea is to make possible to share POSIX
internal implementations for mostly of the code (and making adjustment only
when required).

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,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (ONCE_FLAG_INIT): New macro.
	(once_flag): New type.
	(call_once): New function.
	* nptl/Makefile (libpthread-routines): Add call_once object.
	* nptl/Versions (libphread) [GLIBC_2.28]: Add call_once symbol.
	* nptl/call_once.c: New file.
	* sysdeps/nptl/threads.h (ONCE_FLAG_INIT): New define.
	(once_flag): New type.
	(call_once): New prototype.
2018-07-24 14:07:01 -03:00
Adhemerval Zanella 18d59c1b36 nptl: Add C11 threads mtx_* functions
This patch adds the mtx_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically mtx_init, mtx_destroy, mtx_lock, mtx_timedlock, mtx_trylock,
mtx_unlock, and required types.

Mostly of the definitions are composed based on POSIX conterparts, and mtx_t
is also based on internal pthread fields, but with a distinct internal layout
to avoid possible issues with code interchange (such as trying to pass POSIX
structure on C11 functions and to avoid inclusion of pthread.h).  The idea
is to make possible to share POSIX internal implementations for mostly of
the code (and making adjustment only when required).

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,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/data/threads.h-data (mtx_plain): New constant.
	(mtx_recursive): Likewise.
	(mtx_timed): Likewise.
	(mtx_t): New type.
	(mtx_init): New function.
	(mtx_lock): Likewise.
	(mtx_timedlock): Likewise.
	(mtx_trylock): Likewise.
	(mtx_unlock): Likewise.
	(mtx_destroy): Likewise.
	* nptl/Makefile (libpthread-routines): Add mtx_destroy, mtx_init,
	mtx_lock, mtx_timedlock, mtx_trylock, and mtx_unlock object.
	* nptl/Versions (libpthread) [GLIBC_2.28]): Add mtx_init, mtx_lock,
	mtx_timedlock, mtx_trylock, mtx_unlock, and mtx_destroy.
	* nptl/mtx_destroy.c: New file.
	* nptl/mtx_init.c: Likewise.
	* nptl/mtx_lock.c: Likewise.
	* nptl/mtx_timedlock.c: Likewise.
	* nptl/mtx_trylock.c: Likewise.
	* nptl/mtx_unlock.c: Likewise.
	* sysdeps/nptl/threads.h (mtx_plain): New enumeration.
	(mtx_recursive): Likewise.
	(mtx_timed): Likewise.
	(mtx_t): New type.
	(mtx_init): New prototype.
	(mtx_lock): Likewise.
	(mtx_timedlock): Likewise.
	(mtx_trylock): Likewise.
	(mtx_unlock): Likewise.
	(mtx_destroy): Likewise.
2018-07-24 14:06:54 -03:00
Adhemerval Zanella ce7528f637 nptl: Add C11 threads thrd_* functions
This patch adds the thrd_* definitions from C11 threads (ISO/IEC 9899:2011),
more specifically thrd_create, thrd_curent, rhd_detach, thrd_equal,
thrd_exit, thrd_join, thrd_sleep, thrd_yield, and required types.

Mostly of the definitions are composed based on POSIX conterparts, such as
thrd_t (using pthread_t).  For thrd_* function internally direct
POSIX pthread call are used with the exceptions:

  1. thrd_start uses pthread_create internal implementation, but changes
     how to actually calls the start routine.  This is due the difference
     in signature between POSIX and C11, where former return a 'void *'
     and latter 'int'.
     To avoid calling convention issues due 'void *' to int cast, routines
     from C11 threads are started slight different than default pthread one.
     Explicit cast to expected return are used internally on pthread_create
     and the result is stored back to void also with an explicit cast.

  2. thrd_sleep uses nanosleep internal direct syscall to avoid clobbering
     errno and to handle expected standard return codes.  It is a
     cancellation entrypoint to be consistent with both thrd_join and
     cnd_{timed}wait.

  3. thrd_yield also uses internal direct syscall to avoid errno clobbering.

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,
and x86_64-linux-gnu).

Also ran a full check on aarch64-linux-gnu, x86_64-linux-gnu, i686-linux-gnu,
arm-linux-gnueabhf, and powerpc64le-linux-gnu.

	[BZ #14092]
	* conform/Makefile (conformtest-headers-ISO11): Add threads.h.
	(linknamespace-libs-ISO11): Add libpthread.a.
	* conform/data/threads.h-data: New file: add C11 thrd_* types and
	functions.
	* include/stdc-predef.h (__STDC_NO_THREADS__): Remove definition.
	* nptl/Makefile (headers): Add threads.h.
	(libpthread-routines): Add new C11 thread thrd_create, thrd_current,
	thrd_detach, thrd_equal, thrd_exit, thrd_join, thrd_sleep, and
	thrd_yield.
	* nptl/Versions (libpthread) [GLIBC_2.28]): Add new C11 thread
	thrd_create, thrd_current, thrd_detach, thrd_equal, thrd_exit,
	thrd_join, thrd_sleep, and thrd_yield symbols.
	* nptl/descr.h (struct pthread): Add c11 field.
	* nptl/pthreadP.h (ATTR_C11_THREAD): New define.
	* nptl/pthread_create.c (START_THREAD_DEFN): Call C11 thread start
	routine with expected function prototype.
	(__pthread_create_2_1): Add C11 threads check based on attribute
	value.
	* sysdeps/unix/sysdep.h (INTERNAL_SYSCALL_CANCEL): New macro.
	* nptl/thrd_create.c: New file.
	* nptl/thrd_current.c: Likewise.
	* nptl/thrd_detach.c: Likewise.
	* nptl/thrd_equal.c: Likewise.
	* nptl/thrd_exit.c: Likewise.
	* nptl/thrd_join.c: Likewise.
	* nptl/thrd_priv.h: Likewise.
	* nptl/thrd_sleep.c: Likewise.
	* nptl/thrd_yield.c: Likewise.
	* include/threads.h: Likewise.
2018-07-24 14:06:45 -03:00
H.J. Lu e27f41ba2b Add <bits/indirect-return.h>
Add <bits/indirect-return.h> and include it in <ucontext.h>.
__INDIRECT_RETURN defined in <bits/indirect-return.h> indicates if
swapcontext requires special compiler treatment.  The default
__INDIRECT_RETURN is empty.

On x86, when shadow stack is enabled, __INDIRECT_RETURN is defined
with indirect_return attribute, which has been added to GCC 9, to
indicate that swapcontext returns via indirect branch.  Otherwise
__INDIRECT_RETURN is defined with returns_twice attribute.

When shadow stack is enabled, remove always_inline attribute from
prepare_test_buffer in string/tst-xbzero-opt.c to avoid:

tst-xbzero-opt.c: In function ‘prepare_test_buffer’:
tst-xbzero-opt.c:105:1: error: function ‘prepare_test_buffer’ can never be inlined because it uses setjmp
 prepare_test_buffer (unsigned char *buf)

when indirect_return attribute isn't available.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* bits/indirect-return.h: New file.
	* misc/sys/cdefs.h (__glibc_has_attribute): New.
	* sysdeps/x86/bits/indirect-return.h: Likewise.
	* stdlib/Makefile (headers): Add bits/indirect-return.h.
	* stdlib/ucontext.h: Include <bits/indirect-return.h>.
	(swapcontext): Add __INDIRECT_RETURN.
	* string/tst-xbzero-opt.c (ALWAYS_INLINE): New.
	(prepare_test_buffer): Use it.
2018-07-24 07:55:47 -07:00
Andreas Schwab 21526a507d Fix out-of-bounds access in IBM-1390 converter (bug 23448)
The IBM-1390 converter can consume/produce two UCS4 characters in each
loop.
2018-07-24 16:45:46 +02:00
H.J. Lu 3650e1d928 x86: Update vfork to pop shadow stack
The shadow stack prevents us from pushing the saved return PC onto
the stack and returning normally.  Instead we pop the shadow stack
and return directly.  This is the safest way to return and ensures
any stack manipulations done by the vfork'd child doesn't cause the
parent to terminate when CET is enabled.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/unix/sysv/linux/i386/vfork.S (SYSCALL_ERROR_HANDLER):
	Redefine if shadow stack is enabled.
	(SYSCALL_ERROR_LABEL): Likewise.
	(__vfork): Pop shadow stack and jump back to to caller directly
	when shadow stack is in use.
	* sysdeps/unix/sysv/linux/x86_64/vfork.S (SYSCALL_ERROR_HANDLER):
	Redefine if shadow stack is enabled.
	(SYSCALL_ERROR_LABEL): Likewise.
	(__vfork): Pop shadow stack and jump back to to caller directly
	when shadow stack is in use.
2018-07-24 05:21:07 -07:00
H.J. Lu ca027e0f62 x86-64: Add endbr64 to tst-quadmod[12].S
Add endbr64 to tst-quadmod1.S and tst-quadmod2.S so that func and foo
can be called indirectly.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86_64/tst-quadmod1.S (func): Add endbr64 if IBT is
	enabled.
	(foo): Likewise.
	* sysdeps/x86_64/tst-quadmod2.S (func) : Likewise.
	(foo): Likewise.
2018-07-24 05:12:14 -07:00
Joseph Myers b99f1c957d Use binutils 2.31 branch in build-many-glibcs.py.
* scripts/build-many-glibcs.py (Context.checkout): Default
	binutils version to 2.31 branch.
2018-07-20 16:11:15 +00:00
Zong Li c8fabb8434 Change URL of gcc's tarball
After 7.1.0 version, there is no .bz2 format of gcc's tarball.

	* scripts/build-many-glibcs.py (Context.checkout_tar): Change the
	URL of gcc's tarball.
2018-07-20 15:30:05 +00:00
Florian Weimer 786658a088 regcomp: Fix off-by-one bug in build_equiv_class [BZ #23396]
This bug is very similar to bug 23036: The existing code assumed that
the length count included the length byte itself.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-20 11:58:51 +02:00
Samuel Thibault 2d5c41ded9 check-execstack: Permit sysdeps to xfail some libs
* scripts/check-execstack.awk: Consider `xfail' variable containing a
	list
	of libraries whose stack executability is expected.
	* elf/Makefile ($(objpfx)check-execstack.out): Pass
	$(check-execstack-xfail) to check-execstack.awk through `xfail'
	variable.
	* sysdeps/mach/hurd/i386/Makefile (check-execstack-xfail): Set to ld.so
	libc.so libpthread.so.
2018-07-20 03:28:14 +02:00
Samuel Thibault 8ba1520e8c hurd: Fix installed-headers tests
* sysdeps/mach/include/mach-shortcuts-hidden.h [!_ISOMAC]: Do not
	declare libc hidden prototypes.
	* sysdeps/mach/include/mach/mach_traps.h [!_ISOMAC]: Likewise.
2018-07-20 03:28:08 +02:00
Thomas Schwinge de195be015 hurd: Implement pipe2
* sysdeps/mach/hurd/pipe2.c: New file, copy from pipe.c.  Evolve it to
	implement __pipe2.
	* sysdeps/mach/hurd/pipe.c (__pipe): Reimplement using __pipe2.
2018-07-20 01:29:55 +02:00
Thomas Schwinge 75d5e4a09e hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socketpair
* sysdeps/mach/hurd/socketpair.c (__socketpair): Handle SOCK_CLOEXEC
	and SOCK_NONBLOCK.
2018-07-20 01:24:41 +02:00
Thomas Schwinge 6008824221 hurd: SOCK_CLOEXEC and SOCK_NONBLOCK for socket
* sysdeps/mach/hurd/socket.c (__socket): Handle SOCK_CLOEXEC and
	SOCK_NONBLOCK.
2018-07-20 01:22:12 +02:00
Samuel Thibault 46f2474e93 hurd: Enable thread-safe i386 atomic instructions
* sysdeps/mach/hurd/i386/tls.h (_hurd_tls_init): Set multiple_threads
	to 1.
2018-07-20 01:12:08 +02:00
Leonardo Sandoval 1cf4ae7fe6 benchtests: improve argument parsing through argparse library
The argparse library is used on compare_bench script to improve command line
argument parsing. The 'schema validation file' is now optional, reducing by
one the number of required parameters.

	* benchtests/scripts/compare_bench.py (__main__): use the argparse
	library to improve command line parsing.
	(__main__): make schema file as optional parameter (--schema),
	defaulting to benchtests/scripts/benchout.schema.json.
	(main): move out of the parsing stuff to __main_  and leave it
	only as caller of main comparison functions.
2018-07-19 14:53:37 -05:00
H.J. Lu e84bd8514c INSTALL: Add a note for Intel CET status
* NEWS: Add a note for Intel CET status.
	* manual/install.texi: Likewise.
	* INSTALL: Regenerated.
2018-07-19 12:05:10 -07:00
Quentin PAGÈS df467d229a oc_FR locale: Multiple updates (bug 23140, bug 23422).
Multiple updates for Occitan language including alternative month names,
update abday and abmon, fix typos in day, fix d_fmt, correct LC_NAME,
and use “copy "ca_ES"” as LC_COLLATE.

	[BZ #23140]
	* localedata/locales/oc_FR (mon): Rename to...
	(alt_mon): This, then update October (typo fix).
	(mon): New content (genitive case, month names preceded by
	"de" or "d’").

	[BZ #23422]
	* localedata/locales/oc_FR (abday): Update all items.
	(day): Update Wednesday and Saturday (typo fixes).
	(abmon): Update all items, except May.
	(d_fmt): Update "%d.%m.%Y" -> "%d/%m/%Y".
	(LC_IDENTIFICATION): Bump the revision number and date.
	Keep the "category" entries in alphabetic order.
	(LC_ADDRESS): Remove no longer needed comment.
	(LC_COLLATE): Use “copy "ca_ES"”.
	(LC_NAME): Set the correct values of "name_fmt", "name_mr", and
	"name_mrs".

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-18 23:17:17 +02:00
Joseph Myers 5c112f1b62 Avoid insecure usage of tmpnam in tests.
Various glibc testcases use tmpnam in ways subject to race conditions
(generate a temporary file name, then later open that file without
O_EXCL).

This patch fixes those tests to use mkstemp - generally a minimal
local fix to use mkstemp instead of tmpnam, rather than a larger fix
to use other testsuite infrastructure for temporary files.  The
unchanged use of tmpnam in posix/wordexp-test.c would fail safe in the
event of a race (it's generating a name for use with mkdir rather than
for a file to be opened for writing).

Tested for x86_64.

	* grp/tst_fgetgrent.c: Include <unistd.h>.
	(main): Use mkstemp instead of tmpnam.
	* io/test-utime.c (main): Likewise.
	* posix/annexc.c (macrofile): Change to modifiable array.
	(get_null_defines): Use mkstemp instead of tmpnam.  Do not remove
	macrofile here.
	* posix/bug-getopt1.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt2.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt3.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt4.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* posix/bug-getopt5.c: Include <stdlib.h>.
	(do_test): Use mkstemp instead of tmpnam.
	* stdio-common/bug7.c: Include <stdlib.h> and <unistd.h>.
	(main): Use mkstemp instead of tmpnam.
	* stdio-common/tst-fdopen.c: Include <stdlib.h>.
	(main): Use mkstemp instead of tmpnam.
	* stdio-common/tst-ungetc.c: Include <stdlib.h>.
	(main): use mkstemp instead of tmpnam.
	* stdlib/isomac.c (macrofile): Change to modifiable array.
	(get_null_defines): Use mkstemp instead of tmpnam.  Do not remove
	macrofile here.
2018-07-18 21:04:12 +00:00
H.J. Lu 6d90776dff x86/CET: Document glibc.tune.x86_ibt and glibc.tune.x86_shstk
* manual/tunables.texi: Document glibc.tune.x86_ibt and
	glibc.tune.x86_shstk.
2018-07-18 11:35:03 -07:00
H.J. Lu e6c695099b Intel CET: Document --enable-cet
* NEWS: Mention --enable-cet.
	* manual/install.texi: Document --enable-cet.
	* INSTALL: Regenerated.
2018-07-18 09:52:53 -07:00
H.J. Lu e2d40a8822 x86-64: Use _CET_NOTRACK in memcmp-sse4.S
* sysdeps/x86_64/multiarch/memcmp-sse4.S (BRANCH_TO_JMPTBL_ENTRY):
	Add _CET_NOTRACK before indirect jump to jump table.
2018-07-18 08:07:32 -07:00
H.J. Lu 77a8ae0948 i386: Use _CET_NOTRACK in memset-sse2-rep.S
* sysdeps/i386/i686/multiarch/memset-sse2-rep.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:04:12 -07:00
H.J. Lu 90d15dc577 i386: Use _CET_NOTRACK in strcat-sse2.S
* sysdeps/i386/i686/multiarch/strcat-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:03:15 -07:00
H.J. Lu f1574581c7 i386: Use _CET_NOTRACK in strcpy-sse2.S
* sysdeps/i386/i686/multiarch/strcpy-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:02:26 -07:00
H.J. Lu 7fb613361c i386: Use _CET_NOTRACK in memcpy-ssse3.S
* sysdeps/i386/i686/multiarch/memcpy-ssse3.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 08:01:06 -07:00
H.J. Lu 0a899af097 i386: Use _CET_NOTRACK in memcpy-ssse3-rep.S
* sysdeps/i386/i686/multiarch/memcpy-ssse3-rep.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(BRANCH_TO_JMPTBL_ENTRY_TAIL): Likewise.
2018-07-18 08:00:09 -07:00
H.J. Lu 177824e232 i386: Use _CET_NOTRACK in memcmp-sse4.S
* sysdeps/i386/i686/multiarch/memcmp-sse4.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 07:59:04 -07:00
H.J. Lu 00e7b76a8f i386: Use _CET_NOTRACK in memset-sse2.S
* sysdeps/i386/i686/multiarch/memset-sse2.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 07:57:59 -07:00
H.J. Lu 7e119cd582 i386: Use _CET_NOTRACK in i686/memcmp.S
* sysdeps/i386/i686/memcmp.S (memcmp): Add _CET_NOTRACK before
	indirect jump to jump table.
2018-07-18 07:56:58 -07:00
H.J. Lu 03aaf49b68 x86-64: Use _CET_NOTRACK in memcpy-ssse3.S
* sysdeps/x86_64/multiarch/memcpy-ssse3.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(MEMCPY): Likewise.
2018-07-18 06:39:46 -07:00
H.J. Lu 811e9e52b2 x86-64: Use _CET_NOTRACK in memcpy-ssse3-back.S
* sysdeps/x86_64/multiarch/memcpy-ssse3-back.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
	(MEMCPY): Likewise.
2018-07-18 06:38:23 -07:00
H.J. Lu 8817df4265 x86-64: Use _CET_NOTRACK in strcmp-sse42.S
* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
	_CET_NOTRACK before indirect jump to jump table.
2018-07-18 06:37:09 -07:00
H.J. Lu 921595d151 x86-64: Use _CET_NOTRACK in strcpy-sse2-unaligned.S
* sysdeps/x86_64/multiarch/strcpy-sse2-unaligned.S
	(BRANCH_TO_JMPTBL_ENTRY): Add _CET_NOTRACK before indirect jump
	to jump table.
2018-07-18 06:33:06 -07:00
H.J. Lu 4ef60d9597 x86_64: Use _CET_NOTRACK in strcmp.S
* sysdeps/x86_64/strcmp.S (STRCMP): Add _CET_NOTRACK before
	indirect jump to jump table.
2018-07-18 06:31:53 -07:00
Valery Timiriliyev 61c4aad705 New locale: Yakut (Sakha) for Russia (sah_RU) [BZ #22241]
* localedata/Makefile (test-input): Add sah_RU.UTF-8.
	(LOCALES): Likewise.
	* localedata/SUPPORTED (sah_RU/UTF-8): New entry.
	* localedata/locales/sah_RU: New file.
	* localedata/sah_RU.UTF-8.in: New file.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-18 11:45:44 +02:00
H.J. Lu be9ccd27c0 i386: Add _CET_ENDBR to indirect jump targets in add_n.S/sub_n.S
i386 add_n.S and sub_n.S use a trick to implment jump tables with LEA.
We can't use conditional branches nor normal jump tables since jump
table entries use EFLAGS set by jump table index.  This patch adds
_CET_ENDBR to indirect jump targets and adjust destination for
_CET_ENDBR.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/add_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
	* sysdeps/i386/i686/add_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_add_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
	* sysdeps/i386/sub_n.S: Include <sysdep.h>, instead of
	"sysdep.h".
	(__mpn_sub_n): Save and restore %ebx if IBT is enabed.  Add
	_CET_ENDBR to indirect jump targets and adjust jump destination
	for _CET_ENDBR.
2018-07-17 16:11:44 -07:00
H.J. Lu 5efc6777ad x86-64: Add _CET_ENDBR to STRCMP_SSE42
Add _CET_ENDBR to STRCMP_SSE42, which is called indirectly, to support
IBT.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/x86_64/multiarch/strcmp-sse42.S (STRCMP_SSE42): Add
	_CET_ENDBR.
2018-07-17 16:08:47 -07:00
H.J. Lu 562837c002 x86: Add _CET_ENDBR to functions in dl-tlsdesc.S
Add _CET_ENDBR to functions in dl-tlsdesc.S, which are called indirectly,
to support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/dl-tlsdesc.S (_dl_tlsdesc_return): Add
	_CET_ENDBR.
	(_dl_tlsdesc_undefweak): Likewise.
	(_dl_tlsdesc_dynamic): Likewise.
	(_dl_tlsdesc_resolve_abs_plus_addend): Likewise.
	(_dl_tlsdesc_resolve_rel): Likewise.
	(_dl_tlsdesc_resolve_rela): Likewise.
	(_dl_tlsdesc_resolve_hold): Likewise.
	* sysdeps/x86_64/dl-tlsdesc.S (_dl_tlsdesc_return): Likewise.
	(_dl_tlsdesc_undefweak): Likewise.
	(_dl_tlsdesc_dynamic): Likewise.
	(_dl_tlsdesc_resolve_rela): Likewise.
	(_dl_tlsdesc_resolve_hold): Likewise.
2018-07-17 16:07:17 -07:00
H.J. Lu 124bcde683 x86: Add _CET_ENDBR to functions in crti.S
Add _CET_ENDBR to functions in crti.S, which are called indirectly, to
support IBT.

Tested on i686 and x86-64.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/crti.S (_init): Add _CET_ENDBR.
	(_fini): Likewise.
	* sysdeps/x86_64/crti.S (_init): Likewise.
	(_fini): Likewise.
2018-07-17 16:05:18 -07:00
Rafal Luzynski 9145f0333d os_RU: Add alternative month names (bug 23140).
[BZ #23140]
	* localedata/locales/os_RU (mon): Rename to...
	(alt_mon): This.
	(mon): Import from CLDR (genitive case).

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-17 23:58:56 +02:00
H.J. Lu ba2ea23d05 x86: Always include <dl-cet.h>/cet-tunables.h> for --enable-cet
Always include <dl-cet.h> and cet-tunables.h> when CET is enabled.
Otherwise, configure glibc with --enable-cet --disable-tunables will
fail to build.

	* sysdeps/x86/cpu-features.c: Always include <dl-cet.h> and
	cet-tunables.h> when CET is enabled.
2018-07-17 04:16:35 -07:00
H.J. Lu f753fa7dea x86: Support IBT and SHSTK in Intel CET [BZ #21598]
Intel Control-flow Enforcement Technology (CET) instructions:

https://software.intel.com/sites/default/files/managed/4d/2a/control-flow-en
forcement-technology-preview.pdf

includes Indirect Branch Tracking (IBT) and Shadow Stack (SHSTK).

GNU_PROPERTY_X86_FEATURE_1_IBT is added to GNU program property to
indicate that all executable sections are compatible with IBT when
ENDBR instruction starts each valid target where an indirect branch
instruction can land.  Linker sets GNU_PROPERTY_X86_FEATURE_1_IBT on
output only if it is set on all relocatable inputs.

On an IBT capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable IBT and
lock IBT if GNU_PROPERTY_X86_FEATURE_1_IBT is set on the executable.
2. When loading an executable with an interpreter, enable IBT if
GNU_PROPERTY_X86_FEATURE_1_IBT is set on the interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_IBT isn't set on the executable,
     disable IBT.
  b. Lock IBT.
3. If IBT is enabled, when loading a shared object without
GNU_PROPERTY_X86_FEATURE_1_IBT:
  a. If legacy interwork is allowed, then mark all pages in executable
     PT_LOAD segments in legacy code page bitmap.  Failure of legacy code
     page bitmap allocation causes an error.
  b. If legacy interwork isn't allowed, it causes an error.

GNU_PROPERTY_X86_FEATURE_1_SHSTK is added to GNU program property to
indicate that all executable sections are compatible with SHSTK where
return address popped from shadow stack always matches return address
popped from normal stack.  Linker sets GNU_PROPERTY_X86_FEATURE_1_SHSTK
on output only if it is set on all relocatable inputs.

On a SHSTK capable processor, the following steps should be taken:

1. When loading an executable without an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on the executable.
2. When loading an executable with an interpreter, enable SHSTK if
GNU_PROPERTY_X86_FEATURE_1_SHSTK is set on interpreter.
  a. If GNU_PROPERTY_X86_FEATURE_1_SHSTK isn't set on the executable
     or any shared objects loaded via the DT_NEEDED tag, disable SHSTK.
  b. Otherwise lock SHSTK.
3. After SHSTK is enabled, it is an error to load a shared object
without GNU_PROPERTY_X86_FEATURE_1_SHSTK.

To enable CET support in glibc, --enable-cet is required to configure
glibc.  When CET is enabled, both compiler and assembler must support
CET.  Otherwise, it is a configure-time error.

To support CET run-time control,

1. _dl_x86_feature_1 is added to the writable ld.so namespace to indicate
if IBT or SHSTK are enabled at run-time.  It should be initialized by
init_cpu_features.
2. For dynamic executables:
   a. A l_cet field is added to struct link_map to indicate if IBT or
      SHSTK is enabled in an ELF module.  _dl_process_pt_note or
      _rtld_process_pt_note is called to process PT_NOTE segment for
      GNU program property and set l_cet.
   b. _dl_open_check is added to check IBT and SHSTK compatibilty when
      dlopening a shared object.
3. Replace i386 _dl_runtime_resolve and _dl_runtime_profile with
_dl_runtime_resolve_shstk and _dl_runtime_profile_shstk, respectively if
SHSTK is enabled.

CET run-time control can be changed via GLIBC_TUNABLES with

$ export GLIBC_TUNABLES=glibc.tune.x86_shstk=[permissive|on|off]
$ export GLIBC_TUNABLES=glibc.tune.x86_ibt=[permissive|on|off]

1. permissive: SHSTK is disabled when dlopening a legacy ELF module.
2. on: IBT or SHSTK are always enabled, regardless if there are IBT or
SHSTK bits in GNU program property.
3. off: IBT or SHSTK are always disabled, regardless if there are IBT or
SHSTK bits in GNU program property.

<cet.h> from CET-enabled GCC is automatically included by assembly codes
to add GNU_PROPERTY_X86_FEATURE_1_IBT and GNU_PROPERTY_X86_FEATURE_1_SHSTK
to GNU program property.  _CET_ENDBR is added at the entrance of all
assembly functions whose address may be taken.  _CET_NOTRACK is used to
insert NOTRACK prefix with indirect jump table to support IBT.  It is
defined as notrack when _CET_NOTRACK is defined in <cet.h>.

	 [BZ #21598]
	* configure.ac: Add --enable-cet.
	* configure: Regenerated.
	* elf/Makefille (all-built-dso): Add a comment.
	* elf/dl-load.c (filebuf): Moved before "dynamic-link.h".
	Include <dl-prop.h>.
	(_dl_map_object_from_fd): Call _dl_process_pt_note on PT_NOTE
	segment.
	* elf/dl-open.c: Include <dl-prop.h>.
	(dl_open_worker): Call _dl_open_check.
	* elf/rtld.c: Include <dl-prop.h>.
	(dl_main): Call _rtld_process_pt_note on PT_NOTE segment.  Call
	_rtld_main_check.
	* sysdeps/generic/dl-prop.h: New file.
	* sysdeps/i386/dl-cet.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/cpu-features.c: Likewise.
	* sysdeps/unix/sysv/linux/x86/dl-cet.h: Likewise.
	* sysdeps/x86/cet-tunables.h: Likewise.
	* sysdeps/x86/check-cet.awk: Likewise.
	* sysdeps/x86/configure: Likewise.
	* sysdeps/x86/configure.ac: Likewise.
	* sysdeps/x86/dl-cet.c: Likewise.
	* sysdeps/x86/dl-procruntime.c: Likewise.
	* sysdeps/x86/dl-prop.h: Likewise.
	* sysdeps/x86/libc-start.h: Likewise.
	* sysdeps/x86/link_map.h: Likewise.
	* sysdeps/i386/dl-trampoline.S (_dl_runtime_resolve): Add
	_CET_ENDBR.
	(_dl_runtime_profile): Likewise.
	(_dl_runtime_resolve_shstk): New.
	(_dl_runtime_profile_shstk): Likewise.
	* sysdeps/linux/x86/Makefile (sysdep-dl-routines): Add dl-cet
	if CET is enabled.
	(CFLAGS-.o): Add -fcf-protection if CET is enabled.
	(CFLAGS-.os): Likewise.
	(CFLAGS-.op): Likewise.
	(CFLAGS-.oS): Likewise.
	(asm-CPPFLAGS): Add -fcf-protection -include cet.h if CET
	is enabled.
	(tests-special): Add $(objpfx)check-cet.out.
	(cet-built-dso): New.
	(+$(cet-built-dso:=.note)): Likewise.
	(common-generated): Add $(cet-built-dso:$(common-objpfx)%=%.note).
	($(objpfx)check-cet.out): New.
	(generated): Add check-cet.out.
	* sysdeps/x86/cpu-features.c: Include <dl-cet.h> and
	<cet-tunables.h>.
	(TUNABLE_CALLBACK (set_x86_ibt)): New prototype.
	(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
	(init_cpu_features): Call get_cet_status to check CET status
	and update dl_x86_feature_1 with CET status.  Call
	TUNABLE_CALLBACK (set_x86_ibt) and TUNABLE_CALLBACK
	(set_x86_shstk).  Disable and lock CET in libc.a.
	* sysdeps/x86/cpu-tunables.c: Include <cet-tunables.h>.
	(TUNABLE_CALLBACK (set_x86_ibt)): New function.
	(TUNABLE_CALLBACK (set_x86_shstk)): Likewise.
	* sysdeps/x86/sysdep.h (_CET_NOTRACK): New.
	(_CET_ENDBR): Define if not defined.
	(ENTRY): Add _CET_ENDBR.
	* sysdeps/x86/dl-tunables.list (glibc.tune): Add x86_ibt and
	x86_shstk.
	* sysdeps/x86_64/dl-trampoline.h (_dl_runtime_resolve): Add
	_CET_ENDBR.
	(_dl_runtime_profile): Likewise.
2018-07-16 14:08:27 -07:00
Rogerio Alves 52b2a80fae powerpc64: Always restore TOC on longjmp [BZ #21895]
This patch changes longjmp to always restore the TOC pointer (r2 register)
to the caller frame on powerpc64 and powerpc64le.  This is related to bug
21895 that reports a situation where you have a static longjmp to a
shared object file.

	[BZ #21895]
	* sysdeps/powerpc/powerpc64/__longjmp-common.S: Remove condition code for
	restoring r2 in longjmp.
	* sysdeps/powerpc/powerpc64/Makefile: Added tst-setjmp-bug21895-static to
	test list.
	Added rules to build test tst-setjmp-bug21895-static.
	Added module setjmp-bug21895 and rules to build a shared object from it.
	* sysdeps/powerpc/powerpc64/setjmp-bug21895.c: New test file.
	* sysdeps/powerpc/powerpc64/tst-setjmp-bug21895-static.c: New test file.

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
2018-07-16 16:08:41 -03:00
Wilco Dijkstra 3ae725dfb6 Improve strstr performance
Improve strstr performance.  Strstr tends to be slow because it uses
many calls to memchr and a slow byte loop to scan for the next match.
Performance is significantly improved by using strnlen on larger blocks
and using strchr to search for the next matching character.  strcasestr
can also use strnlen to scan ahead, and memmem can use memchr to check
for the next match.

On the GLIBC bench tests the performance gains on Cortex-A72 are:
strstr: +25%
strcasestr: +4.3%
memmem: +18%

On a 256KB dataset strstr performance improves by 67%, strcasestr by 47%.

    Reviewd-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
2018-07-16 17:51:52 +01:00
H.J. Lu 31e422ca96 x86_64: Undef SHADOW_STACK_POINTER_OFFSET last
Since SHADOW_STACK_POINTER_OFFSET is defined in jmp_buf-ssp.h, we must
undef SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.

	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Undef
	SHADOW_STACK_POINTER_OFFSET after including <jmp_buf-ssp.h>.
2018-07-15 08:48:54 -07:00
H.J. Lu faaee1f07e x86: Support shadow stack pointer in setjmp/longjmp
Save and restore shadow stack pointer in setjmp and longjmp to support
shadow stack in Intel CET.  Use feature_1 in tcbhead_t to check if
shadow stack is enabled before saving and restoring shadow stack pointer.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	* sysdeps/i386/__longjmp.S: Include <jmp_buf-ssp.h>.
	(__longjmp): Restore shadow stack pointer if shadow stack is
	enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
	isn't defined for __longjmp_cancel.
	* sysdeps/i386/bsd-_setjmp.S: Include <jmp_buf-ssp.h>.
	(_setjmp): Save shadow stack pointer if shadow stack is enabled
	and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/i386/bsd-setjmp.S: Include <jmp_buf-ssp.h>.
	(setjmp): Save shadow stack pointer if shadow stack is enabled
	and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/i386/setjmp.S: Include <jmp_buf-ssp.h>.
	(__sigsetjmp): Save shadow stack pointer if shadow stack is
	enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/unix/sysv/linux/i386/____longjmp_chk.S: Include
	<jmp_buf-ssp.h>.
	(____longjmp_chk): Restore shadow stack pointer if shadow stack
	is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/unix/sysv/linux/x86/Makefile (gen-as-const-headers):
	Remove jmp_buf-ssp.sym.
	* sysdeps/unix/sysv/linux/x86_64/____longjmp_chk.S: Include
	<jmp_buf-ssp.h>.
	(____longjmp_chk): Restore shadow stack pointer if shadow stack
	is enabled and SHADOW_STACK_POINTER_OFFSET is defined.
	* sysdeps/x86/Makefile (gen-as-const-headers): Add
	jmp_buf-ssp.sym.
	* sysdeps/x86/jmp_buf-ssp.sym: New dummy file.
	* sysdeps/x86_64/__longjmp.S: Include <jmp_buf-ssp.h>.
	(__longjmp): Restore shadow stack pointer if shadow stack is
	enabled, SHADOW_STACK_POINTER_OFFSET is defined and __longjmp
	isn't defined for __longjmp_cancel.
	* sysdeps/x86_64/setjmp.S: Include <jmp_buf-ssp.h>.
	(__sigsetjmp): Save shadow stack pointer if shadow stack is
	enabled and SHADOW_STACK_POINTER_OFFSET is defined.
2018-07-14 05:59:53 -07:00
H.J. Lu ebff9c5cfa x86: Rename __glibc_reserved1 to feature_1 in tcbhead_t [BZ #22563]
feature_1 has X86_FEATURE_1_IBT and X86_FEATURE_1_SHSTK bits for CET
run-time control.

CET_ENABLED, IBT_ENABLED and SHSTK_ENABLED are defined to 1 or 0 to
indicate that if CET, IBT and SHSTK are enabled.

<tls-setup.h> is added to set up thread-local data.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

	[BZ #22563]
	* nptl/pthread_create.c: Include <tls-setup.h>.
	(__pthread_create_2_1): Call tls_setup_tcbhead.
	* sysdeps/generic/tls-setup.h: New file.
	* sysdeps/x86/nptl/tls-setup.h: Likewise.
	* sysdeps/i386/nptl/tcb-offsets.sym (FEATURE_1_OFFSET): New.
	* sysdeps/x86_64/nptl/tcb-offsets.sym (FEATURE_1_OFFSET):
	Likewise.
	* sysdeps/i386/nptl/tls.h (tcbhead_t): Rename __glibc_reserved1
	to feature_1.
	* sysdeps/x86_64/nptl/tls.h (tcbhead_t): Likewise.
	* sysdeps/x86/sysdep.h (X86_FEATURE_1_IBT): New.
	(X86_FEATURE_1_SHSTK): Likewise.
	(CET_ENABLED): Likewise.
	(IBT_ENABLED): Likewise.
	(SHSTK_ENABLED): Likewise.
2018-07-14 05:56:46 -07:00
Rafal Luzynski 0a83bad2aa dsb_DE locale: Fix syntax error and add tests (bug 23208).
Fixed syntax error in the collation rules of Lower Sorbian language.
Collation test added in order to test the bugs like this early.

Reported-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>

	[BZ #23208]
	* localedata/Makefile (test-input): Add dsb_DE.UTF-8.
	(LOCALES): Likewise.
	* localedata/dsb_DE.UTF-8.in: New file.
	* localedata/locales/dsb_DE (LC_COLLATE): Fix syntax error.
2018-07-13 23:06:32 +02:00
Florian Weimer 046bfed9de nptl: Use __mprotect consistently for _STACK_GROWS_UP 2018-07-12 15:01:43 +02:00
Florian Weimer 93304f5f7a Install <bits/statx.h> header 2018-07-11 08:59:51 +02:00
Mike FABIAN 4beefeeb8e Put the correct Unicode version number 11.0.0 into the generated files
In some places there was still the old Unicode version 10.0.0 in the files.

	* localedata/charmaps/UTF-8: Use correct Unicode version 11.0.0 in comment.
	* localedata/locales/i18n_ctype: Use correct Unicode version in comments
	and headers.
	* localedata/unicode-gen/utf8_gen.py: Add option to specify Unicode version
	* localedata/unicode-gen/Makefile: Use option to specify Unicode version
	for utf8_gen.py
2018-07-10 17:30:31 +02:00
Florian Weimer fd70af4552 Add the statx function 2018-07-10 16:14:45 +02:00
Adhemerval Zanella b444e8f7cc Comment tst-ofdlocks-compat expected failure in some Linux releases
As pointed out in a libc-alpha thread [1], the misc/tst-ofdlocks-compat
may fail in some specific Linux releases.  This patch adds a comment
along with a link to discussion in the test source code.

No changes are expected.

	* sysdeps/unix/sysv/linux/tst-ofdlocks-compat.c: Add a comment about
	a kernel issue which lead to test failure in some cases.

[1] https://sourceware.org/ml/libc-alpha/2018-07/msg00243.html
2018-07-10 10:28:39 -03:00
Florian Weimer 7b2f4cedf0 regexec: Fix off-by-one bug in weight comparison [BZ #23036]
Each weight is prefixed by its length, and the length does not include
itself in the count.  This can be seen clearly from the find_idx
function in string/strxfrm_l.c, for example.  The old code behaved as if
the length itself counted, thus comparing an additional byte after the
weight, leading to spurious comparison failures and incorrect further
partitioning of character equivalence classes.
2018-07-10 11:18:26 +02:00
Florian Weimer 4fa34da679 Fix copyright years in recent commits 2018-07-10 11:03:08 +02:00
Florian Weimer 916124ed84 nss_files: Fix re-reading of long lines [BZ #18991]
Use the new __libc_readline_unlocked function to pick up
reading at the same line in case the buffer needs to be enlarged.
2018-07-06 17:52:54 +02:00
Florian Weimer 3f5e3f5d06 libio: Implement internal function __libc_readline_unlocked
This is a variant of fgets which fails with ERANGE if the
buffer is too small, and the buffer length is given as an
argument of type size_t.

This function will be useful for implementing NSS file reading
operations.  Compared to a direct implementation using the public API,
it avoids an lseek system call in case the line terminator can be
found in the internal read buffer.
2018-07-06 17:52:54 +02:00
Szabolcs Nagy 397c54c1af aarch64: add HWCAP_ATOMICS to HWCAP_IMPORTANT
This enables searching shared libraries in atomics/ when the hardware
supports LSE atomics of armv8.1 so one can provide optimized variants
of libraries in a portable way.

LSE atomics does not affect library abi, the new instructions can
interoperate with old ones.

I considered the earlier comments on the patch

https://sourceware.org/ml/libc-alpha/2018-04/msg00400.html
https://sourceware.org/ml/libc-alpha/2018-04/msg00625.html

It turns out that the way glibc dynamic linker decides on the search
path is not very flexible: it wants to use hwcap bits and associated
strings.  So some targets reuse hwcap bits for glibc internal purposes
to affect the search logic.  But hwcap is an interface with the kernel,
glibc should not allocate bits in it for its internal logic as that
limits future hwcap extensions and confusing to users who expect to see
hwcap bits in ifunc resolvers.  Instead of rewriting the dynamic linker
path logic (which affects all targets) this patch just uses the existing
mechanism, however this means that the path name has to be the hwcap
name "atomics" and cannot be changed to something more meaningful to
users.

It is hard to tell how much performance benefit this can give, in
principle armv8.1 atomics can be better optimized in the hardware, so it
can make a difference for synchronization heavy code.  On some systems
such multilib setup may be the only viable way to get optimized
libraries used.

	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT): Add
	HWCAP_ATOMICS.
2018-07-06 15:58:16 +01:00
Szabolcs Nagy d0cd798071 aarch64: Remove HWCAP_CPUID from HWCAP_IMPORTANT
This partially reverts

commit f82e9672ad
Author:     Siddhesh Poyarekar <siddhesh@sourceware.org>

    aarch64: Allow overriding HWCAP_CPUID feature check using HWCAP_MASK

The idea was to make it possible to disable cpuid based ifunc resolution
in glibc by changing the hwcap mask which the user could already control.

However the hwcap mask has an orthogonal role: it specifies additional
library search paths for the dynamic linker.  So "cpuid" got added to
the search paths when it was set in the default mask (HWCAP_IMPORTANT),
which is not useful behaviour, the hwcap masking should not be reused
in the cpu features code.

Meanwhile there is a tunable to set the cpu explicitly so it is possible
to disable the cpuid based dispatch without using a hwcap mask:

  GLIBC_TUNABLES=glibc.tune.cpu=generic

	* sysdeps/unix/sysv/linux/aarch64/cpu-features.c (init_cpu_features):
	Use dl_hwcap without masking.
	* sysdeps/unix/sysv/linux/aarch64/dl-procinfo.h (HWCAP_IMPORTANT):
	Remove HWCAP_CPUID.
2018-07-06 15:57:18 +01:00
Florian Weimer ddb3c626b0 conform/conformtest.pl: Escape literal braces in regular expressions
This suppresses Perl warnings like these:

Unescaped left brace in regex is deprecated here (and will be fatal in
Perl 5.32), passed through in regex; marked by <-- HERE in m/^element
*({ <-- HERE ([^}]*)}|([^{ ]*)) *({([^}]*)}|([^{ ]*)) *([A-Za-z0-9_]*)
*(.*)/ at conformtest.pl line 370.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-06 16:31:55 +02:00
Amit Pawar bce5911b67 Use AVX_Fast_Unaligned_Load from Zen onwards.
From Zen onwards this will be enabled. It was disabled for the
Excavator case and will remain disabled.

Reviewd-by: Carlos O'Donell <carlos@redhat.com>
2018-07-06 09:55:36 -04:00
Florian Weimer 3a885c1f51 Build csu/elf-init.c and csu/static-reloc.c with stack protector
This does not change generated code (with -fstack-protector-strong), but
is important for formal compiler flags compliance.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-05 22:57:45 +02:00
Florian Weimer 38cade0c46 Compile debug/stack_chk_fail_local.c with stack protector
The resulting object file is statically linked into applications, so
it is desirable to have (formal) stack protector coverage there.
2018-07-05 19:28:35 +02:00
Maciej W. Rozycki 9449a295ad libc-abis: Define ABSOLUTE ABI [BZ #19818][BZ #23307]
Define a new ABSOLUTE ABI for static linker's use with EI_ABIVERSION
where correct absolute (SHN_ABS) symbol run-time load semantics is
required.  This way it can be ensured at static link time that a program
or DSO will not suffer from previous semantics where absolute symbols
were relocated by the base address, or symbols whose `st_value' is zero
silently ignored leading to a confusing "undefined symbol" error message
at load time, and instead "ELF file ABI version invalid" is printed with
old dynamic loaders, making it clear that there is an ABI version
incompatibility.

	[BZ #19818]
	[BZ #23307]
	* libc-abis (ABSOLUTE): New ABI.
	* sysdeps/unix/sysv/linux/mips/libc-abis (ABSOLUTE): New ABI.
	* NEWS: Mention the new ABI.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-05 18:06:43 +01:00
Florian Weimer d6da5cb6a8 Add renameat2 function [BZ #17662]
The implementation falls back to renameat if renameat2 is not available
in the kernel (or in the kernel headers) and the flags argument is zero.
Without kernel support, a non-zero argument returns EINVAL, not ENOSYS.
This mirrors what the kernel does for invalid renameat2 flags.
2018-07-05 19:00:10 +02:00
Adhemerval Zanella 1002d70823 posix: Fix bug-regex33 after regex sync
On some platforms the inclusion of regex-internal.h in bug-regex33
testcase show a MAX redefinition if test-skeleton.c is include later.
This patch fixes by removing regex-internal.h inclusion and using
SBC_MAX value directly.

Checked on aarch64-linux-gnu.

	* posix/bug-regex33.c: Fix build after regex sync.
2018-07-04 17:29:49 -03:00
Carlos O'Donell 34fdb893e0 locale: XFAIL newlocale usage in static binary (Bug 23164)
There is a glibc optimization which allows for locale categories
to be removed during static compilation. There have been various
bugs for this support over the years, with bug 16915 being the
most recent. The solution there was to emit a reference to all the
categories to avoid any being removed. This fix, although it's in
the generic __nl_langinfo_l function, doesn't appear to be enough
to fix the case for a statically linked program that uses newlocale
and nl_langinfo_l. This commit doesn't fix the problem, but it does
add a XFAIL'd test case such that a fix can be applied against this
and the XFAIL removed. It's not entirely clear that the problem is
the same as that which was seen in bug 16915.
2018-07-04 15:23:50 -04:00
Florian Weimer f2873d2da0 testrun.sh: Implement --tool=strace, --tool=valgrind
$(file …) appears to be the only convenient way to create files
with newlines and make substitution variables.  This needs make 4.0
(released in 2013), so update the requirement to match.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-04 15:30:45 +02:00
Adhemerval Zanella eb04c21373 posix: Sync gnulib regex implementation
This patch syncs the regex implementation with gnulib (commit 0ee5212).
Only two changes in GLIBC regex testing are required:

  1. posix/bug-regex28.c: as previously discussed [1] the change of
     expected results on the pattern should be safe.

  2. posix/PCRE.tests: the ERE (a)|\1 is malformed (in the sense that
     the \1 doesn't mean anything) and although current GLIBC accepts
     it has undefined behavior.  This patch removes the specific test.

This sync contains some patches from thread 'Regex: Make libc regex
more usable outside GLIBC.' [2] which have been pushed upstream in
gnulib.  This patches also fixes some regex issues (BZ #23233,
BZ #21163, BZ #18986, BZ #13762) and I did not add testcases for
both #23233 and #13762 because I couldn't think a simple way to
trigger the expected failure path to trigger them.

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

	[BZ #23233]
	[BZ #21163]
	[BZ #18986]
	[BZ #13762]
	* posix/Makefile (tests): Add bug-regex37 and bug-regex38.
	* posix/PCRE.tests: Remove invalid test.
	* posix/bug-regex28.c: Fix expected values for used syntax.
	* posix/bug-regex37.c: New file.
	* posix/bug-regex38.c: Likewise.
	* posix/regcomp.c: Sync with gnulib.
	* posix/regex.c: Likewise.
	* posix/regex.h: Likewise.
	* posix/regex_internal.c: Likewise.
	* posix/regex_internal.h: Likewise.
	* posix/regexec.c: Likewise.

[1] https://sourceware.org/ml/libc-alpha/2017-12/msg00807.html
[2] https://sourceware.org/ml/libc-alpha/2017-12/msg00237.html
2018-07-04 09:54:45 -03:00
Mike FABIAN b11643c21c Bug 23308: Update to Unicode 11.0.0
Unicode 11.0.0 Support: Character encoding, character type info, and
transliteration tables are all updated to Unicode 11.0.0, using
the generator scripts contributed by Mike FABIAN (Red Hat).

Some info about the number of characters added:

Total added characters in newly generated CHARMAP: 684
Total added characters in newly generated WIDTH: 119
alpha: Added 380 characters in new ctype which were not in old ctype
combining: Added 56 characters in new ctype which were not in old ctype
combining_level3: Added 37 characters in new ctype which were not in old ctype
graph: Added 684 characters in new ctype which were not in old ctype
lower: Added 82 characters in new ctype which were not in old ctype
print: Added 684 characters in new ctype which were not in old ctype
punct: Added 304 characters in new ctype which were not in old ctype
tolower: Added 79 characters in new ctype which were not in old ctype
totitle: Added 33 characters in new ctype which were not in old ctype
toupper: Added 79 characters in new ctype which were not in old ctype
upper: Added 79 characters in new ctype which were not in old ctype

No characters were removed.

	[BZ #23308]
	* unicode-gen/Makefile (UNICODE_VERSION): Set to 11.0.0.
	* localedata/unicode-gen/DerivedCoreProperties.txt: Update to Unicode 11.0.0.
	* localedata/unicode-gen/EastAsianWidth.txt: likewise.
	* localedata/unicode-gen/PropList.txt: likewise.
	* localedata/unicode-gen/UnicodeData.txt: likewise.
	* localedata/charmaps/UTF-8: Regenerate.
	* localedata/locales/i18n_ctype: likewise.
	* localedata/locales/tr_TR: likewise.
	* localedata/locales/translit_circle: likewise.
	* localedata/locales/translit_cjk_compat: likewise.
	* localedata/locales/translit_combining: likewise.
	* localedata/locales/translit_compat: likewise.
	* localedata/locales/translit_font: likewise.
	* localedata/locales/translit_fraction: likewise.
2018-07-04 12:03:33 +02:00
Florian Weimer 5a35750665 stdio-common/tst-printf.c: Remove part under a non-free license [BZ #23363]
The license does not allow modification.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
2018-07-03 18:29:16 +02:00
Adhemerval Zanella 7279af007c Fix hurd expected fcntl version
Different than Linux, hurd does not need the OFD locks fix from
06ab719d30 (since OFD locks are current Linux specific). This in
turn allows hurd to not provide a fcntl compat symbol.

Checked on a i686-gnu with check-abi.

	* sysdeps/mach/hurd/i386/libc.abilist [GLIBC_2.28] (fcntl): Remove
	symbol.
2018-07-03 10:02:06 -03:00
Gabriel F. T. Gomes b7b88cea41 ldbl-128ibm-compat: Add printf_size
Since the addition of the _Float128 API, strfromf128 and printf_size use
__printf_fp to print _Float128 values.  This is achieved by setting the
'is_binary128' member of the 'printf_info' structure to one.  Now that
the format of long double on powerpc64le is getting a third option, this
mechanism is reused for long double values that have binary128 format
(i.e.: when -mabi=ieeelongdouble).

This patch adds __printf_sizeieee128 as an exported symbol, but doesn't
provide redirections from printf_size, yet.  All redirections will be
installed in a future commit, once all other functions that print or
read long double values with binary128 format are ready.  In
__printf_fp, when 'is_binary128' is one, the floating-point argument is
treated as if it was of _Float128 type, regardless of the value of
'is_long_double', thus __printf_sizeieee128 sets 'is_binary128' to the
same value of 'is_long_double'.  Otherwise, double values would not be
printed correctly.

Tested for powerpc64le.
2018-07-02 10:51:01 -03:00
Szabolcs Nagy 2b445206a1 Use uint32_t sign in single precision math error handling functions
Ideally sign should be bool, but sometimes (e.g. in powf) it's more
efficient to pass a non-zero value than 1 to indicate that the sign
should be set.  The fixed size int is less ambigous than unsigned
long.

	* sysdeps/ieee754/flt-32/e_powf.c (__powf): Use uint32_t.
	(exp2f_inline): Likewise.
	* sysdeps/ieee754/flt-32/math_config.h (__math_oflowf): Likewise.
	(__math_uflowf): Likewise.
	(__math_may_uflowf): Likewise.
	(__math_divzerof): Likewise.
	(__math_invalidf): Likewise.
	* sysdeps/ieee754/flt-32/math_errf.c (xflowf): Likewise.
	(__math_oflowf): Likewise.
	(__math_uflowf): Likewise.
	(__math_may_uflowf): Likewise.
	(__math_divzerof): Likewise.
	(__math_invalidf): Likewise.
2018-07-02 09:29:04 +01:00
Carlos O'Donell 2827ab990a libc: Extend __libc_freeres framework (Bug 23329).
The __libc_freeres framework does not extend to non-libc.so objects.
This causes problems in general for valgrind and mtrace detecting
unfreed objects in both libdl.so and libpthread.so.  This change is
a pre-requisite to properly moving the malloc hooks out of malloc
since such a move now requires precise accounting of all allocated
data before destructors are run.

This commit adds a proper hook in libc.so.6 for both libdl.so and
for libpthread.so, this ensures that shm-directory.c which uses
freeit () to free memory is called properly.  We also remove the
nptl_freeres hook and fall back to using weak-ref-and-check idiom
for a loaded libpthread.so, thus making this process similar for
all DSOs.

Lastly we follow best practice and use explicit free calls for
both libdl.so and libpthread.so instead of the generic hook process
which has undefined order.

Tested on x86_64 with no regressions.

Signed-off-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Carlos O'Donell <carlos@redhat.com>
2018-06-29 22:39:06 -04:00
Rajalakshmi Srinivasaraghavan 37d3d244e1 Add long double input for strfmon test
This patch adds long double type inputs in strfmon_l test
which will help in long double migration.

Tested for powerpc64le.
2018-06-30 06:54:34 +05:30
Michael Wolf a1e0c5fa88 New locale: Lower Sorbian (dsb_DE) [BZ #23208]
[BZ #23208]
	* localedata/SUPPORTED (dsb_DE/UTF-8): New entry.
	* localedata/locales/dsb_DE: New file.
2018-06-29 23:03:06 +02:00
Rafal Luzynski 2e0c5de622 hy_AM: Add alternative month names (bug 23140).
This locale already contained correct data in mon array.  Updated from
CLDR to start the month names with the lowercase letters.

alt_mon is a new import from CLDR.  The change has been consulted
off-list with a native speaker.

	[BZ #23140]
	* localedata/locales/hy_AM (mon): Synchronize with CLDR (lowercase,
	genitive case).
	(alt_mon): New entry, import from CLDR (nominative case).
2018-06-29 22:18:24 +02:00
Sylvain Lesage cdb52c7182 es_BO locale: Change LC_PAPER to en_US (bug 22996).
[BZ #22996]
	* localedata/locales/es_BO (LC_PAPER): Change to “copy "en_US"”.
2018-06-29 21:45:16 +02:00
Siddhesh Poyarekar 0aec4c1d18 aarch64,falkor: Use vector registers for memcpy
Vector registers perform better than scalar register pairs for copying
data so prefer them instead.  This results in a time reduction of over
50% (i.e. 2x speed improvemnet) for some smaller sizes for memcpy-walk.
Larger sizes show improvements of around 1% to 2%.  memcpy-random shows
a very small improvement, in the range of 1-2%.

	* sysdeps/aarch64/multiarch/memcpy_falkor.S (__memcpy_falkor):
	Use vector registers.
2018-06-29 22:45:59 +05:30
Siddhesh Poyarekar ce76a5cb8d aarch64,falkor: Use vector registers for memmove
Vector registers perform much better for moves compared to pairs of
registers on falkor, so use them instead.  This results in a time
reduction of up to 50% (i.e. 2x improvement) for a lot of the smaller
sizes, i.e. up to 1K in memmove-walk.  Improvements for larger sizes are
smaller, at about 1%-2%.

	* sysdeps/aarch64/multiarch/memmove_falkor.S
	(__memcpy_falkor): Use vector registers.
2018-06-29 22:45:07 +05:30