]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
6 years agoNew pow implementation
Szabolcs Nagy [Tue, 26 Jun 2018 15:25:12 +0000 (16:25 +0100)]
New pow implementation

The new implementation is provided under !__OBSOLETE_MATH, it uses
ISO C99 code.  With default settings the worst case error in nearest
rounding mode is 0.54 ULP with inlined fma and fma contraction.  It uses
a 4 KB lookup table in addition to the table in exp_data.c, on aarch64
.text+.rodata size of libm.a is increased by 2295 bytes.

Improvements on Cortex-A72:
latency: 3.3x
thruput: 4.9x

6 years agoNew log2 implementation
Szabolcs Nagy [Tue, 26 Jun 2018 15:06:54 +0000 (16:06 +0100)]
New log2 implementation

The new implementation is provided under !__OBSOLETE_MATH, it uses
ISO C99 code.  With default settings the worst case error in nearest
rounding mode is 0.547 ULP with inlined fma and fma contraction.  It uses
a 1 KB lookup table, on aarch64 .text+.rodata size of libm.a is increased
by 1584 bytes.

Note that the math.h header defines log2(x) to be log(x)/Ln2, this is
not changed, so the new code is only used if that macro is suppressed.

Improvements on Cortex-A72:
latency: 2.0x
thruput: 2.2x

6 years agoNew log implementation
Szabolcs Nagy [Tue, 26 Jun 2018 14:27:50 +0000 (15:27 +0100)]
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

6 years agoNew exp and exp2 implementations
Szabolcs Nagy [Fri, 22 Jun 2018 17:12:26 +0000 (18:12 +0100)]
New exp and exp2 implementations

The new implementations are provided under !__OBSOLETE_MATH, they use
ISO C99 code.  There are several settings, with the default one the
worst case error in nearest rounding mode is 0.509 ULP for exp and
0.507 ULP for exp2 when a multiply and add is contracted into an fma.
They use a shared 2 KB lookup table, on aarch64 .text+.rodata size
of libm.a is increased by 1868 bytes.  The w_*.c wrappers are disabled
for the new code as it takes care of error handling inline.

The old exp2(x) code used to be just pow(2,x) so the speedup there
is more significant.

The file name has no special prefix to avoid any name collision with
existing files.

Improvements on Cortex-A72:
exp latency: 3.2x
exp thruput: 4.1x
exp2 latency: 7.8x
exp2 thruput: 18.8x

6 years agoUse uint32_t sign argument to math error functions
Szabolcs Nagy [Mon, 25 Jun 2018 16:39:27 +0000 (17:39 +0100)]
Use uint32_t sign argument to math error functions

This change is equivalent to the commit
https://github.com/ARM-software/optimized-routines/commit/c65db17340782d647c49e17cbba244862dc38402
and only affects code that is from the Arm optimized-routines project.

It does not affect the observable behaviour, but the code generation
can be different on 64bit targets.  The intention is to make the
portable semantics of the code obvious by using a fixed size type.

6 years agoCygwin: fix bumptious GCC 7 warnings
Corinna Vinschen [Tue, 26 Jun 2018 15:20:48 +0000 (17:20 +0200)]
Cygwin: fix bumptious GCC 7 warnings

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: Allow to build without experimental AF_UNIX code by default
Corinna Vinschen [Tue, 26 Jun 2018 14:31:17 +0000 (16:31 +0200)]
Cygwin: Allow to build without experimental AF_UNIX code by default

Introduce __WITH_AF_UNIX preprocessor flag to enable the new code

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: add Unicode patch to release notes
Corinna Vinschen [Tue, 26 Jun 2018 08:21:18 +0000 (10:21 +0200)]
Cygwin: add Unicode patch to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoFix Unicode table.
Takashi Yano [Mon, 25 Jun 2018 04:34:47 +0000 (13:34 +0900)]
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

6 years agoRevert "Remove -fno-builtin to allow gcc to inline functions such as fabs, floor...
Corinna Vinschen [Tue, 26 Jun 2018 08:17:04 +0000 (10:17 +0200)]
Revert "Remove -fno-builtin to allow gcc to inline functions such as fabs, floor, creal, imag."

This reverts commit c077b9de99c6980a0c1631ec2938f6ff2cf0c289.

Yet another accidental commit...

