From 94ba134cf6431dad0aaece271a16761bc793d490 Mon Sep 17 00:00:00 2001 From: joseph Date: Tue, 2 Jul 2013 00:11:45 +0000 Subject: Merge changes between r23363 and r23421 from /fsf/trunk. git-svn-id: svn://svn.eglibc.org/trunk@23422 7b3dc134-2b1b-0410-93df-9e9f96275f8d --- libc/ChangeLog | 193 +++++++ libc/INSTALL | 11 +- libc/NEWS | 41 +- libc/configure | 2 +- libc/configure.in | 2 +- libc/dlfcn/Makefile | 18 +- libc/dlfcn/modstatic3.c | 31 ++ libc/dlfcn/modstatic5.c | 26 + libc/dlfcn/tststatic3.c | 128 +++++ libc/dlfcn/tststatic4.c | 363 ++++++++++++++ libc/dlfcn/tststatic5.c | 76 +++ libc/elf/dl-load.c | 10 +- libc/elf/dl-open.c | 26 +- libc/elf/dl-profile.c | 13 +- libc/elf/dl-support.c | 55 +- libc/elf/dl-sysdep.c | 10 +- libc/elf/elf.h | 5 +- libc/include/libc-internal.h | 20 + libc/locale/locarchive.h | 7 + libc/locale/programs/locarchive.c | 62 ++- libc/manual/install.texi | 4 +- libc/manual/texinfo.tex | 555 +++++++++++++-------- libc/misc/getauxval.c | 2 + libc/nptl/ChangeLog | 5 + libc/nptl/pthread_exit.c | 4 + libc/nscd/connections.c | 4 +- libc/ports/ChangeLog.aarch64 | 10 + libc/ports/ChangeLog.alpha | 17 + libc/ports/ChangeLog.arm | 7 + libc/ports/ChangeLog.ia64 | 7 + libc/ports/ChangeLog.m68k | 27 + libc/ports/ChangeLog.mips | 12 + libc/ports/ChangeLog.tile | 9 + libc/ports/sysdeps/aarch64/dl-machine.h | 4 +- libc/ports/sysdeps/alpha/Versions | 4 + libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrt.S | 9 + libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S | 9 + libc/ports/sysdeps/alpha/dl-procinfo.h | 2 +- libc/ports/sysdeps/alpha/fpu/e_sqrt.c | 22 + libc/ports/sysdeps/alpha/fpu/e_sqrtf.c | 14 + libc/ports/sysdeps/alpha/soft-fp/e_sqrtl.c | 10 + libc/ports/sysdeps/m68k/dl-trampoline.S | 54 +- libc/ports/sysdeps/m68k/fpu_control.h | 64 +-- libc/ports/sysdeps/m68k/sysdep.h | 4 +- libc/ports/sysdeps/mips/dl-procinfo.h | 2 +- libc/ports/sysdeps/tile/fegetenv.c | 29 -- libc/ports/sysdeps/tile/fegetround.c | 25 - libc/ports/sysdeps/tile/feholdexcpt.c | 27 - libc/ports/sysdeps/tile/fesetenv.c | 31 -- libc/ports/sysdeps/tile/fesetround.c | 26 - libc/ports/sysdeps/tile/feupdateenv.c | 27 - .../sysdeps/unix/sysv/linux/aarch64/getcontext.S | 3 +- .../unix/sysv/linux/alpha/nptl/libm.abilist | 5 + .../sysdeps/unix/sysv/linux/arm/dl-procinfo.h | 6 +- .../ports/sysdeps/unix/sysv/linux/ia64/dl-static.c | 7 - .../ports/sysdeps/unix/sysv/linux/mips/dl-static.c | 7 - libc/string/test-memcmp.c | 24 + libc/sysdeps/generic/dl-procinfo.h | 2 +- libc/sysdeps/generic/ldsodefs.h | 4 + libc/sysdeps/generic/libc-mmap.h | 26 + libc/sysdeps/i386/dl-procinfo.h | 2 +- libc/sysdeps/powerpc/Makefile | 2 +- libc/sysdeps/powerpc/bits/hwcap.h | 23 +- libc/sysdeps/powerpc/dl-procinfo.c | 15 +- libc/sysdeps/powerpc/dl-procinfo.h | 57 ++- libc/sysdeps/powerpc/powerpc32/power8/Implies | 2 + libc/sysdeps/powerpc/powerpc64/power8/Implies | 2 + libc/sysdeps/powerpc/rtld-global-offsets.sym | 1 + libc/sysdeps/s390/dl-procinfo.h | 2 +- libc/sysdeps/sparc/dl-procinfo.h | 6 +- libc/sysdeps/unix/sysv/linux/i386/dl-procinfo.h | 6 +- libc/sysdeps/unix/sysv/linux/mmap64.c | 2 +- .../sysv/linux/powerpc/powerpc32/power8/Implies | 2 + .../sysv/linux/powerpc/powerpc64/power8/Implies | 2 + libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h | 6 +- libc/sysdeps/x86_64/multiarch/init-arch.c | 10 +- libc/sysdeps/x86_64/multiarch/init-arch.h | 4 + libc/sysdeps/x86_64/multiarch/memcmp-ssse3.S | 6 +- libc/sysdeps/x86_64/multiarch/strchr.S | 2 + libc/sysdeps/x86_64/multiarch/strcmp.S | 34 +- libc/sysdeps/x86_64/multiarch/strrchr.S | 2 + 81 files changed, 1809 insertions(+), 588 deletions(-) create mode 100644 libc/dlfcn/modstatic3.c create mode 100644 libc/dlfcn/modstatic5.c create mode 100644 libc/dlfcn/tststatic3.c create mode 100644 libc/dlfcn/tststatic4.c create mode 100644 libc/dlfcn/tststatic5.c create mode 100644 libc/ports/sysdeps/alpha/fpu/e_sqrtf.c delete mode 100644 libc/ports/sysdeps/tile/fegetenv.c delete mode 100644 libc/ports/sysdeps/tile/fegetround.c delete mode 100644 libc/ports/sysdeps/tile/feholdexcpt.c delete mode 100644 libc/ports/sysdeps/tile/fesetenv.c delete mode 100644 libc/ports/sysdeps/tile/fesetround.c delete mode 100644 libc/ports/sysdeps/tile/feupdateenv.c create mode 100644 libc/sysdeps/generic/libc-mmap.h create mode 100644 libc/sysdeps/powerpc/powerpc32/power8/Implies create mode 100644 libc/sysdeps/powerpc/powerpc64/power8/Implies create mode 100644 libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/power8/Implies create mode 100644 libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/power8/Implies diff --git a/libc/ChangeLog b/libc/ChangeLog index ac92ef164..406ca28bd 100644 --- a/libc/ChangeLog +++ b/libc/ChangeLog @@ -1,3 +1,196 @@ +2013-06-28 Liubov Dmitrieva + + * sysdeps/x86_64/multiarch/init-arch.c (__init_cpu_features): Set + bit_Slow_SSE4_2 and bit_Prefer_PMINUB_for_stringop for Intel + Silvermont. + * sysdeps/x86_64/multiarch/init-arch.h (bit_Slow_SSE4_2): New + macro. + (index_Slow_SSE4_2): Likewise. + (index_Prefer_PMINUB_for_stringop): Likewise. + * sysdeps/x86_64/multiarch/strchr.S: Skip SSE4.2 version if + bit_Slow_SSE4_2 is set. + * sysdeps/x86_64/multiarch/strcmp.S: Likewise. + * sysdeps/x86_64/multiarch/strrchr.S: Likewise. + +2013-06-28 Ryan S. Arnold + + * sysdeps/powerpc/Makefile: Add comment about generating an offset to + rtld_global._dl_hwcap2. + * sysdeps/powerpc/bits/hwcap.h: Added PPC_FEATURE2_* definitions for + POWER8. + * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_cap_flags): Extend for + POWER8 feature descriptions defined in _dl_hwcap2. + * sysdeps/powerpc/dl-procinfo.h (_dl_procinfo): Implement AT_HWCAP2 + string handling for POWER8 feature bits. + (_DL_HWCAP_COUNT): Increment to 64 to cover AT_HWCAP2 bits. + (_DL_HWCAP_LAST): New definition for position of last AT_HWCAP bit in + _dl_powerpc_cap_flags. + (_DL_HWCAP2_LAST): New definition for last usable bit of AT_HWCAP2. + * sysdeps/powerpc/rtld-global-offsets.sym + (RTLD_GLOBAL_RO_DL_HWCAP2_OFFSET): New offset macro to locate + _dl_hwcap2 in the rtld_global_ro structure. + +2013-06-28 Ryan S. Arnold + + * elf/dl-support.c (_dl_hwcap2): Add a new hwcap field for more + hardware capabilities in support of AT_HWCAP2. + (_dl_aux_init): Read AT_HWCAP2 into GLRO(dl_hwcap2). + * elf/dl-sysdep.c (_dl_sysdep_start): Read AT_HWCAP2 into + GLRO(dl_hwcap2). + (_dl_show_auxv): Add support for calling _dl_procinfo to display + AT_HWCAP2. If a platform doesn't chose to handle displaying AT_HWCAP2 + explicitly the unknown a_type display mechanism is used. + * misc/getauxval.c (__getauxval): Return GLRO(dl_hwcap2) on AT_HWCAP2. + * sysdeps/generic/ldsodefs.h (rtld_global_ro): Add _dl_hwcap2 as a new + struct member. + * sysdeps/generic/dl-procinfo.h (_dl_procinfo): Add TYPE parameter + to macro prototype for AT_HWCAP2 support. + * sysdeps/i386/dl-procinfo.h: Likewise. + * sysdeps/s390/dl-procinfo.h: Likewise. + * sysdeps/powerpc/dl-procinfo.h (_dl_procinfo): Add TYPE parameter to + macro prototype for AT_HWCAP2 support. Make WORD unsigned long int + rather than signed int. Stub in handler for TYPE == AT_HWCAP2 to + return -1 for unknown a_type display fallback. + * sysdeps/sparc/dl-procinfo.h: Likewise. + * sysdeps/unix/sysv/linux/i386/dl-procinfo.h: Likewise. + * sysdeps/unix/sysv/linux/s390/dl-procinfo.h: Likewise. + +2013-06-28 Joseph Myers + + * sysdeps/unix/sysv/linux/mmap64.c (__mmap64): Shift by page_shift + instead of MMAP2_PAGE_SHIFT in call to INLINE_SYSCALL. + +2013-06-28 Pierre Ynard + + [BZ #12492] + * elf/dl-load.c (_dl_map_object_from_fd): Test for failure of + mprotect making __stack_prot writable. + +2013-06-28 Nathan Froyd + Joseph Myers + + * elf/dl-profile.c (struct here_cg_arc_record): Declare 'count' + as being properly aligned. + +2013-06-28 Maciej W. Rozycki + + * dlfcn/modstatic5.c: New file. + * dlfcn/tststatic5.c: New file. + * dlfcn/Makefile (tests): Add tststatic5. + (tests-static): Likewise. + (modules-names): Add modstatic5. + (tststatic5-ENV): New variable. + ($(objpfx)tststatic5, $(objpfx)tststatic5.out): New dependencies. + + [BZ #15022] + * elf/dl-support.c (_dl_main_map): New variable. + (_dl_ns): Use it to initialize [LM_ID_BASE] element. + (_dl_nns, _dl_load_adds): Set to 1. + (_dl_initial_searchlist): Refer to _dl_main_map. + (_dl_non_dynamic_init): Initialize _dl_main_map.l_origin. + * elf/dl-load.c (_dl_dst_substitute) [!SHARED]: Remove fallback + call to _dl_get_origin. + * elf/dl-open.c (dl_open_worker): Remove !SHARED special casing + around call_map. + (_dl_open) [!SHARED]: Remove code to initialize GL(dl_nns). + * dlfcn/modstatic3.c: New file. + * dlfcn/tststatic3.c: New file. + * dlfcn/tststatic4.c: New file. + * dlfcn/Makefile (tests): Add tststatic3 and tststatic4. + (tests-static): Likewise. + (modules-names): Add modstatic3. + (tststatic3-ENV, tststatic4-ENV): New variables. + ($(objpfx)tststatic3, $(objpfx)tststatic3.out): New dependencies. + ($(objpfx)tststatic4, $(objpfx)tststatic4.out): Likewise. + +2013-06-26 Joseph Myers + + * configure.in (CC): Require GCC version 4.4 or later. + * configure: Regenerated. + * manual/install.texi (Tools for Compilation): Update GCC version + requirement. + * INSTALL: Regenerated. + +2013-06-26 Liubov Dmitrieva + + [BZ #15674] + * string/test-memcmp.c (check2): New. + (main): Call check2. + + * sysdeps/x86_64/multiarch/memcmp-ssse3.S: Fix buffers overrun. + +2013-06-26 Maciej W. Rozycki + + [BZ #15022] + * elf/dl-open.c (_dl_open) [!SHARED]: Move call to DL_STATIC_INIT + over to... + (dl_open_worker) [!SHARED]: ... here. + +2013-06-26 Ryan S. Arnold + + * elf/elf.h (AT_HWCAP2): Add a new a_type entry. + +2013-06-25 Richard Henderson + + * locale/programs/locarchive.c: Include + +2013-06-25 Joseph Myers + + * manual/texinfo.tex: Update to version 2013-06-21.17, with + trailing whitespace removed. + +2013-06-24 Mike Frysinger + + [BZ #10283] + * locale/locarchive.h (struct locarhandle): Add mmap_base and mmap_len. + * locale/programs/locarchive.c: Include libc-mmap.h. + (prepare_address_space): Take two new outputs (the mmap base and len). + Align p to MAP_FIXED_ALIGNMENT. Set mmap base and len to the right + values. + (create_archive): Declare new mmap base and len values for + prepare_address_space, and store the result in ah. + (file_data_available_p): Replace pagesz with MAP_FIXED_ALIGNMENT. + (enlarge_archive): If ah->mmap_base is not NULL, use that and + ah->mmap_len to unmap rather than ah->addr and ah->reserved. + Declare new mmap base and len values for + prepare_address_space, and store the result in new_ah. + (open_archive): Declare new mmap base and len values for + prepare_address_space, and store the result in ah. + (close_archive): If ah->mmap_base is not NULL, use that and + ah->mmap_len to unmap rather than ah->addr and ah->reserved. + * sysdeps/generic/libc-mmap.h: New file. + +2013-06-24 Mike Frysinger + + * include/libc-internal.h (ALIGN_DOWN): New helper macro. + (ALIGN_UP): Likewise. + (PTR_ALIGN_DOWN): Likewise. + (PTR_ALIGN_UP): Likewise. + +2013-06-24 Ryan S. Arnold + + * sysdeps/powerpc/dl-procinfo.c (_dl_powerpc_platforms): Add "power8" + entry mapped to PPC_PLATFORM_POWER8. + * sysdeps/powerpc/dl-procinfo.h (_DL_PLATFORMS_COUNT): Increment for + POWER8. + (PPC_PLATFORM_POWER8): Add new platform bit for POWER8 processor. + (_dl_string_platform): Add case for exporting platform position for + POWER8. + * sysdeps/unix/sysv/linux/powerpc/powerpc32/power8/Implies: Chain + search path to sysdeps/powerpc/powerpc32/power8 directory. + * sysdeps/unix/sysv/linux/powerpc/powerpc64/power8/Implies: Chain + search path to sysdeps/powerpc/powerpc64/power8 directory. + * sysdeps/powerpc/powerpc32/power8/Implies: Chain search path to + power7 directories. + * sysdeps/powerpc/powerpc64/power8/Implies: Chain search path to + power7 directories. + +2013-06-24 Siddhesh Poyarekar + + * INSTALL: Regenerate. + + * nscd/connections.c (nscd_init): Fix comment. + 2013-06-22 Joseph Myers * sysdeps/unix/sysv/linux/libc_fatal.c: Include . diff --git a/libc/INSTALL b/libc/INSTALL index 6088275a1..4327ea193 100644 --- a/libc/INSTALL +++ b/libc/INSTALL @@ -327,9 +327,9 @@ build the GNU C Library: recommend GNU `make' version 3.79. All earlier versions have severe bugs or lack features. - * GCC 4.3 or newer, GCC 4.6 recommended + * GCC 4.4 or newer, GCC 4.6 recommended - GCC 4.3 or higher is required; as of this writing, GCC 4.6 is the + GCC 4.4 or higher is required; as of this writing, GCC 4.6 is the compiler we advise to use to build the GNU C Library. You can use whatever compiler you like to compile programs that use @@ -352,10 +352,11 @@ build the GNU C Library: installation mechanism for the info files is not present or works differently. - * GNU `awk' 3.0, or higher + * GNU `awk' 3.1.2, or higher - `Awk' is used in several places to generate files. `gawk' 3.0 is - known to work. + `awk' is used in several places to generate files. Some `gawk' + extensions are used, including the `asorti' function, which was + introduced in version 3.1.2 of `gawk'. * Perl 5 diff --git a/libc/NEWS b/libc/NEWS index ea4a4651a..9d37d1008 100644 --- a/libc/NEWS +++ b/libc/NEWS @@ -9,19 +9,19 @@ Version 2.18 * The following bugs are resolved with this release: - 2546, 2560, 5159, 6809, 7006, 10060, 10062, 10357, 10686, 11120, 11561, - 12387, 12515, 12723, 13550, 13889, 13951, 13988, 14142, 14176, 14200, - 14256, 14280, 14293, 14317, 14327, 14478, 14496, 14582, 14686, 14812, - 14888, 14894, 14907, 14908, 14909, 14920, 14952, 14964, 14981, 14982, - 14985, 14991, 14994, 14996, 15000, 15003, 15006, 15007, 15014, 15020, - 15023, 15036, 15054, 15055, 15062, 15078, 15084, 15085, 15086, 15100, - 15160, 15214, 15221, 15232, 15234, 15283, 15285, 15287, 15304, 15305, - 15307, 15309, 15327, 15330, 15335, 15336, 15337, 15339, 15342, 15346, - 15359, 15361, 15366, 15380, 15381, 15394, 15395, 15405, 15406, 15409, - 15416, 15418, 15419, 15423, 15424, 15426, 15429, 15431, 15432, 15441, - 15442, 15448, 15465, 15480, 15485, 15488, 15490, 15492, 15493, 15497, - 15506, 15529, 15536, 15553, 15577, 15583, 15618, 15627, 15631, 15654, - 15655, 15667. + 2546, 2560, 5159, 6809, 7006, 10060, 10062, 10283, 10357, 10686, 11120, + 11561, 12310, 12387, 12492, 12515, 12723, 13550, 13889, 13951, 13988, + 14142, 14176, 14200, 14256, 14280, 14293, 14317, 14327, 14478, 14496, + 14582, 14686, 14812, 14888, 14894, 14907, 14908, 14909, 14920, 14952, + 14964, 14981, 14982, 14985, 14991, 14994, 14996, 15000, 15003, 15006, + 15007, 15014, 15020, 15022, 15023, 15036, 15054, 15055, 15062, 15078, + 15084, 15085, 15086, 15100, 15160, 15214, 15221, 15232, 15234, 15283, + 15285, 15287, 15304, 15305, 15307, 15309, 15327, 15330, 15335, 15336, + 15337, 15339, 15342, 15346, 15359, 15361, 15366, 15380, 15381, 15394, + 15395, 15405, 15406, 15409, 15416, 15418, 15419, 15423, 15424, 15426, + 15429, 15431, 15432, 15441, 15442, 15448, 15465, 15480, 15485, 15488, + 15490, 15492, 15493, 15497, 15506, 15529, 15536, 15553, 15577, 15583, + 15618, 15627, 15631, 15654, 15655, 15666, 15667, 15674. * CVE-2013-0242 Buffer overrun in regexp matcher has been fixed (Bugzilla #15078). @@ -39,6 +39,21 @@ Version 2.18 * Support for priority inherited mutexes in pthread condition variables on non-x86 architectures. +* Port to Xilinx MicroBlaze contributed by David Holsgrove. + +* Optimized string functions for AArch64. Implemented by Marcus Shawcroft. + +* Optimized string functions for ARM. Implemented by Will Newton and + Richard Henderson. + +* Optimized libm functions for SPARC. Implemented by David S. Miller. + +* Support for building more of ARM glibc as Thumb-2 code. Implemented by + Richard Henderson. + +* Support for building most of MIPS glibc as MIPS16 code. Implemented by + Chung-Lin Tang, Maciej W. Rozycki and Maxim Kuvyrkov. + * Added a benchmark framework to track performance of functions in glibc. * New macro named issignaling to check for a signaling NaN (sNaN). diff --git a/libc/configure b/libc/configure index 9f66de782..c10d7925e 100755 --- a/libc/configure +++ b/libc/configure @@ -4678,7 +4678,7 @@ $as_echo_n "checking version of $CC... " >&6; } ac_prog_version=`$CC -v 2>&1 | sed -n 's/^.*version \([egcygnustpi-]*[0-9.]*\).*$/\1/p'` case $ac_prog_version in '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;; - 4.[3-9].* | 4.[1-9][0-9].* | [5-9].* ) + 4.[4-9].* | 4.[1-9][0-9].* | [5-9].* ) ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;; *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;; diff --git a/libc/configure.in b/libc/configure.in index 4aed67336..2a7d5faa0 100644 --- a/libc/configure.in +++ b/libc/configure.in @@ -966,7 +966,7 @@ AC_CHECK_PROG_VER(LD, $LD, --version, # These programs are version sensitive. AC_CHECK_TOOL_PREFIX AC_CHECK_PROG_VER(CC, ${ac_tool_prefix}gcc ${ac_tool_prefix}cc, -v, - [version \([egcygnustpi-]*[0-9.]*\)], [4.[3-9].* | 4.[1-9][0-9].* | [5-9].* ], + [version \([egcygnustpi-]*[0-9.]*\)], [4.[4-9].* | 4.[1-9][0-9].* | [5-9].* ], critic_missing="$critic_missing gcc") AC_CHECK_PROG_VER(MAKE, gnumake gmake make, --version, [GNU Make[^0-9]*\([0-9][0-9.]*\)], diff --git a/libc/dlfcn/Makefile b/libc/dlfcn/Makefile index 441c62649..35b7e50f9 100644 --- a/libc/dlfcn/Makefile +++ b/libc/dlfcn/Makefile @@ -51,11 +51,14 @@ glreflib2.so-no-z-defs = yes errmsg1mod.so-no-z-defs = yes ifeq (yes,$(build-shared)) -tests += tststatic tststatic2 -tests-static += tststatic tststatic2 -modules-names += modstatic modstatic2 +tests += tststatic tststatic2 tststatic3 tststatic4 tststatic5 +tests-static += tststatic tststatic2 tststatic3 tststatic4 tststatic5 +modules-names += modstatic modstatic2 modstatic3 modstatic5 tststatic-ENV = LD_LIBRARY_PATH=$(objpfx):$(common-objpfx):$(common-objpfx)elf tststatic2-ENV = $(tststatic-ENV) +tststatic3-ENV = $(tststatic-ENV) +tststatic4-ENV = $(tststatic-ENV) +tststatic5-ENV = $(tststatic-ENV) endif extra-test-objs += $(modules-names:=.os) @@ -108,6 +111,15 @@ $(objpfx)tststatic2.out: $(objpfx)tststatic2 $(objpfx)modstatic.so \ $(objpfx)modstatic2.so: $(libdl) +$(objpfx)tststatic3: $(objpfx)libdl.a +$(objpfx)tststatic3.out: $(objpfx)tststatic3 $(objpfx)modstatic3.so + +$(objpfx)tststatic4: $(objpfx)libdl.a +$(objpfx)tststatic4.out: $(objpfx)tststatic4 $(objpfx)modstatic3.so + +$(objpfx)tststatic5: $(objpfx)libdl.a +$(objpfx)tststatic5.out: $(objpfx)tststatic5 $(objpfx)modstatic5.so + $(objpfx)bug-dlopen1: $(libdl) $(objpfx)bug-dlsym1: $(libdl) $(objpfx)bug-dlsym1-lib2.so diff --git a/libc/dlfcn/modstatic3.c b/libc/dlfcn/modstatic3.c new file mode 100644 index 000000000..cd24986f2 --- /dev/null +++ b/libc/dlfcn/modstatic3.c @@ -0,0 +1,31 @@ +/* DSO used for dlopen testing with a static executable. + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +unsigned int foo; + +unsigned int +getfoo (void) +{ + return foo; +} + +void +setfoo (unsigned int f) +{ + foo = f; +} diff --git a/libc/dlfcn/modstatic5.c b/libc/dlfcn/modstatic5.c new file mode 100644 index 000000000..40c541e63 --- /dev/null +++ b/libc/dlfcn/modstatic5.c @@ -0,0 +1,26 @@ +/* DSO used for GLRO(dl_pagesize) initialization testing with a static + executable. + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include + +int +my_getpagesize (void) +{ + return getpagesize (); +} diff --git a/libc/dlfcn/tststatic3.c b/libc/dlfcn/tststatic3.c new file mode 100644 index 000000000..8a3421e80 --- /dev/null +++ b/libc/dlfcn/tststatic3.c @@ -0,0 +1,128 @@ +/* Global-scope DSO mapping test with a static executable (BZ #15022). + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#define MAGIC0 0 +#define MAGIC1 0x5500ffaa +#define MAGIC2 0xaaff0055 + +/* Mapping a DSO into the global scope used to crash in static + executables. Check that it succeeds and then that symbols from + the DSO can be accessed and operate as expected. */ +static int +do_test (void) +{ + unsigned int (*getfoo) (void); + void (*setfoo) (unsigned int); + unsigned int *foop; + unsigned int foo; + void *handle; + + /* Try to map a module into the global scope. */ + handle = dlopen ("modstatic3.so", RTLD_LAZY | RTLD_GLOBAL); + if (handle == NULL) + { + printf ("dlopen (modstatic3.so): %s\n", dlerror ()); + return 1; + } + + /* Get at its symbols. */ + foop = dlsym (handle, "foo"); + if (foop == NULL) + { + printf ("dlsym (foo): %s\n", dlerror ()); + return 1; + } + + getfoo = dlsym (handle, "getfoo"); + if (getfoo == NULL) + { + printf ("dlsym (getfoo): %s\n", dlerror ()); + return 1; + } + + setfoo = dlsym (handle, "setfoo"); + if (setfoo == NULL) + { + printf ("dlsym (setfoo): %s\n", dlerror ()); + return 1; + } + + /* Make sure the view of the initial state is consistent. */ + foo = *foop; + if (foo != MAGIC0) + { + printf ("*foop: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + foo = getfoo (); + if (foo != MAGIC0) + { + printf ("getfoo: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + /* Likewise with one change to its state. */ + setfoo (MAGIC1); + + foo = *foop; + if (foo != MAGIC1) + { + printf ("*foop: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + foo = getfoo (); + if (foo != MAGIC1) + { + printf ("getfoo: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + /* And with another. */ + setfoo (MAGIC2); + + foo = *foop; + if (foo != MAGIC2) + { + printf ("*foop: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + foo = getfoo (); + if (foo != MAGIC2) + { + printf ("getfoo: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + /* All done, clean up. */ + getfoo = NULL; + setfoo = NULL; + foop = NULL; + dlclose (handle); + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/dlfcn/tststatic4.c b/libc/dlfcn/tststatic4.c new file mode 100644 index 000000000..f6078e07a --- /dev/null +++ b/libc/dlfcn/tststatic4.c @@ -0,0 +1,363 @@ +/* Global object symbol access tests with a static executable (BZ #15022). + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include + +#define MAGIC0 0 +#define MAGIC1 0x5500ffaa +#define MAGIC2 0xaaff0055 +#define MAGIC3 0xff55aa00 + +/* Check the ability to access the global symbol object and then + global-scope symbol access consistency via different mappings + requested from a static executable. */ +static int +do_test (void) +{ + unsigned int (*initial_getfoo) (void); + void (*initial_setfoo) (unsigned int); + unsigned int (*global_getfoo) (void); + void (*global_setfoo) (unsigned int); + unsigned int (*local_getfoo) (void); + void (*local_setfoo) (unsigned int); + unsigned int *initial_foop; + unsigned int *global_foop; + unsigned int *local_foop; + void *initial_handle; + void *global_handle; + void *local_handle; + unsigned int foo; + + /* Try to map self. */ + initial_handle = dlopen (NULL, RTLD_LAZY | RTLD_GLOBAL); + if (initial_handle == NULL) + { + printf ("dlopen [initial] (NULL): %s\n", dlerror ()); + return 1; + } + + /* Make sure symbol lookups fail gracefully. */ + initial_foop = dlsym (initial_handle, "foo"); + if (initial_foop != NULL) + { + printf ("dlsym [initial] (foo): got %p, expected NULL\n", initial_foop); + return 1; + } + + initial_getfoo = dlsym (initial_handle, "getfoo"); + if (initial_getfoo != NULL) + { + printf ("dlsym [initial] (getfoo): got %p, expected NULL\n", + initial_getfoo); + return 1; + } + + initial_setfoo = dlsym (initial_handle, "setfoo"); + if (initial_setfoo != NULL) + { + printf ("dlsym [initial] (setfoo): got %p, expected NULL\n", + initial_setfoo); + return 1; + } + + /* Try to map a module into the global scope. */ + global_handle = dlopen ("modstatic3.so", RTLD_LAZY | RTLD_GLOBAL); + if (global_handle == NULL) + { + printf ("dlopen [global] (modstatic3.so): %s\n", dlerror ()); + return 1; + } + + /* Get at its symbols. */ + global_foop = dlsym (global_handle, "foo"); + if (global_foop == NULL) + { + printf ("dlsym [global] (foo): %s\n", dlerror ()); + return 1; + } + + global_getfoo = dlsym (global_handle, "getfoo"); + if (global_getfoo == NULL) + { + printf ("dlsym [global] (getfoo): %s\n", dlerror ()); + return 1; + } + + global_setfoo = dlsym (global_handle, "setfoo"); + if (global_setfoo == NULL) + { + printf ("dlsym [global] (setfoo): %s\n", dlerror ()); + return 1; + } + + /* Try to map self again now. */ + local_handle = dlopen (NULL, RTLD_LAZY | RTLD_LOCAL); + if (local_handle == NULL) + { + printf ("dlopen [local] (NULL): %s\n", dlerror ()); + return 1; + } + + /* Make sure we can get at the previously loaded module's symbols + via this handle too. */ + local_foop = dlsym (local_handle, "foo"); + if (local_foop == NULL) + { + printf ("dlsym [local] (foo): %s\n", dlerror ()); + return 1; + } + + local_getfoo = dlsym (local_handle, "getfoo"); + if (local_getfoo == NULL) + { + printf ("dlsym [local] (getfoo): %s\n", dlerror ()); + return 1; + } + + local_setfoo = dlsym (local_handle, "setfoo"); + if (local_setfoo == NULL) + { + printf ("dlsym [local] (setfoo): %s\n", dlerror ()); + return 1; + } + + /* Make sure we can get at the previously loaded module's symbols + via a handle that was obtained before the module was loaded too. */ + initial_foop = dlsym (initial_handle, "foo"); + if (initial_foop == NULL) + { + printf ("dlsym [initial] (foo): %s\n", dlerror ()); + return 1; + } + + initial_getfoo = dlsym (initial_handle, "getfoo"); + if (initial_getfoo == NULL) + { + printf ("dlsym [initial] (getfoo): %s\n", dlerror ()); + return 1; + } + + initial_setfoo = dlsym (initial_handle, "setfoo"); + if (initial_setfoo == NULL) + { + printf ("dlsym [initial] (setfoo): %s\n", dlerror ()); + return 1; + } + + /* Make sure the view of the initial state is consistent. */ + foo = *initial_foop; + if (foo != MAGIC0) + { + printf ("*foop [initial]: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + foo = *global_foop; + if (foo != MAGIC0) + { + printf ("*foop [global]: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + foo = *local_foop; + if (foo != MAGIC0) + { + printf ("*foop [local]: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + foo = initial_getfoo (); + if (foo != MAGIC0) + { + printf ("getfoo [initial]: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + foo = global_getfoo (); + if (foo != MAGIC0) + { + printf ("getfoo [global]: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + foo = local_getfoo (); + if (foo != MAGIC0) + { + printf ("getfoo [local]: got %#x, expected %#x\n", foo, MAGIC0); + return 1; + } + + /* Likewise with a change to its state made through the first handle. */ + initial_setfoo (MAGIC1); + + foo = *initial_foop; + if (foo != MAGIC1) + { + printf ("*foop [initial]: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + foo = *global_foop; + if (foo != MAGIC1) + { + printf ("*foop [global]: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + foo = *local_foop; + if (foo != MAGIC1) + { + printf ("*foop [local]: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + foo = initial_getfoo (); + if (foo != MAGIC1) + { + printf ("getfoo [initial]: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + foo = global_getfoo (); + if (foo != MAGIC1) + { + printf ("getfoo [global]: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + foo = local_getfoo (); + if (foo != MAGIC1) + { + printf ("getfoo [local]: got %#x, expected %#x\n", foo, MAGIC1); + return 1; + } + + /* Likewise with a change to its state made through the second handle. */ + global_setfoo (MAGIC2); + + foo = *initial_foop; + if (foo != MAGIC2) + { + printf ("*foop [initial]: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + foo = *global_foop; + if (foo != MAGIC2) + { + printf ("*foop [global]: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + foo = *local_foop; + if (foo != MAGIC2) + { + printf ("*foop [local]: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + foo = initial_getfoo (); + if (foo != MAGIC2) + { + printf ("getfoo [initial]: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + foo = global_getfoo (); + if (foo != MAGIC2) + { + printf ("getfoo [global]: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + foo = local_getfoo (); + if (foo != MAGIC2) + { + printf ("getfoo [local]: got %#x, expected %#x\n", foo, MAGIC2); + return 1; + } + + /* Likewise with a change to its state made through the third handle. */ + local_setfoo (MAGIC3); + + foo = *initial_foop; + if (foo != MAGIC3) + { + printf ("*foop [initial]: got %#x, expected %#x\n", foo, MAGIC3); + return 1; + } + + foo = *global_foop; + if (foo != MAGIC3) + { + printf ("*foop [global]: got %#x, expected %#x\n", foo, MAGIC3); + return 1; + } + + foo = *local_foop; + if (foo != MAGIC3) + { + printf ("*foop [local]: got %#x, expected %#x\n", foo, MAGIC3); + return 1; + } + + foo = initial_getfoo (); + if (foo != MAGIC3) + { + printf ("getfoo [initial]: got %#x, expected %#x\n", foo, MAGIC3); + return 1; + } + + foo = global_getfoo (); + if (foo != MAGIC3) + { + printf ("getfoo [global]: got %#x, expected %#x\n", foo, MAGIC3); + return 1; + } + + foo = local_getfoo (); + if (foo != MAGIC3) + { + printf ("getfoo [local]: got %#x, expected %#x\n", foo, MAGIC3); + return 1; + } + + /* All done, clean up. */ + initial_getfoo = NULL; + initial_setfoo = NULL; + initial_foop = NULL; + + local_getfoo = NULL; + local_setfoo = NULL; + local_foop = NULL; + dlclose (local_handle); + + global_getfoo = NULL; + global_setfoo = NULL; + global_foop = NULL; + dlclose (global_handle); + + dlclose (initial_handle); + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/dlfcn/tststatic5.c b/libc/dlfcn/tststatic5.c new file mode 100644 index 000000000..3d0ff7f31 --- /dev/null +++ b/libc/dlfcn/tststatic5.c @@ -0,0 +1,76 @@ +/* GLRO(dl_pagesize) initialization DSO test with a static executable. + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#include +#include +#include +#include + +/* Check that the same page size is reported both directly and by a DSO + mapped from a static executable. + + On targets that support different page sizes, the kernel communicates + the size currently in use via the auxiliary vector. This vector is + available to initial startup, but not any DSOs loaded later on. As + static executables do not export their symbols a DSO cannot access + the value obtained by initial startup and the value therefore has to + be passed on to the DSO and stored within its data area explicitly. + This is performed by a call to DL_STATIC_INIT that is defined in a + target-dependent way, and that on variable page size targets stores + it in the GLRO(dl_pagesize) variable of the DSO's dynamic linker. */ +static int +do_test (void) +{ + int pagesize = getpagesize (); + int (*my_getpagesize) (void); + int my_pagesize; + void *handle; + + /* Try to map a module. */ + handle = dlopen ("modstatic5.so", RTLD_LAZY | RTLD_LOCAL); + if (handle == NULL) + { + printf ("dlopen (modstatic5.so): %s\n", dlerror ()); + return 1; + } + + /* Get at its symbol. */ + my_getpagesize = dlsym (handle, "my_getpagesize"); + if (my_getpagesize == NULL) + { + printf ("dlsym (my_getpagesize): %s\n", dlerror ()); + return 1; + } + + /* Make sure the page size reported is the same either way. */ + my_pagesize = my_getpagesize (); + if (my_pagesize != pagesize) + { + printf ("my_getpagesize: got %i, expected %i\n", my_pagesize, pagesize); + return 1; + } + + /* All done, clean up. */ + my_getpagesize = NULL; + dlclose (handle); + + return 0; +} + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/libc/elf/dl-load.c b/libc/elf/dl-load.c index 3db7d5b46..62e03d187 100644 --- a/libc/elf/dl-load.c +++ b/libc/elf/dl-load.c @@ -342,13 +342,7 @@ _dl_dst_substitute (struct link_map *l, const char *name, char *result, if ((len = is_dst (start, name, "ORIGIN", is_path, INTUSE(__libc_enable_secure))) != 0) { -#ifndef SHARED - if (l == NULL) - repl = _dl_get_origin (); - else -#endif - repl = l->l_origin; - + repl = l->l_origin; check_for_trusted = (INTUSE(__libc_enable_secure) && l->l_type == lt_executable); } @@ -1495,7 +1489,7 @@ cannot allocate TLS data structures for initial thread"); /* The variable lies in the region protected by RELRO. */ if (__mprotect ((void *) p, s, PROT_READ|PROT_WRITE) < 0) { - errstring = N_("cannot change memory protection"); + errstring = N_("cannot change memory protections"); goto call_lose_errno; } __stack_prot |= PROT_READ|PROT_WRITE|PROT_EXEC; diff --git a/libc/elf/dl-open.c b/libc/elf/dl-open.c index 4a6a89470..356a98ff1 100644 --- a/libc/elf/dl-open.c +++ b/libc/elf/dl-open.c @@ -204,11 +204,9 @@ dl_open_worker (void *a) { const void *caller_dlopen = args->caller_dlopen; -#ifdef SHARED /* We have to find out from which object the caller is calling. By default we assume this is the main application. */ call_map = GL(dl_ns)[LM_ID_BASE]._ns_loaded; -#endif struct link_map *l = _dl_find_dso_for_object ((ElfW(Addr)) caller_dlopen); @@ -216,15 +214,7 @@ dl_open_worker (void *a) call_map = l; if (args->nsid == __LM_ID_CALLER) - { -#ifndef SHARED - /* In statically linked apps there might be no loaded object. */ - if (call_map == NULL) - args->nsid = LM_ID_BASE; - else -#endif - args->nsid = call_map->l_ns; - } + args->nsid = call_map->l_ns; } assert (_dl_debug_initialize (0, args->nsid)->r_state == RT_CONSISTENT); @@ -568,6 +558,10 @@ cannot load any more object with static TLS")); if (relocation_in_progress) LIBC_PROBE (reloc_complete, 3, args->nsid, r, new); +#ifndef SHARED + DL_STATIC_INIT (new); +#endif + /* Run the initializer functions of new objects. */ _dl_init (new, args->argc, args->argv, args->env); @@ -638,12 +632,6 @@ no more namespaces available for dlmopen()")); || GL(dl_ns)[nsid]._ns_loaded->l_auditing)) _dl_signal_error (EINVAL, file, NULL, N_("invalid target namespace in dlmopen()")); -#ifndef SHARED - else if ((nsid == LM_ID_BASE || nsid == __LM_ID_CALLER) - && GL(dl_ns)[LM_ID_BASE]._ns_loaded == NULL - && GL(dl_nns) == 0) - GL(dl_nns) = 1; -#endif struct dl_open_args args; args.file = file; @@ -721,10 +709,6 @@ no more namespaces available for dlmopen()")); /* Release the lock. */ __rtld_lock_unlock_recursive (GL(dl_load_lock)); -#ifndef SHARED - DL_STATIC_INIT (args.map); -#endif - return args.map; } diff --git a/libc/elf/dl-profile.c b/libc/elf/dl-profile.c index 823f3d709..8fa6efca4 100644 --- a/libc/elf/dl-profile.c +++ b/libc/elf/dl-profile.c @@ -131,7 +131,18 @@ struct here_cg_arc_record { uintptr_t from_pc; uintptr_t self_pc; - uint32_t count __attribute__((aligned(__alignof__(uint32_t)))); + /* The count field is atomically incremented in _dl_mcount, which + requires it to be properly aligned for its type, and for this + alignment to be visible to the compiler. The amount of data + before an array of this structure is calculated as + expected_size in _dl_start_profile. Everything in that + calculation is a multiple of 4 bytes (in the case of + kcountsize, because it is derived from a subtraction of + page-aligned values, and the corresponding calculation in + __monstartup also ensures it is at least a multiple of the size + of u_long), so all copies of this field do in fact have the + appropriate alignment. */ + uint32_t count __attribute__ ((aligned (__alignof__ (uint32_t)))); } __attribute__ ((packed)); static struct here_cg_arc_record *data; diff --git a/libc/elf/dl-support.c b/libc/elf/dl-support.c index 75f713fc9..fe5804fe3 100644 --- a/libc/elf/dl-support.c +++ b/libc/elf/dl-support.c @@ -73,17 +73,52 @@ const char *_dl_origin_path; /* Nonzero if runtime lookup should not update the .got/.plt. */ int _dl_bind_not; +/* A dummy link map for the executable, used by dlopen to access the global + scope. We don't export any symbols ourselves, so this can be minimal. */ +static struct link_map _dl_main_map = + { + .l_name = (char *) "", + .l_real = &_dl_main_map, + .l_ns = LM_ID_BASE, + .l_libname = &(struct libname_list) { .name = "", .dont_free = 1 }, + .l_searchlist = + { + .r_list = &(struct link_map *) { &_dl_main_map }, + .r_nlist = 1, + }, + .l_symbolic_searchlist = { .r_list = &(struct link_map *) { NULL } }, + .l_type = lt_executable, + .l_scope_mem = { &_dl_main_map.l_searchlist }, + .l_scope_max = (sizeof (_dl_main_map.l_scope_mem) + / sizeof (_dl_main_map.l_scope_mem[0])), + .l_scope = _dl_main_map.l_scope_mem, + .l_local_scope = { &_dl_main_map.l_searchlist }, + .l_used = 1, + .l_tls_offset = NO_TLS_OFFSET, + .l_serial = 1, + }; + /* Namespace information. */ -struct link_namespaces _dl_ns[DL_NNS]; -size_t _dl_nns; +struct link_namespaces _dl_ns[DL_NNS] = + { + [LM_ID_BASE] = + { + ._ns_loaded = &_dl_main_map, + ._ns_nloaded = 1, + ._ns_main_searchlist = &_dl_main_map.l_searchlist, + } + }; +size_t _dl_nns = 1; /* Incremented whenever something may have been added to dl_loaded. */ -unsigned long long _dl_load_adds; +unsigned long long _dl_load_adds = 1; -/* Fake scope. In dynamically linked binaries this is the scope of the - main application but here we don't have something like this. So - create a fake scope containing nothing. */ -struct r_scope_elem _dl_initial_searchlist; +/* Fake scope of the main application. */ +struct r_scope_elem _dl_initial_searchlist = + { + .r_list = &(struct link_map *) { &_dl_main_map }, + .r_nlist = 1, + }; #ifndef HAVE_INLINED_SYSCALLS /* Nonzero during startup. */ @@ -133,6 +168,7 @@ ElfW(auxv_t) *_dl_auxv; const ElfW(Phdr) *_dl_phdr; size_t _dl_phnum; uint64_t _dl_hwcap __attribute__ ((nocommon)); +uint64_t _dl_hwcap2 __attribute__ ((nocommon)); /* This is not initialized to HWCAP_IMPORTANT, matching the definition of _dl_important_hwcaps, below, where no hwcap strings are ever @@ -217,6 +253,9 @@ _dl_aux_init (ElfW(auxv_t) *av) case AT_HWCAP: GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val; break; + case AT_HWCAP2: + GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val; + break; #ifdef NEED_DL_SYSINFO case AT_SYSINFO: GL(dl_sysinfo) = av->a_un.a_val; @@ -268,6 +307,8 @@ void internal_function _dl_non_dynamic_init (void) { + _dl_main_map.l_origin = _dl_get_origin (); + if (HP_TIMING_AVAIL) HP_TIMING_NOW (_dl_cpuclock_offset); diff --git a/libc/elf/dl-sysdep.c b/libc/elf/dl-sysdep.c index 52de23f44..08c74ef83 100644 --- a/libc/elf/dl-sysdep.c +++ b/libc/elf/dl-sysdep.c @@ -156,6 +156,9 @@ _dl_sysdep_start (void **start_argptr, case AT_HWCAP: GLRO(dl_hwcap) = (unsigned long int) av->a_un.a_val; break; + case AT_HWCAP2: + GLRO(dl_hwcap2) = (unsigned long int) av->a_un.a_val; + break; case AT_CLKTCK: GLRO(dl_clktck) = av->a_un.a_val; break; @@ -303,6 +306,7 @@ _dl_show_auxv (void) [AT_SYSINFO - 2] = { "SYSINFO: 0x", hex }, [AT_SYSINFO_EHDR - 2] = { "SYSINFO_EHDR: 0x", hex }, [AT_RANDOM - 2] = { "RANDOM: 0x", hex }, + [AT_HWCAP2 - 2] = { "HWCAP2: 0x", hex }, }; unsigned int idx = (unsigned int) (av->a_type - 2); @@ -314,10 +318,10 @@ _dl_show_auxv (void) assert (AT_NULL == 0); assert (AT_IGNORE == 1); - if (av->a_type == AT_HWCAP) + if (av->a_type == AT_HWCAP || av->a_type == AT_HWCAP2) { - /* This is handled special. */ - if (_dl_procinfo (av->a_un.a_val) == 0) + /* These are handled in a special way per platform. */ + if (_dl_procinfo (av->a_type, av->a_un.a_val) == 0) continue; } diff --git a/libc/elf/elf.h b/libc/elf/elf.h index 4ad4f3999..f372271ed 100644 --- a/libc/elf/elf.h +++ b/libc/elf/elf.h @@ -993,7 +993,7 @@ typedef struct /* Some more special a_type values describing the hardware. */ #define AT_PLATFORM 15 /* String identifying platform. */ -#define AT_HWCAP 16 /* Machine dependent hints about +#define AT_HWCAP 16 /* Machine-dependent hints about processor capabilities. */ /* This entry gives some information about the FPU initialization @@ -1015,6 +1015,9 @@ typedef struct #define AT_RANDOM 25 /* Address of 16 random bytes. */ +#define AT_HWCAP2 26 /* More machine-dependent hints about + processor capabilities. */ + #define AT_EXECFN 31 /* Filename of executable. */ /* Pointer to the global system page used for system calls and other diff --git a/libc/include/libc-internal.h b/libc/include/libc-internal.h index 0c0fa024a..78f82da58 100644 --- a/libc/include/libc-internal.h +++ b/libc/include/libc-internal.h @@ -50,4 +50,24 @@ extern void __init_misc (int, char **, char **); /* Cast an integer or a pointer VAL to integer with proper type. */ # define cast_to_integer(val) ((__integer_if_pointer_type (val)) (val)) +/* Align a value by rounding down to closest size. + e.g. Using size of 4096, we get this behavior: + {4095, 4096, 4097} = {0, 4096, 4096}. */ +#define ALIGN_DOWN(base, size) ((base) & -((__typeof__ (base)) (size))) + +/* Align a value by rounding up to closest size. + e.g. Using size of 4096, we get this behavior: + {4095, 4096, 4097} = {4096, 4096, 8192}. + + Note: The size argument has side effects (expanded multiple times). */ +#define ALIGN_UP(base, size) ALIGN_DOWN ((base) + (size) - 1, (size)) + +/* Same as ALIGN_DOWN(), but automatically casts when base is a pointer. */ +#define PTR_ALIGN_DOWN(base, size) \ + ((__typeof__ (base)) ALIGN_DOWN ((uintptr_t) (base), (size))) + +/* Same as ALIGN_UP(), but automatically casts when base is a pointer. */ +#define PTR_ALIGN_UP(base, size) \ + ((__typeof__ (base)) ALIGN_UP ((uintptr_t) (base), (size))) + #endif /* _LIBC_INTERNAL */ diff --git a/libc/locale/locarchive.h b/libc/locale/locarchive.h index db05603df..f2d84771a 100644 --- a/libc/locale/locarchive.h +++ b/libc/locale/locarchive.h @@ -84,6 +84,13 @@ struct locarhandle void *addr; size_t mmaped; size_t reserved; + /* If this mmap required adjustment (such as re-aligning), then this is the + real address that was returned from mmap and thus should be passed to the + munmap call. The addr field above is the first usable address. */ + void *mmap_base; + /* Same as above for mmap_base vs addr, but this is the real length of the + map rather than the usable (which is what reserved represents). */ + size_t mmap_len; }; diff --git a/libc/locale/programs/locarchive.c b/libc/locale/programs/locarchive.c index 8475e295a..4e3bbfec9 100644 --- a/libc/locale/programs/locarchive.c +++ b/libc/locale/programs/locarchive.c @@ -37,8 +37,11 @@ #include #include #include +#include #include +#include +#include #include "../../crypt/md5.h" #include "../localeinfo.h" #include "../locarchive.h" @@ -79,21 +82,29 @@ static const char *locnames[] = mapping affects the address selection. So do this mapping from the actual file, even though it's only a dummy to reserve address space. */ static void * -prepare_address_space (int fd, size_t total, size_t *reserved, int *xflags) +prepare_address_space (int fd, size_t total, size_t *reserved, int *xflags, + void **mmap_base, size_t *mmap_len) { if (total < RESERVE_MMAP_SIZE) { void *p = mmap64 (NULL, RESERVE_MMAP_SIZE, PROT_NONE, MAP_SHARED, fd, 0); if (p != MAP_FAILED) - { - *reserved = RESERVE_MMAP_SIZE; - *xflags = MAP_FIXED; - return p; - } + { + void *aligned_p = PTR_ALIGN_UP (p, MAP_FIXED_ALIGNMENT); + size_t align_adjust = aligned_p - p; + *mmap_base = p; + *mmap_len = RESERVE_MMAP_SIZE; + assert (align_adjust < RESERVE_MMAP_SIZE); + *reserved = RESERVE_MMAP_SIZE - align_adjust; + *xflags = MAP_FIXED; + return aligned_p; + } } *reserved = total; *xflags = 0; + *mmap_base = NULL; + *mmap_len = 0; return NULL; } @@ -151,9 +162,11 @@ create_archive (const char *archivefname, struct locarhandle *ah) error (EXIT_FAILURE, errval, _("cannot resize archive file")); } - size_t reserved; + size_t reserved, mmap_len; int xflags; - void *p = prepare_address_space (fd, total, &reserved, &xflags); + void *mmap_base; + void *p = prepare_address_space (fd, total, &reserved, &xflags, &mmap_base, + &mmap_len); /* Map the header and all the administration data structures. */ p = mmap64 (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); @@ -199,6 +212,8 @@ create_archive (const char *archivefname, struct locarhandle *ah) } ah->fd = fd; + ah->mmap_base = mmap_base; + ah->mmap_len = mmap_len; ah->addr = p; ah->mmaped = total; ah->reserved = reserved; @@ -271,8 +286,7 @@ file_data_available_p (struct locarhandle *ah, uint32_t offset, uint32_t size) if (st.st_size > ah->reserved) return false; - const size_t pagesz = getpagesize (); - size_t start = ah->mmaped & ~(pagesz - 1); + size_t start = ALIGN_DOWN (ah->mmaped, MAP_FIXED_ALIGNMENT); void *p = mmap64 (ah->addr + start, st.st_size - start, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, ah->fd, start); @@ -333,10 +347,15 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) MAP_SHARED | MAP_FIXED, ah->fd, 0); else { - munmap (ah->addr, ah->reserved); + if (ah->mmap_base) + munmap (ah->mmap_base, ah->mmap_len); + else + munmap (ah->addr, ah->reserved); ah->addr = mmap64 (NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, ah->fd, 0); ah->reserved = st.st_size; + ah->mmap_base = NULL; + ah->mmap_len = 0; head = ah->addr; } if (ah->addr == MAP_FAILED) @@ -402,9 +421,11 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) error (EXIT_FAILURE, errval, _("cannot resize archive file")); } - size_t reserved; + size_t reserved, mmap_len; int xflags; - void *p = prepare_address_space (fd, total, &reserved, &xflags); + void *mmap_base; + void *p = prepare_address_space (fd, total, &reserved, &xflags, &mmap_base, + &mmap_len); /* Map the header and all the administration data structures. */ p = mmap64 (p, total, PROT_READ | PROT_WRITE, MAP_SHARED | xflags, fd, 0); @@ -424,6 +445,8 @@ enlarge_archive (struct locarhandle *ah, const struct locarhead *head) } new_ah.mmaped = total; + new_ah.mmap_base = mmap_base; + new_ah.mmap_len = mmap_len; new_ah.addr = p; new_ah.fd = fd; new_ah.reserved = reserved; @@ -607,9 +630,11 @@ open_archive (struct locarhandle *ah, bool readonly) ah->fd = fd; ah->mmaped = st.st_size; - size_t reserved; + size_t reserved, mmap_len; int xflags; - void *p = prepare_address_space (fd, st.st_size, &reserved, &xflags); + void *mmap_base; + void *p = prepare_address_space (fd, st.st_size, &reserved, &xflags, + &mmap_base, &mmap_len); /* Map the entire file. We might need to compare the category data in the file with the newly added data. */ @@ -621,6 +646,8 @@ open_archive (struct locarhandle *ah, bool readonly) error (EXIT_FAILURE, errno, _("cannot map archive header")); } ah->reserved = reserved; + ah->mmap_base = mmap_base; + ah->mmap_len = mmap_len; } @@ -629,7 +656,10 @@ close_archive (struct locarhandle *ah) { if (ah->fd != -1) { - munmap (ah->addr, ah->reserved); + if (ah->mmap_base) + munmap (ah->mmap_base, ah->mmap_len); + else + munmap (ah->addr, ah->reserved); close (ah->fd); } } diff --git a/libc/manual/install.texi b/libc/manual/install.texi index 3608a114f..96d3bef00 100644 --- a/libc/manual/install.texi +++ b/libc/manual/install.texi @@ -353,9 +353,9 @@ recommend GNU @code{make} version 3.79. All earlier versions have severe bugs or lack features. @item -GCC 4.3 or newer, GCC 4.6 recommended +GCC 4.4 or newer, GCC 4.6 recommended -GCC 4.3 or higher is required; as of this writing, GCC 4.6 is the +GCC 4.4 or higher is required; as of this writing, GCC 4.6 is the compiler we advise to use to build @theglibc{}. You can use whatever compiler you like to compile programs that use diff --git a/libc/manual/texinfo.tex b/libc/manual/texinfo.tex index 928cc286f..332943d9e 100644 --- a/libc/manual/texinfo.tex +++ b/libc/manual/texinfo.tex @@ -3,11 +3,11 @@ % Load plain if necessary, i.e., if running under initex. \expandafter\ifx\csname fmtname\endcsname\relax\input plain\fi % -\def\texinfoversion{2012-01-19.16} +\def\texinfoversion{2013-06-21.17} % % Copyright 1985, 1986, 1988, 1990, 1991, 1992, 1993, 1994, 1995, % 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -% 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc. +% 2007, 2008, 2009, 2010, 2011, 2012, 2013 Free Software Foundation, Inc. % % This texinfo.tex file is free software: you can redistribute it and/or % modify it under the terms of the GNU General Public License as @@ -24,13 +24,14 @@ % % As a special exception, when this file is read by TeX when processing % a Texinfo source document, you may use the result without -% restriction. (This has been our intent since Texinfo was invented.) +% restriction. This Exception is an additional permission under section 7 +% of the GNU General Public License, version 3 ("GPLv3"). % % Please try the latest version of texinfo.tex before submitting bug % reports; you can get the latest version from: -% http://www.gnu.org/software/texinfo/ (the Texinfo home page), or -% ftp://tug.org/tex/texinfo.tex -% (and all CTAN mirrors, see http://www.ctan.org). +% http://ftp.gnu.org/gnu/texinfo/ (the Texinfo release area), or +% http://ftpmirror.gnu.org/texinfo/ (same, via a mirror), or +% http://www.gnu.org/software/texinfo/ (the Texinfo home page) % The texinfo.tex in any given distribution could well be out % of date, so if that's what you're using, please check. % @@ -594,7 +595,7 @@ \def\:{\spacefactor=1000 } % @* forces a line break. -\def\*{\hfil\break\hbox{}\ignorespaces} +\def\*{\unskip\hfil\break\hbox{}\ignorespaces} % @/ allows a line break. \let\/=\allowbreak @@ -887,7 +888,7 @@ where each line of input produces a line of output.} \def\popthisfilestack{\errthisfilestackempty} \def\errthisfilestackempty{\errmessage{Internal error: the stack of filenames is empty.}} - +% \def\thisfile{} % @center line @@ -895,36 +896,46 @@ where each line of input produces a line of output.} % \parseargdef\center{% \ifhmode - \let\next\centerH + \let\centersub\centerH \else - \let\next\centerV + \let\centersub\centerV \fi - \next{\hfil \ignorespaces#1\unskip \hfil}% + \centersub{\hfil \ignorespaces#1\unskip \hfil}% + \let\centersub\relax % don't let the definition persist, just in case } -\def\centerH#1{% - {% - \hfil\break - \advance\hsize by -\leftskip - \advance\hsize by -\rightskip - \line{#1}% - \break - }% +\def\centerH#1{{% + \hfil\break + \advance\hsize by -\leftskip + \advance\hsize by -\rightskip + \line{#1}% + \break +}} +% +\newcount\centerpenalty +\def\centerV#1{% + % The idea here is the same as in \startdefun, \cartouche, etc.: if + % @center is the first thing after a section heading, we need to wipe + % out the negative parskip inserted by \sectionheading, but still + % prevent a page break here. + \centerpenalty = \lastpenalty + \ifnum\centerpenalty>10000 \vskip\parskip \fi + \ifnum\centerpenalty>9999 \penalty\centerpenalty \fi + \line{\kern\leftskip #1\kern\rightskip}% } -\def\centerV#1{\line{\kern\leftskip #1\kern\rightskip}} % @sp n outputs n lines of vertical space - +% \parseargdef\sp{\vskip #1\baselineskip} % @comment ...line which is ignored... % @c is the same as @comment % @ignore ... @end ignore is another way to write a comment - +% \def\comment{\begingroup \catcode`\^^M=\other% \catcode`\@=\other \catcode`\{=\other \catcode`\}=\other% \commentxxx} {\catcode`\^^M=\other \gdef\commentxxx#1^^M{\endgroup}} - +% \let\c=\comment % @paragraphindent NCHARS @@ -1097,7 +1108,7 @@ where each line of input produces a line of output.} % for display in the outlines, and in other places. Thus, we have to % double any backslashes. Otherwise, a name like "\node" will be % interpreted as a newline (\n), followed by o, d, e. Not good. -% +% % See http://www.ntg.nl/pipermail/ntg-pdftex/2004-July/000654.html and % related messages. The final outcome is that it is up to the TeX user % to double the backslashes and otherwise make the string valid, so @@ -1107,7 +1118,7 @@ where each line of input produces a line of output.} % #1 is a control sequence in which to do the replacements, % which we \xdef. \def\txiescapepdf#1{% - \ifx\pdfescapestring\relax + \ifx\pdfescapestring\thisisundefined % No primitive available; should we give a warning or log? % Many times it won't matter. \else @@ -1173,8 +1184,8 @@ output) for that.)} % % #1 is image name, #2 width (might be empty/whitespace), #3 height (ditto). \def\dopdfimage#1#2#3{% - \def\imagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% - \def\imageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% + \def\pdfimagewidth{#2}\setbox0 = \hbox{\ignorespaces #2}% + \def\pdfimageheight{#3}\setbox2 = \hbox{\ignorespaces #3}% % % pdftex (and the PDF format) support .pdf, .png, .jpg (among % others). Let's try in that order, PDF first since if @@ -1212,8 +1223,8 @@ output) for that.)} \else \immediate\pdfximage \fi - \ifdim \wd0 >0pt width \imagewidth \fi - \ifdim \wd2 >0pt height \imageheight \fi + \ifdim \wd0 >0pt width \pdfimagewidth \fi + \ifdim \wd2 >0pt height \pdfimageheight \fi \ifnum\pdftexversion<13 #1.\pdfimgext \else @@ -1357,12 +1368,17 @@ output) for that.)} \def\skipspaces#1{\def\PP{#1}\def\D{|}% \ifx\PP\D\let\nextsp\relax \else\let\nextsp\skipspaces - \ifx\p\space\else\addtokens{\filename}{\PP}% - \advance\filenamelength by 1 - \fi + \addtokens{\filename}{\PP}% + \advance\filenamelength by 1 \fi \nextsp} - \def\getfilename#1{\filenamelength=0\expandafter\skipspaces#1|\relax} + \def\getfilename#1{% + \filenamelength=0 + % If we don't expand the argument now, \skipspaces will get + % snagged on things like "@value{foo}". + \edef\temp{#1}% + \expandafter\skipspaces\temp|\relax + } \ifnum\pdftexversion < 14 \let \startlink \pdfannotlink \else @@ -1459,9 +1475,6 @@ output) for that.)} \def\ttsl{\setfontstyle{ttsl}} -% Default leading. -\newdimen\textleading \textleading = 13.2pt - % Set the baselineskip to #1, and the lineskip and strut size % correspondingly. There is no deep meaning behind these magic numbers % used as factors; they just match (closely enough) what Knuth defined. @@ -1473,6 +1486,7 @@ output) for that.)} % can get a sort of poor man's double spacing by redefining this. \def\baselinefactor{1} % +\newdimen\textleading \def\setleading#1{% \dimen0 = #1\relax \normalbaselineskip = \baselinefactor\dimen0 @@ -1745,18 +1759,24 @@ end \fi\fi -% Set the font macro #1 to the font named #2, adding on the -% specified font prefix (normally `cm'). +% Set the font macro #1 to the font named \fontprefix#2. % #3 is the font's design size, #4 is a scale factor, #5 is the CMap -% encoding (currently only OT1, OT1IT and OT1TT are allowed, pass -% empty to omit). +% encoding (only OT1, OT1IT and OT1TT are allowed, or empty to omit). +% Example: +% #1 = \textrm +% #2 = \rmshape +% #3 = 10 +% #4 = \mainmagstep +% #5 = OT1 +% \def\setfont#1#2#3#4#5{% \font#1=\fontprefix#2#3 scaled #4 \csname cmap#5\endcsname#1% } % This is what gets called when #5 of \setfont is empty. \let\cmap\gobble -% emacs-page end of cmaps +% +% (end of cmaps) % Use cm as the default font prefix. % To specify the font prefix, you must define \fontprefix @@ -1766,7 +1786,7 @@ end \fi % Support font families that don't use the same naming scheme as CM. \def\rmshape{r} -\def\rmbshape{bx} %where the normal face is bold +\def\rmbshape{bx} % where the normal face is bold \def\bfshape{b} \def\bxshape{bx} \def\ttshape{tt} @@ -1781,8 +1801,7 @@ end \def\scshape{csc} \def\scbshape{csc} -% Definitions for a main text size of 11pt. This is the default in -% Texinfo. +% Definitions for a main text size of 11pt. (The default in Texinfo.) % \def\definetextfontsizexi{% % Text fonts (11.2pt, magstep1). @@ -1907,7 +1926,7 @@ end \textleading = 13.2pt % line spacing for 11pt CM \textfonts % reset the current fonts \rm -} % end of 11pt text font size definitions +} % end of 11pt text font size definitions, \definetextfontsizexi % Definitions to make the main text be 10pt Computer Modern, with @@ -2039,7 +2058,7 @@ end \textleading = 12pt % line spacing for 10pt CM \textfonts % reset the current fonts \rm -} % end of 10pt text font size definitions +} % end of 10pt text font size definitions, \definetextfontsizex % We provide the user-level command @@ -2254,8 +2273,6 @@ end \gdef\markupsetcodequoteleft{\let`\codequoteleft} \gdef\markupsetcodequoteright{\let'\codequoteright} - -\gdef\markupsetnoligaturesquoteleft{\let`\noligaturesquoteleft} } \let\markupsetuplqcode \markupsetcodequoteleft @@ -2264,6 +2281,9 @@ end \let\markupsetuplqexample \markupsetcodequoteleft \let\markupsetuprqexample \markupsetcodequoteright % +\let\markupsetuplqkbd \markupsetcodequoteleft +\let\markupsetuprqkbd \markupsetcodequoteright +% \let\markupsetuplqsamp \markupsetcodequoteleft \let\markupsetuprqsamp \markupsetcodequoteright % @@ -2273,8 +2293,6 @@ end \let\markupsetuplqverbatim \markupsetcodequoteleft \let\markupsetuprqverbatim \markupsetcodequoteright -\let\markupsetuplqkbd \markupsetnoligaturesquoteleft - % Allow an option to not use regular directed right quote/apostrophe % (char 0x27), but instead the undirected quote from cmtt (char 0x0d). % The undirected quote is ugly, so don't make it the default, but it @@ -2364,8 +2382,7 @@ end \aftersmartic } -% like \smartslanted except unconditionally uses \ttsl, and no ic. -% @var is set to this for defun arguments. +% Unconditional use \ttsl, and no ic. @var is set to this for defuns. \def\ttslanted#1{{\ttsl #1}} % @cite is like \smartslanted except unconditionally use \sl. We never want @@ -2430,34 +2447,12 @@ end % @samp. \def\samp#1{{\setupmarkupstyle{samp}\lq\tclose{#1}\rq\null}} -% definition of @key that produces a lozenge. Doesn't adjust to text size. -%\setfont\keyrm\rmshape{8}{1000}{OT1} -%\font\keysy=cmsy9 -%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% -% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% -% \vbox{\hrule\kern-0.4pt -% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% -% \kern-0.4pt\hrule}% -% \kern-.06em\raise0.4pt\hbox{\angleright}}}} - -% definition of @key with no lozenge. If the current font is already -% monospace, don't change it; that way, we respect @kbdinputstyle. But -% if it isn't monospace, then use \tt. -% -\def\key#1{{\setupmarkupstyle{key}% - \nohyphenation - \ifmonospace\else\tt\fi - #1}\null} - -% ctrl is no longer a Texinfo command. -\def\ctrl #1{{\tt \rawbackslash \hat}#1} - -% @file, @option are the same as @samp. -\let\file=\samp -\let\option=\samp +% @indicateurl is \samp, that is, with quotes. +\let\indicateurl=\samp -% @code is a modification of @t, -% which makes spaces the same size as normal in the surrounding text. +% @code (and similar) prints in typewriter, but with spaces the same +% size as normal in the surrounding text, without hyphenation, etc. +% This is a subroutine for that. \def\tclose#1{% {% % Change normal interword space to be same as for the current font. @@ -2480,14 +2475,14 @@ end } % We *must* turn on hyphenation at `-' and `_' in @code. +% (But see \codedashfinish below.) % Otherwise, it is too hard to avoid overfull hboxes % in the Emacs manual, the Library manual, etc. - +% % Unfortunately, TeX uses one parameter (\hyphenchar) to control % both hyphenation at - and hyphenation within words. % We must therefore turn them both off (\tclose does that) -% and arrange explicitly to hyphenate at a dash. -% -- rms. +% and arrange explicitly to hyphenate at a dash. -- rms. { \catcode`\-=\active \catcode`\_=\active \catcode`\'=\active \catcode`\`=\active @@ -2501,17 +2496,36 @@ end \let-\codedash \let_\codeunder \else - \let-\realdash + \let-\normaldash \let_\realunder \fi + % Given -foo (with a single dash), we do not want to allow a break + % after the hyphen. + \global\let\codedashprev=\codedash + % \codex } + % + \gdef\codedash{\futurelet\next\codedashfinish} + \gdef\codedashfinish{% + \normaldash % always output the dash character itself. + % + % Now, output a discretionary to allow a line break, unless + % (a) the next character is a -, or + % (b) the preceding character is a -. + % E.g., given --posix, we do not want to allow a break after either -. + % Given --foo-bar, we do want to allow a break between the - and the b. + \ifx\next\codedash \else + \ifx\codedashprev\codedash + \else \discretionary{}{}{}\fi + \fi + \global\let\codedashprev=\next + } } - +\def\normaldash{-} +% \def\codex #1{\tclose{#1}\endgroup} -\def\realdash{-} -\def\codedash{-\discretionary{}{}{}} \def\codeunder{% % this is all so @math{@code{var_name}+1} can work. In math mode, _ % is "active" (mathcode"8000) and \normalunderscore (or \char95, etc.) @@ -2525,9 +2539,9 @@ end } % An additional complication: the above will allow breaks after, e.g., -% each of the four underscores in __typeof__. This is undesirable in -% some manuals, especially if they don't have long identifiers in -% general. @allowcodebreaks provides a way to control this. +% each of the four underscores in __typeof__. This is bad. +% @allowcodebreaks provides a document-level way to turn breaking at - +% and _ on and off. % \newif\ifallowcodebreaks \allowcodebreakstrue @@ -2546,6 +2560,13 @@ end \fi\fi } +% For @command, @env, @file, @option quotes seem unnecessary, +% so use \code rather than \samp. +\let\command=\code +\let\env=\code +\let\file=\code +\let\option=\code + % @uref (abbreviation for `urlref') takes an optional (comma-separated) % second argument specifying the text to display and an optional third % arg as text to display instead of (rather than in addition to) the url @@ -2692,10 +2713,6 @@ end \let\email=\uref \fi -% @kbd is like @code, except that if the argument is just one @key command, -% then @kbd has no effect. -\def\kbd#1{{\setupmarkupstyle{kbd}\def\look{#1}\expandafter\kbdfoo\look??\par}} - % @kbdinputstyle -- arg is `distinct' (@kbd uses slanted tty font always), % `example' (@kbd uses ttsl only inside of @example and friends), % or `code' (@kbd uses normal tty font always). @@ -2719,16 +2736,36 @@ end % Default is `distinct'. \kbdinputstyle distinct +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. +\def\kbd#1{{\def\look{#1}\expandafter\kbdsub\look??\par}} + \def\xkey{\key} -\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% -\ifx\one\xkey\ifx\threex\three \key{#2}% -\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi -\else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi} +\def\kbdsub#1#2#3\par{% + \def\one{#1}\def\three{#3}\def\threex{??}% + \ifx\one\xkey\ifx\threex\three \key{#2}% + \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi + \else{\tclose{\kbdfont\setupmarkupstyle{kbd}\look}}\fi +} -% For @indicateurl, @env, @command quotes seem unnecessary, so use \code. -\let\indicateurl=\code -\let\env=\code -\let\command=\code +% definition of @key that produces a lozenge. Doesn't adjust to text size. +%\setfont\keyrm\rmshape{8}{1000}{OT1} +%\font\keysy=cmsy9 +%\def\key#1{{\keyrm\textfont2=\keysy \leavevmode\hbox{% +% \raise0.4pt\hbox{\angleleft}\kern-.08em\vtop{% +% \vbox{\hrule\kern-0.4pt +% \hbox{\raise0.4pt\hbox{\vphantom{\angleleft}}#1}}% +% \kern-0.4pt\hrule}% +% \kern-.06em\raise0.4pt\hbox{\angleright}}}} + +% definition of @key with no lozenge. If the current font is already +% monospace, don't change it; that way, we respect @kbdinputstyle. But +% if it isn't monospace, then use \tt. +% +\def\key#1{{\setupmarkupstyle{key}% + \nohyphenation + \ifmonospace\else\tt\fi + #1}\null} % @clicksequence{File @click{} Open ...} \def\clicksequence#1{\begingroup #1\endgroup} @@ -2836,6 +2873,9 @@ end } } +% ctrl is no longer a Texinfo command, but leave this definition for fun. +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + % @inlinefmt{FMTNAME,PROCESSED-TEXT} and @inlineraw{FMTNAME,RAW-TEXT}. % Ignore unless FMTNAME == tex; then it is like @iftex and @tex, % except specified as a normal braced arg, so no newlines to worry about. @@ -3126,12 +3166,17 @@ end % hopefully nobody will notice/care. \edef\ecsize{\csname\curfontsize ecsize\endcsname}% \edef\nominalsize{\csname\curfontsize nominalsize\endcsname}% - \ifx\curfontstyle\bfstylename - % bold: - \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize + \ifmonospace + % typewriter: + \font\thisecfont = ectt\ecsize \space at \nominalsize \else - % regular: - \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize + \ifx\curfontstyle\bfstylename + % bold: + \font\thisecfont = ecb\ifusingit{i}{x}\ecsize \space at \nominalsize + \else + % regular: + \font\thisecfont = ec\ifusingit{ti}{rm}\ecsize \space at \nominalsize + \fi \fi \thisecfont } @@ -3244,6 +3289,20 @@ end \finishedtitlepagetrue } +% Settings used for typesetting titles: no hyphenation, no indentation, +% don't worry much about spacing, ragged right. This should be used +% inside a \vbox, and fonts need to be set appropriately first. Because +% it is always used for titles, nothing else, we call \rmisbold. \par +% should be specified before the end of the \vbox, since a vbox is a group. +% +\def\raggedtitlesettings{% + \rmisbold + \hyphenpenalty=10000 + \parindent=0pt + \tolerance=5000 + \ptexraggedright +} + % Macros to be used within @titlepage: \let\subtitlerm=\tenrm @@ -3251,7 +3310,7 @@ end \parseargdef\title{% \checkenv\titlepage - \leftline{\titlefonts\rmisbold #1} + \vbox{\titlefonts \raggedtitlesettings #1\par}% % print a rule at the page bottom also. \finishedtitlepagefalse \vskip4pt \hrule height 4pt width \hsize \vskip4pt @@ -4148,7 +4207,7 @@ end % ..., but we might end up with active ones in the argument if % we're called from @code, as @code{@value{foo-bar_}}, though. % So \let them to their normal equivalents. - \let-\realdash \let_\normalunderscore + \let-\normaldash \let_\normalunderscore } } @@ -4172,7 +4231,8 @@ end % @ifset VAR ... @end ifset reads the `...' iff VAR has been defined % with @set. % -% To get special treatment of `@end ifset,' call \makeond and the redefine. +% To get the special treatment we need for `@end ifset,' we call +% \makecond and then redefine. % \makecond{ifset} \def\ifset{\parsearg{\doifset{\let\next=\ifsetfail}}} @@ -4188,7 +4248,7 @@ end } \def\ifsetfail{\doignore{ifset}} -% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been +% @ifclear VAR ... @end executes the `...' iff VAR has never been % defined with @set, or has been undefined with @clear. % % The `\else' inside the `\doifset' parameter is a trick to reuse the @@ -4199,6 +4259,35 @@ end \def\ifclear{\parsearg{\doifset{\else \let\next=\ifclearfail}}} \def\ifclearfail{\doignore{ifclear}} +% @ifcommandisdefined CMD ... @end executes the `...' if CMD (written +% without the @) is in fact defined. We can only feasibly check at the +% TeX level, so something like `mathcode' is going to considered +% defined even though it is not a Texinfo command. +% +\makecond{ifcommanddefined} +\def\ifcommanddefined{\parsearg{\doifcmddefined{\let\next=\ifcmddefinedfail}}} +% +\def\doifcmddefined#1#2{{% + \makevalueexpandable + \let\next=\empty + \expandafter\ifx\csname #2\endcsname\relax + #1% If not defined, \let\next as above. + \fi + \expandafter + }\next +} +\def\ifcmddefinedfail{\doignore{ifcommanddefined}} + +% @ifcommandnotdefined CMD ... handled similar to @ifclear above. +\makecond{ifcommandnotdefined} +\def\ifcommandnotdefined{% + \parsearg{\doifcmddefined{\else \let\next=\ifcmdnotdefinedfail}}} +\def\ifcmdnotdefinedfail{\doignore{ifcommandnotdefined}} + +% Set the `txicommandconditionals' variable, so documents have a way to +% test if the @ifcommand...defined conditionals are available. +\set txicommandconditionals + % @dircategory CATEGORY -- specify a category of the dir file % which this file should belong to. Ignore this in TeX. \let\dircategory=\comment @@ -4435,6 +4524,7 @@ end \definedummyword\guillemetright \definedummyword\guilsinglleft \definedummyword\guilsinglright + \definedummyword\lbracechar \definedummyword\leq \definedummyword\minus \definedummyword\ogonek @@ -4447,6 +4537,7 @@ end \definedummyword\quoteleft \definedummyword\quoteright \definedummyword\quotesinglbase + \definedummyword\rbracechar \definedummyword\result \definedummyword\textdegree % @@ -4498,6 +4589,7 @@ end \definedummyword\t % % Commands that take arguments. + \definedummyword\abbr \definedummyword\acronym \definedummyword\anchor \definedummyword\cite @@ -4509,7 +4601,9 @@ end \definedummyword\emph \definedummyword\env \definedummyword\file + \definedummyword\image \definedummyword\indicateurl + \definedummyword\inforef \definedummyword\kbd \definedummyword\key \definedummyword\math @@ -4556,7 +4650,10 @@ end % content at all. So for index sorting, we map @{ and @} to strings % starting with |, since that ASCII character is between ASCII { and }. \def\{{|a}% + \def\lbracechar{|a}% + % \def\}{|b}% + \def\rbracechar{|b}% % % Non-English letters. \def\AA{AA}% @@ -4732,10 +4829,9 @@ end % % ..., ready, GO: % -\def\safewhatsit#1{% -\ifhmode +\def\safewhatsit#1{\ifhmode #1% -\else + \else % \lastskip and \lastpenalty cannot both be nonzero simultaneously. \whatsitskip = \lastskip \edef\lastskipmacro{\the\lastskip}% @@ -4759,7 +4855,6 @@ end % to re-insert the same penalty (values >10000 are used for various % signals); since we just inserted a non-discardable item, any % following glue (such as a \parskip) would be a breakpoint. For example: - % % @deffn deffn-whatever % @vindex index-whatever % Description. @@ -4772,8 +4867,7 @@ end % (the whatsit from the \write), so we must insert a \nobreak. \nobreak\vskip\whatsitskip \fi -\fi -} +\fi} % The index entry written in the file actually looks like % \entry {sortstring}{page}{topic} @@ -5520,14 +5614,6 @@ end % Define @majorheading, @heading and @subheading -% NOTE on use of \vbox for chapter headings, section headings, and such: -% 1) We use \vbox rather than the earlier \line to permit -% overlong headings to fold. -% 2) \hyphenpenalty is set to 10000 because hyphenation in a -% heading is obnoxious; this forbids it. -% 3) Likewise, headings look best if no \parindent is used, and -% if justification is not attempted. Hence \raggedright. - \def\majorheading{% {\advance\chapheadingskip by 10pt \chapbreak }% \parsearg\chapheadingzzz @@ -5535,10 +5621,8 @@ end \def\chapheading{\chapbreak \parsearg\chapheadingzzz} \def\chapheadingzzz#1{% - {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\ptexraggedright - \rmisbold #1\hfill}}% - \bigskip \par\penalty 200\relax + \vbox{\chapfonts \raggedtitlesettings #1\par}% + \nobreak\bigskip \nobreak \suppressfirstparagraphindent } @@ -5697,8 +5781,7 @@ end % % Typeset the actual heading. \nobreak % Avoid page breaks at the interline glue. - \vbox{\hyphenpenalty=10000 \tolerance=5000 \parindent=0pt \ptexraggedright - \hangindent=\wd0 \centerparametersmaybe + \vbox{\raggedtitlesettings \hangindent=\wd0 \centerparametersmaybe \unhbox0 #1\par}% }% \nobreak\bigskip % no page break after a chapter title @@ -5720,18 +5803,18 @@ end \def\setchapterstyle #1 {\csname CHAPF#1\endcsname} % \def\unnchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt\ptexraggedright - \rmisbold #1\hfill}}\bigskip \par\nobreak + \chapoddpage + \vbox{\chapfonts \raggedtitlesettings #1\par}% + \nobreak\bigskip\nobreak } \def\chfopen #1#2{\chapoddpage {\chapfonts \vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% \par\penalty 5000 % } \def\centerchfopen #1{% -\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 - \parindent=0pt - \hfill {\rmisbold #1}\hfill}}\bigskip \par\nobreak + \chapoddpage + \vbox{\chapfonts \raggedtitlesettings \hfill #1\hfill}% + \nobreak\bigskip \nobreak } \def\CHAPFopen{% \global\let\chapmacro=\chfopen @@ -5876,14 +5959,15 @@ end % % We'll almost certainly start a paragraph next, so don't let that % glue accumulate. (Not a breakpoint because it's preceded by a - % discardable item.) + % discardable item.) However, when a paragraph is not started next + % (\startdefun, \cartouche, \center, etc.), this needs to be wiped out + % or the negative glue will cause weirdly wrong output, typically + % obscuring the section heading with something else. \vskip-\parskip % - % This is purely so the last item on the list is a known \penalty > - % 10000. This is so \startdefun can avoid allowing breakpoints after - % section headings. Otherwise, it would insert a valid breakpoint between: - % @section sec-whatever - % @deffn def-whatever + % This is so the last item on the main vertical list is a known + % \penalty > 10000, so \startdefun, etc., can recognize the situation + % and do the needful. \penalty 10001 } @@ -6303,7 +6387,7 @@ end % If this cartouche directly follows a sectioning command, we need the % \parskip glue (backspaced over by default) or the cartouche can % collide with the section heading. - \ifnum\lastpenalty>10000 \vskip\parskip \fi + \ifnum\lastpenalty>10000 \vskip\parskip \penalty\lastpenalty \fi % \vbox\bgroup \baselineskip=0pt\parskip=0pt\lineskip=0pt @@ -6338,7 +6422,7 @@ end \newdimen\nonfillparindent \def\nonfillstart{% \aboveenvbreak - \hfuzz = 12pt % Don't be fussy + \ifdim\hfuzz < 12pt \hfuzz = 12pt \fi % Don't be fussy \sepspaces % Make spaces be word-separators rather than space tokens. \let\par = \lisppar % don't ignore blank lines \obeylines % each line of input is a line of output @@ -6496,16 +6580,9 @@ end \makedispenvdef{quotation}{\quotationstart} % \def\quotationstart{% - {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip - \parindent=0pt - % - % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \indentedblockstart % same as \indentedblock, but increase right margin too. \ifx\nonarrowing\relax - \advance\leftskip by \lispnarrowing \advance\rightskip by \lispnarrowing - \exdentamount = \lispnarrowing - \else - \let\nonarrowing = \relax \fi \parsearg\quotationlabel } @@ -6531,6 +6608,32 @@ end \fi } +% @indentedblock is like @quotation, but indents only on the left and +% has no optional argument. +% +\makedispenvdef{indentedblock}{\indentedblockstart} +% +\def\indentedblockstart{% + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \parindent=0pt + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \exdentamount = \lispnarrowing + \else + \let\nonarrowing = \relax + \fi +} + +% Keep a nonzero parskip for the environment, since we're doing normal filling. +% +\def\Eindentedblock{% + \par + {\parskip=0pt \afterenvbreak}% +} +\def\Esmallindentedblock{\Eindentedblock} + % LaTeX-like @verbatim...@end verbatim and @verb{...} % If we want to allow any as delimiter, @@ -7009,7 +7112,10 @@ end \df \sl \hyphenchar\font=0 % % On the other hand, if an argument has two dashes (for instance), we - % want a way to get ttsl. Let's try @var for that. + % want a way to get ttsl. We used to recommend @var for that, so + % leave the code in, but it's strange for @var to lead to typewriter. + % Nowadays we recommend @code, since the difference between a ttsl hyphen + % and a tt hyphen is pretty tiny. @code also disables ?` !`. \def\var##1{{\setupmarkupstyle{var}\ttslanted{##1}}}% #1% \sl\hyphenchar\font=45 @@ -7793,7 +7899,7 @@ end \fi\fi } - +% % @xref, @pxref, and @ref generate cross-references. For \xrefX, #1 is % the node name, #2 the name of the Info cross-reference, #3 the printed % node name, #4 the name of the Info file, #5 the name of the printed @@ -7803,16 +7909,21 @@ end \def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} \def\ref#1{\xrefX[#1,,,,,,,]} % -\newbox\topbox +\newbox\toprefbox \newbox\printedrefnamebox +\newbox\infofilenamebox \newbox\printedmanualbox % \def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup \unsepspaces % + % Get args without leading/trailing spaces. \def\printedrefname{\ignorespaces #3}% \setbox\printedrefnamebox = \hbox{\printedrefname\unskip}% % + \def\infofilename{\ignorespaces #4}% + \setbox\infofilenamebox = \hbox{\infofilename\unskip}% + % \def\printedmanual{\ignorespaces #5}% \setbox\printedmanualbox = \hbox{\printedmanual\unskip}% % @@ -7845,12 +7956,20 @@ end \ifpdf {\indexnofonts \turnoffactive + \makevalueexpandable % This expands tokens, so do it after making catcode changes, so _ - % etc. don't get their TeX definitions. + % etc. don't get their TeX definitions. This ignores all spaces in + % #4, including (wrongly) those in the middle of the filename. \getfilename{#4}% % + % This (wrongly) does not take account of leading or trailing + % spaces in #1, which should be ignored. \edef\pdfxrefdest{#1}% - \txiescapepdf\pdfxrefdest + \ifx\pdfxrefdest\empty + \def\pdfxrefdest{Top}% no empty targets + \else + \txiescapepdf\pdfxrefdest % escape PDF special chars + \fi % \leavevmode \startlink attr{/Border [0 0 0]}% @@ -7883,7 +8002,7 @@ end \printedrefname \fi % - % if the user also gave the printed manual name (fifth arg), append + % If the user also gave the printed manual name (fifth arg), append % "in MANUALNAME". \ifdim \wd\printedmanualbox > 0pt \space \putwordin{} \cite{\printedmanual}% @@ -7898,32 +8017,20 @@ end % this is a loss. Therefore, we give the text of the node name % again, so it is as if TeX is seeing it for the first time. % - % Cross-manual reference. Only include the "Section ``foo'' in" if - % the foo is neither missing or Top. Thus, @xref{,,,foo,The Foo Manual} - % outputs simply "see The Foo Manual". \ifdim \wd\printedmanualbox > 0pt - % What is the 7sp about? The idea is that we also want to omit - % the Section part if we would be printing "Top", since they are - % clearly trying to refer to the whole manual. But, this being - % TeX, we can't easily compare strings while ignoring the possible - % spaces before and after in the input. By adding the arbitrary - % 7sp, we make it much less likely that a real node name would - % happen to have the same width as "Top" (e.g., in a monospaced font). - % I hope it will never happen in practice. + % Cross-manual reference with a printed manual name. % - % For the same basic reason, we retypeset the "Top" at every - % reference, since the current font is indeterminate. + \crossmanualxref{\cite{\printedmanual\unskip}}% + % + \else\ifdim \wd\infofilenamebox > 0pt + % Cross-manual reference with only an info filename (arg 4), no + % printed manual name (arg 5). This is essentially the same as + % the case above; we output the filename, since we have nothing else. % - \setbox\topbox = \hbox{Top\kern7sp}% - \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% - \ifdim \wd2 > 7sp - \ifdim \wd2 = \wd\topbox \else - \putwordSection{} ``\printedrefname'' \putwordin{}\space - \fi - \fi - \cite{\printedmanual}% + \crossmanualxref{\code{\infofilename\unskip}}% + % \else - % Reference in this manual. + % Reference within this manual. % % _ (for example) has to be the character _ for the purposes of the % control sequence corresponding to the node, but it has to expand @@ -7944,11 +8051,37 @@ end % % output the `page 3'. \turnoffactive \putwordpage\tie\refx{#1-pg}{}% - \fi + \fi\fi \fi \endlink \endgroup} +% Output a cross-manual xref to #1. Used just above (twice). +% +% Only include the text "Section ``foo'' in" if the foo is neither +% missing or Top. Thus, @xref{,,,foo,The Foo Manual} outputs simply +% "see The Foo Manual", the idea being to refer to the whole manual. +% +% But, this being TeX, we can't easily compare our node name against the +% string "Top" while ignoring the possible spaces before and after in +% the input. By adding the arbitrary 7sp below, we make it much less +% likely that a real node name would have the same width as "Top" (e.g., +% in a monospaced font). Hopefully it will never happen in practice. +% +% For the same basic reason, we retypeset the "Top" at every +% reference, since the current font is indeterminate. +% +\def\crossmanualxref#1{% + \setbox\toprefbox = \hbox{Top\kern7sp}% + \setbox2 = \hbox{\ignorespaces \printedrefname \unskip \kern7sp}% + \ifdim \wd2 > 7sp % nonempty? + \ifdim \wd2 = \wd\toprefbox \else % same as Top? + \putwordSection{} ``\printedrefname'' \putwordin{}\space + \fi + \fi + #1% +} + % This macro is called from \xrefX for the `[nodename]' part of xref % output. It's a separate macro only so it can be changed more easily, % since square brackets don't work well in some documents. Particularly @@ -8316,7 +8449,7 @@ end it from ftp://tug.org/tex/epsf.tex.} % \def\image#1{% - \ifx\epsfbox\thisiundefined + \ifx\epsfbox\thisisundefined \ifwarnednoepsf \else \errhelp = \noepsfhelp \errmessage{epsf.tex not found, images will be ignored}% @@ -8340,6 +8473,13 @@ end % If the image is by itself, center it. \ifvmode \imagevmodetrue + \else \ifx\centersub\centerV + % for @center @image, we need a vbox so we can have our vertical space + \imagevmodetrue + \vbox\bgroup % vbox has better behavior than vtop herev + \fi\fi + % + \ifimagevmode \nobreak\medskip % Usually we'll have text after the image which will insert % \parskip glue, so insert it here too to equalize the space @@ -8349,9 +8489,13 @@ end \fi % % Leave vertical mode so that indentation from an enclosing - % environment such as @quotation is respected. On the other hand, if - % it's at the top level, we don't want the normal paragraph indentation. - \noindent + % environment such as @quotation is respected. + % However, if we're at the top level, we don't want the + % normal paragraph indentation. + % On the other hand, if we are in the case of @center @image, we don't + % want to start a paragraph, which will create a hsize-width box and + % eradicate the centering. + \ifx\centersub\centerV\else \noindent \fi % % Output the image. \ifpdf @@ -8363,7 +8507,10 @@ end \epsfbox{#1.eps}% \fi % - \ifimagevmode \medskip \fi % space after the standalone image + \ifimagevmode + \medskip % space after a standalone image + \fi + \ifx\centersub\centerV \egroup \fi \endgroup} @@ -9866,22 +10013,26 @@ directory should work if nowhere else does.} @gdef@otherbackslash{@let\=@realbackslash} % Same as @turnoffactive except outputs \ as {\tt\char`\\} instead of -% the literal character `\'. -% -@def@normalturnoffactive{% - @let"=@normaldoublequote - @let$=@normaldollar %$ font-lock fix - @let+=@normalplus - @let<=@normalless - @let>=@normalgreater - @let\=@normalbackslash - @let^=@normalcaret - @let_=@normalunderscore - @let|=@normalverticalbar - @let~=@normaltilde - @markupsetuplqdefault - @markupsetuprqdefault - @unsepspaces +% the literal character `\'. Also revert - to its normal character, in +% case the active - from code has slipped in. +% +{@catcode`- = @active + @gdef@normalturnoffactive{% + @let-=@normaldash + @let"=@normaldoublequote + @let$=@normaldollar %$ font-lock fix + @let+=@normalplus + @let<=@normalless + @let>=@normalgreater + @let\=@normalbackslash + @let^=@normalcaret + @let_=@normalunderscore + @let|=@normalverticalbar + @let~=@normaltilde + @markupsetuplqdefault + @markupsetuprqdefault + @unsepspaces + } } % Make _ and + \other characters, temporarily. diff --git a/libc/misc/getauxval.c b/libc/misc/getauxval.c index 4321e3718..e0317fd6f 100644 --- a/libc/misc/getauxval.c +++ b/libc/misc/getauxval.c @@ -26,6 +26,8 @@ __getauxval (unsigned long int type) if (type == AT_HWCAP) return GLRO(dl_hwcap); + else if (type == AT_HWCAP2) + return GLRO(dl_hwcap2); for (p = GLRO(dl_auxv); p->a_type != AT_NULL; p++) if (p->a_type == type) diff --git a/libc/nptl/ChangeLog b/libc/nptl/ChangeLog index 875bdbdca..7c0354858 100644 --- a/libc/nptl/ChangeLog +++ b/libc/nptl/ChangeLog @@ -1,3 +1,8 @@ +2013-06-24 Vladimir Nikulichev + + [BZ #12310] + * pthread_exit.c: Add reference to pthread_create. + 2013-06-22 Joseph Myers * pthread_getattr_default_np.c: Include . diff --git a/libc/nptl/pthread_exit.c b/libc/nptl/pthread_exit.c index 371808116..263e79280 100644 --- a/libc/nptl/pthread_exit.c +++ b/libc/nptl/pthread_exit.c @@ -29,3 +29,7 @@ __pthread_exit (value) __do_cancel (); } strong_alias (__pthread_exit, pthread_exit) + +/* After a thread terminates, __libc_start_main decrements + __nptl_nthreads defined in pthread_create.c. */ +PTHREAD_STATIC_FN_REQUIRE (pthread_create) diff --git a/libc/nscd/connections.c b/libc/nscd/connections.c index 69e3e7dc0..e54d4f213 100644 --- a/libc/nscd/connections.c +++ b/libc/nscd/connections.c @@ -722,8 +722,8 @@ cannot create read-only descriptor for \"%s\"; no mmap"), cannot create read-only descriptor for \"%s\"; no mmap"), dbs[cnt].db_filename); - /* Before we create the header, initialiye the hash - table. So that if we get interrupted if writing + /* Before we create the header, initialize the hash + table. That way if we get interrupted while writing the header we can recognize a partially initialized database. */ size_t ps = sysconf (_SC_PAGESIZE); diff --git a/libc/ports/ChangeLog.aarch64 b/libc/ports/ChangeLog.aarch64 index 8119c4234..25276218e 100644 --- a/libc/ports/ChangeLog.aarch64 +++ b/libc/ports/ChangeLog.aarch64 @@ -1,3 +1,13 @@ +2013-06-28 Marcus Shawcroft + + * sysdeps/aarch64/dl-machine.h (elf_machine_dynamic): De-reference + _GLOBAL_OFFSET_TABLE_. + +2013-06-28 Marcus Shawcroft + + * sysdeps/unix/sysv/linux/aarch64/getcontext.S (__getcontext): Simplify + oPSTATE initialization. + 2013-06-15 Siddhesh Poyarekar * sysdeps/unix/sysv/linux/aarch64/nptl/libpthread.abilist: diff --git a/libc/ports/ChangeLog.alpha b/libc/ports/ChangeLog.alpha index d2e4813c5..1ccae37e9 100644 --- a/libc/ports/ChangeLog.alpha +++ b/libc/ports/ChangeLog.alpha @@ -1,3 +1,20 @@ +2013-06-28 Ryan S. Arnold + + * sysdeps/alpha/dl-procinfo.h (_dl_procinfo): Add TYPE parameter + to macro prototype for AT_HWCAP2 support. + +2013-06-24 Richard Henderson + + [BZ #15666] + * sysdeps/alpha/Versions (GLIBC_2.18): Add __sqrt_finite, + __sqrtf_finite, and __sqrtl_finite. + * sysdeps/unix/sysv/linux/alpha/nptl/libm.abilist: Likewise. + * sysdeps/alpha/alphaev6/fpu/e_sqrt.S: Add __sqrt_finite. + * sysdeps/alpha/alphaev6/fpu/e_sqrtf.S: Add __sqrtf_finite. + * sysdeps/alpha/fpu/e_sqrt.c: Add __sqrt_finite compatibility. + * sysdeps/alpha/fpu/e_sqrtf.c: New file. + * sysdeps/alpha/soft-fp/e_sqrtl.c: Add __sqrtl_finite. + 2013-06-23 Richard Henderson * sysdeps/alpha/fpu/libm-test-ulps: Update. diff --git a/libc/ports/ChangeLog.arm b/libc/ports/ChangeLog.arm index 2c07021cd..6cc665c99 100644 --- a/libc/ports/ChangeLog.arm +++ b/libc/ports/ChangeLog.arm @@ -1,3 +1,10 @@ +2013-06-28 Ryan S. Arnold + + * sysdeps/unix/sysv/linux/arm/dl-procinfo.h (_dl_procinfo): Add + TYPE parameter to macro prototype for AT_HWCAP2 support. Make WORD + unsigned long int rather than signed int. Stub in handler for TYPE == + AT_HWCAP2 to return -1 for unknown a_type display fallback. + 2013-06-18 Roland McGrath * sysdeps/arm/arm-mcount.S: Comment typo fix. diff --git a/libc/ports/ChangeLog.ia64 b/libc/ports/ChangeLog.ia64 index 78d6b586a..0189858ff 100644 --- a/libc/ports/ChangeLog.ia64 +++ b/libc/ports/ChangeLog.ia64 @@ -1,3 +1,10 @@ +2013-06-27 Maciej W. Rozycki + + * sysdeps/unix/sysv/linux/ia64/dl-static.c: Do not include + . + (_dl_static_lock): Remove variable. + (_dl_static_init): Remove _dl_static_lock locking. + 2013-06-15 Siddhesh Poyarekar * sysdeps/unix/sysv/linux/ia64/nptl/libpthread.abilist: Update. diff --git a/libc/ports/ChangeLog.m68k b/libc/ports/ChangeLog.m68k index f9a5f0b21..c96bbdee5 100644 --- a/libc/ports/ChangeLog.m68k +++ b/libc/ports/ChangeLog.m68k @@ -1,3 +1,30 @@ +2013-06-30 Joseph Myers + + * sysdeps/m68k/dl-trampoline.S (FMOVE): Define conditional on + [__mcoldfire__] and [__mcffpu__]. + (FPSPACE): Likewise. + (_dl_runtime_profile): Save and restore %fp0 with FMOVE, only if + [FMOVE]. Use FPSPACE in stack offsets. + +2013-06-28 Joseph Myers + + * sysdeps/m68k/fpu_control.h: Fix preprocessor indentation. + +2013-06-28 Nathan Sidwell + + * sysdeps/m68k/fpu_control.h [__mcoldfire__ && !__mcffpu__] + (_FPU_RESERVED): Provide alternative definition. + [__mcoldfire__ && !__mcffpu__] (_FPU_DEFAULT): Likewise. + [__mcoldfire__ && !__mcffpu__] (_FPU_GETCW): Likewise. + [__mcoldfire__ && !__mcffpu__] (_FPU_SETCW): Likewise. + [!(__mcoldfire__ && !__mcffpu__)]: Make existing macro definitions + conditional. + +2013-06-25 Andreas Schwab + + * sysdeps/m68k/sysdep.h (CALL_MCOUNT) [PROF]: Use %a6 instead of + %fp in cfi insns. + 2013-06-15 Siddhesh Poyarekar * sysdeps/unix/sysv/linux/m68k/coldfire/nptl/libpthread.abilist: diff --git a/libc/ports/ChangeLog.mips b/libc/ports/ChangeLog.mips index bdb9e5ce4..1f69593a2 100644 --- a/libc/ports/ChangeLog.mips +++ b/libc/ports/ChangeLog.mips @@ -1,3 +1,15 @@ +2013-06-28 Ryan S. Arnold + + * sysdeps/mips/dl-procinfo.h (_dl_procinfo): Add TYPE parameter + to macro prototype for AT_HWCAP2 support. + +2013-06-27 Maciej W. Rozycki + + * sysdeps/unix/sysv/linux/mips/dl-static.c: Do not include + . + (_dl_static_lock): Remove variable. + (_dl_static_init): Remove _dl_static_lock locking. + 2013-06-15 Siddhesh Poyarekar * sysdeps/unix/sysv/linux/mips/mips32/nptl/libpthread.abilist: diff --git a/libc/ports/ChangeLog.tile b/libc/ports/ChangeLog.tile index 733c541b6..978aad5f6 100644 --- a/libc/ports/ChangeLog.tile +++ b/libc/ports/ChangeLog.tile @@ -1,3 +1,12 @@ +2013-06-28 Chris Metcalf + + * sysdeps/tile/fegetenv.c: Delete now-redundant file. + * sysdeps/tile/fegetround.c: Likewise. + * sysdeps/tile/feholdexcpt.c: Likewise. + * sysdeps/tile/fesetenv.c: Likewise. + * sysdeps/tile/fesetround.c: Likewise. + * sysdeps/tile/feupdateenv.c: Likewise. + 2013-06-15 Siddhesh Poyarekar * sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/nptl/libpthread.abilist: diff --git a/libc/ports/sysdeps/aarch64/dl-machine.h b/libc/ports/sysdeps/aarch64/dl-machine.h index c91b0c42e..71dd6b389 100644 --- a/libc/ports/sysdeps/aarch64/dl-machine.h +++ b/libc/ports/sysdeps/aarch64/dl-machine.h @@ -36,8 +36,8 @@ elf_machine_matches_host (const ElfW(Ehdr) *ehdr) static inline ElfW(Addr) __attribute__ ((unused)) elf_machine_dynamic (void) { - ElfW(Addr) addr = (ElfW(Addr)) &_DYNAMIC; - return addr; + extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden; + return _GLOBAL_OFFSET_TABLE_[0]; } /* Return the run-time load address of the shared object. */ diff --git a/libc/ports/sysdeps/alpha/Versions b/libc/ports/sysdeps/alpha/Versions index 76b67a6b9..ae8fde7b2 100644 --- a/libc/ports/sysdeps/alpha/Versions +++ b/libc/ports/sysdeps/alpha/Versions @@ -10,4 +10,8 @@ libm { # used in inline functions. __atan2; } + GLIBC_2.18 { + # forgotten when the symbols were added to glibc 2.15 for other targets + __sqrt_finite; __sqrtf_finite; __sqrtl_finite; + } } diff --git a/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrt.S b/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrt.S index 66be65e51..2aac3d328 100644 --- a/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrt.S +++ b/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrt.S @@ -16,6 +16,7 @@ . */ #include +#include .arch ev6 .set noreorder @@ -42,3 +43,11 @@ ENTRY(__ieee754_sqrt) nop END(__ieee754_sqrt) + +#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +strong_alias(__ieee754_sqrt, __sqrt_finite1) +compat_symbol(libm, __sqrt_finite1, __sqrt_finite, GLIBC_2_15) +versioned_symbol(libm, __ieee754_sqrt, __sqrt_finite, GLIBC_2_18) +#else +strong_alias(__ieee754_sqrt, __sqrt_finite) +#endif diff --git a/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S b/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S index ad89786f2..5aeafca9a 100644 --- a/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S +++ b/libc/ports/sysdeps/alpha/alphaev6/fpu/e_sqrtf.S @@ -16,6 +16,7 @@ . */ #include +#include .arch ev6 .set noreorder @@ -42,3 +43,11 @@ ENTRY(__ieee754_sqrtf) nop END(__ieee754_sqrtf) + +#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +strong_alias(__ieee754_sqrtf, __sqrtf_finite1) +compat_symbol(libm, __sqrtf_finite1, __sqrtf_finite, GLIBC_2_15) +versioned_symbol(libm, __ieee754_sqrtf, __sqrtf_finite, GLIBC_2_18) +#else +strong_alias(__ieee754_sqrtf, __sqrtf_finite) +#endif diff --git a/libc/ports/sysdeps/alpha/dl-procinfo.h b/libc/ports/sysdeps/alpha/dl-procinfo.h index 523d96676..0344dbc96 100644 --- a/libc/ports/sysdeps/alpha/dl-procinfo.h +++ b/libc/ports/sysdeps/alpha/dl-procinfo.h @@ -51,7 +51,7 @@ _dl_string_platform (const char *str) }; /* We cannot provide a general printing function. */ -#define _dl_procinfo(word) -1 +#define _dl_procinfo(type, word) -1 /* There are no hardware capabilities defined. */ #define _dl_hwcap_string(idx) "" diff --git a/libc/ports/sysdeps/alpha/fpu/e_sqrt.c b/libc/ports/sysdeps/alpha/fpu/e_sqrt.c index 538ff1da6..6abca0896 100644 --- a/libc/ports/sysdeps/alpha/fpu/e_sqrt.c +++ b/libc/ports/sysdeps/alpha/fpu/e_sqrt.c @@ -18,6 +18,7 @@ #include #include +#include #if !defined(_IEEE_FP_INEXACT) @@ -157,9 +158,30 @@ $fixup: \n\ \n\ .end __ieee754_sqrt"); +/* Avoid the __sqrt_finite alias that dbl-64/e_sqrt.c would give... */ +#undef strong_alias +#define strong_alias(a,b) + +/* ... defining our own. */ +#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +asm (".global __sqrt_finite1; __sqrt_finite1 = __ieee754_sqrt"); +#else +asm (".global __sqrt_finite; __sqrt_finite = __ieee754_sqrt"); +#endif + static double __full_ieee754_sqrt(double) __attribute_used__; #define __ieee754_sqrt __full_ieee754_sqrt +#elif SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +# define __sqrt_finite __sqrt_finite1 #endif /* _IEEE_FP_INEXACT */ #include + +/* Work around forgotten symbol in alphaev6 build. */ +#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +# undef __sqrt_finite +# undef __ieee754_sqrt +compat_symbol (libm, __sqrt_finite1, __sqrt_finite, GLIBC_2_15); +versioned_symbol (libm, __ieee754_sqrt, __sqrt_finite, GLIBC_2_18); +#endif diff --git a/libc/ports/sysdeps/alpha/fpu/e_sqrtf.c b/libc/ports/sysdeps/alpha/fpu/e_sqrtf.c new file mode 100644 index 000000000..ad523f5cf --- /dev/null +++ b/libc/ports/sysdeps/alpha/fpu/e_sqrtf.c @@ -0,0 +1,14 @@ +#include + +#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +# define __sqrtf_finite __sqrtf_finite1 +#endif + +#include + +/* Work around forgotten symbol in alphaev6 build. */ +#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +# undef __sqrtf_finite +compat_symbol (libm, __sqrtf_finite1, __sqrtf_finite, GLIBC_2_15); +versioned_symbol (libm, __ieee754_sqrtf, __sqrtf_finite, GLIBC_2_18); +#endif diff --git a/libc/ports/sysdeps/alpha/soft-fp/e_sqrtl.c b/libc/ports/sysdeps/alpha/soft-fp/e_sqrtl.c index 40e97b887..2cb076e4c 100644 --- a/libc/ports/sysdeps/alpha/soft-fp/e_sqrtl.c +++ b/libc/ports/sysdeps/alpha/soft-fp/e_sqrtl.c @@ -21,6 +21,7 @@ #include #include #include +#include long double __ieee754_sqrtl (const long double a) @@ -37,3 +38,12 @@ __ieee754_sqrtl (const long double a) FP_HANDLE_EXCEPTIONS; return c; } + +/* ??? We forgot to add this symbol in 2.15. Getting this into 2.18 isn't as + straight-forward as just adding the alias, since a generic Versions file + includes the 2.15 version and the linker uses the first one it sees. */ +#if SHLIB_COMPAT (libm, GLIBC_2_15, GLIBC_2_18) +versioned_symbol (libm, __ieee754_sqrtl, __sqrtl_finite, GLIBC_2_18); +#else +strong_alias(__ieee754_sqrtl, __sqrtl_finite) +#endif diff --git a/libc/ports/sysdeps/m68k/dl-trampoline.S b/libc/ports/sysdeps/m68k/dl-trampoline.S index 16f20dcad..a4caa67a8 100644 --- a/libc/ports/sysdeps/m68k/dl-trampoline.S +++ b/libc/ports/sysdeps/m68k/dl-trampoline.S @@ -18,6 +18,16 @@ #include +#if !defined (__mcoldfire__) +# define FMOVE fmove.x +# define FPSPACE 12 +#elif defined (__mcffpu__) +# define FMOVE fmove.d +# define FPSPACE 8 +#else +# define FPSPACE 0 +#endif + .text .globl _dl_runtime_resolve .type _dl_runtime_resolve, @function @@ -174,16 +184,9 @@ _dl_runtime_profile: +4 %a1 %sp %a0 */ -#if !defined (__mcoldfire__) - fmove.x %fp0, -(%sp) - cfi_adjust_cfa_offset (12) -#elif defined (__mcffpu__) - fmove.d %fp0, -(%sp) - cfi_adjust_cfa_offset (8) -#else - clr.l -(%sp) - clr.l -(%sp) - cfi_adjust_cfa_offset (8) +#ifdef FMOVE + FMOVE %fp0, -(%sp) + cfi_adjust_cfa_offset (FPSPACE) #endif move.l %a0, -(%sp) cfi_adjust_cfa_offset (4) @@ -193,21 +196,12 @@ _dl_runtime_profile: cfi_adjust_cfa_offset (4) pea (%sp) cfi_adjust_cfa_offset (4) -#ifdef __mcoldfire__ - pea 24(%sp) + pea (16+FPSPACE)(%sp) cfi_adjust_cfa_offset (4) - move.l 40(%sp), -(%sp) - cfi_adjust_cfa_offset (4) - move.l 40(%sp), -(%sp) - cfi_adjust_cfa_offset (4) -#else - pea 28(%sp) + move.l (32+FPSPACE)(%sp), -(%sp) cfi_adjust_cfa_offset (4) - move.l 44(%sp), -(%sp) + move.l (32+FPSPACE)(%sp), -(%sp) cfi_adjust_cfa_offset (4) - move.l 44(%sp), -(%sp) - cfi_adjust_cfa_offset (4) -#endif jbsr _dl_call_pltexit lea 16(%sp), %sp cfi_adjust_cfa_offset (-16) @@ -217,20 +211,12 @@ _dl_runtime_profile: cfi_adjust_cfa_offset (-4) move.l (%sp)+, %a0 cfi_adjust_cfa_offset (-4) -#if !defined (__mcoldfire__) - fmove.x (%sp)+, %fp0 - cfi_adjust_cfa_offset (-12) - lea 20(%sp), %sp - cfi_adjust_cfa_offset (-20) -#elif defined (__mcffpu__) - fmove.l (%sp)+, %fp0 - cfi_adjust_cfa_offset (-8) +#ifdef FMOVE + FMOVE (%sp)+, %fp0 + cfi_adjust_cfa_offset (-FPSPACE) +#endif lea 20(%sp), %sp cfi_adjust_cfa_offset (-20) -#else - lea 28(%sp), %sp - cfi_adjust_cfa_offset (-28) -#endif rts cfi_endproc .size _dl_runtime_profile, . - _dl_runtime_profile diff --git a/libc/ports/sysdeps/m68k/fpu_control.h b/libc/ports/sysdeps/m68k/fpu_control.h index 71b9c3002..7b22a95c7 100644 --- a/libc/ports/sysdeps/m68k/fpu_control.h +++ b/libc/ports/sysdeps/m68k/fpu_control.h @@ -55,58 +55,58 @@ #if defined (__mcoldfire__) && !defined (__mcffpu__) -#define _FPU_RESERVED 0xffffffff -#define _FPU_DEFAULT 0x00000000 -#define _FPU_GETCW(cw) ((cw) = 0) -#define _FPU_SETCW(cw) ((void)(cw)) +# define _FPU_RESERVED 0xffffffff +# define _FPU_DEFAULT 0x00000000 +# define _FPU_GETCW(cw) ((cw) = 0) +# define _FPU_SETCW(cw) ((void) (cw)) #else /* masking of interrupts */ -#define _FPU_MASK_BSUN 0x8000 -#define _FPU_MASK_SNAN 0x4000 -#define _FPU_MASK_OPERR 0x2000 -#define _FPU_MASK_OVFL 0x1000 -#define _FPU_MASK_UNFL 0x0800 -#define _FPU_MASK_DZ 0x0400 -#define _FPU_MASK_INEX1 0x0200 -#define _FPU_MASK_INEX2 0x0100 +# define _FPU_MASK_BSUN 0x8000 +# define _FPU_MASK_SNAN 0x4000 +# define _FPU_MASK_OPERR 0x2000 +# define _FPU_MASK_OVFL 0x1000 +# define _FPU_MASK_UNFL 0x0800 +# define _FPU_MASK_DZ 0x0400 +# define _FPU_MASK_INEX1 0x0200 +# define _FPU_MASK_INEX2 0x0100 /* precision control */ -#ifdef __mcoldfire__ -#define _FPU_DOUBLE 0x00 -#else -#define _FPU_EXTENDED 0x00 /* RECOMMENDED */ -#define _FPU_DOUBLE 0x80 -#endif -#define _FPU_SINGLE 0x40 /* DO NOT USE */ +# ifdef __mcoldfire__ +# define _FPU_DOUBLE 0x00 +# else +# define _FPU_EXTENDED 0x00 /* RECOMMENDED */ +# define _FPU_DOUBLE 0x80 +# endif +# define _FPU_SINGLE 0x40 /* DO NOT USE */ /* rounding control */ -#define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */ -#define _FPU_RC_ZERO 0x10 -#define _FPU_RC_DOWN 0x20 -#define _FPU_RC_UP 0x30 +# define _FPU_RC_NEAREST 0x00 /* RECOMMENDED */ +# define _FPU_RC_ZERO 0x10 +# define _FPU_RC_DOWN 0x20 +# define _FPU_RC_UP 0x30 -#ifdef __mcoldfire__ -#define _FPU_RESERVED 0xFFFF800F -#else -#define _FPU_RESERVED 0xFFFF000F /* Reserved bits in fpucr */ -#endif +# ifdef __mcoldfire__ +# define _FPU_RESERVED 0xFFFF800F +# else +# define _FPU_RESERVED 0xFFFF000F /* Reserved bits in fpucr */ +# endif /* Now two recommended fpucr */ /* The fdlibm code requires no interrupts for exceptions. Don't change the rounding mode, it would break long double I/O! */ -#define _FPU_DEFAULT 0x00000000 +# define _FPU_DEFAULT 0x00000000 /* IEEE: same as above, but exceptions. We must make it non-zero so that __setfpucw works. This bit will be ignored. */ -#define _FPU_IEEE 0x00000001 +# define _FPU_IEEE 0x00000001 /* Macros for accessing the hardware control word. */ -#define _FPU_GETCW(cw) __asm__ ("fmove%.l %!, %0" : "=dm" (cw)) -#define _FPU_SETCW(cw) __asm__ volatile ("fmove%.l %0, %!" : : "dm" (cw)) +# define _FPU_GETCW(cw) __asm__ ("fmove%.l %!, %0" : "=dm" (cw)) +# define _FPU_SETCW(cw) __asm__ volatile ("fmove%.l %0, %!" : : "dm" (cw)) #endif /* Type of the control word. */ diff --git a/libc/ports/sysdeps/m68k/sysdep.h b/libc/ports/sysdeps/m68k/sysdep.h index cd34dd836..f8ad70e01 100644 --- a/libc/ports/sysdeps/m68k/sysdep.h +++ b/libc/ports/sysdeps/m68k/sysdep.h @@ -45,11 +45,11 @@ to locate our caller, so push one just for its benefit. */ # define CALL_MCOUNT \ move.l %fp, -(%sp); \ - cfi_adjust_cfa_offset (4); cfi_rel_offset (%fp, 0); \ + cfi_adjust_cfa_offset (4); cfi_rel_offset (%a6, 0); \ move.l %sp, %fp; \ jbsr JUMPTARGET (_mcount); \ move.l (%sp)+, %fp; \ - cfi_adjust_cfa_offset (-4); cfi_restore (%fp); + cfi_adjust_cfa_offset (-4); cfi_restore (%a6); # else # define CALL_MCOUNT /* Do nothing. */ # endif diff --git a/libc/ports/sysdeps/mips/dl-procinfo.h b/libc/ports/sysdeps/mips/dl-procinfo.h index 5cc9a4444..e96550c40 100644 --- a/libc/ports/sysdeps/mips/dl-procinfo.h +++ b/libc/ports/sysdeps/mips/dl-procinfo.h @@ -51,7 +51,7 @@ _dl_string_platform (const char *str) }; /* We cannot provide a general printing function. */ -#define _dl_procinfo(word) -1 +#define _dl_procinfo(type, word) -1 /* There are no hardware capabilities defined. */ #define _dl_hwcap_string(idx) "" diff --git a/libc/ports/sysdeps/tile/fegetenv.c b/libc/ports/sysdeps/tile/fegetenv.c deleted file mode 100644 index acb81ecbd..000000000 --- a/libc/ports/sysdeps/tile/fegetenv.c +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (C) 2011-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include - -int -__fegetenv (fenv_t *envp) -{ - /* As a no-op, this always succeeds. */ - return 0; -} -libm_hidden_ver (__fegetenv, fegetenv) -versioned_symbol (libm, __fegetenv, fegetenv, GLIBC_2_2); diff --git a/libc/ports/sysdeps/tile/fegetround.c b/libc/ports/sysdeps/tile/fegetround.c deleted file mode 100644 index fb8416d60..000000000 --- a/libc/ports/sysdeps/tile/fegetround.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright (C) 2011-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -int -fegetround (void) -{ - return FE_TONEAREST; -} diff --git a/libc/ports/sysdeps/tile/feholdexcpt.c b/libc/ports/sysdeps/tile/feholdexcpt.c deleted file mode 100644 index 268b4a856..000000000 --- a/libc/ports/sysdeps/tile/feholdexcpt.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2011-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -/* Tile has no exception flags, so this routine can be a no-op. */ -int -feholdexcept (fenv_t *envp) -{ - return 0; -} -libm_hidden_def (feholdexcept) diff --git a/libc/ports/sysdeps/tile/fesetenv.c b/libc/ports/sysdeps/tile/fesetenv.c deleted file mode 100644 index f46f761f1..000000000 --- a/libc/ports/sysdeps/tile/fesetenv.c +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (C) 2011-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include -#include - -/* The only way to get an initialized fenv_t on Tile is with feholdexcept() - or via FE_DFL_ENV, either of which restores the environment to its - normal state, i.e. FE_DFL_ENV. */ -int -__fesetenv (const fenv_t *envp) -{ - return 0; -} -libm_hidden_ver (__fesetenv, fesetenv) -versioned_symbol (libm, __fesetenv, fesetenv, GLIBC_2_2); diff --git a/libc/ports/sysdeps/tile/fesetround.c b/libc/ports/sysdeps/tile/fesetround.c deleted file mode 100644 index 73b4d30f6..000000000 --- a/libc/ports/sysdeps/tile/fesetround.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (C) 2011-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -int -fesetround (int round) -{ - return (round == FE_TONEAREST) ? 0 : 1; -} -libm_hidden_def (fesetround) diff --git a/libc/ports/sysdeps/tile/feupdateenv.c b/libc/ports/sysdeps/tile/feupdateenv.c deleted file mode 100644 index 5745c3094..000000000 --- a/libc/ports/sysdeps/tile/feupdateenv.c +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (C) 2011-2013 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Chris Metcalf , 2011. - - The GNU C Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - The GNU C Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with the GNU C Library. If not, see - . */ - -#include - -/* Tile has no exception flags, so this routine can be a no-op. */ -int -feupdateenv (const fenv_t *envp) -{ - return 0; -} -libm_hidden_def (feupdateenv) diff --git a/libc/ports/sysdeps/unix/sysv/linux/aarch64/getcontext.S b/libc/ports/sysdeps/unix/sysv/linux/aarch64/getcontext.S index c3709575b..2ba48044e 100644 --- a/libc/ports/sysdeps/unix/sysv/linux/aarch64/getcontext.S +++ b/libc/ports/sysdeps/unix/sysv/linux/aarch64/getcontext.S @@ -54,8 +54,7 @@ ENTRY(__getcontext) str x2, [x0, oSP] /* Initialize the pstate. */ - mov x3, #0 - str x3, [x0, oPSTATE] + str xzr, [x0, oPSTATE] /* Figure out where to place the first context extension block. */ diff --git a/libc/ports/sysdeps/unix/sysv/linux/alpha/nptl/libm.abilist b/libc/ports/sysdeps/unix/sysv/linux/alpha/nptl/libm.abilist index 400a851d4..d9b44b531 100644 --- a/libc/ports/sysdeps/unix/sysv/linux/alpha/nptl/libm.abilist +++ b/libc/ports/sysdeps/unix/sysv/linux/alpha/nptl/libm.abilist @@ -382,6 +382,8 @@ GLIBC_2.15 __sinh_finite F __sinhf_finite F __sinhl_finite F + __sqrt_finite F + __sqrtf_finite F __y0_finite F __y0f_finite F __y0l_finite F @@ -396,6 +398,9 @@ GLIBC_2.18 __issignaling F __issignalingf F __issignalingl F + __sqrt_finite F + __sqrtf_finite F + __sqrtl_finite F GLIBC_2.2 GLIBC_2.2 A feclearexcept F diff --git a/libc/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h b/libc/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h index 161e86c79..251653ae1 100644 --- a/libc/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h +++ b/libc/ports/sysdeps/unix/sysv/linux/arm/dl-procinfo.h @@ -31,10 +31,14 @@ static inline int __attribute__ ((unused)) -_dl_procinfo (int word) +_dl_procinfo (unsigned int type, unsigned long int word) { int i; + /* Fallback to unknown output mechanism. */ + if (type == AT_HWCAP2) + return -1; + _dl_printf ("AT_HWCAP: "); for (i = 0; i < _DL_HWCAP_COUNT; ++i) diff --git a/libc/ports/sysdeps/unix/sysv/linux/ia64/dl-static.c b/libc/ports/sysdeps/unix/sysv/linux/ia64/dl-static.c index de635db40..9853253dc 100644 --- a/libc/ports/sysdeps/unix/sysv/linux/ia64/dl-static.c +++ b/libc/ports/sysdeps/unix/sysv/linux/ia64/dl-static.c @@ -35,9 +35,6 @@ _dl_var_init (void *array[]) } #else -#include - -__libc_lock_define_initialized_recursive (static, _dl_static_lock) static void *variables[] = { @@ -52,8 +49,6 @@ _dl_static_init (struct link_map *map) lookup_t loadbase; void (*f) (void *[]); - __libc_lock_lock_recursive (_dl_static_lock); - loadbase = _dl_lookup_symbol_x ("_dl_var_init", map, &ref, map->l_local_scope, NULL, 0, 1, NULL); if (ref != NULL) @@ -61,8 +56,6 @@ _dl_static_init (struct link_map *map) f = (void (*) (void *[])) DL_SYMBOL_ADDRESS (loadbase, ref); f (variables); } - - __libc_lock_unlock_recursive (_dl_static_lock); } #endif diff --git a/libc/ports/sysdeps/unix/sysv/linux/mips/dl-static.c b/libc/ports/sysdeps/unix/sysv/linux/mips/dl-static.c index e0501be3b..9290ed9ed 100644 --- a/libc/ports/sysdeps/unix/sysv/linux/mips/dl-static.c +++ b/libc/ports/sysdeps/unix/sysv/linux/mips/dl-static.c @@ -33,9 +33,6 @@ _dl_var_init (void *array[]) } #else -#include - -__libc_lock_define_initialized_recursive (static, _dl_static_lock) static void *variables[] = { @@ -64,8 +61,6 @@ _dl_static_init (struct link_map *l) void (*f) (void *[]); size_t i; - __libc_lock_lock_recursive (_dl_static_lock); - loadbase = _dl_lookup_symbol_x ("_dl_var_init", l, &ref, l->l_local_scope, NULL, 0, 1, NULL); @@ -84,8 +79,6 @@ _dl_static_init (struct link_map *l) f (variables); _dl_protect_relro (rtld_map); } - - __libc_lock_unlock_recursive (_dl_static_lock); } #endif diff --git a/libc/string/test-memcmp.c b/libc/string/test-memcmp.c index b30e34d0e..0420cd0b7 100644 --- a/libc/string/test-memcmp.c +++ b/libc/string/test-memcmp.c @@ -448,6 +448,29 @@ check1 (void) } } +/* This test checks that memcmp doesn't overrun buffers. */ +static void +check2 (void) +{ + size_t max_length = page_size / sizeof (CHAR); + + /* Initialize buf2 to the same values as buf1. The bug requires the + last compared byte to be different. */ + memcpy (buf2, buf1, page_size); + ((char *) buf2)[page_size - 1] ^= 0x11; + + for (size_t length = 1; length < max_length; length++) + { + CHAR *s1 = (CHAR *) buf1 + max_length - length; + CHAR *s2 = (CHAR *) buf2 + max_length - length; + + const int exp_result = SIMPLE_MEMCMP (s1, s2, length); + + FOR_EACH_IMPL (impl, 0) + check_result (impl, s1, s2, length, exp_result); + } +} + int test_main (void) { @@ -456,6 +479,7 @@ test_main (void) test_init (); check1 (); + check2 (); printf ("%23s", ""); FOR_EACH_IMPL (impl, 0) diff --git a/libc/sysdeps/generic/dl-procinfo.h b/libc/sysdeps/generic/dl-procinfo.h index 90c87d942..a184a5918 100644 --- a/libc/sysdeps/generic/dl-procinfo.h +++ b/libc/sysdeps/generic/dl-procinfo.h @@ -21,7 +21,7 @@ #define _DL_PROCINFO_H 1 /* We cannot provide a general printing function. */ -#define _dl_procinfo(word) -1 +#define _dl_procinfo(type, word) -1 /* There are no hardware capabilities defined. */ #define _dl_hwcap_string(idx) "" diff --git a/libc/sysdeps/generic/ldsodefs.h b/libc/sysdeps/generic/ldsodefs.h index 1d47f8819..2d0ed3ed0 100644 --- a/libc/sysdeps/generic/ldsodefs.h +++ b/libc/sysdeps/generic/ldsodefs.h @@ -562,6 +562,10 @@ struct rtld_global_ro EXTERN struct link_map *_dl_sysinfo_map; #endif + /* Mask for more hardware capabilities that are available on some + platforms. */ + EXTERN uint64_t _dl_hwcap2; + #ifdef SHARED /* We add a function table to _rtld_global which is then used to call the function instead of going through the PLT. The result diff --git a/libc/sysdeps/generic/libc-mmap.h b/libc/sysdeps/generic/libc-mmap.h new file mode 100644 index 000000000..0ddd20d42 --- /dev/null +++ b/libc/sysdeps/generic/libc-mmap.h @@ -0,0 +1,26 @@ +/* Internal logic for dealing with mmap quirks. + Copyright (C) 2013 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + . */ + +#ifndef _LIBC_MMAP_H +#define _LIBC_MMAP_H 1 + +/* Using MAP_FIXED with mmap sometimes requires larger alignment. */ +#include +#define MAP_FIXED_ALIGNMENT SHMLBA + +#endif diff --git a/libc/sysdeps/i386/dl-procinfo.h b/libc/sysdeps/i386/dl-procinfo.h index 883fa7f0a..233a3257e 100644 --- a/libc/sysdeps/i386/dl-procinfo.h +++ b/libc/sysdeps/i386/dl-procinfo.h @@ -61,7 +61,7 @@ enum }; /* We cannot provide a general printing function. */ -#define _dl_procinfo(word) -1 +#define _dl_procinfo(type, word) -1 static inline const char * __attribute__ ((unused)) diff --git a/libc/sysdeps/powerpc/Makefile b/libc/sysdeps/powerpc/Makefile index 7442b6709..f75e62523 100644 --- a/libc/sysdeps/powerpc/Makefile +++ b/libc/sysdeps/powerpc/Makefile @@ -17,7 +17,7 @@ endif endif ifeq ($(subdir),csu) -# get offset to rtld_global._dl_hwcap +# get offset to rtld_global._dl_hwcap and rtld_global._dl_hwcap2 gen-as-const-headers += rtld-global-offsets.sym # get offset to __locale_struct.__ctype_tolower gen-as-const-headers += locale-defines.sym diff --git a/libc/sysdeps/powerpc/bits/hwcap.h b/libc/sysdeps/powerpc/bits/hwcap.h index 783138a0e..0c02fc68e 100644 --- a/libc/sysdeps/powerpc/bits/hwcap.h +++ b/libc/sysdeps/powerpc/bits/hwcap.h @@ -1,4 +1,4 @@ -/* Defines for bits in AT_HWCAP. +/* Defines for bits in AT_HWCAP and AT_HWCAP2. Copyright (C) 2012-2013 Free Software Foundation, Inc. This file is part of the GNU C Library. @@ -20,9 +20,9 @@ # error "Never include directly; use instead." #endif -/* - * The following must match the kernels asm/cputable.h. - */ +/* The bit numbers must match those in the kernel's asm/cputable.h. */ + +/* Feature definitions in AT_HWCAP. */ #define PPC_FEATURE_32 0x80000000 /* 32-bit mode. */ #define PPC_FEATURE_64 0x40000000 /* 64-bit mode. */ #define PPC_FEATURE_601_INSTR 0x20000000 /* 601 chip, Old POWER ISA. */ @@ -39,8 +39,9 @@ #define PPC_FEATURE_POWER5 0x00040000 /* POWER5 ISA 2.02 */ #define PPC_FEATURE_POWER5_PLUS 0x00020000 /* POWER5+ ISA 2.03 */ #define PPC_FEATURE_CELL_BE 0x00010000 /* CELL Broadband Engine */ -#define PPC_FEATURE_BOOKE 0x00008000 -#define PPC_FEATURE_SMT 0x00004000 /* Simultaneous Multi-Threading */ +#define PPC_FEATURE_BOOKE 0x00008000 /* ISA Category Embedded */ +#define PPC_FEATURE_SMT 0x00004000 /* Simultaneous + Multi-Threading */ #define PPC_FEATURE_ICACHE_SNOOP 0x00002000 #define PPC_FEATURE_ARCH_2_05 0x00001000 /* ISA 2.05 */ #define PPC_FEATURE_PA6T 0x00000800 /* PA Semi 6T Core */ @@ -51,3 +52,13 @@ #define PPC_FEATURE_PSERIES_PERFMON_COMPAT 0x00000040 #define PPC_FEATURE_TRUE_LE 0x00000002 #define PPC_FEATURE_PPC_LE 0x00000001 + +/* Feature definitions in AT_HWCAP2. */ +#define PPC_FEATURE2_ARCH_2_07 0x80000000 /* ISA 2.07 */ +#define PPC_FEATURE2_HAS_HTM 0x40000000 /* Hardware Transactional + Memory */ +#define PPC_FEATURE2_HAS_DSCR 0x20000000 /* Data Stream Control + Register */ +#define PPC_FEATURE2_HAS_EBB 0x10000000 /* Event Base Branching */ +#define PPC_FEATURE2_HAS_ISEL 0x08000000 /* Integer Select */ +#define PPC_FEATURE2_HAS_TAR 0x04000000 /* Target Address Register */ diff --git a/libc/sysdeps/powerpc/dl-procinfo.c b/libc/sysdeps/powerpc/dl-procinfo.c index 0f5c2b3d6..2984af197 100644 --- a/libc/sysdeps/powerpc/dl-procinfo.c +++ b/libc/sysdeps/powerpc/dl-procinfo.c @@ -45,7 +45,7 @@ #if !defined PROCINFO_DECL && defined SHARED ._dl_powerpc_cap_flags #else -PROCINFO_CLASS const char _dl_powerpc_cap_flags[25][10] +PROCINFO_CLASS const char _dl_powerpc_cap_flags[57][10] #endif #ifndef PROCINFO_DECL = { @@ -56,6 +56,14 @@ PROCINFO_CLASS const char _dl_powerpc_cap_flags[25][10] "notb", "efpdouble", "efpsingle", "spe", "ucache", "4xxmac", "mmu", "fpu", "altivec", "ppc601", "ppc64", "ppc32", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "", "", + "", "", "tar", "isel", + "ebb", "dscr", "htm", "arch_2_07", } #endif #if !defined SHARED || defined PROCINFO_DECL @@ -67,7 +75,7 @@ PROCINFO_CLASS const char _dl_powerpc_cap_flags[25][10] #if !defined PROCINFO_DECL && defined SHARED ._dl_powerpc_platforms #else -PROCINFO_CLASS const char _dl_powerpc_platforms[13][12] +PROCINFO_CLASS const char _dl_powerpc_platforms[14][12] #endif #ifndef PROCINFO_DECL = { @@ -83,7 +91,8 @@ PROCINFO_CLASS const char _dl_powerpc_platforms[13][12] [PPC_PLATFORM_PPC405] = "ppc405", [PPC_PLATFORM_PPC440] = "ppc440", [PPC_PLATFORM_PPC464] = "ppc464", - [PPC_PLATFORM_PPC476] = "ppc476" + [PPC_PLATFORM_PPC476] = "ppc476", + [PPC_PLATFORM_POWER8] = "power8", } #endif #if !defined SHARED || defined PROCINFO_DECL diff --git a/libc/sysdeps/powerpc/dl-procinfo.h b/libc/sysdeps/powerpc/dl-procinfo.h index 568fe19dd..e7eeed9d2 100644 --- a/libc/sysdeps/powerpc/dl-procinfo.h +++ b/libc/sysdeps/powerpc/dl-procinfo.h @@ -20,17 +20,27 @@ #define _DL_PROCINFO_H 1 #include -#include /* This defines the PPC_FEATURE_* macros. */ +#include /* This defines the PPC_FEATURE[2]_* macros. */ /* There are 25 bits used, but they are bits 7..31. */ #define _DL_HWCAP_FIRST 7 -#define _DL_HWCAP_COUNT 32 + +/* The total number of available bits (including those prior to + _DL_HWCAP_FIRST). Some of these bits might not be used. */ +#define _DL_HWCAP_COUNT 64 + +/* Features started at bit 31 and decremented as new features were added. */ +#define _DL_HWCAP_LAST 31 + +/* AT_HWCAP2 features started at bit 31 and decremented as new features were + added. HWCAP2 feature bits start at bit 0. */ +#define _DL_HWCAP2_LAST 31 /* These bits influence library search. */ #define HWCAP_IMPORTANT (PPC_FEATURE_HAS_ALTIVEC \ + PPC_FEATURE_HAS_DFP) -#define _DL_PLATFORMS_COUNT 13 +#define _DL_PLATFORMS_COUNT 14 #define _DL_FIRST_PLATFORM 32 /* Mask to filter out platforms. */ @@ -51,6 +61,7 @@ #define PPC_PLATFORM_PPC440 10 #define PPC_PLATFORM_PPC464 11 #define PPC_PLATFORM_PPC476 12 +#define PPC_PLATFORM_POWER8 13 static inline const char * __attribute__ ((unused)) @@ -111,6 +122,9 @@ _dl_string_platform (const char *str) case '7': ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER7; break; + case '8': + ret = _DL_FIRST_PLATFORM + PPC_PLATFORM_POWER8; + break; default: return -1; } @@ -155,16 +169,35 @@ _dl_string_platform (const char *str) #ifdef IS_IN_rtld static inline int __attribute__ ((unused)) -_dl_procinfo (int word) +_dl_procinfo (unsigned int type, unsigned long int word) { - _dl_printf ("AT_HWCAP: "); - - for (int i = _DL_HWCAP_FIRST; i < _DL_HWCAP_COUNT; ++i) - if (word & (1 << i)) - _dl_printf (" %s", _dl_hwcap_string (i)); - - _dl_printf ("\n"); - + switch(type) + { + case AT_HWCAP: + _dl_printf ("AT_HWCAP: "); + + for (int i = _DL_HWCAP_FIRST; i <= _DL_HWCAP_LAST; ++i) + if (word & (1 << i)) + _dl_printf (" %s", _dl_hwcap_string (i)); + break; + case AT_HWCAP2: + { + unsigned int offset = _DL_HWCAP_LAST + 1; + + _dl_printf ("AT_HWCAP2: "); + + /* We have to go through them all because the kernel added the + AT_HWCAP2 features starting with the high bits. */ + for (int i = 0; i <= _DL_HWCAP2_LAST; ++i) + if (word & (1 << i)) + _dl_printf (" %s", _dl_hwcap_string (offset + i)); + break; + } + default: + /* This should not happen. */ + return -1; + } + _dl_printf ("\n"); return 0; } #endif diff --git a/libc/sysdeps/powerpc/powerpc32/power8/Implies b/libc/sysdeps/powerpc/powerpc32/power8/Implies new file mode 100644 index 000000000..083f3e950 --- /dev/null +++ b/libc/sysdeps/powerpc/powerpc32/power8/Implies @@ -0,0 +1,2 @@ +powerpc/powerpc32/power7/fpu +powerpc/powerpc32/power7 diff --git a/libc/sysdeps/powerpc/powerpc64/power8/Implies b/libc/sysdeps/powerpc/powerpc64/power8/Implies new file mode 100644 index 000000000..9a5e3c727 --- /dev/null +++ b/libc/sysdeps/powerpc/powerpc64/power8/Implies @@ -0,0 +1,2 @@ +powerpc/powerpc64/power7/fpu +powerpc/powerpc64/power7 diff --git a/libc/sysdeps/powerpc/rtld-global-offsets.sym b/libc/sysdeps/powerpc/rtld-global-offsets.sym index ff4e97f2a..f5ea5a146 100644 --- a/libc/sysdeps/powerpc/rtld-global-offsets.sym +++ b/libc/sysdeps/powerpc/rtld-global-offsets.sym @@ -5,3 +5,4 @@ #define rtld_global_ro_offsetof(mem) offsetof (struct rtld_global_ro, mem) RTLD_GLOBAL_RO_DL_HWCAP_OFFSET rtld_global_ro_offsetof (_dl_hwcap) +RTLD_GLOBAL_RO_DL_HWCAP2_OFFSET rtld_global_ro_offsetof (_dl_hwcap2) diff --git a/libc/sysdeps/s390/dl-procinfo.h b/libc/sysdeps/s390/dl-procinfo.h index 717f6f9a5..45e27f102 100644 --- a/libc/sysdeps/s390/dl-procinfo.h +++ b/libc/sysdeps/s390/dl-procinfo.h @@ -56,7 +56,7 @@ enum | HWCAP_S390_EIMM | HWCAP_S390_DFP) /* We cannot provide a general printing function. */ -#define _dl_procinfo(word) -1 +#define _dl_procinfo(type, word) -1 static inline const char * __attribute__ ((unused)) diff --git a/libc/sysdeps/sparc/dl-procinfo.h b/libc/sysdeps/sparc/dl-procinfo.h index a18b09958..71b279acd 100644 --- a/libc/sysdeps/sparc/dl-procinfo.h +++ b/libc/sysdeps/sparc/dl-procinfo.h @@ -27,10 +27,14 @@ static inline int __attribute__ ((unused)) -_dl_procinfo (int word) +_dl_procinfo (unsigned int type, unsigned long int word) { int i; + /* Fallback to unknown output mechanism. */ + if (type == AT_HWCAP2) + return -1; + _dl_printf ("AT_HWCAP: "); for (i = 0; i < _DL_HWCAP_COUNT; ++i) diff --git a/libc/sysdeps/unix/sysv/linux/i386/dl-procinfo.h b/libc/sysdeps/unix/sysv/linux/i386/dl-procinfo.h index a82f8f5b8..10f1c00b7 100644 --- a/libc/sysdeps/unix/sysv/linux/i386/dl-procinfo.h +++ b/libc/sysdeps/unix/sysv/linux/i386/dl-procinfo.h @@ -24,12 +24,16 @@ #undef _dl_procinfo static inline int __attribute__ ((unused)) -_dl_procinfo (int word) +_dl_procinfo (unsigned int type, unsigned long int word) { /* This table should match the information from arch/i386/kernel/setup.c in the kernel sources. */ int i; + /* Fallback to unknown output mechanism. */ + if (type == AT_HWCAP2) + return -1; + _dl_printf ("AT_HWCAP: "); for (i = 0; i < _DL_HWCAP_COUNT; ++i) diff --git a/libc/sysdeps/unix/sysv/linux/mmap64.c b/libc/sysdeps/unix/sysv/linux/mmap64.c index 175e4abba..e2dcdc4d9 100644 --- a/libc/sysdeps/unix/sysv/linux/mmap64.c +++ b/libc/sysdeps/unix/sysv/linux/mmap64.c @@ -56,7 +56,7 @@ __mmap64 (void *addr, size_t len, int prot, int flags, int fd, off64_t offset) result = (void *) INLINE_SYSCALL (mmap2, 6, addr, len, prot, flags, fd, - (off_t) (offset >> MMAP2_PAGE_SHIFT)); + (off_t) (offset >> page_shift)); return result; } weak_alias (__mmap64, mmap64) diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/power8/Implies b/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/power8/Implies new file mode 100644 index 000000000..066dea279 --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/powerpc/powerpc32/power8/Implies @@ -0,0 +1,2 @@ +powerpc/powerpc32/power8/fpu +powerpc/powerpc32/power8 diff --git a/libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/power8/Implies b/libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/power8/Implies new file mode 100644 index 000000000..fad2505ab --- /dev/null +++ b/libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/power8/Implies @@ -0,0 +1,2 @@ +powerpc/powerpc64/power8/fpu +powerpc/powerpc64/power8 diff --git a/libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h b/libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h index 5ca4b76ca..331230443 100644 --- a/libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h +++ b/libc/sysdeps/unix/sysv/linux/s390/dl-procinfo.h @@ -24,12 +24,16 @@ #undef _dl_procinfo static inline int __attribute__ ((unused)) -_dl_procinfo (int word) +_dl_procinfo (unsigned int type, unsigned long int word) { /* This table should match the information from arch/s390/kernel/setup.c in the kernel sources. */ int i; + /* Fallback to unknown output mechanism. */ + if (type == AT_HWCAP2) + return -1; + _dl_printf ("AT_HWCAP: "); for (i = 0; i < _DL_HWCAP_COUNT; ++i) diff --git a/libc/sysdeps/x86_64/multiarch/init-arch.c b/libc/sysdeps/x86_64/multiarch/init-arch.c index 9524aeea1..55839610e 100644 --- a/libc/sysdeps/x86_64/multiarch/init-arch.c +++ b/libc/sysdeps/x86_64/multiarch/init-arch.c @@ -81,8 +81,16 @@ __init_cpu_features (void) case 0x37: /* Unaligned load versions are faster than SSSE3 on Silvermont. */ +#if index_Fast_Unaligned_Load != index_Prefer_PMINUB_for_stringop +# error index_Fast_Unaligned_Load != index_Prefer_PMINUB_for_stringop +#endif +#if index_Fast_Unaligned_Load != index_Slow_SSE4_2 +# error index_Fast_Unaligned_Load != index_Slow_SSE4_2 +#endif __cpu_features.feature[index_Fast_Unaligned_Load] - |= bit_Fast_Unaligned_Load; + |= (bit_Fast_Unaligned_Load + | bit_Prefer_PMINUB_for_stringop + | bit_Slow_SSE4_2); break; default: diff --git a/libc/sysdeps/x86_64/multiarch/init-arch.h b/libc/sysdeps/x86_64/multiarch/init-arch.h index 28edbf7d0..0cb5f5bc3 100644 --- a/libc/sysdeps/x86_64/multiarch/init-arch.h +++ b/libc/sysdeps/x86_64/multiarch/init-arch.h @@ -23,6 +23,7 @@ #define bit_AVX_Usable (1 << 6) #define bit_FMA_Usable (1 << 7) #define bit_FMA4_Usable (1 << 8) +#define bit_Slow_SSE4_2 (1 << 9) /* CPUID Feature flags. */ @@ -62,6 +63,7 @@ # define index_AVX_Usable FEATURE_INDEX_1*FEATURE_SIZE # define index_FMA_Usable FEATURE_INDEX_1*FEATURE_SIZE # define index_FMA4_Usable FEATURE_INDEX_1*FEATURE_SIZE +# define index_Slow_SSE4_2 FEATURE_INDEX_1*FEATURE_SIZE #else /* __ASSEMBLER__ */ @@ -156,9 +158,11 @@ extern const struct cpu_features *__get_cpu_features (void) # define index_Fast_Copy_Backward FEATURE_INDEX_1 # define index_Slow_BSF FEATURE_INDEX_1 # define index_Fast_Unaligned_Load FEATURE_INDEX_1 +# define index_Prefer_PMINUB_for_stringop FEATURE_INDEX_1 # define index_AVX_Usable FEATURE_INDEX_1 # define index_FMA_Usable FEATURE_INDEX_1 # define index_FMA4_Usable FEATURE_INDEX_1 +# define index_Slow_SSE4_2 FEATURE_INDEX_1 # define HAS_ARCH_FEATURE(name) \ ((__get_cpu_features ()->feature[index_##name] & (bit_##name)) != 0) diff --git a/libc/sysdeps/x86_64/multiarch/memcmp-ssse3.S b/libc/sysdeps/x86_64/multiarch/memcmp-ssse3.S index bdd2ed213..e319df926 100644 --- a/libc/sysdeps/x86_64/multiarch/memcmp-ssse3.S +++ b/libc/sysdeps/x86_64/multiarch/memcmp-ssse3.S @@ -1463,10 +1463,8 @@ L(next_24_bytes): test $0x40, %dh jnz L(Byte22) - mov -9(%rdi), %eax - and $0xff, %eax - mov -9(%rsi), %edx - and $0xff, %edx + movzbl -9(%rdi), %eax + movzbl -9(%rsi), %edx sub %edx, %eax ret # else diff --git a/libc/sysdeps/x86_64/multiarch/strchr.S b/libc/sysdeps/x86_64/multiarch/strchr.S index 686032944..f170238b5 100644 --- a/libc/sysdeps/x86_64/multiarch/strchr.S +++ b/libc/sysdeps/x86_64/multiarch/strchr.S @@ -29,6 +29,8 @@ ENTRY(strchr) jne 1f call __init_cpu_features 1: leaq __strchr_sse2(%rip), %rax + testl $bit_Slow_SSE4_2, __cpu_features+CPUID_OFFSET+index_Slow_SSE4_2(%rip) + jnz 2f testl $bit_SSE4_2, __cpu_features+CPUID_OFFSET+index_SSE4_2(%rip) jz 2f leaq __strchr_sse42(%rip), %rax diff --git a/libc/sysdeps/x86_64/multiarch/strcmp.S b/libc/sysdeps/x86_64/multiarch/strcmp.S index f69aaf42b..1d4d71183 100644 --- a/libc/sysdeps/x86_64/multiarch/strcmp.S +++ b/libc/sysdeps/x86_64/multiarch/strcmp.S @@ -88,14 +88,16 @@ ENTRY(STRCMP) jne 1f call __init_cpu_features 1: + testl $bit_Slow_SSE4_2, __cpu_features+CPUID_OFFSET+index_Slow_SSE4_2(%rip) + jnz 2f leaq STRCMP_SSE42(%rip), %rax testl $bit_SSE4_2, __cpu_features+CPUID_OFFSET+index_SSE4_2(%rip) - jnz 2f - leaq STRCMP_SSSE3(%rip), %rax + jnz 3f +2: leaq STRCMP_SSSE3(%rip), %rax testl $bit_SSSE3, __cpu_features+CPUID_OFFSET+index_SSSE3(%rip) - jnz 2f + jnz 3f leaq STRCMP_SSE2(%rip), %rax -2: ret +3: ret END(STRCMP) # ifdef USE_AS_STRCASECMP_L @@ -109,16 +111,18 @@ ENTRY(__strcasecmp) # ifdef HAVE_AVX_SUPPORT leaq __strcasecmp_avx(%rip), %rax testl $bit_AVX_Usable, __cpu_features+FEATURE_OFFSET+index_AVX_Usable(%rip) - jnz 2f + jnz 3f # endif + testl $bit_Slow_SSE4_2, __cpu_features+CPUID_OFFSET+index_Slow_SSE4_2(%rip) + jnz 2f leaq __strcasecmp_sse42(%rip), %rax testl $bit_SSE4_2, __cpu_features+CPUID_OFFSET+index_SSE4_2(%rip) - jnz 2f - leaq __strcasecmp_ssse3(%rip), %rax + jnz 3f +2: leaq __strcasecmp_ssse3(%rip), %rax testl $bit_SSSE3, __cpu_features+CPUID_OFFSET+index_SSSE3(%rip) - jnz 2f + jnz 3f leaq __strcasecmp_sse2(%rip), %rax -2: ret +3: ret END(__strcasecmp) weak_alias (__strcasecmp, strcasecmp) # endif @@ -133,16 +137,18 @@ ENTRY(__strncasecmp) # ifdef HAVE_AVX_SUPPORT leaq __strncasecmp_avx(%rip), %rax testl $bit_AVX_Usable, __cpu_features+FEATURE_OFFSET+index_AVX_Usable(%rip) - jnz 2f + jnz 3f # endif + testl $bit_Slow_SSE4_2, __cpu_features+CPUID_OFFSET+index_Slow_SSE4_2(%rip) + jnz 2f leaq __strncasecmp_sse42(%rip), %rax testl $bit_SSE4_2, __cpu_features+CPUID_OFFSET+index_SSE4_2(%rip) - jnz 2f - leaq __strncasecmp_ssse3(%rip), %rax + jnz 3f +2: leaq __strncasecmp_ssse3(%rip), %rax testl $bit_SSSE3, __cpu_features+CPUID_OFFSET+index_SSSE3(%rip) - jnz 2f + jnz 3f leaq __strncasecmp_sse2(%rip), %rax -2: ret +3: ret END(__strncasecmp) weak_alias (__strncasecmp, strncasecmp) # endif diff --git a/libc/sysdeps/x86_64/multiarch/strrchr.S b/libc/sysdeps/x86_64/multiarch/strrchr.S index ee6af6e9d..3f92a41ef 100644 --- a/libc/sysdeps/x86_64/multiarch/strrchr.S +++ b/libc/sysdeps/x86_64/multiarch/strrchr.S @@ -32,6 +32,8 @@ ENTRY(strrchr) jne 1f call __init_cpu_features 1: leaq __strrchr_sse2(%rip), %rax + testl $bit_Slow_SSE4_2, __cpu_features+CPUID_OFFSET+index_Slow_SSE4_2(%rip) + jnz 2f testl $bit_SSE4_2, __cpu_features+CPUID_OFFSET+index_SSE4_2(%rip) jz 2f leaq __strrchr_sse42(%rip), %rax -- cgit v1.2.3