Commit Graph

2476 Commits

Author SHA1 Message Date
Kumar Gala 6d7e0b337c Print sign of NaN values to nano-vfprintf.
Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
2018-07-17 14:41:59 +02:00
Jordi Sanfeliu ab640f4cd5 Fix to stop a fall-through in a switch statement
The following fixes a fall-through that prevented from reading the
next entry in the UTMP file and terminated the program with an abort().
2018-07-13 13:33:33 +02:00
Siddhesh Poyarekar d02cc7a09d strcmp.S: Improve performance for misaligned strings
Replace the simple byte-wise compare in the misaligned case with a
dword compare with page boundary checks in place.  For simplicity I've
chosen a 4K page boundary so that we don't have to query the actual
page size on the system.

This results in up to 3x improvement in performance in the unaligned
case on falkor and about 2.5x improvement on mustang as measured using
bench-strcmp in glibc.
2018-07-13 13:27:54 +02:00
Siddhesh Poyarekar 2d9f35c2cc memcmp.S: optimize for medium to large sizes
This improved memcmp provides a fast path for compares up to 16 bytes
and then compares 16 bytes at a time, thus optimizing loads from both
sources.  The glibc memcmp microbenchmark retains performance (with an
error of ~1ns) for smaller compare sizes and reduces up to 31% of
execution time for compares up to 4K on the APM Mustang.  On Qualcomm
Falkor this improves to almost 48%, i.e. it is almost 2x improvement
for sizes of 2K and above.
2018-07-13 13:27:54 +02:00
Siddhesh Poyarekar f44eee8f1b Improve strncmp for mutually misaligned inputs
The mutually misaligned inputs on aarch64 are compared with a simple
byte copy, which is not very efficient.  Enhance the comparison
similar to strcmp by loading a double-word at a time.  The peak
performance improvement (i.e. 4k maxlen comparisons) due to this on
the strncmp microbenchmark in glibc is as follows:

falkor: 3.5x (up to 72% time reduction)
cortex-a73: 3.5x (up to 71% time reduction)
cortex-a53: 3.5x (up to 71% time reduction)

All mutually misaligned inputs from 16 bytes maxlen onwards show
upwards of 15% improvement and there is no measurable effect on the
performance of aligned/mutually aligned inputs.
2018-07-13 13:27:54 +02:00
Szabolcs Nagy 393a1cb4ea Move __HAVE_FAST_FMA to math_config.h
Define it consistently with other HAVE_* macros that only affect code
using math_config.h.  This is also closer to the Arm Optimized Routines
code.
2018-07-06 10:29:01 +02:00
Takashi Yano 6a3e08a53e Fix newlib functions perror()/psignal() not to use writev().
This fix is for some platforms which do not have writev().
*perror.c: Use _write_r() instead of writev().
*psignal.c: Use write() insetad of writev().

Revise commit: d4f4e7ae1b
2018-07-05 15:33:49 -04:00
Takashi Yano d4f4e7ae1b Fix a bug of perror()/psignal() that changes the orientation of stderr.
* perror.c: Fix the problem that perror() changes the orientation
  of stderr to byte-oriented mode if stderr is not oriented yet.
* psignal.c: Ditto.
2018-07-04 14:17:28 +02:00
Corinna Vinschen 006520ca2b newlib: enable new math functions on Cygwin
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-27 15:53:51 +02:00
Szabolcs Nagy e5791079c6 New log implementation
The new implementations are provided under !__OBSOLETE_MATH, it uses
ISO C99 code.  With default settings the worst case error in nearest
rounding mode is 0.519 ULP with inlined fma and fma contraction.  It uses
a 2 KB lookup table, on aarch64 .text+.rodata size of libm.a is increased
by 1703 bytes.  The w_log.c wrapper is disabled since error handling is
inline in the new code.

New __HAVE_FAST_FMA and __HAVE_FAST_FMA_DEFAULT feature macros were
added to enable selecting between the code path that uses fma and the
one that does not.  Targets supposed to set __HAVE_FAST_FMA_DEFAULT
if they have single instruction fma and the compiler can actually
inline it (gcc has __FP_FAST_FMA macro but that does not guarantee
inlining with -fno-builtin-fma).

Improvements on Cortex-A72:
latency: 1.9x
thruput: 2.3x
2018-06-27 15:40:49 +02:00
Takashi Yano 048490485a Fix Unicode table.
* (mkcategories): Fix a bug that outputs incorrect Unicode category
  table for code point ranges.
* (categories.t): Rebuild it using the bug-fixed mkcategories.