6 years agoCygwin: exceptions: fix FPE exception flags
Corinna Vinschen [Tue, 26 Jun 2018 08:09:29 +0000 (10:09 +0200)]
Cygwin: exceptions: fix FPE exception flags

The FPE flags for divisions by zero were not implemented

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: signal.h: improve exception flags definition
Corinna Vinschen [Tue, 26 Jun 2018 08:10:48 +0000 (10:10 +0200)]
Cygwin: signal.h: improve exception flags definition

- add numbers for readability
- add a preprocessor macro for each flag

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoRemove -fno-builtin to allow gcc to inline functions such as fabs, floor, creal,...
Jon Beniston [Fri, 22 Jun 2018 09:39:39 +0000 (10:39 +0100)]
Remove -fno-builtin to allow gcc to inline functions such as fabs, floor, creal, imag.

6 years agoFix the handling of out-of-band (OOB) data in a socket.
Takashi Yano [Thu, 21 Jun 2018 14:11:49 +0000 (23:11 +0900)]
Fix the handling of out-of-band (OOB) data in a socket.

* fhandler.h (class fhandler_socket_inet): Add variable bool oobinline.
* fhandler_socket_inet.cc (fhandler_socket_inet::fhandler_socket_inet):
  Initialize variable oobinline.
(fhandler_socket_inet::recv_internal): Make the handling of OOB data
  as consistent with POSIX as possible. Add simulation of inline mode
  for OOB data as a workaround for broken winsock behavior.
(fhandler_socket_inet::setsockopt): Ditto.
(fhandler_socket_inet::getsockopt): Ditto.
(fhandler_socket_wsock::ioctl): Fix return value of SIOCATMARK command.
  The return value of SIOCATMARK of winsock is almost opposite to
  expectation.
* fhandler_socket_local.cc (fhandler_socket_local::recv_internal):
  Remove the handling of OOB data from AF_LOCAL domain socket. Operation
  related to OOB data will result in an error like Linux does.
(fhandler_socket_local::sendto): Ditto.
(fhandler_socket_local::sendmsg): Ditto.

This fixes the issue reported in following post.
https://cygwin.com/ml/cygwin/2018-06/msg00143.html

6 years agoImprove performance of sinf/cosf/sincosf
Wilco Dijkstra [Wed, 20 Jun 2018 12:07:22 +0000 (12:07 +0000)]
Improve performance of sinf/cosf/sincosf

Here is the correct patch with both filenames and int cast fixed:

This patch is a complete rewrite of sinf, cosf and sincosf.  The new version
is significantly faster, as well as simple and accurate.
The worst-case ULP is 0.56072, maximum relative error is 0.5303p-23 over all
4 billion inputs.  In non-nearest rounding modes the error is 1ULP.

The algorithm uses 3 main cases: small inputs which don't need argument
reduction, small inputs which need a simple range reduction and large inputs
requiring complex range reduction.  The code uses approximate integer
comparisons to quickly decide between these cases - on some targets this may
be slow, so this can be configured to use floating point comparisons.

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

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

Simple benchmark showing speedup factor on AArch64 for various ranges:

range 0.7853982 sinf 1.7 cosf 2.2 sincosf 2.8
range 1.570796 sinf 1.9 cosf 1.9 sincosf 2.7
range 3.141593 sinf 2.0 cosf 2.0 sincosf 3.5
range 6.283185 sinf 2.3 cosf 2.3 sincosf 4.2
range 125.6637 sinf 2.9 cosf 3.0 sincosf 5.1
range 1.1259e15 sinf 26.8 cosf 26.8 sincosf 45.2

ChangeLog:
2018-05-18  Wilco Dijkstra  <wdijkstr@arm.com>

        * newlib/libm/common/Makefile.in: Regenerated.
        * newlib/libm/common/Makefile.am: Add sinf.c, cosf.c, sincosf.c
        sincosf.h, sincosf_data.c. Add -fbuiltin -fno-math-errno to CFLAGS.
        * newlib/libm/common/math_config.h: Add HAVE_FAST_ROUND, HAVE_FAST_LROUND,
        roundtoint, converttoint, force_eval_float, force_eval_double, eval_as_float,
        eval_as_double, likely, unlikely.
        * newlib/libm/common/cosf.c: New file.
        * newlib/libm/common/sinf.c: Likewise.
        * newlib/libm/common/sincosf.h: Likewise.
        * newlib/libm/common/sincosf.c: Likewise.
        * newlib/libm/common/sincosf_data.c: Likewise.
        * newlib/libm/math/sf_cos.c: Add #if to build conditionally.
        * newlib/libm/math/sf_sin.c: Likewise.
        * newlib/libm/math/wf_sincos.c: Likewise.

