glibc:hjl/hwcap/master

Last commit made on 2017-04-07
Get this branch:
git clone -b hjl/hwcap/master https://git.launchpad.net/glibc

Branch merges

Branch information

Name:
hjl/hwcap/master
Repository:
lp:glibc

Recent commits

32ffd2e... by "H.J. Lu" <email address hidden>

x86: Set dl_hwcap from CPU features

On x86, the usage of AT_HWCAP in glibc is obsolete since addition of
dl_x86_cpu_features. dl_hwcap, which was set from AT_HWCAP, is used by
dynamic linker to build an array of hardware capability names, which are
added to search path when loading shared object. dl_hwcap was unused on
x86-64 and only SSE2 was used on i386.

This patch sets dl_hwcap with new hardware capabilities from CPU
features. Currently, 2 capabilities, SSE2 and AVX2, are supported.
The maximum number of hardware capabilities is 64. Since x86-64
includes SSE2, SSE2 is skipped on x86-64. dl_x86_cap_flags is kepted
for i386 and is used by _dl_show_auxv. dl_x86_hwcap_flags is added
for new hardware capabilities.

 * sysdeps/i386/dl-hwcap.h: New file.
 * sysdeps/x86/dl-hwcap.h: Likewise.
 * sysdeps/x86_64/dl-hwcap.h: Likewise.
 * sysdeps/x86_64/dl-procinfo.h: Likewise.
 * sysdeps/i386/dl-procinfo.c (_dl_x86_hwcap_flags): New.
 * sysdeps/i386/dl-procinfo.h: Include <dl-hwcap.h>.
 (_DL_HWCAP_COUNT): Removed.
 (HWCAP_I386_XXX): Likewise.
 (HWCAP_IMPORTANT): Likewise.
 (_dl_procinfo): Likewise.
 (_dl_hwcap_string): Likewise.
 (_dl_string_hwcap): Likewise.
 * sysdeps/unix/sysv/linux/i386/dl-procinfo.h (_dl_procinfo):
 Replace _DL_HWCAP_COUNT with 32.
 * sysdeps/unix/sysv/linux/x86_64/dl-procinfo.h [!IS_IN (ldconfig)]:
 Include <sysdeps/x86_64/dl-procinfo.h>.
 * sysdeps/x86/cpu-features.c: Include <dl-hwcap.h>.
 (init_cpu_features): Set dl_hwcap and dl_hwcap_mask.
 * sysdeps/x86_64/dl-procinfo.c (_dl_x86_hwcap_flags): New.

bf77301... by "H.J. Lu" <email address hidden>

Check if SSE is available with HAS_CPU_FEATURE

Similar to other CPU feature checks, check if SSE is available with
HAS_CPU_FEATURE.

 * sysdeps/i386/fpu/fclrexcpt.c (__feclearexcept): Use
 HAS_CPU_FEATURE to check for SSE.
 * sysdeps/i386/fpu/fedisblxcpt.c (fedisableexcept): Likewise.
 * sysdeps/i386/fpu/feenablxcpt.c (feenableexcept): Likewise.
 * sysdeps/i386/fpu/fegetenv.c (__fegetenv): Likewise.
 * sysdeps/i386/fpu/fegetmode.c (fegetmode): Likewise.
 * sysdeps/i386/fpu/feholdexcpt.c (__feholdexcept): Likewise.
 * sysdeps/i386/fpu/fesetenv.c (__fesetenv): Likewise.
 * sysdeps/i386/fpu/fesetmode.c (fesetmode): Likewise.
 * sysdeps/i386/fpu/fesetround.c (__fesetround): Likewise.
 * sysdeps/i386/fpu/feupdateenv.c (__feupdateenv): Likewise.
 * sysdeps/i386/fpu/fgetexcptflg.c (__fegetexceptflag): Likewise.
 * sysdeps/i386/fpu/fsetexcptflg.c (__fesetexceptflag): Likewise.
 * sysdeps/i386/fpu/ftestexcept.c (fetestexcept): Likewise.
 * sysdeps/i386/setfpucw.c (__setfpucw): Likewise.
 * sysdeps/x86/cpu-features.h (bit_cpu_SSE): New.
 (index_cpu_SSE): Likewise.
 (reg_SSE): Likewise.

