]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
5 years agoPOSIX Asynchronous I/O support: other files
Mark Geisert [Tue, 24 Jul 2018 05:31:59 +0000 (22:31 -0700)]
POSIX Asynchronous I/O support: other files

Updates to misc files to integrate AIO into the Cygwin source tree.
Much of it has to be done when adding any new syscalls.  There are
some updates to limits.h for AIO-specific limits.  And some doc mods.

5 years agoPOSIX Asynchronous I/O support: fhandler files
Mark Geisert [Tue, 24 Jul 2018 05:31:58 +0000 (22:31 -0700)]
POSIX Asynchronous I/O support: fhandler files

This code is where the AIO implementation is wired into existing Cygwin
mechanisms for file and device I/O: the fhandler* functions.  It makes
use of an existing internal routine prw_open to supply a "shadow fd"
that permits asynchronous operations on a file the user app accesses
via its own fd.  This allows AIO to read or write at arbitrary locations
within a file without disturbing the app's file pointer.  (This was
already the case with normal pread|pwrite; we're just adding "async"
to the mix.)

5 years agoPOSIX Asynchronous I/O support: aio files
Mark Geisert [Tue, 24 Jul 2018 05:31:57 +0000 (22:31 -0700)]
POSIX Asynchronous I/O support: aio files

This is the core of the AIO implementation: aio.cc and aio.h.  The
latter is used within the Cygwin DLL by aio.cc and the fhandler* modules,
as well as by user programs wanting the AIO functionality.

5 years agogetfacl: Simplify by using acl_to_any_text
Ken Brown [Mon, 23 Jul 2018 21:46:41 +0000 (17:46 -0400)]
getfacl: Simplify by using acl_to_any_text

6 years agogetfacl and setfacl: Align with Linux
Ken Brown [Mon, 23 Jul 2018 14:10:03 +0000 (10:10 -0400)]
getfacl and setfacl: Align with Linux

Make getfacl print two colons instead of one after "other" and "mask".
Change the help text for setfacl to indicate that there can be either
one colon or two.

6 years agoctype: Fix bitfield types on 16-bit targets newlib-snapshot-20180720
Sebastian Huber [Fri, 20 Jul 2018 11:04:56 +0000 (13:04 +0200)]
ctype: Fix bitfield types on 16-bit targets

This prevents errors like this:

newlib/libc/ctype/categories.c:6:3: error: width of 'first' exceeds its type
   unsigned int first: 24;
   ^

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
6 years agoCygwin: move FP environment exports to common.din
Corinna Vinschen [Fri, 20 Jul 2018 11:55:26 +0000 (13:55 +0200)]
Cygwin: move FP environment exports to common.din

We only have the symbols defined for i686 by accident since 2013...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoRTEMS: Unconditionally define _off_t to int64_t
Sebastian Huber [Thu, 19 Jul 2018 13:30:18 +0000 (15:30 +0200)]
RTEMS: Unconditionally define _off_t to int64_t

Exotic RTEMS targets can define this back to int32_t as an exception if
there are good reasons.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
6 years agoRemove myself from MAINTAINERS
DJ Delorie [Fri, 20 Jul 2018 01:32:40 +0000 (21:32 -0400)]
Remove myself from MAINTAINERS

Stepping down from target-specific maintainerships.

6 years agofix duration handling in sigtimedwait
Mark Geisert [Thu, 19 Jul 2018 09:35:40 +0000 (02:35 -0700)]
fix duration handling in sigtimedwait

6 years agoPrint sign of NaN values to nano-vfprintf.
Kumar Gala [Thu, 12 Jul 2018 18:13:53 +0000 (13:13 -0500)]
Print sign of NaN values to nano-vfprintf.

Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
6 years agoFix to stop a fall-through in a switch statement
Jordi Sanfeliu [Fri, 13 Jul 2018 10:15:46 +0000 (12:15 +0200)]
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().

6 years agostrcmp.S: Improve performance for misaligned strings
Siddhesh Poyarekar [Fri, 29 Jun 2018 12:38:22 +0000 (18:08 +0530)]
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.

6 years agomemcmp.S: optimize for medium to large sizes
Siddhesh Poyarekar [Fri, 29 Jun 2018 12:38:21 +0000 (18:08 +0530)]
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.

6 years agoImprove strncmp for mutually misaligned inputs
Siddhesh Poyarekar [Fri, 29 Jun 2018 12:38:20 +0000 (18:08 +0530)]
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.

6 years agoCygwin: Treat PROCESSOR_ARCHITECTURE_INTEL as running under WOW64 on ARM64
Corinna Vinschen [Thu, 12 Jul 2018 13:28:13 +0000 (15:28 +0200)]
Cygwin: Treat PROCESSOR_ARCHITECTURE_INTEL as running under WOW64 on ARM64