--

6 years agoRevert "Improve performance of sinf/cosf/sincosf"
Corinna Vinschen [Thu, 21 Jun 2018 07:36:11 +0000 (09:36 +0200)]
Revert "Improve performance of sinf/cosf/sincosf"

This reverts commit fca80a9d1b3fa6620cdaccec6b726eef1a6530a1.

Accidentally pushed a preliminary version

6 years agolibm/common/s_round.c (round): Add cast for 16-bit CPUs
Jon Beniston [Wed, 20 Jun 2018 19:47:24 +0000 (20:47 +0100)]
libm/common/s_round.c (round): Add cast for 16-bit CPUs

6 years agoImprove performance of sinf/cosf/sincosf
Wilco Dijkstra [Mon, 18 Jun 2018 17:59:37 +0000 (17:59 +0000)]
Improve performance of sinf/cosf/sincosf

This patch is a complete rewrite of sinf, cosf and sincosf.  The new version
is significantly faster, as well as simple and accurate.
The worst-case ULP is 0.56072, maximum relative error is 0.5303p-23 over all
4 billion inputs.  In non-nearest rounding modes the error is 1ULP.

The algorithm uses 3 main cases: small inputs which don't need argument
reduction, small inputs which need a simple range reduction and large inputs
requiring complex range reduction.  The code uses approximate integer
comparisons to quickly decide between these cases - on some targets this may
be slow, so this can be configured to use floating point comparisons.

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

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

Simple benchmark showing speedup factor on AArch64 for various ranges:

range 0.7853982 sinf 1.7 cosf 2.2 sincosf 2.8
range 1.570796 sinf 1.9 cosf 1.9 sincosf 2.7
range 3.141593 sinf 2.0 cosf 2.0 sincosf 3.5
range 6.283185 sinf 2.3 cosf 2.3 sincosf 4.2
range 125.6637 sinf 2.9 cosf 3.0 sincosf 5.1
range 1.1259e15 sinf 26.8 cosf 26.8 sincosf 45.2

ChangeLog:
2018-06-18  Wilco Dijkstra  <wdijkstr@arm.com>

        * newlib/libm/common/Makefile.in: Regenerated.
        * newlib/libm/common/Makefile.am: Add sinf.c, cosf.c, sincosf.c
        sincosf.h, sincosf_data.c. Add -fbuiltin -fno-math-errno to CFLAGS.
        * newlib/libm/common/math_config.h: Add HAVE_FAST_ROUND, HAVE_FAST_LROUND,
        roundtoint, converttoint, force_eval_float, force_eval_double, eval_as_float,
        eval_as_double, likely, unlikely.
        * newlib/libm/common/cosf.c: New file.
        * newlib/libm/common/sinf.c: Likewise.
        * newlib/libm/common/sincosf.h: Likewise.
        * newlib/libm/common/sincosf.c: Likewise.
        * newlib/libm/common/sincosf_data.c: Likewise.
        * newlib/libm/math/sf_cos.c: Add #if to build conditionally.
        * newlib/libm/math/sf_sin.c: Likewise.
        * newlib/libm/math/wf_sincos.c: Likewise.

--

6 years agonewlib: getopt now permutes multi-flag options correctly
Thomas Kindler [Tue, 29 May 2018 12:04:56 +0000 (14:04 +0200)]
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>
6 years agoBump Cygwin DLL version to 2.11.0
Ken Brown [Wed, 6 Jun 2018 15:45:59 +0000 (11:45 -0400)]
Bump Cygwin DLL version to 2.11.0

6 years agoCygwin: Document clearenv and bump API minor
Ken Brown [Wed, 6 Jun 2018 15:45:58 +0000 (11:45 -0400)]
Cygwin: Document clearenv and bump API minor

Also add earlier "What changed" items to new-features.xml.

6 years agoCygwin: Remove workaround in environ.cc
Ken Brown [Wed, 6 Jun 2018 15:45:57 +0000 (11:45 -0400)]
Cygwin: Remove workaround in environ.cc