This fixes the problem reported in the following post.
https://cygwin.com/ml/cygwin/2018-06/msg00248.html
2018-06-26 10:19:12 +02:00
Thomas Kindler 9dd3c3b0ad newlib: getopt now permutes multi-flag options correctly
Previously, "test 1 2 3 -a -b -c"  was permuted to "test -a -b -c 1 2 3",
but "test 1 2 3 -abc" was left as "test 1 2 3 -abc".

Signed-off-by: Thomas Kindler <mail+newlib@t-kindler.de>
2018-06-18 18:45:44 +02:00
Jeff Johnston 4a3d0a5a5d Fix issue with malloc_extend_top
- when calculating a correction to align next brk to page boundary,
  ensure that the correction is less than a page size
- if allocating the correction fails, ensure that the top size is
  set to brk + sbrk_size (minus any front alignment made)

Signed-off-by: Jeff Johnston <jjohnstn@redhat.com>
2018-05-29 10:16:48 -04:00
Freddie Chopin 3305f35570 Fix 32-bit overflow in mktime() when time_t is 64-bits long
When converting number of days since epoch (32-bits) to seconds,
calculations using 32-bit `long` overflow for years above 2038. Solve
this by casting number of days to `time_t` just before final
multiplication.

Signed-off-by: Freddie Chopin <freddie.chopin@gmail.com>
2018-05-29 15:27:03 +02:00
Jeff Johnston cd31fbb2ae Add nvptx port.
- From: Cesar Philippidis <cesar@codesourcery.com>
  Date: Tue, 10 Apr 2018 14:43:42 -0700
  Subject: [PATCH] nvptx port

  This port adds support for Nvidia GPU's, which are primarily used as
  offload accelerators in OpenACC and OpenMP.
2018-04-13 15:42:37 -04:00
Corinna Vinschen 27652b608d strtod: Convert 64 bit double to 64 bit int during computation
The gdtoa implementation uses the type long, defined as Long, in lots
of code.  For historical reason newlib defines Long as int32_t instead.

This works fine, as long as floating point exceptions are not enabled.
The conversion to 32 bit int can lead to a FE_INVALID situation.

Example:

  const char *str = "121645100408832000.0";
  char *ptr;

  feenableexcept (FE_INVALID);
  strtod (str, &ptr);

This leads to the following situation in strtod

  double aadj;
  Long L;

  [...]
  L = (Long)aadj;

For instance, on x86_64 the code here is

  cvttsd2si %xmm0,%eax

At this point, aadj is 2529648000.0 in our example.  The conversion to
32 bit %eax results in a negative int value, thus the conversion is
invalid.  With feenableexcept (FE_INVALID), a SIGFPE is raised.

Fix this by always using 64 bit ints here if double is not a 32 bit type
to avoid this type of FP exceptions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-04-09 11:31:04 +02:00
Corinna Vinschen 1ee6654e50 newlib: fix iswupper_l in !_MB_CAPABLE case
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-27 12:35:27 +02:00
Thomas Wolff fc59da00c8 comments to document struct caseconv_entry
explain design of compact (packed) struct caseconv_entry,
in case it needs to be modified for future Unicode versions
2018-03-26 12:01:50 +02:00
Thomas Wolff b49ce5af1b newlib: fix indentation in toulower
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-26 10:00:16 +02:00
Hakan Lindqvist 3ce38df8d1 Reduce qsort stack consumption
Classical function call recursion wastes a lot of stack space.
Each recursion level requires a full stack frame comprising all
local variables and additional space as dictated by the
processor calling convention.

This implementation instead stores the variables that are unique
for each recursion level in a parameter stack array, and uses
iteration to emulate recursion. Function call recursion is not
used until the array is full.

To ensure the stack consumption isn't worsened by this design, the
size of the parameter stack array is chosen to be similar to the
stack frame excluding the array. Each function call recursion level
can handle 8 iterative recursion levels.

Stack consumption will worsen when sorting tiny arrays that do not
need recursion (of 6 elements or less). It will be about equal for
up to 15 elements, and be an improvement for larger arrays. The best
case improvement is a stack size reduction down to about one quarter
of the stack consumption before the change.

A design where the parameter stack array is large enough for the
worst case recursion level was rejected because it would worsen
the stack consumption when sorting arrays smaller than about 1500
elements. The worst case is 31 levels on a 32-bit system.

