strptime's %z specifier parses a string consisting of a sign ('+'
or '-'), two hours digits, and optionally two minutes digits, into a
tm.tm_gmtoff field containing the signed number of seconds the time
zone is offset from UTC time.
The time/tst-strptime2.c program passes a short list of strings through
strptime, validating that either the gmtoff value returned matches an
expected value, or that strptime returns an expected NULL for invalid
strings (for example, when the minutes portion of the string is outside
of the range 00 to 59, or the sign is missing before the hours digits).
In review of strptime fixes, Carlos O'Donell expressed a wish that
the test function iterate through the entire range of all possible
numeric strings (-9999 to +9999) which could be passed to strptime %z,
and validate the correct response.
Specifically, the test will look for a NULL response from strptime
when:
* sign ('+' or '-') is not present before the first digit (invalid
format).
* A sign and no digits are found (invalid format).
* A sign and one digit are found (invalid format).
* A sign and three digits are found (invalid format).
* A sign and four digits (-9999 to +9999) are found but the last
two digits (minutes) are in the range 60 to 99.
The test will look for a success response from strptime with
tm.tm_gmtoff matching the calculated tm_gmtoff value when:
* A sign and four digits are found (-9999 to +9999), and the last
two digits (minutes) are in the range 00 to 59.
* A sign and two digit strings are found (-99 to +99).
The test's iteration over the possible digit values results in 22223
test strings prepared, tested, and passed by strptime.
The test supports a --verbose command line option which will show
the test results of every test input, and a final summary of all
tests. Here is some sample output:
PASS: input "1113472456 1030", expected: invalid, return value NULL
PASS: input "1113472456 +", expected: invalid, return value NULL
PASS: input "1113472456 -", expected: invalid, return value NULL
PASS: input "1113472456 +0", expected: invalid, return value NULL
PASS: input "1113472456 -0", expected: invalid, return value NULL
PASS: input "1113472456 +1", expected: invalid, return value NULL
...
PASS: input "1113472456 +9", expected: invalid, return value NULL
PASS: input "1113472456 -9", expected: invalid, return value NULL
PASS: input "1113472456 +00", expected: valid, tm.tm_gmtoff 0
PASS: input "1113472456 -00", expected: valid, tm.tm_gmtoff 0
PASS: input "1113472456 +01", expected: valid, tm.tm_gmtoff 3600
PASS: input "1113472456 -01", expected: valid, tm.tm_gmtoff -3600
PASS: input "1113472456 +02", expected: valid, tm.tm_gmtoff 7200
...
PASS: input "1113472456 +99", expected: valid, tm.tm_gmtoff 356400
PASS: input "1113472456 -99", expected: valid, tm.tm_gmtoff -356400
PASS: input "1113472456 +000", expected: invalid, return value NULL
PASS: input "1113472456 -000", expected: invalid, return value NULL
PASS: input "1113472456 +001", expected: invalid, return value NULL
...
PASS: input "1113472456 +999", expected: invalid, return value NULL
PASS: input "1113472456 -999", expected: invalid, return value NULL
PASS: input "1113472456 +0000", expected: valid, tm.tm_gmtoff 0
PASS: input "1113472456 -0000", expected: valid, tm.tm_gmtoff 0
PASS: input "1113472456 +0001", expected: valid, tm.tm_gmtoff 60
PASS: input "1113472456 -0001", expected: valid, tm.tm_gmtoff -60
...
PASS: input "1113472456 +0059", expected: valid, tm.tm_gmtoff 3540
PASS: input "1113472456 -0059", expected: valid, tm.tm_gmtoff -3540
PASS: input "1113472456 +0060", expected: invalid, return value NULL
PASS: input "1113472456 -0060", expected: invalid, return value NULL
...
PASS: input "1113472456 +0099", expected: invalid, return value NULL
PASS: input "1113472456 -0099", expected: invalid, return value NULL
PASS: input "1113472456 +0100", expected: valid, tm.tm_gmtoff 3600
PASS: input "1113472456 -0100", expected: valid, tm.tm_gmtoff -3600
PASS: input "1113472456 +0101", expected: valid, tm.tm_gmtoff 3660
...
PASS: input "1113472456 +9999", expected: invalid, return value NULL
PASS: input "1113472456 -9999", expected: invalid, return value NULL
PASS: 22223 input strings: 0 fail, 22223 pass
Any failing test will result in printing the failed line to stdout, and
will trigger the printing of the summary line at the of all tests. For
example:
FAIL: input "1113472456 1030", expected: invalid, return value NULL,
got: valid, tm.tm_gmtoff 37800
FAIL: 22223 input strings: 1 fail, 22222 pass
Topic: strptime supports a %z input field descriptor, which parses a
time zone offset from UTC time into the broken-out time field tm_gmtoff.
Problems:
1) In the current implementation, the minutes portion calculation is
correct only for minutes evenly divisible by 3. This is because the
minutes value is converted to decimal time, but inadequate precision
leads to rounding which calculates results that are too low for
some values.
For example, due to rounding, a +1159 offset string results in an
incorrect tm_gmtoff of 43128 (== 11 * 3600 + 58.8 * 60) seconds,
instead of 43140 (== 11 * 3600 + 59 * 60) seconds. In contrast,
a +1157 offset (minutes divisible by 3) does not cause the bug,
and results in a correct tm_gmtoff of 43020.
2) strptime's %z specifier will not parse time offsets less than
-1200 or greater than +1200, or if only hour digits are present, less
than -12 or greater than +12. It will return NULL for offsets outside
that range. These limits do not meet historical and modern use cases:
* Present day exceeds the +1200 limit:
- Pacific/Auckland (New Zealand) summer time is +1300.
- Pacific/Kiritimati (Christmas Island) is +1400.
- Pacific/Apia (Samoa) summer time is +1400.
* Historical offsets exceeded +1500/-1500.
* POSIX supports -2459 to +2559.
* Offsets up to +/-9959 may occasionally be useful.
* Paul Eggert's notes provide additional detail:
- https://sourceware.org/ml/libc-alpha/2014-12/msg00068.html
- https://sourceware.org/ml/libc-alpha/2014-12/msg00072.html
3) tst-strptime2, part of the 'make check' test suite, does not test
for the above problems.
Corrective actions:
1) In time/strptime_l.c, calculate the offset from the hour and
minute portions directly, without the rounding errors introduced by
decimal time.
2) Remove the +/-1200 range limit, permitting strptime to parse offsets
from -9959 through +9959.
3) Add zone offset values to time/tst-strptime2.c.
* Test minutes evenly divisible by three (+1157) and not evenly
divisible by three (+1158 and +1159).
* Test offsets near the old and new range limits (-1201, -1330, -2459,
-2500, -99, -9959, +1201, +1330, +1400, +1401, +2559, +2600, +99,
and +9959)
The revised strptime passes all old and new tst-strptime2 tests.
This patch fixes the default wordsize-32 mmap implementation offset
calculation for negative values. Current code uses signed shift
operation to calculate the multiple size to use with syscall and
it is implementation defined. Change it to use a division base
on mmap page size (default being as before, 4096).
Tested on armv7hf.
[BZ #18877]
* posix/Makefile (tests): Add tst-mmap-offset.
* posix/tst-mmap.c: New file.
* sysdeps/unix/sysv/linux/generic/wordsize-32/mmap.c (__mmap): Fix
offset calculation for negative values.
We detect i586 and i686 features at run-time by checking CX8 and CMOV
CPUID features bits. We can use these information to select the best
implementation in ix86 multiarch. HAS_I586/HAS_I686 is true if i586/i686
instructions are available on the processor.
Due to the reordering and the other nifty extensions in i686, it is not
really good to use heavily i586 optimized code on an i686. It's better
to use i486 code if it isn't an i586. USE_I586/USE_I686 is true if
i586/i686 implementation should be used for the processor. USE_I586
is true only if i686 instructions aren't available. If i686 instructions
are available, we always choose i686 or i486 implementation, in that order,
and we never choose i586 implementation for i686-class processors.
* sysdeps/i386/init-arch.h: New file.
* sysdeps/i386/i586/init-arch.h: Likewise.
* sysdeps/i386/i686/init-arch.h: Likewise.
* sysdeps/x86/cpu-features.c (init_cpu_features): Set bit_I586
bit if CX8 is available. Set bit_I686 bit if CMOV is available.
* sysdeps/x86/cpu-features.h (bit_I586): New.
(bit_I686): Likewise.
(bit_CX8): Likewise.
(bit_CMOV): Likewise.
(index_CX8): Likewise.
(index_CMOV): Likewise.
(index_I586): Likewise.
(index_I686): Likewise.
(reg_CX8): Likewise.
(reg_CMOV): Likewise.
(HAS_I586): Defined as HAS_ARCH_FEATURE (I586) if i586 isn't
available at compile-time.
(HAS_I686): Defined as HAS_ARCH_FEATURE (I686) if i686 isn't
available at compile-time.
* sysdeps/x86/init-arch.h (USE_I586): New macro.
(USE_I686): Likewise.
GCC 6 puts out warnings in a different location then GCC 5. Move the
DIAG macros so that the warnings are supressed for both compilers.
ChangeLog:
* soft-fp/fmasf4.c: Add include of sys/cdefs.h.
Move DIAG_PUSH_NEEDS_COMMENT, DIAG_IGNORE_NEEDS_COMMENT to front of
file, move DIAG_POP_NEEDS_COMMENT to end of file.
* soft-fp/fmadf4.c: Ditto.
* soft-fp/fmatf4.c: Ditto.
Since glibc doesn't support i386 any more, we can remove i486 subdirectory.
* sysdeps/i386/i586/Implies: Removed.
* sysdeps/i386/i686/Implies: Likewise.
Since glibc doesn't support i386 any more, we can move i486/strlen.S
to strlen.S.
* sysdeps/i386/i486/strlen.S: Moved to ...
* sysdeps/i386/strlen.S: Here.
Since glibc doesn't support i386 any more, we can move i486/strcat.S
to strcat.S.
* sysdeps/i386/i486/strcat.S: Moved to ...
* sysdeps/i386/strcat.S: Here.
* sysdeps/i386/i686/multiarch/strcat.S: Updated.
Since glibc doesn't support i386 any more, we can move
i486/pthread_spin_trylock.S to pthread_spin_trylock.S
* sysdeps/i386/i486/pthread_spin_trylock.S: Moved to ...
* sysdeps/i386/pthread_spin_trylock.S: Here.
* sysdeps/i386/i586/pthread_spin_trylock.S: Removed.
* sysdeps/i386/i686/pthread_spin_trylock.S: Updated.
Since glibc doesn't support i386 any more, we can move
i486/string-inlines.c to string-inlines.c.
* sysdeps/i386/i486/string-inlines.c: Moved to ...
* sysdeps/i386/string-inlines.c: Here.
Since glibc doesn't support i386 any more, we can move i486/bits/atomic.h
to bits/atomic.h.
* sysdeps/i386/i486/bits/atomic.h: Moved to ...
* sysdeps/i386/bits/atomic.h: Here.
As with other spots in the code, GCC 4.8 unnecessarily complains about
an uninitialized variable in tanl calcs, so this patch disables. With
it, the library and sees the usual set of test passes.
* sysdeps/ieee754/ldbl-96/k_tanl.c: Include <libc-internal.h>.
(__kernel_tanl): Ignore uninitialized warnings around use of SIGN.
Linux commit b4b56f9ecab40f3b4ef53e130c9f6663be491894 introduced
a new HWCAP2 bit to indicate that the kernel now aborts a memory
transaction when a syscall is made. This patch adds that bit to
sysdeps/powerpc/bits/hwcap.h.
2015-08-26 Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
* sysdeps/powerpc/bits/hwcap.h: Add PPC_FEATURE2_HTM_NOSC.
* sysdeps/powerpc/dl-procinfo.c:
(_dl_powerpc_cap_flags): Added descriptor for this hwcap
feature so it shows when LD_SHOW_AUXV=1.
Power ISA 2.07B section B.5.5 relaxed the barrier requirement around a
TLE enabled lock. It is now identical to a traditional lock.
2015-08-26 Paul E. Murphy <murphyp@linux.vnet.ibm.com>
* sysdeps/unix/sysv/linux/powerpc/elision-lock.c
(__arch_compare_and_exchange_val_32_acq): Remove and use common
definition. ISA 2.07B no longer requires full sync.
Replace BZERO_P with USE_AS_BZERO in i586/i686 memset.S to support i386
multi-arch memset. Also we should check SHARED not PIC for libc.so
since libc.a may be compiled with PIC.
* sysdeps/i386/i586/bzero.S (USE_AS_BZERO): New.
* sysdeps/i386/i686/bzero.S (USE_AS_BZERO): Likewise.
* sysdeps/i386/i586/memset.S (BZERO_P): Removed.
Check USE_AS_BZERO/SHARED instead of BZERO_P/PIC.
(__memset_zero_constant_len_parameter): New.
* sysdeps/i386/i686/memset.S (BZERO_P): Removed.
Check USE_AS_BZERO/SHARED instead of BZERO_P/PIC.
(__memset_zero_constant_len_parameter): Don't define if
__memset_chk or USE_AS_BZERO are defined.
Replace MEMPCPY_P with USE_AS_MEMPCPY in i586 memcpy.S to support i386
multi-arch memcpy. Also we should check SHARED not PIC for libc.so
since libc.a may be compiled with PIC.
* sysdeps/i386/i586/memcpy.S (MEMPCPY_P): Removed.
Check USE_AS_MEMPCPY/SHARED instead of MEMPCPY_P/PIC.
* sysdeps/i386/i586/mempcpy.S (USE_AS_MEMPCPY): New.
Since x86-64 ld.so preserves vector registers now, we can use SSE in
x86-64 ld.so. We should run tst-ld-sse-use.sh only on i386.
* sysdeps/x86/Makefile [$(subdir) == elf] (CFLAGS-.os,
tests-special, $(objpfx)tst-ld-sse-use.out): Moved to ...
* sysdeps/i386/Makefile [$(subdir) == elf] (CFLAGS-.os,
tests-special, $(objpfx)tst-ld-sse-use.out): Here. Update
comments.
* sysdeps/x86_64/Makefile [$(subdir) == elf] (CFLAGS-.os): Add
-mno-mmx for $(all-rtld-routines).
* sysdeps/x86/tst-ld-sse-use.sh: Moved to ...
* sysdeps/i386/tst-ld-sse-use.sh: Here. Replace x86-64 with
i386.
Building glibc on s390-32 with gcc option -mzarch produces the error due to
sysdeps/s390/jmpbuf-unwind.h:37:10: (void *) (_Unwind_GetCFA (_context):
cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
Building on s390-32 in esa-mode or s390-64 is fine.
_Unwind_GetCFA returns an _Unwind_Word which is an unsigned
with a size of 4 bytes on s390-32 (esa-mode) and 8 bytes on s390-64.
On s390-32 (zarch-mode), _Unwind_Word has a size of 8 bytes, too.
_Unwind_Word is defined in sysdeps/generic/unwind.h as
typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
In libgcc unwind header (<gcc-src>/libgcc/unwind-generic.h) this typedef has
changed to "typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));"
in June 2008.
With this mode, _Unwind_Word has a size of 4 bytes on s390-32 (zarch-mode).
The same change applies to _Unwind_Sword.
Thus this patch updates the unwind header according to these changes.
Afterwards, the int-to-pointer-cast-warning is gone away on s390-32 (zarch-mode)
and the testsuite runs with the same test-failures as s390-32 (esa-mode)
plus FAIL: c++-types-check. Here register_t is expected to has a size of 4 bytes,
but it has a size of 8 bytes due to:
posix/sys/types.h:205:typedef int register_t __attribute__ ((__mode__ (__word__)));
The libgcc-patch for gcc 4.4 can be found here:
"[PATCH, spu, unwind] Remove attribute ((mode (word))) from unwind.h"
https://gcc.gnu.org/ml/gcc-patches/2008-06/msg00969.html
ChangeLog:
* sysdeps/generic/unwind.h
(_Unwind_Word): Use __mode__(__unwind_word__)
instead of __mode__(__word__).
(_Unwind_Sword): Likewise.
This patch fixes the build error with gcc6:
array subscript is above array bounds [-Werror=array-bounds]
While including loop.c to construct the SINGLE(LOOPFCT) method
for converting from UTF-16 to UTF-8, the bytebuf array with length
MAX_NEEDED_INPUT is used as inptr. MAX_NEEDED_INPUT defaults to
MIN_NEEDED_INPUT if not defined before including loop.c.
Thus bytebuf has a length of 2.
This patch defines MAX_NEEDED_INPUT to MAX_NEEDED_TO, which is 4.
ChangeLog:
* sysdeps/s390/s390-64/utf8-utf16-z9.c
(MAX_NEEDED_INPUT): New define.
(MAX_NEEDED_OUTPUT): New define.
This patch set introduces optimized string, wcsmbs and memory functions for
S390/S390x. The functions are accelerated by the usage of the new z13 vector
instructions.
The Principles of Operations manual for IBM z13 is publically available:
http://publibfi.boulder.ibm.com/epubs/pdf/dz9zr010.pdf
The support for these instructions in assembler was introduced by commits:
-"[Committed] S/390: Add support for IBM z13."
(https://sourceware.org/ml/binutils/2015-01/msg00197.html)
-"[Committed] S/390: Add more IBM z13 instructions"
(https://sourceware.org/ml/binutils/2015-03/msg00088.html)
The first patches do preparation for the latter optimization patches.
The floating point exception handling - fetestexcept(), ... - is fixed and
the platform and hwcap strings are extended.
The current ifunc routines memset, memcpy and memcmp are refactored and the
ifunc test-framework is now enabled.
A S390 specific configure-check tests if the used binutils supports the new
vector instructions. The optimized functions are provided via ifunc if the
binutils supports the vector instructions. Otherwise a message is dumped to
configure output and only the currently used common code functions are
available.
The optimized functions are implemented in common for s390-32 and s390-64
and the few differences are handled via #ifdef.
The ifunc-resolvers are defined in files sysdeps/s390/multiarch/<func>.c,
which choose either the current implementation __<func>_c() or the vector
implementation __<func>_vx() depending on the HWCAP_S390_VX flag bit in
AT_HWCAP field. If the bit is set, the hardware and the kernel are supporting
vector registers and instructions. If the used binutils lacks vector-support,
then the default implementation in string or wcsmbs directory is included
here instead.
The file sysdeps/s390/multiarch/<func>-c.c includes the current implementation
and defines the function name __<func>_c.
The assembler files sysdeps/s390/multiarch/<func>-vx.S with the vector
instructions are using the directive '.machine "z13"' to allow building glibc
without option '-march=z13'. Additionally the directive '.machinemode
"zarch_nohighgprs"' is needed for the 31bit glibc. This mode does not set the
highgprs flag in ELF header, which would lead to an unloadable libc on a 31bit
kernel.
The most optimized string functions are structured in the same way:
The first 16 bytes of the string is loaded unaligned via vlbb - vector load
to block boundary (e.g. 4k). This instruction loads 16 bytes if possible.
In case of a page cross, it only loads the last bytes of the current page
without a segmentation fault.
Afterwards these first part of string is processed. If e.g. for strlen the end
of string is reached within this first part, the function returns. Otherwise
the pointer is aligned to 16 byte, so i can load a full vector register with vl
without checking for a page cross. Afterwards the first part of string is
processed. If e.g. for strlen the end of string is reached within this first
part, the function returns. Otherwise the pointer is aligned to 16 byte, so
a full vector register can be loaded with vl - vector load - without checking
for a page cross. The remaining string is processed in a four times unrolled
loop, because benchmark results measured improvements compared to a non
unrolled loop.
The optimized wide string functions can only handle 4byte aligned string
pointers. Although a wchar_t pointer should always be 4byte aligned, the most
current common code wide string functions can handle non aligned strings.
Thus the optimized functions will fall back to the common code functions in
case of a non aligned wide string to behave the same as before this patch.
Some string tests can test the string and the wide string version of a function.
The remaining ones are extended and new wide string tests are added.
This is the same in case of the benchtests.
ChangeLog:
* NEWS: New item for IBM z13 string optimizations.
This patch provides optimized version of memrchr with the z13 vector
instructions.
ChangeLog:
* sysdeps/s390/multiarch/memrchr-c.c: New File.
* sysdeps/s390/multiarch/memrchr-vx.S: Likewise.
* sysdeps/s390/multiarch/memrchr.c: Likewise.
* sysdeps/s390/multiarch/Makefile
(sysdep_routines): Add memrchr functions.
* sysdeps/s390/multiarch/ifunc-impl-list-common.c
(__libc_ifunc_impl_list_common): Add ifunc test for memrchr.
This patch provides optimized versions of memccpy with the z13 vector
instructions.
ChangeLog:
* sysdeps/s390/multiarch/memccpy-c.c: New File.
* sysdeps/s390/multiarch/memccpy-vx.S: Likewise.
* sysdeps/s390/multiarch/memccpy.c: Likewise.
* sysdeps/s390/multiarch/Makefile
(sysdep_routines): Add memccpy functions.
* sysdeps/s390/multiarch/ifunc-impl-list-common.c
(__libc_ifunc_impl_list_common): Add ifunc test for memccpy.
* string/memccpy.c: Use MEMCCPY if defined.
This patch provides optimized versions of strcmp and wcscmp with the z13
vector instructions.
The architecture specific string.h had a typo, which leads to ommiting the
inline version in this file if __USE_STRING_INLINES is defined.
Tested this inline version by tweaking test-strcmp.c.
ChangeLog:
* sysdeps/s390/multiarch/strcmp-vx.S: New File.
* sysdeps/s390/multiarch/strcmp.c: Likewise.
* sysdeps/s390/multiarch/wcscmp-c.c: Likewise.
* sysdeps/s390/multiarch/wcscmp-vx.S: Likewise.
* sysdeps/s390/multiarch/wcscmp.c: Likewise.
* sysdeps/s390/s390-32/multiarch/strcmp.c: Likewise.
* sysdeps/s390/s390-64/multiarch/strcmp.c: Likewise.
* sysdeps/s390/multiarch/Makefile (sysdep_routines): Add strcmp and
wcscmp functions.
* sysdeps/s390/multiarch/ifunc-impl-list.c
(__libc_ifunc_impl_list): Add ifunc test for strcmp, wcscmp.
* string/strcmp.c (STRCMP): Define and use macro.
* benchtests/bench-wcscmp.c: New File.
* benchtests/Makefile (wcsmbs-bench): Add wcscmp.
* sysdeps/s390/bits/string.h: Fix typo: _HAVE_STRING_ARCH_strcmp
instead of _HAVE_STRING_ARCH_memchr.
This patch provides optimized versions of strlen and wcslen with the z13 vector
instructions.
The helper macro IFUNC_VX_IMPL is introduced and is used to register all
__<func>_c() and __<func>_vx() functions within __libc_ifunc_impl_list()
to the ifunc test framework.
ChangeLog:
* sysdeps/s390/multiarch/Makefile: New File.
* sysdeps/s390/multiarch/strlen-c.c: Likewise.
* sysdeps/s390/multiarch/strlen-vx.S: Likewise.
* sysdeps/s390/multiarch/strlen.c: Likewise.
* sysdeps/s390/multiarch/wcslen-c.c: Likewise.
* sysdeps/s390/multiarch/wcslen-vx.S: Likewise.
* sysdeps/s390/multiarch/wcslen.c: Likewise.
* string/strlen.c (STRLEN): Define and use macro.
* sysdeps/s390/multiarch/ifunc-impl-list.c
(IFUNC_VX_IMPL): New macro function.
(__libc_ifunc_impl_list): Add ifunc test for strlen, wcslen.
* benchtests/Makefile (wcsmbs-bench): New variable.
(string-bench-all): Added wcsmbs-bench.
* benchtests/bench-wcslen.c: New File.
This patch introduces a s390 specific ifunc resolver macro for 32/64bit,
which chooses <func>_vx with vector instructions if HWCAP_S390_VX flag
in hwcaps is set or <func>_c if not.
ChangeLog:
* sysdeps/s390/multiarch/ifunc-resolve.h (s390_vx_libc_ifunc,
s390_vx_libc_ifunc2): New macro function.