Commit ebd645e on 2001-10-03 made environ.cc:_addenv() add unneeded
space at the end of the environment block to "work around problems
with some buggy applications."  This clutters the code and is
presumably no longer needed.

6 years agoCygwin: Implement the GNU extension clearenv
Ken Brown [Wed, 6 Jun 2018 15:45:56 +0000 (11:45 -0400)]
Cygwin: Implement the GNU extension clearenv

6 years agoCygwin: Allow the environment pointer to be NULL
Ken Brown [Wed, 6 Jun 2018 15:45:55 +0000 (11:45 -0400)]
Cygwin: Allow the environment pointer to be NULL

Following glibc, interpret this as meaning the environment is empty.

6 years agoCygwin: Clarify some code in environ.cc
Ken Brown [Wed, 6 Jun 2018 15:45:54 +0000 (11:45 -0400)]
Cygwin: Clarify some code in environ.cc

6 years agoCygwin: Add pthread_rwlock_* fix to release notes
Ken Brown [Fri, 1 Jun 2018 12:31:43 +0000 (08:31 -0400)]
Cygwin: Add pthread_rwlock_* fix to release notes

6 years agoDeclare the pthread_rwlock_* functions if __cplusplus >= 201402L
Ken Brown [Wed, 30 May 2018 20:19:01 +0000 (16:19 -0400)]
Declare the pthread_rwlock_* functions if __cplusplus >= 201402L

Some of these functions are used in the <shared_mutex> C++ header.

6 years agoCygwin: Add stack alignment crash after fork fix to release notes
Corinna Vinschen [Tue, 29 May 2018 16:41:31 +0000 (18:41 +0200)]
Cygwin: Add stack alignment crash after fork fix to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: Fixing the math behind rounding down ch.stacklimit to page size.
Sergejs Lukanihins [Fri, 25 May 2018 16:27:21 +0000 (17:27 +0100)]
Cygwin: Fixing the math behind rounding down ch.stacklimit to page size.

6 years agoCygwin: Add Sergejs Lukanihins to contributors
Corinna Vinschen [Tue, 29 May 2018 16:34:54 +0000 (18:34 +0200)]
Cygwin: Add Sergejs Lukanihins to contributors

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: Add buffer underrun fix to release notes
Corinna Vinschen [Tue, 29 May 2018 16:31:07 +0000 (18:31 +0200)]
Cygwin: Add buffer underrun fix to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: normalize_win32_path: Avoid buffer underruns
Corinna Vinschen [Tue, 29 May 2018 16:11:42 +0000 (18:11 +0200)]
Cygwin: normalize_win32_path: Avoid buffer underruns

Thanks to Ken Harris <Ken.Harris@mathworks.com> for the diagnosis.

When backing up tail to handle a "..", the code only checked that
it didn't underrun the destination buffer while removing path
components.  It did *not* take into account that the first backslash
in the path had to be kept intact.  Example path to trigger the
problem: "C:\A..\..\..\B'

Fix this by moving the dst pointer to the first backslash so subsequent
tests cannot underrun this position.  Also make sure that we always
*have* a backslash.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: TEST only: Add a buffer underrun assertion to symlink_info::check
Corinna Vinschen [Tue, 29 May 2018 16:04:14 +0000 (18:04 +0200)]
Cygwin: TEST only: Add a buffer underrun assertion to symlink_info::check

Thanks to Ken Harris <Ken.Harris@mathworks.com> for the diagnosis
which led to a buffer underrun in this loop.

Revert before release.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoFix issue with malloc_extend_top
Jeff Johnston [Fri, 25 May 2018 03:53:15 +0000 (23:53 -0400)]
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>
6 years agofix llrint and lrint for 52 <= exponent <= 62
Matthias Kannwischer [Mon, 14 May 2018 13:00:18 +0000 (14:00 +0100)]
fix llrint and lrint for 52 <= exponent <= 62

6 years agoFix 32-bit overflow in mktime() when time_t is 64-bits long
Freddie Chopin [Tue, 15 May 2018 18:58:08 +0000 (20:58 +0200)]
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>
6 years agoUse _LDBL_EQ_DBL in nexttowardf.c
Jeff Johnston [Mon, 7 May 2018 16:22:12 +0000 (12:22 -0400)]
Use _LDBL_EQ_DBL in nexttowardf.c

2018-05-07  Tom de Vries  <tom@codesourcery.com>

* libm/common/nexttowardf.c: Use _LDBL_EQ_DBL instead of
_LDBL_EQ_DOUBLE.