A design with a dynamic parameter array size was rejected because
of limitations in some compilers.
2018-03-16 10:21:23 +01:00
Hakan Lindqvist 0045445ad6 Ensure qsort recursion depth is bounded
The qsort algorithm splits the input array in three parts. The
left and right parts may need further sorting. One of them is
sorted by recursion, the other by iteration. This update ensures
that it is the smaller part that is chosen for recursion.

By choosing the smaller part, each recursion level will handle
less than half the array of the previous recursion level. Hence
the recursion depth is bounded to be less than log2(n) i.e. 1
level per significant bit in the array size n.

The update also includes code comments explaining the algorithm.
2018-03-16 10:21:23 +01:00
Joel Sherrill 948db3e4b7 Correct prototypes of pthread_mutex_getprioceiling() and pthread_setschedparam() 2018-03-15 09:25:45 -05:00
Richard Earnshaw 0bb8697333 [arm] Fix syscalls.c for newlib embedded syscalls builds
Newlib has a build configuration where syscalls can be directly
embedded in the newlib library rather than relying on libgloss.

This configuration was broken recently by an update to the libgloss
support for Arm that was not propagated to the syscalls interface in
newlib itself.  This patch restores the build.  It's essentially a
copy of https://sourceware.org/ml/newlib/2018/msg00128.html but there
are some other minor cleanups and changes that I've made at the same
time.  None of those cleanups affect functionality.

The prototypes of the following functions have been updated: _link,
_sbrk, _getpid, _write, _swiwrite, _lseek, _swilseek, _read and
_swiread.

Signed-off-by: Richard Earnshaw <Richard.Earnshaw@arm.com>
2018-03-15 09:55:11 +00:00
Yaakov Selkowitz 829820af6e ssp: fix wchar.h with -std=c99
https://sourceware.org/ml/newlib/2018/msg00261.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-03-14 10:46:32 -05:00
Yaakov Selkowitz e494b56035 Fix alloc_align and alloc_size macros for multiple arguments
https://sourceware.org/ml/newlib/2018/msg00263.html

This is a follow-up to commit 4564b30f33.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-03-14 10:17:51 -05:00
Corinna Vinschen 134f93f313 ctype: align size of category bit fields to small targets needs
E.g. arm ABI requires -fshort-enums for bare-metal toolchains.
Given there are only 29 category enums, the compiler chooses an
8 bit enum type, so a size of 11 bits for the bitfield leads to
a compile time error:

  error: width of 'cat' exceeds its type
    enum category cat: 11;
                  ^~~

Fix this by aligning the size of the category members to byte
borders.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-14 11:38:24 +01:00
Corinna Vinschen edcf783dc2 Revert "ctype: align size of category bit fields to small targets needs"
This reverts commit e98d3eb3eb.

It has accidentally included some work in progress.
2018-03-14 11:36:06 +01:00
Thomas Wolff 44d90834fb fix/enhance Unicode table generation scripts
Scripts do not try to acquire Unicode data by best-effort magic anymore.
Options supported:
-h for help
-i to copy Unicode data from /usr/share/unicode/ucd first
-u to download Unicode data from unicode.org first
If (despite of -i or -u if given) the necessary Unicode files are not
available locally, table generation is skipped, but no error code is
returned, so not to obstruct the build process if called from a Makefile.
2018-03-14 10:44:32 +01:00
Corinna Vinschen e98d3eb3eb ctype: align size of category bit fields to small targets needs
E.g. arm ABI requires -fshort-enums for bare-metal toolchains.
Given there are only 29 category enums, the compiler chooses an
8 bit enum type, so a size of 11 bits for the bitfield leads to
a compile time error:

  error: width of 'cat' exceeds its type
    enum category cat: 11;
                  ^~~

Fix this by aligning the size of the category members to byte
borders.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-14 10:36:38 +01:00
Corinna Vinschen e186dc8661 towctrans_l: Always return a value from helper functions
touupper and toulower didn't return a value in all cases.  Worse,
this only broke Cygwin when building without optimization for debug
purposes.

Why GCC neglects to notice this is a mystery.