Bug in current ARM64 WOW64: GetNativeSystemInfo returns
PROCESSOR_ARCHITECTURE_INTEL rather than PROCESSOR_ARCHITECTURE_ARM64.
Provide for this.

Make code better readable.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoFix AArch32 semihosting SYS_EXIT call on semihosting v1.
Tamar Christina [Wed, 11 Jul 2018 12:26:16 +0000 (13:26 +0100)]
Fix AArch32 semihosting SYS_EXIT call on semihosting v1.

The current SYS_EXIT has a bug that when making the call it always uses
the v2 calling convention.  This is undefined behavior according to the
semihosting specification:
https://developer.arm.com/docs/100863/latest/semihosting-operations/sys_exit-0x18

This patch fixes it by making sure v1 passes the argument directly in the register instead
of in a block. And for v2 it does the same if the v2 extension isn't supported.

The sequence generated now is

   12424:       ebfffecd        bl      11f60 <_has_ext_exit_extended>
   12428:       e3500000        cmp     r0, #0
   1242c:       11a0500d        movne   r5, sp
   12430:       059d5000        ldreq   r5, [sp]
   12434:       e1a00004        mov     r0, r4
   12438:       e1a01005        mov     r1, r5
   1243c:       ef00f000        svc     0x0000f000

Signed-off-by: Tamar Christina <tamar.christina@arm.com>
6 years agoRemove float compare option from sincosf
Szabolcs Nagy [Tue, 10 Jul 2018 16:14:32 +0000 (17:14 +0100)]
Remove float compare option from sincosf

PREFER_FLOAT_COMPARISON setting was not correct as it could raise
spurious exceptions.  Fixing it is easy: just use ISLESS(x, y) instead
of abstop12(x) < abstop12(y) with appropriate non-signaling definition
for ISLESS.  However it seems this setting is not very useful (there is
only minor performance difference on various architectures), so remove
this option for now.

6 years agoFix the documentation comments for log_inline in pow
Szabolcs Nagy [Tue, 10 Jul 2018 16:13:27 +0000 (17:13 +0100)]
Fix the documentation comments for log_inline in pow

There was a typo and the arguments were not explained clearly.

6 years agoCygwin: Don't print FAST_CWD warning in WOW64 on ARM64 systems
Corinna Vinschen [Tue, 10 Jul 2018 12:45:52 +0000 (14:45 +0200)]
Cygwin: Don't print FAST_CWD warning in WOW64 on ARM64 systems

No way to test this, yet.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: fix a race in the FAST_CWD fallback code
Corinna Vinschen [Tue, 10 Jul 2018 12:13:15 +0000 (14:13 +0200)]
Cygwin: fix a race in the FAST_CWD fallback code

Guard the entire operation with the FastPebLock critical section
used by RtlSetCurrentDirectory_U as well, thus eliminating the
race between concurrent chdir/fchdir/SetCurrentDirectory calls.

Streamline comment explaining the fallback method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoUpdate config.guess and config.sub
Sebastian Huber [Fri, 6 Jul 2018 06:57:22 +0000 (08:57 +0200)]
Update config.guess and config.sub

Update to the latest versions of config.sub (2018-07-03) and
config.guess (2018-06-26).

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
6 years agoFix a problem that connection to syslogd fails.
Takashi Yano [Thu, 5 Jul 2018 14:46:34 +0000 (23:46 +0900)]
Fix a problem that connection to syslogd fails.

* fhandler_socket_local.cc (get_inet_addr_local): Change type from
  'static int' to 'int' to be callable from syslog.cc.
* syslog.cc (connect_syslogd): Use get_inet_addr_local() instead of
  getsockname() to retrieve name information of the syslogd socket.

6 years agoFix namespace issues in sinf, cosf and sincosf
Szabolcs Nagy [Wed, 4 Jul 2018 16:52:36 +0000 (17:52 +0100)]
Fix namespace issues in sinf, cosf and sincosf

Use const sincos_t for clarity instead of making the typedef const.
Use __inv_pi4 and __sincosf_table to avoid namespace issues with
static linking.

6 years agoFix large ulp error in pow without fma very near 1.0
Szabolcs Nagy [Tue, 3 Jul 2018 12:05:31 +0000 (13:05 +0100)]
Fix large ulp error in pow without fma very near 1.0

The !HAVE_FAST_FMA code path split r = z/c - 1 into r = rhi + rlo such
that when z = 1-tiny and c = 1 then rlo and rhi could have much larger
magnitude than r which later caused large rounding errors.

So do a nearest rounding instead of truncation at the split.