6 years agolibgloss: microblaze: adjust handlers to be weak.
Ben Levinsky [Fri, 27 Apr 2018 16:05:54 +0000 (09:05 -0700)]
libgloss: microblaze: adjust handlers to be weak.

Previously, hw exception handler stub and interrupt handler stub for microbaze were unable to
be overwritten. Change to weak to fix this.

Signed-off-by: Ben Levinsky <ben.levinsky@xilinx.com>
6 years agoCygwin: fix build with GCC 7
Yaakov Selkowitz [Tue, 17 Apr 2018 03:46:11 +0000 (22:46 -0500)]
Cygwin: fix build with GCC 7

GCC 7 is able to see straight through this trick, so use a more formal
method to avoid the warning.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
6 years agoAdd nvptx port.
Jeff Johnston [Fri, 13 Apr 2018 19:42:37 +0000 (15:42 -0400)]
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.

6 years agoCygwin: fix guard checking for current user's AuthZ context
Corinna Vinschen [Thu, 12 Apr 2018 07:43:12 +0000 (09:43 +0200)]
Cygwin: fix guard checking for current user's AuthZ context

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: add cuinof changes to release text
Corinna Vinschen [Wed, 11 Apr 2018 10:46:18 +0000 (12:46 +0200)]
Cygwin: add cuinof changes to release text

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: cpuinfo: Use active CPU count per group
Corinna Vinschen [Wed, 11 Apr 2018 10:45:57 +0000 (12:45 +0200)]
Cygwin: cpuinfo: Use active CPU count per group

There are systems with a MaximumProcessorCount not
reflecting the actually available CPUs.  The ActiveProcessorCount
is correct though.  So we use ActiveProcessorCount rather than
MaximumProcessorCount per group to set group affinity correctly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: wincap: expose more SYSTEM_INFO members and use as appropriate
Corinna Vinschen [Wed, 11 Apr 2018 09:59:35 +0000 (11:59 +0200)]
Cygwin: wincap: expose more SYSTEM_INFO members and use as appropriate

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: cpuinfo: report L3 cache on Intel CPUs
Corinna Vinschen [Wed, 11 Apr 2018 08:06:25 +0000 (10:06 +0200)]
Cygwin: cpuinfo: report L3 cache on Intel CPUs

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: add strtod fix to release notes
Corinna Vinschen [Mon, 9 Apr 2018 09:48:33 +0000 (11:48 +0200)]
Cygwin: add strtod fix to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agostrtod: Convert 64 bit double to 64 bit int during computation
Corinna Vinschen [Mon, 9 Apr 2018 09:31:04 +0000 (11:31 +0200)]
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>
6 years agonewlib: fix iswupper_l in !_MB_CAPABLE case
Corinna Vinschen [Tue, 27 Mar 2018 10:35:27 +0000 (12:35 +0200)]
newlib: fix iswupper_l in !_MB_CAPABLE case

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_LOCAL: fix identifing abstract sockets in FS-related functions
Corinna Vinschen [Mon, 26 Mar 2018 16:11:10 +0000 (18:11 +0200)]
Cygwin: AF_LOCAL: fix identifing abstract sockets in FS-related functions

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: fix typo in accept on inet and local sockets
Corinna Vinschen [Mon, 26 Mar 2018 15:21:30 +0000 (17:21 +0200)]
Cygwin: fix typo in accept on inet and local sockets

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agocomments to document struct caseconv_entry
Thomas Wolff [Mon, 26 Mar 2018 09:46:40 +0000 (11:46 +0200)]
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

6 years agonewlib: fix indentation in toulower
Thomas Wolff [Mon, 26 Mar 2018 08:00:16 +0000 (10:00 +0200)]
newlib: fix indentation in toulower

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: delete /dev/kmsg and thus fhandler_mailslot without substitution
Corinna Vinschen [Sun, 25 Mar 2018 10:38:14 +0000 (12:38 +0200)]
Cygwin: delete /dev/kmsg and thus fhandler_mailslot without substitution

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: Redesign various aspects
Corinna Vinschen [Sun, 18 Mar 2018 19:46:43 +0000 (20:46 +0100)]
Cygwin: AF_UNIX: Redesign various aspects