While at it, fix formatting.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-13 22:09:30 +01:00
Joel Sherrill 5b97e36239 rtems/.../dirent.h: Add alphasort() prototype 2018-03-13 09:11:47 -05:00
Jon Turney 4564b30f33 Correct alloc_size annotation on reallocarray()
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2018-03-13 09:04:56 -05:00
Thomas Wolff a352730004 character data generation 2018-03-12 11:39:50 +01:00
Thomas Wolff 41f72ab4d7 use generated character data
The tow* functions use an included case conversion table which can be
generated from Unicode data.
The isw* functions use a character categories table (provided by
categories.c) which can be generated from Unicode data.
Delegation between current-locale and specific-locale-dependent functions
was reverted towards the generic locale-dependent functions (*_l.c);
this is however only relevant on systems with non-Unicode wide character
locales, thus not on Cygwin.
2018-03-12 11:39:42 +01:00
Thomas Wolff 3ccfb407af generated character category data, Unicode 10.0
Table categories.t and tag enumeration categories.cat provide
character class data for most of the isw* functions.
These data are generated from Unicode data.
2018-03-12 11:09:31 +01:00
Thomas Wolff 402daa2f80 generated case conversion data, Unicode 10.0
Table caseconv.t provides case conversion data for the tow* functions,
especially towupper and towlower.
These data are generated from Unicode data.
2018-03-12 11:09:31 +01:00
Thomas Wolff 37132125bc width data generation 2018-03-12 10:17:20 +01:00
Thomas Wolff 8e8fd6c849 use generated width data 2018-03-12 10:17:20 +01:00
Thomas Wolff 71291047e2 generated width data, Unicode 10.0
These tables provide character width properties for use by the
wcwidth/wcswidth functions. They are generated from Unicode.
2018-03-12 10:17:20 +01:00
Sebastian Huber f641474cb2 RTEMS: Use int for _CLOCKID_T_
Linux and FreeBSD use int as well.  In addition, this fixes an Ada
incompatiblity problem on 64-bit targets.  See also GCC:

  gcc/ada/libgnarl/s-osinte__rtems.ads

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-03-06 11:40:16 +01:00
Sebastian Huber a9c8434527 Make _CLOCKID_T_ system configurable
Let systems optionally provide the _CLOCKID_T_ type via
<machine/_types.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-03-06 11:40:16 +01:00
Thomas Wolff f92f048528 Locale modifier @cjkwide to adjust ambiguous-width in non-CJK locales
Locale modifier @cjkwide makes Unicode "ambiguous width" characters
wide.  So ambiguous width characters can be enforced to have width 2
even in non-CJK locales. This gives e.g. users of "Powerline symbols"
the opportunity to adjust their width to the desired behaviour (and the
behaviour apparently expected by some tools) without having to set a CJK
locale and without losing consistence of terminal character width with
wcwidth/wcswidth locale width.
2018-03-05 17:15:12 +01:00
Our Air Quality b7520b14d5 Add global stdio streams support for reent small. 2018-03-01 18:05:31 -05:00
Jaap de Wolff 8329f4867b add forward declaration to __cxa_atexit to aeabi_atexit, to prevent warnings 2018-02-16 12:16:07 +01:00
Jaap de Wolff 337cee51ca Add prototype to _malloc_lock() and *unlock() to malloc.h, and inlude this from nano-mallocr.c 2018-02-16 12:16:07 +01:00
Corinna Vinschen 4c73ad6b20 newlib: drop Cygwin license from sys/select.h
This license was accidentally retained when moving the file from Cygwin to newlib.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-02 11:27:58 +01:00
Jon Beniston b8272e3b8d Fix vprintf and vfscanf for GCC PR 14577 2018-02-01 13:28:28 +01:00
Sebastian Huber 1658a57715 epiphany: Additional setjmp() and longjmp() syms
At least with Binutils 2.30 and GCC 7.3 we need symbol definitions
without the leading underscore.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-01-31 08:17:19 +01:00
Yaakov Selkowitz b920561fe3 ssp: do not use __ssp_protected_ symbol prefixes
This is a NetBSD-specific detail which does not apply to Newlib, causing
linking issues in certain scenarios:

https://cygwin.com/ml/cygwin/2018-01/msg00189.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-26 11:51:15 -06:00
Thomas Preudhomme 7d09d0e261 Disable powf/log2?f/exp2?f optimization for single-precision Arm FPU
New optimized powf, logf, log2f, expf and exp2f yield worse performance
on Arm targets with only single precision instructions because the
double precision arithmetic is then implemented via softfloat routines.
This patch uses the old implementation when double precision
instructions are not available on Arm targets.

Testing: Built newlib with GCC's rmprofile Arm multilibs and compared
before/after -> only the above functions are changed and calls to them
(name change from logf to __ieee754_logf and similar). Testing the
changed function on a panel of values yields the same result before the
original patches to improve them and after this one. Double checking the
performance by looping the same panel of values being tested on Arm
Cortex-M4 does show the performance regression is fixed.
2018-01-25 16:08:35 +01:00