In newlib with default settings this was observable on some arm targets
that enable the new math code but has no fma.

6 years agoChange the return type of converttoint and document the semantics
Szabolcs Nagy [Wed, 4 Jul 2018 10:09:39 +0000 (11:09 +0100)]
Change the return type of converttoint and document the semantics

The roundtoint and converttoint internal functions are only called with small
values, so 32 bit result is enough for converttoint and it is a signed int
conversion so the natural return type is int32_t.

The original idea was to help the compiler keeping the result in uint64_t,
then it's clear that no sign extension is needed and there is no accidental
undefined or implementation defined signed int arithmetics.

But it turns out gcc does a good job with inlining so changing the type has
no overhead and the semantics of the conversion is less surprising this way.
Since we want to allow the asuint64 (x + 0x1.8p52) style conversion, the top
bits were never usable and the existing code ensures that only the bottom
32 bits of the conversion result are used.

In newlib with default settings only aarch64 is affected and there is no
significant code generation change with gcc after the patch.

6 years agoRemove unused TOINT_RINT and TOINT_SHIFT macros
Szabolcs Nagy [Thu, 5 Jul 2018 11:42:13 +0000 (12:42 +0100)]
Remove unused TOINT_RINT and TOINT_SHIFT macros

Only have separate code paths for TOINT_INTRINSICS and !TOINT_INTRINSICS.

6 years agoMove __HAVE_FAST_FMA to math_config.h
Szabolcs Nagy [Thu, 5 Jul 2018 11:37:25 +0000 (12:37 +0100)]
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.

6 years agoFix code style and comments of new math code
Szabolcs Nagy [Tue, 3 Jul 2018 11:54:36 +0000 (12:54 +0100)]
Fix code style and comments of new math code

Synchronize code style and comments with Arm Optimized Routines, there
are no code changes in this patch.  This ensures different projects using
the same code have consistent code style so bug fix patches can be applied
more easily.

6 years agoFix newlib functions perror()/psignal() not to use writev().
Takashi Yano [Thu, 5 Jul 2018 14:01:26 +0000 (23:01 +0900)]
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: d4f4e7ae1be1bcf8c021f2b0865aafc16b338aa3

6 years agoCygwin: Include local ntsecapi.h
Takashi Yano [Wed, 4 Jul 2018 10:42:39 +0000 (12:42 +0200)]
Cygwin: Include local ntsecapi.h

Our local ntsecapi.h wrapper corrects a bug in the definition of
SystemFunction036 which otherwise leads to crashes on 32 bit when
using RtlGenRandom.  The fhandler_socket_local.cc file accidentally
included the incorrect w32api version of that file, rather than the
local wrapper.  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoFix a bug of perror()/psignal() that changes the orientation of stderr.
Takashi Yano [Tue, 3 Jul 2018 09:04:31 +0000 (18:04 +0900)]
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.

6 years agoFix a bug of psiginfo() that changes the orientation of stderr.
Takashi Yano [Tue, 3 Jul 2018 10:09:48 +0000 (19:09 +0900)]
Fix a bug of psiginfo() that changes the orientation of stderr.

* strsig.cc (psiginfo): Fix the problem that psiginfo() changes
  the orientation of stderr to byte-oriented mode if stderr is
  not oriented yet.

6 years agoIntroduce @unless/@endunless and postbootstrap Makefile targets
Alexandre Oliva [Sat, 30 Jun 2018 02:49:28 +0000 (23:49 -0300)]
Introduce @unless/@endunless and postbootstrap Makefile targets

This patch turns dependencies of non-bootstrap targets on bootstrap
targets for bootstrap builds into dependencies on stage_last.  This
arrangement gets stage1-bubble to run from stage_last if we haven't
started a bootstrap yet, and to use the current stage otherwise.  This
was already the case of target libs, just not of non-bootstrapped host
modules.

In order to retain preexisting dependencies in non-bootstrap builds,
or in gcc-less builds, this introduces support for @unless/@endunless
pairs in Makefile.in.

There is a remaining possibility of problem if activating, in a tree
configured for bootstrap, a parallel build of two or more modules, at
least one bootstrapped and one not.  In this case, make might decide
to build stage_current and stage_last in parallel, the latter will
start a submake to build stage1 while the initial make, having
satisfied stage_current, proceeds to build the bootstrapped module in
non-bootstrapped configurations.  The two builds will overlap and will
likely conflict.  This situation does NOT arise in normal settings,
however: a post-bootstrap build of all-host all-target will indeed
activate such targets concurrently, but only after building all
bootstrapped modules successfully, and it will have both stage_last
and stage_current targets already satisfied, so the potential race
between builds will not arise.