893ba3e... by Paul Eggert

getopt: merge from gnulib: use angle-bracket includes consistently

 * posix/getopt1.c: Include <config.h>, not "config.h".

06576cb... by Zack Weinberg

getopt: annotate files with relationship to gnulib.

As the final act in this patchset, adjust the "This file is part of
the GNU C Library" message at the top of each file to indicate which
files are synced with gnulib.

 * posix/bits/getopt_core.h, posix/bits/getopt_ext.h
 * posix/getopt.c, posix/getopt1.c, posix/getopt_int.h:
 Mention in top-of-file boilerplate that these files are shared
 with gnulib.
 * posix/getopt.h, posix/bits/getopt_posix.h:
 Mention in top-of-file boilerplate that these files are NOT shared
 with gnulib, unlike the rest of the getopt implementation.

10a33cf... by Zack Weinberg

getopt: eliminate __need_getopt by splitting up getopt.h.

__need_getopt is misnamed; what it really means is "we want only the
getopt features specified in POSIX, not the GNU extensions". Because
this code is shared with gnulib, it winds up being cleanest to split
getopt.h into *four* headers. getopt_core.h and getopt_ext.h will
be shared with gnulib, getopt_posix.h will be just for glibc, and
each project will have its own copy of getopt.h.

 * posix/bits/getopt_core.h, posix/bits/getopt_ext.h:
 New files, intended to be shared with gnulib.
 * posix/bits/getopt_posix.h:
 New file, not intended to be shared with gnulib.
 * posix/getopt.h: Now just includes features.h,
 bits/getopt_core.h, and bits/getopt_ext.h. Will
 no longer be shared with gnulib.
 * include/bits/getopt_core.h, include/bits/getopt_ext.h
 * include/bits/getopt_posix.h: New wrappers.
 * posix/Makefile: Install new headers.
 * posix/unistd.h, libio/stdio.h:
 Include bits/getopt_posix.h instead of getopt.h.

0f3be87... by Zack Weinberg

getopt: merge _GL_UNUSED annotations from gnulib

gnulib now has annotations on at least some functions to cater to
compilation with -Wunused-parameter. In order to follow suit cleanly,
I've added to libc-symbols.h some of the _GL_* macros that
gnulib-common.m4 puts into config.h. (I don't think they belong in
sys/cdefs.h, at least not without further thought.)

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

 * include/libc-symbols.h: For gnulib compatibility, define
 _GL_UNUSED, _GL_UNUSED_LABEL, _GL_ATTRIBUTE_PURE, and
 _GL_ATTRIBUTE_CONST.
 * posix/getopt.c (_getopt_initialize): Mark argc and argv
 parameters with _GL_UNUSED.

aeacb9f... by Zack Weinberg

getopt: merge from gnulib: alloca avoidance

In one place, glibc's getopt uses alloca to construct a linked list of
possibilities for an "ambiguous" long option. In gnulib, malloc
should be used instead. Providing for both cases complicates things a
fair bit. Instead of merging straight across, therefore, I have
chosen to rewrite it using a boolean vector instead of a linked list.
There is then only one allocation that might need freeing; in glibc it
can honor __libc_use_alloca as usual, and in gnulib we define
__libc_use_alloca to always be false, so we don't need ifdefs in the
middle of the function. This should also be slightly more efficient
in the normal case of long options being fully spelled out -- I think
most people aren't even aware they _can_ sometimes abbreviate long
options.

One interesting consequence is that the list of possibilities is now
printed in exactly the order they appear in the list of long options,
instead of the first possibility being shuffled to the end. This
shouldn't be a big deal but it did break one test that relied on the
exact text of this error message.