* Change set_socket_type/get_socket_type to virtual methods
* Move various variables into af_unix_shmem_t
* Change sun_name_t to match new usage pattern
* Move shut_state definition and add a name for the 0 value
* Allow marking packet as administrative packet.  This allows
  filtering out info packets exchange between peers and tweak
  data accordingly.
* Rename send_my_name to send_sock_info and send credentials
  if not called from bind (so the socket was already connected)
* Handle SO_PASSCRED in setsockopt/getsockopt
* Add input size checking to setsockopt/getsockopt
* Use NT functions where appropriate

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: ntdll.h: Define FSCTL_PIPE_PEEK and NtWaitForSingleObject
Corinna Vinschen [Sun, 18 Mar 2018 19:07:35 +0000 (20:07 +0100)]
Cygwin: ntdll.h: Define FSCTL_PIPE_PEEK and NtWaitForSingleObject

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: Add state_lock to guard manipulating shared state info
Corinna Vinschen [Sun, 18 Mar 2018 19:06:43 +0000 (20:06 +0100)]
Cygwin: AF_UNIX: Add state_lock to guard manipulating shared state info

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: Use spinlock rather than SRWLOCKs
Corinna Vinschen [Sun, 18 Mar 2018 17:46:15 +0000 (18:46 +0100)]
Cygwin: AF_UNIX: Use spinlock rather than SRWLOCKs

We need to share socket info between threads *and* processes.
SRWLOCKs are single-process only, unfortunately.  Provide a
sharable low-profile spinlock instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: tags: drop _EXFUN regex
Corinna Vinschen [Sat, 17 Mar 2018 15:55:22 +0000 (16:55 +0100)]
Cygwin: tags: drop _EXFUN regex

_EXFUN has been removed a while back

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoReduce qsort stack consumption
Hakan Lindqvist [Mon, 12 Mar 2018 13:55:01 +0000 (14:55 +0100)]
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.

6 years agoEnsure qsort recursion depth is bounded
Hakan Lindqvist [Mon, 12 Mar 2018 12:51:07 +0000 (13:51 +0100)]
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.

6 years agoCorrect prototypes of pthread_mutex_getprioceiling() and pthread_setschedparam()
Joel Sherrill [Wed, 14 Mar 2018 22:49:29 +0000 (17:49 -0500)]
Correct prototypes of pthread_mutex_getprioceiling() and pthread_setschedparam()