Another remaining problem, that is slightly expanded with this patch,
is that of an interrupted build in a tree configured for bootstrap,
continued with a non-bootstrapped target.  Target modules that were
not bootstrapped would already fail to complete the current stage when
activated explicitly in the command line for a retry; host modules,
however, would attempt to build their bootstrapped dependencies, which
is what led to the problem of concurrent builds addressed with this
patch.  An interrupted or failed build might still recover correctly,
if the non-bootstrapped target is activated in both builds, because
then make will remove stage_last when its build command is
interrupted, so that it will attempt to recreate it with stage1-bubble
in the second try.  A bootstrap build, however, will not be attempting
to build stage_last, so the file will remain and the retry won't go
through stage1-bubble.  We have lived with that for target modules, so
we can probably live with that for host modules too.

Another undesirable consequence of this change is that non-boostrapped
host modules, in a tree configured for bootstrap, when activated as
make all-<module>, will build all of stage1 instead of only the
module's usual dependencies.  This is intentional and necessary to fix
the parallel-build problem.  If it's not desirable, disabling the
unnecessary bootstrap configuration will suffice to restore the
original set of dependencies.

for  ChangeLog

* configure.ac: Introduce support for @unless/@endunless.
* Makefile.tpl (dep-kind): Rewrite with cond; return
postbootstrap in some cases.
(make-postboot-dep, postboot-targets): New.
(dependencies): Do not output postbootstrap dependencies at
first.  Output non-target ones changed for configure to depend
on stage_last @if gcc-bootstrap, and the original deps @unless
gcc-bootstrap.
* configure.in, Makefile.in: Rebuilt.

6 years agoAdd OBJCOPY to Makefile.tpl too, to keep it on Makefile.in rebuild
Alexandre Oliva [Sat, 30 Jun 2018 03:07:44 +0000 (00:07 -0300)]
Add OBJCOPY to Makefile.tpl too, to keep it on Makefile.in rebuild

for  ChangeLog

* Makefile.tpl (OBJCOPY): Add it.
* Makefile.in: Rebuilt, unchanged.

6 years agoCygwin: tape: Handle non-standard "no medium" error code
Corinna Vinschen [Fri, 29 Jun 2018 13:29:36 +0000 (15:29 +0200)]
Cygwin: tape: Handle non-standard "no medium" error code

Certain tape drives (known example: QUANTUM_ULTRIUM-HH6) return
the non-standard ERROR_NOT_READY rather than ERROR_NO_MEDIA_IN_DRIVE
if no media is present.  ERROR_NOT_READY is not documented as valid
return code from GetTapeStatus.  Without handling this error code
Cygwin's tape code can't report an offline state to user space.

Fix this by converting ERROR_NOT_READY to ERROR_NO_MEDIA_IN_DRIVE
where appropriate.

Add a debug_printf to mtinfo_drive::get_status to allow requesting
user info without having to rebuild the DLL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: define pthread_tryjoin_np/pthread_timedjoin_np _GNU_VISIBLE
Corinna Vinschen [Wed, 27 Jun 2018 16:17:51 +0000 (18:17 +0200)]
Cygwin: define pthread_tryjoin_np/pthread_timedjoin_np _GNU_VISIBLE

These functions are GNU extensions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: doc: add pthread_tryjoin_np, pthread_timedjoin_np
Corinna Vinschen [Wed, 27 Jun 2018 16:16:10 +0000 (18:16 +0200)]
Cygwin: doc: add pthread_tryjoin_np, pthread_timedjoin_np

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: pthread_timedjoin_np: return ETIMEDOUT, not EBUSY
Corinna Vinschen [Wed, 27 Jun 2018 16:13:38 +0000 (18:13 +0200)]
Cygwin: pthread_timedjoin_np: return ETIMEDOUT, not EBUSY

pthread_timedjoin_np returns ETIMEDOUT if a thread is still running,
not EBUSY as pthread_tryjoin_np.

Also, clean up initializing timeout in pthread_tryjoin_np.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agoCygwin: Implement pthread_tryjoin_np and pthread_timedjoin_np
Corinna Vinschen [Wed, 27 Jun 2018 15:56:59 +0000 (17:56 +0200)]
Cygwin: Implement pthread_tryjoin_np and pthread_timedjoin_np

- Move pthread_join to thread.cc to have all `join' calls in
  the same file (pthread_timedjoin_np needs pthread_convert_abstime
  which is static inline in thread.cc)
- Bump API version

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
6 years agonewlib: enable new math functions on Cygwin
Corinna Vinschen [Wed, 27 Jun 2018 13:53:51 +0000 (15:53 +0200)]
newlib: enable new math functions on Cygwin

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
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.

This page took 0.071612 seconds and 5 git commands to generate.