(The reason the previous patch was "in aid of" merging from gnulib is
I didn't want to have to make this change in two places.)

(The patch looks bigger than it really is because there's a fair bit
of reindentation and code rearrangement.)

 * posix/getopt.c: When used standalone, define __libc_use_alloca
 as always false and alloca to abort if called.
 (process_long_option): Rewrite handling of ambiguous long options
 to use a single boolean vector, not a linked list; use
 __libc_use_alloca to decide whether to allocate this using alloca.

 * posix/tst-getopt_long1.c: Adjust text of expected error message.

dfbea09... by Zack Weinberg

getopt: refactor long-option handling

There were two copies of the bulk of the code to handle long options.
Now there is only one. (Yes, this is in aid of merging from gnulib.)

The change to bug-getopt4.c clarifies the error messages when the test
fails.

 * posix/getopt.c (process_long_option): New function split out
 from _getopt_internal_r.
 (_getopt_internal_r): Replace both copies of the long-option
 processing code with calls to process_long_option.
 * posix/bug-getopt4.c (one_test): Print argv[0] in error messages.
 (do_test): Differentiate argv[0] in the two subtests.

c1af877... by Zack Weinberg

getopt: tidy up _getopt_initialize a bit

_getopt_data.__posixly_correct is completely redundant to
_getopt_data.__ordering, and some work that logically belongs in
_getopt_initialize was being done by _getopt_internal_r, making the
code harder to understand.

As a side effect, getenv will no longer be called if the first
character of the options string is '+' or '-', which is probably a
Good Thing. (Perhaps we should have a flag character that
specifically asks for the permutation behavior?)

 * posix/getopt_int.h (_getopt_data): Remove __posixly_correct field.
 * posix/getopt.c (_getopt_internal_r): Move some initialization code...
 (_getopt_initialize): ...here. Don't set d->__posixly_correct.

7a7be6c... by Zack Weinberg

getopt: merge from gnulib: function prototype adjustments

For standards compliance, getopt, getopt_long, and getopt_long_only in
glibc have to take 'char *const *argv' even though they can mutate the
array. gnulib has tried to clean this up as much as possible: all the
internal functions use 'char **argv', and when used standalone, so do
getopt_long and getopt_long_only.

Also brought over are __nonnull annotations, corrections to documentation,
and apparently it is no longer necessary to worry about conflicting
prototypes for getopt. The macroification of the definitions of
getopt and __posix_getopt goes beyond what is currently in gnulib.

At this point getopt1.c and getopt_int.h are identical to their gnulib
versions.

 * posix/getopt.h: Add backup definition of __nonnull for
 consistency with gnulib. Define __getopt_argv_const to const
 if not already defined.
 (getopt): Update doc comment from gnulib. Prototype
 unconditionally. Add __nonnull annotation.
 (__posix_getopt): Add __nonnull annotation.
 (getopt_long, getopt_long_only): Use __getopt_argv_const in
 prototypes for consistency with gnulib. Add __nonnull
 annotations.
 * posix/getopt.c (_getopt_initialize, _getopt_internal_r)
 (getopt_internal): Change 'argv' argument to type 'char **'.
 Remove now-unnecessary casts.
 (getopt, __posix_getopt): Eliminate repetition with a macro.
 Cast 'argv' to 'char **' when calling _getopt_internal.
 * posix/getopt1.c (getopt_long, getopt_long_only):
 Use __getopt_argv_const for consistency with gnulib.
 Cast 'argv' to 'char **' when calling _getopt_internal.
 (_getopt_long_r, _getopt_long_only_r):
 Change 'argv' argument to type 'char **'.
 (main): Constify 'long_options'.
 * posix/getopt_int.h (getopt_internal, _getopt_internal_r)
 (_getopt_long_r, _getopt_long_only_r):
 Change 'argv' argument to type 'char **'.