6 years ago[arm] Fix syscalls.c for newlib embedded syscalls builds
Richard Earnshaw [Thu, 15 Mar 2018 09:55:11 +0000 (09:55 +0000)]
[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>
6 years agossp: fix wchar.h with -std=c99
Yaakov Selkowitz [Wed, 14 Mar 2018 15:40:27 +0000 (10:40 -0500)]
ssp: fix wchar.h with -std=c99

https://sourceware.org/ml/newlib/2018/msg00261.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
6 years agoFix alloc_align and alloc_size macros for multiple arguments
Yaakov Selkowitz [Wed, 14 Mar 2018 15:17:51 +0000 (10:17 -0500)]
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 4564b30f331a067e71b25308ac7c8a85ceb4b122.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
6 years agoctype: align size of category bit fields to small targets needs
Corinna Vinschen [Wed, 14 Mar 2018 09:36:34 +0000 (10:36 +0100)]
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>
6 years agoRevert "ctype: align size of category bit fields to small targets needs"
Corinna Vinschen [Wed, 14 Mar 2018 10:36:06 +0000 (11:36 +0100)]
Revert "ctype: align size of category bit fields to small targets needs"

This reverts commit e98d3eb3eb9b6abd897e102031a14b7057641a65.

It has accidentally included some work in progress.

6 years agofix/enhance Unicode table generation scripts
Thomas Wolff [Tue, 13 Mar 2018 17:26:19 +0000 (18:26 +0100)]
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.

6 years agoctype: align size of category bit fields to small targets needs
Corinna Vinschen [Wed, 14 Mar 2018 09:36:34 +0000 (10:36 +0100)]
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>
6 years agotowctrans_l: Always return a value from helper functions
Corinna Vinschen [Tue, 13 Mar 2018 21:09:30 +0000 (22:09 +0100)]
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>
6 years agortems/.../dirent.h: Add alphasort() prototype
Joel Sherrill [Mon, 12 Mar 2018 16:54:06 +0000 (11:54 -0500)]
rtems/.../dirent.h: Add alphasort() prototype

6 years agoCorrect alloc_size annotation on reallocarray()
Jon Turney [Mon, 12 Mar 2018 19:54:11 +0000 (19:54 +0000)]
Correct alloc_size annotation on reallocarray()

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
6 years agoCygwin: mark muto object as NO_COPY
Corinna Vinschen [Mon, 12 Mar 2018 21:13:20 +0000 (22:13 +0100)]
Cygwin: mark muto object as NO_COPY

muto in smallprint.cc is missing a NO_COPY.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: store per-socket info in shared memory
Corinna Vinschen [Mon, 12 Mar 2018 14:26:12 +0000 (15:26 +0100)]
Cygwin: AF_UNIX: store per-socket info in shared memory

Per-socket info in fhandler isn't correctly shared between multiple
instances of th same descriptor.  Implement a basic shared info which
is shared between all instances of a socket.

This also requires to move the fhandler_socket status bits into
fhandler_socket_wsock since the data is moved to the shared region
for AF_UNIX sockets.

Also, drop backing file requirement for socketpair server socket.
This will be handled differently in recvmsg/sendmsg.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agomake target for explicit Unicode data tables generation
Thomas Wolff [Wed, 7 Mar 2018 23:08:29 +0000 (00:08 +0100)]
make target for explicit Unicode data tables generation

Run 'make unidata' in newlib target directory to generate Unicode
data tables for libc functions wcwidth, tow* and isw*.

6 years agocharacter data generation
Thomas Wolff [Wed, 7 Mar 2018 23:02:35 +0000 (00:02 +0100)]
character data generation

6 years agouse generated character data
Thomas Wolff [Fri, 9 Mar 2018 12:30:33 +0000 (13:30 +0100)]
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.

6 years agogenerated character category data, Unicode 10.0
Thomas Wolff [Sun, 25 Feb 2018 15:30:27 +0000 (16:30 +0100)]
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.

6 years agogenerated case conversion data, Unicode 10.0
Thomas Wolff [Sun, 25 Feb 2018 15:29:33 +0000 (16:29 +0100)]
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.

6 years agowidth data generation
Thomas Wolff [Wed, 7 Mar 2018 22:55:52 +0000 (23:55 +0100)]
width data generation

6 years agouse generated width data
Thomas Wolff [Sun, 25 Feb 2018 15:25:49 +0000 (16:25 +0100)]
use generated width data

6 years agogenerated width data, Unicode 10.0
Thomas Wolff [Sun, 25 Feb 2018 15:25:25 +0000 (16:25 +0100)]
generated width data, Unicode 10.0

These tables provide character width properties for use by the
wcwidth/wcswidth functions. They are generated from Unicode.

6 years agoCygwin: AF_UNIX: fix up thread parameter block allocation
Corinna Vinschen [Sun, 11 Mar 2018 13:56:02 +0000 (14:56 +0100)]
Cygwin: AF_UNIX: fix up thread parameter block allocation

* don't abort on failing allocation, just return with error
* make sure the allocation is restricted to a single process

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: use get_unique_id to create pipe name
Corinna Vinschen [Sun, 11 Mar 2018 13:54:20 +0000 (14:54 +0100)]
Cygwin: AF_UNIX: use get_unique_id to create pipe name

It's the same as get_plain_ino in this case, but it's cleaner
and easier to understand.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: fix dup
Corinna Vinschen [Sat, 10 Mar 2018 20:12:27 +0000 (21:12 +0100)]
Cygwin: AF_UNIX: fix dup

Reorder so fhandler_socket::dup is called first.  Add missing
duplication of backing_file_handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: Add fixup_after_exec method
Corinna Vinschen [Sat, 10 Mar 2018 20:09:28 +0000 (21:09 +0100)]
Cygwin: AF_UNIX: Add fixup_after_exec method

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: fix creating abstract socket symlink name
Corinna Vinschen [Sat, 10 Mar 2018 20:07:46 +0000 (21:07 +0100)]
Cygwin: AF_UNIX: fix creating abstract socket symlink name

Add missing NUL termination when creating symlink representing
abstract socket.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: don't skip O_TMPFILE files in readdir
Corinna Vinschen [Fri, 9 Mar 2018 20:13:28 +0000 (21:13 +0100)]
Cygwin: don't skip O_TMPFILE files in readdir

Bad idea.  A file hidden from directory listings is not seen by
rm either, so it never calls unlink for the file and a recursive
removal of the parent directory fails with "directory not empty".

Fix comments accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: Implemant socketpair
Corinna Vinschen [Fri, 9 Mar 2018 13:19:36 +0000 (14:19 +0100)]
Cygwin: AF_UNIX: Implemant socketpair

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: fix socketpair prototype
Corinna Vinschen [Fri, 9 Mar 2018 13:17:39 +0000 (14:17 +0100)]
Cygwin: fix socketpair prototype

Last parameter is a vector of 2 ints, not a pointer to int

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agodescribe new locale modifier @cjkwide for user guide
Thomas Wolff [Wed, 7 Mar 2018 23:29:25 +0000 (00:29 +0100)]
describe new locale modifier @cjkwide for user guide

6 years agoCygwin: AF_UNIX: implement getsockopt SO_RCVBUF/SO_SNDBUF
Corinna Vinschen [Wed, 7 Mar 2018 20:56:42 +0000 (21:56 +0100)]
Cygwin: AF_UNIX: implement getsockopt SO_RCVBUF/SO_SNDBUF

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: define AF_UNIX_CONNECT_TIMEOUT
Corinna Vinschen [Wed, 7 Mar 2018 20:55:34 +0000 (21:55 +0100)]
Cygwin: AF_UNIX: define AF_UNIX_CONNECT_TIMEOUT

Use macro AF_UNIX_CONNECT_TIMEOUT instead of numerical constant
for connect timeout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: Define FSCTL_PIPE_FLUSH
Corinna Vinschen [Wed, 7 Mar 2018 20:54:46 +0000 (21:54 +0100)]
Cygwin: Define FSCTL_PIPE_FLUSH

This fsctl might come in handy at one point...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: Implement read, readv, recvfrom, write, writev, sendto
Corinna Vinschen [Wed, 7 Mar 2018 20:53:56 +0000 (21:53 +0100)]
Cygwin: AF_UNIX: Implement read, readv, recvfrom, write, writev, sendto

All of these functions just call recvfrom/sendmsg which are still TODO

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: reorder read/write calls in fhandler_socket_unix
Corinna Vinschen [Wed, 7 Mar 2018 20:52:29 +0000 (21:52 +0100)]
Cygwin: reorder read/write calls in fhandler_socket_unix

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: fix accept behaviour
Corinna Vinschen [Wed, 7 Mar 2018 15:23:44 +0000 (16:23 +0100)]
Cygwin: AF_UNIX: fix accept behaviour

* Use correct cygwait/WFSO invocation to not die on cancel and signals
  uncontrolled.
* Manage io handles under io_lock.
* Copy peer address to user space under SEH to avoid a resource leak.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: make sure connect wait thread is cleanly interruptible
Corinna Vinschen [Wed, 7 Mar 2018 15:19:32 +0000 (16:19 +0100)]
Cygwin: AF_UNIX: make sure connect wait thread is cleanly interruptible

Using TerminateThread potentially leaks resources.  In our case,
the connect wait thread may be forcefully terminated after
having successfully opened a client side pipe handle.  If this
occurs, we have a stale pipe server instance, so the pipe will
never be closed as long as the process lives.

Avoid this by changing the npfs handle to non-blocking, so we can
wait on a termination event object from inside the thread itself
and cleanly exit from the thread instead of terminating.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: some pipe errors may have multiple status codes
Corinna Vinschen [Wed, 7 Mar 2018 15:12:55 +0000 (16:12 +0100)]
Cygwin: AF_UNIX: some pipe errors may have multiple status codes

Depending on the exact circumstances, some erros are indicated
by different status codes.  Add helper macros to handle them
together.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: fix SEGV when sending an empty socket name from connect
Corinna Vinschen [Wed, 7 Mar 2018 15:08:15 +0000 (16:08 +0100)]
Cygwin: AF_UNIX: fix SEGV when sending an empty socket name from connect

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: AF_UNIX: fix creation of npfs handle
Corinna Vinschen [Wed, 7 Mar 2018 14:48:21 +0000 (15:48 +0100)]
Cygwin: AF_UNIX: fix creation of npfs handle

The handle to the device is never needed.  As the name impies,
FSCTL_PIPE_WAIT works on the file system, not on the device level.

Drop opening the device and make sure to open only one handle to NPFS.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This page took 0.088027 seconds and 5 git commands to generate.