]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
3 years agoCygwin: ldd: Also look for not found DLLs when exit status is non-zero
Jon Turney [Mon, 7 Sep 2020 15:24:39 +0000 (16:24 +0100)]
Cygwin: ldd: Also look for not found DLLs when exit status is non-zero

If the process exited with e.g. STATUS_DLL_NOT_FOUND, also process the
file to look for not found DLLs.

(We currently only do this when a STATUS_DLL_NOT_FOUND exception occurs,
which I haven't managed to observe)

This still isn't 100% correct, as it only examines the specified file
for missing DLLs, not recursively on the DLLs it depends upon.

3 years agoCygwin: pty: Prevent garbled output for existing non-cygwin apps.
Takashi Yano via Cygwin-patches [Fri, 11 Sep 2020 10:54:40 +0000 (19:54 +0900)]
Cygwin: pty: Prevent garbled output for existing non-cygwin apps.

- If pseudo console is disabled, non-cygwin apps do not detect
  console device. In this case, some apps output UTF-8 regardless
  of the locale setting. At least git-for-windows, rust-based apps
  and node.js do that. This patch provides backward compatibility
  as default behaviour by setting console codepage to the charset of
  the locale. Even in the cases above, garbled output is prevented
  with this patch in most cases because mintty uses UTF-8 by default.

  I beleave this is not really a problem in cygwin side but that in
  app side, however, some users complain about garbled output with
  existing apps in MSYS2 (which is based on cygwin) in which pseudo
  console is disabled by default.

3 years agoCygwin: pty: setup new pty on opening the master, not in constructor
Corinna Vinschen [Wed, 9 Sep 2020 20:50:11 +0000 (22:50 +0200)]
Cygwin: pty: setup new pty on opening the master, not in constructor

Setting up the pty in the master constructor ends up creating a new pty
on every stat(2) call on /dev/ptmx.  Only do this when actually opening
the device, not when using the device class in another, non-opening
context.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: pty: Fix input charset for non-cygwin apps with disable_pcon.
Takashi Yano via Cygwin-patches [Wed, 9 Sep 2020 15:28:00 +0000 (00:28 +0900)]
Cygwin: pty: Fix input charset for non-cygwin apps with disable_pcon.

- If the non-cygwin apps is executed under pseudo console disabled,
  multibyte input for the apps are garbled. This patch fixes the
  issue.

3 years agoCygwin: pty: Revise convert_mb_str() function.
Takashi Yano via Cygwin-patches [Wed, 9 Sep 2020 15:27:59 +0000 (00:27 +0900)]
Cygwin: pty: Revise convert_mb_str() function.

- Use tmp_pathbuf instead of HeapAlloc()/HeapFree().
- Remove mb_str_free() function.
- Consider the case where the multibyte string stops in the middle
  of a multibyte char.

3 years agoCygwin: document last bug fix
Ken Brown [Tue, 8 Sep 2020 18:28:19 +0000 (14:28 -0400)]
Cygwin: document last bug fix

3 years agoCygwin: path_conv::check: handle error from fhandler_process::exists
Ken Brown [Tue, 8 Sep 2020 16:23:32 +0000 (12:23 -0400)]
Cygwin: path_conv::check: handle error from fhandler_process::exists

fhandler_process::exists is called when we are checking a path
starting with "/proc/<pid>/fd".  If it returns virt_none and sets an
errno, there is no need for further checking.  Just set 'error' and
return.

3 years agoCygwin: format_process_fd: add directory check
Ken Brown [Tue, 8 Sep 2020 15:45:09 +0000 (11:45 -0400)]
Cygwin: format_process_fd: add directory check

The incoming path is allowed to have the form "$PID/fd/[0-9]*/.*"
provided the descriptor symlink points to a directory.  Check that
this is indeed the case.

3 years agoCygwin: pty: move codepage evaluation to nlsfuncs.cc
Corinna Vinschen [Tue, 8 Sep 2020 08:36:04 +0000 (10:36 +0200)]
Cygwin: pty: move codepage evaluation to nlsfuncs.cc

The new function __eval_codepage_from_internal_charset
is a simplified version of the former code in
fhandler_tty.cc.  It probably needs some extension,
but the gist is to use knowledge of internals to
be as quick as possible.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: drop internal O_NOSYMLINK and O_DIROPEN flags
Corinna Vinschen [Mon, 7 Sep 2020 20:45:38 +0000 (22:45 +0200)]
Cygwin: drop internal O_NOSYMLINK and O_DIROPEN flags

Both flags are outdated and collide with official flags in
sys/_default_fcntl.h, which may result in weird misbehaviour
of file functions.

O_NOSYMLINK is not used anyway.

O_DIROPEN is used in fhandler_virtual and derived classes.
The collision with O_NOFOLLOW results in spurious EISDIR
errors when, e. g., reading files in the registry.
fhandler_base::open_fs uses O_DIROPEN in the call to
fhandler_base::open, but it's not used in this context
further down the road.

Drop both flags and create an alternative "diropen" bool
flag in fhandler_virtual.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agolibm: Fix 'gamma' and 'gammaf' functions. Clean up other gamma code. [v2]
Keith Packard via Newlib [Fri, 4 Sep 2020 16:25:27 +0000 (09:25 -0700)]
libm: Fix 'gamma' and 'gammaf' functions. Clean up other gamma code. [v2]

The current gamma, gamma_r, gammaf and gammaf_r functions return
|gamma(x)| instead of ln(|gamma(x)|) due to a change made back in 2002
to the __ieee754_gamma_r implementation. This patch fixes that, making
all of these functions map too their lgamma equivalents.

To fix the underlying bug, the __ieee754_gamma functions have been
changed to return gamma(x), removing the _r variants as those are no
longer necessary. Their names have been changed to __ieee754_tgamma to
avoid potential confusion from users.

Now that the __ieee754_tgamma functions return the correctly signed
value, the tgamma functions have been modified to use them.

libm.a now exposes the following gamma functions:

    ln(|gamma(x)|):

__ieee754_lgamma_r
__ieee754_lgammaf_r

lgamma
lgamma_r
gamma
gamma_r

lgammaf
lgammaf_r
gammaf
gammaf_r

lgammal (on machines where long double is double)

    gamma(x):

__ieee754_tgamma
__ieee754_tgammaf
tgamma
tgammaf
tgammal (on machines where long double is double)

Additional aliases for any of the above functions can be added if
necessary; in particular, I'm not sure if we need to include
__ieee754_gamma*_r functions (which would return ln(|(gamma(x)|).

Signed-off-by: Keith Packard <keithp@keithp.com>
----

v2:
Switch commit message to ASCII

3 years agolibm/riscv: Use common fma code when necessary
Keith Packard via Newlib [Thu, 3 Sep 2020 20:54:33 +0000 (13:54 -0700)]
libm/riscv: Use common fma code when necessary

For RISC-V targets without hardware FMA support, include the
common fma implementation to provide that API.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/riscv: Fix machine-specific sqrt build process
Keith Packard via Newlib [Thu, 3 Sep 2020 20:54:32 +0000 (13:54 -0700)]
libm/riscv: Fix machine-specific sqrt build process

Like ARM, some RISC-V implementations have hardware sqrt. Support for
that can be detected at compile time, which the code did. However, the
filenames were incorrect so that both the risc-v specific and general
code were getting included in the resulting library.

Fix this by following the ARM model and #include'ing the general code
when the architecture-specific support is not available.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agoMSP430: Fix calculation of string length in sbrk.c
Jozef Lawrynowicz [Thu, 3 Sep 2020 13:00:32 +0000 (14:00 +0100)]
MSP430: Fix calculation of string length in sbrk.c

3 years agoCygwin: create install dir for libs
David McFarland via Cygwin-patches [Thu, 27 Aug 2020 12:02:46 +0000 (09:02 -0300)]
Cygwin: create install dir for libs

This fixes a race in parallel installs.

3 years agoloadlocale: don't casecmp digits
Corinna Vinschen [Fri, 4 Sep 2020 12:21:10 +0000 (14:21 +0200)]
loadlocale: don't casecmp digits

strcmp is sufficient here

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoMSP430: Fix message in sbrk.c printing binary character
Jozef Lawrynowicz [Wed, 2 Sep 2020 15:16:55 +0000 (16:16 +0100)]
MSP430: Fix message in sbrk.c printing binary character

The call to write() in sbrk.c was using the wrong value for the length
argument, causing the NUL terminating character of the string to be
printed.

3 years agoFix warnings when building for msp430-elf
Jozef Lawrynowicz [Wed, 2 Sep 2020 14:50:07 +0000 (15:50 +0100)]
Fix warnings when building for msp430-elf

The MSP430 target supports both 16-bit and 20-bit size_t and intptr_t.
Some implicit casts in Newlib expect these types to be
"long", (a 32-bit type on MSP430) which causes warnings during
compilation such as:
  "cast from pointer to integer of different size"

3 years agolibm/machine/arm: Rename s*_fma.c -> s*_fma_arm.c
Keith Packard via Newlib [Tue, 1 Sep 2020 19:49:49 +0000 (12:49 -0700)]
libm/machine/arm: Rename s*_fma.c -> s*_fma_arm.c

This is required to avoid colliding with files built from libm/common
that would end up with the same object name.

When libm.a was constructed from the individual sub-libraries, the
contents of the libm/common files would be replaced by that from
libm/machine/arm with the same name.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agoCygwin: libpthread: Export C11 thread symbols from libpthread.a as well
Corinna Vinschen [Tue, 1 Sep 2020 10:52:08 +0000 (12:52 +0200)]
Cygwin: libpthread: Export C11 thread symbols from libpthread.a as well

...as on glibc right now.  This is supposed to support autoconf scripts
checking for existence of these symbols in libpthread.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: mtx_init: drop glibc workaround
Corinna Vinschen [Tue, 1 Sep 2020 10:46:12 +0000 (12:46 +0200)]
Cygwin: mtx_init: drop glibc workaround

GLibc will change this code in the forseeable future to align more
with FreeBSD, so this hack is not actually desired.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: pty: Fix a bug in the code removing set window title sequence.
Takashi Yano via Cygwin-patches [Mon, 31 Aug 2020 12:02:13 +0000 (21:02 +0900)]
Cygwin: pty: Fix a bug in the code removing set window title sequence.

- Commit 4e08fe42c9f3fdba63a57a8e3a6d705c4e10f50f has a bug which
  may cause infinite loop in pty_master_fwd_thread(). This patch
  fixes the issue.

3 years agoCygwin: pty: Disable pseudo console if TERM does not have CSI6n.
Takashi Yano via Cygwin-patches [Mon, 31 Aug 2020 09:48:54 +0000 (18:48 +0900)]
Cygwin: pty: Disable pseudo console if TERM does not have CSI6n.

- Pseudo console internally sends escape sequence CSI6n (query cursor
  position) on startup of non-cygwin apps. If the terminal does not
  support CSI6n, CreateProcess() hangs waiting for response. To prevent
  hang, this patch disables pseudo console if the terminal does not
  have CSI6n. This is checked on the first execution of non-cygwin
  app using the following steps.
    1) Check if the terminal support ANSI escape sequences by looking
       into terminfo database. If terminfo has cursor_home (ESC [H),
       the terminal is supposed to support ANSI escape sequences.
    2) If the terminal supports ANSI escape sequneces, send CSI6n for
       a test and wait for a responce for 40ms.
    3) If there is a responce within 40ms, CSI6n is supposed to be
       supported.
  Also set-title capability is checked, and removes escape sequence
  for setting window title if the terminal does not have the set-
  title capability.

3 years agoCygwin: Remove waitloop argument from try_to_debug()
Jon Turney [Thu, 27 Aug 2020 15:12:47 +0000 (16:12 +0100)]
Cygwin: Remove waitloop argument from try_to_debug()

Currently, when using CYGWIN's error_start facility, the faulting
process isn't stopped while the error_start process is started when the
fault is caused by an exception. (it even seems possible in theory that
the faulting process could have exited before the error_start process
attaches).

This leads to e.g. the core dump written by CYGWIN='error_start=dumper'
in response to an exception being non-deterministic.

Remove the waitloop argument from try_to_debug(), only used in the
exception case, so the faulting process busy-waits until the error_start
process attaches.

Code archaeology to determine why the code is this way didn't really
turn up any answers, but this seems a low-risk change, as this only
changes the behaviour when:

 - a debugger isn't already attached
 - an error_start is specified in CYGWIN env var
 - an exception has occurred which will be translated to a signal

If error_start invokes something which doesn't attach using
DebugActiveProcess(), we will spin indefinitely, but that will also
currently occur for any of the existing other uses of try_to_debug(),
which default to waitloop=TRUE.

3 years agoCygwin: sigproc.cc: add comment
Ken Brown [Sat, 29 Aug 2020 09:59:56 +0000 (05:59 -0400)]
Cygwin: sigproc.cc: add comment

3 years agoCygwin: Add modfl fix to release notes
Corinna Vinschen [Sun, 30 Aug 2020 12:15:58 +0000 (14:15 +0200)]
Cygwin: Add modfl fix to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: crt: Add "volatile" to all inline assembly snippets under math
Martin Storsjö [Sun, 30 Aug 2020 12:12:48 +0000 (14:12 +0200)]
Cygwin: crt: Add "volatile" to all inline assembly snippets under math

On 32 bit x86, clang seems to miss loading input parameters based
on asm constraints for inline assembly that uses the x87 floating
registers, unless the snippet has got the volatile keyword.

Signed-off-by: Martin Storsjö <martin@martin.st>
3 years agoCygwin: math/modfl.c: Fix segment faults in modfl().
Liu Hao [Sun, 30 Aug 2020 11:56:31 +0000 (13:56 +0200)]
Cygwin: math/modfl.c: Fix segment faults in modfl().

Reference: https://sourceforge.net/p/mingw-w64/bugs/478/
Signed-off-by: Liu Hao <lh_mouse@126.com>
3 years agoCygwin: Add Cygwin 3.2 release info
Corinna Vinschen [Sun, 30 Aug 2020 11:30:13 +0000 (13:30 +0200)]
Cygwin: Add Cygwin 3.2 release info

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: Add C11 threads API
Corinna Vinschen [Sat, 29 Aug 2020 19:29:24 +0000 (21:29 +0200)]
Cygwin: Add C11 threads API

Code taken from FreeBSD, which implements C11 threads as
wrapper around pthreads.  Fix up machine/_threads.h which
is called from newlib's machine-independent threads.h to
match Cygwin's pthreads types.

Add the FreeBSD source files to libc subdir and take
opportunity to define LIBC_OFILES var in Makefile.

Add new symbols to common.din and sort symbols.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: make pthread_yield available for internal usage
Corinna Vinschen [Sat, 29 Aug 2020 19:21:21 +0000 (21:21 +0200)]
Cygwin: make pthread_yield available for internal usage

In preparation of importing FreeBSDs stdthreads functions,
change the way pthread_yield is exported, so that the symbol
can be used internally as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: pthread_yield: Add BSD visibility
Corinna Vinschen [Sat, 29 Aug 2020 19:09:33 +0000 (21:09 +0200)]
Cygwin: pthread_yield: Add BSD visibility

pthread_yield was only declared under GNU visibility,
but the function should be available under BSD visibility
as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: pthreads: iterate over key destructors per POSIX
Corinna Vinschen [Sat, 29 Aug 2020 19:08:31 +0000 (21:08 +0200)]
Cygwin: pthreads: iterate over key destructors per POSIX

POSIX requires that key destructors are called in a loop
for each key with a non-NULL value until all values are
NULL, or until all destructors for non-NULL values
have been called at least PTHREAD_DESTRUCTOR_ITERATIONS
(per POSIX: 4) times.

Cygwinonly called all destructors with non-NULL values
exactly once.  This patch fixes Cygwin to follow POSIX.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: Remove .drone.yml
Jon Turney [Sun, 23 Aug 2020 19:31:43 +0000 (20:31 +0100)]
Cygwin: Remove .drone.yml

tea-ci.org was a CI service for MSYS2, but is no longer operating.

3 years agoCygwin: Add github action to cross-build on Fedora
Jon Turney [Sun, 23 Aug 2020 16:49:42 +0000 (17:49 +0100)]
Cygwin: Add github action to cross-build on Fedora

This helps avoid unpleasant surprises when we come to actually make a
release (which are cross-built in this manner)

3 years agoCygwin: Add .appveyor.yml
Jon Turney [Sun, 23 Aug 2020 19:33:22 +0000 (20:33 +0100)]
Cygwin: Add .appveyor.yml

This is a slightly more polished version of the configuration being used
for CI builds at https://ci.appveyor.com/project/cygwin/cygwin, which is
not currently under version control.

3 years agoCygwin: sigproc: Fix a thinko in array size
Corinna Vinschen [Fri, 28 Aug 2020 17:38:05 +0000 (19:38 +0200)]
Cygwin: sigproc: Fix a thinko in array size

We need one more entry than max children in the arrays.
There's no reason to do this for the static array, though.
One more entry in the overflow array is sufficient.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: sigproc: Eliminate redundant copying of chld_procs
Corinna Vinschen [Fri, 28 Aug 2020 17:34:52 +0000 (19:34 +0200)]
Cygwin: sigproc: Eliminate redundant copying of chld_procs

On PROC_EXEC_CLEANUP, the pinfo's in chld_procs are removed.
This is done in a loop always removing the child with index 0.
This, however, results in copying the last child's pinfo in
chld_procs to position 0.  Do this for 100 children and you
get 99 entirely useless copy operations.

Fix this by calling remove_proc in reverse order.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: sigproc: fix minor formatting issue
Corinna Vinschen [Fri, 28 Aug 2020 13:40:16 +0000 (15:40 +0200)]
Cygwin: sigproc: fix minor formatting issue

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: select: Fix a bug on closing pi->bye event.
Takashi Yano via Cygwin-patches [Thu, 27 Aug 2020 09:46:20 +0000 (18:46 +0900)]
Cygwin: select: Fix a bug on closing pi->bye event.

- Close event handle pi->bye only if it was created.
  Addresses:
  https://cygwin.com/pipermail/cygwin-developers/2020-August/011948.html

3 years agoCygwin: sigproc: Allow more child processes per process
Corinna Vinschen [Fri, 28 Aug 2020 13:22:58 +0000 (15:22 +0200)]
Cygwin: sigproc: Allow more child processes per process

256 children per process is a bit tight in some scenarios.

Fix this by revamping the `procs' array.  Convert it to an
extensible class child_procs and rename procs to chld_procs.
Fix code throughout to use matching class methods rather than
direct access.

To allow a lot more child processes while trying to avoid
allocations at DLL startup, maintain two arrays within class
child_procs, one using a default size for 255 (i686) or 1023
(x86_64) children, the other, dynamically allocated on overflowing
the first array, giving room for another 1023 (i686) or 4095
(x86_64) processes.

On testing with a simple reproducer on a x86_64 machine with
4 Gigs RAM, a system memory overflow occured after forking
about 1450 child processes, so this simple dynamic should
suffice for a while.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: drop PROC_DETACHED_CHILD flag
Corinna Vinschen [Fri, 28 Aug 2020 09:10:48 +0000 (11:10 +0200)]
Cygwin: drop PROC_DETACHED_CHILD flag

pinfo::remember with the detach parameter set to true is
the only way to call proc_subproc with PROC_DETACHED_CHILD.
This call is exclusively used in spawn to set up a pinfo for
a detached child, and that pinfo goes out of scope right
afterwards without any further action.

Drop the flag and drop the detach parameter from pinfo::remember.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: sigproc: drop __stdcall
Corinna Vinschen [Thu, 27 Aug 2020 19:56:43 +0000 (21:56 +0200)]
Cygwin: sigproc: drop __stdcall

Nothing to gain here

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: sigproc: return int from remove_proc
Corinna Vinschen [Thu, 27 Aug 2020 19:48:54 +0000 (21:48 +0200)]
Cygwin: sigproc: return int from remove_proc

The return value is used in a numerical context and remove_proc
already returned inconsistently "true" vs. 0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: fix up proc_subproc flags and matching pinfo methods
Corinna Vinschen [Thu, 27 Aug 2020 19:38:50 +0000 (21:38 +0200)]
Cygwin: fix up proc_subproc flags and matching pinfo methods

After patch 23a779bf3d7c2afc9eab88f6b8727c1db5544547
"Cygwin: pinfo: stop remember doing reattach",
PROC_ADDCHILD actually just sets up a new child, mirroring
PROC_DETACHED_CHILD.  The actual attaching of the child is
performed by action PROC_REATTACH_CHILD or pinfo::reattach
respectively.

To better reflect what's going on, rename PROC_REATTACH_CHILD
to PROC_ATTACH_CHILD and rename pinfo::reattach to pinfo::attach.
For better readability change PROC_ADDCHILD to PROC_ADD_CHILD.
Fix comments accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: fhandler_fifo::delete_client_handler: improve efficiency
Ken Brown [Wed, 26 Aug 2020 22:21:20 +0000 (18:21 -0400)]
Cygwin: fhandler_fifo::delete_client_handler: improve efficiency

Delete a client handler by swapping it with the last one in the list
instead of calling memmove.

3 years agowinsup/doc/faq-api.xml(faq.api.timezone): explain time zone updates
Brian Inglis [Thu, 27 Aug 2020 07:17:09 +0000 (01:17 -0600)]
winsup/doc/faq-api.xml(faq.api.timezone): explain time zone updates

based on material from tz@IANA.org mailing list sources

3 years agoCygwin: console: Replace WriteConsoleA() with WriteConsoleW().
Takashi Yano via Cygwin-patches [Thu, 27 Aug 2020 03:35:03 +0000 (12:35 +0900)]
Cygwin: console: Replace WriteConsoleA() with WriteConsoleW().

- To allow sending non-ASCII chars to console, all WriteConsoleA()
  are replaced by WriteConsoleW().
  Addresses:
  https://cygwin.com/pipermail/cygwin-patches/2020q3/010476.html

3 years agodoc: Also update shebang for chapter-texi2docbook.py
Jon Turney [Tue, 25 Aug 2020 16:16:36 +0000 (17:16 +0100)]
doc: Also update shebang for chapter-texi2docbook.py

3 years agowinsup/doc/faq-api.xml, -programming.xml: change Win32 to Windows/API
Brian Inglis [Tue, 25 Aug 2020 12:57:14 +0000 (06:57 -0600)]
winsup/doc/faq-api.xml, -programming.xml: change Win32 to Windows/API

3 years agowinsup/doc/faq-setup.xml, faq-using.xml: update setup FAQ
Brian Inglis [Tue, 25 Aug 2020 12:57:13 +0000 (06:57 -0600)]
winsup/doc/faq-setup.xml, faq-using.xml: update setup FAQ

change all kinds of setup references to "the Cygwin Setup program";
emphasize 64 bit and deemphasize 32 bit;
update options list;
explain why installing everything is now extremely inadvisable, with stats

3 years agoEnabled _CS* defines for RTEMS
Eshan dhawan via Newlib [Mon, 24 Aug 2020 14:43:12 +0000 (20:13 +0530)]
Enabled _CS* defines for RTEMS

Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
3 years agodoc: Various fixes to makedocbook for python3.8 topic/fifo github/topic/fifo
Jon Turney [Sat, 22 Aug 2020 16:15:24 +0000 (17:15 +0100)]
doc: Various fixes to makedocbook for python3.8

Also update shebang to explicitly use python3, since python2 is EOL and
(per PEP 0394) 'python' may not exist at all.

3 years agoCygwin: cwdstuff::get: clean up debug_printf output
Ken Brown [Sun, 23 Aug 2020 22:41:18 +0000 (18:41 -0400)]
Cygwin: cwdstuff::get: clean up debug_printf output

Set errno = 0 at the beginning so that the debug_printf call at the
end doesn't report a nonzero errno left over from some other function
call.

3 years agoCygwin: pty: Implement new pseudo console support.
Takashi Yano [Wed, 19 Aug 2020 11:25:21 +0000 (20:25 +0900)]
Cygwin: pty: Implement new pseudo console support.

- In this implementation, pseudo console is created for each native
  console app. Advantages and disadvantages of this implementation
  over the previous implementation are as follows.

  Advantages:
  1) No performance degradation in pty output for cygwin process.
      https://cygwin.com/pipermail/cygwin/2020-February/243858.html
  2) Free from the problem caused by difference of behaviour of control
     sequences between real terminal and pseudo console.
      https://cygwin.com/pipermail/cygwin/2019-December/243281.html
      https://cygwin.com/pipermail/cygwin/2020-February/243855.html
  3) Free from the problem in cgdb and emacs gud.
      https://cygwin.com/pipermail/cygwin/2020-January/243601.html
      https://cygwin.com/pipermail/cygwin/2020-March/244146.html
  4) Redrawing screen on executing native console apps is not necessary.
  5) cygwin-console-helper is not necessary for the pseudo console
     support.
  6) The codes for pseudo console support are much simpler than that
     of the previous one.

  Disadvantages:
  1) The cygwin program which calls console API directly does not work.
  2) The apps which use console API cannot be debugged with gdb. This
     is because pseudo console is not activated since gdb uses
     CreateProcess() rather than exec(). Even with this limitation,
     attaching gdb to native apps, in which pseudo console is already
     activated, works.
  3) Typeahead key inputs are discarded while native console app is
     executed. Simirally, typeahead key inputs while cygwin app is
     executed are not inherited to native console app.
  4) Code page cannot be changed by chcp.com. Acctually, chcp works
     itself and changes code page of its own pseudo console.  However,
     since pseudo console is recreated for another process, it cannot
     inherit the code page.
  5) system_printf() does not work after stderr is closed. (Same with
     cygwin 3.0.7)
  6) Startup time of native console apps is about 3 times slower than
     previous implemenation.
  7) Pseudo console cannot be activated if it is already activated for
     another process on same pty.

3 years agoCygwin: bump version to 3.2.0
Corinna Vinschen [Sat, 22 Aug 2020 11:43:46 +0000 (13:43 +0200)]
Cygwin: bump version to 3.2.0

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: strace: ignore GCC exceptions cygwin-3_1_7-release
Ken Brown [Thu, 20 Aug 2020 13:47:47 +0000 (09:47 -0400)]
Cygwin: strace: ignore GCC exceptions

Any C++ app that calls 'throw' on 64-bit Cygwin results in an
exception of type STATUS_GCC_THROW (0x20474343) generated by the C++
runtime.  Don't pollute the strace output by printing information
about this and other GCC exceptions.

3 years agoCygwin: add header defining GCC exception codes
Ken Brown [Thu, 20 Aug 2020 14:35:43 +0000 (10:35 -0400)]
Cygwin: add header defining GCC exception codes

Include it in exceptions.cc instead of defining the exception codes
there.

3 years agoCygwin: main exception handler (64-bit): continue GCC exceptions
Ken Brown [Mon, 17 Aug 2020 20:24:59 +0000 (16:24 -0400)]
Cygwin: main exception handler (64-bit): continue GCC exceptions

This is necessary in order to be consistent with the following comment
in the definition of _Unwind_RaiseException() in the GCC source file
libgcc/unwind-seh.c:

     The exception handler installed in crt0 will continue any GCC
     exception that reaches there (and isn't marked non-continuable).

Previously we failed to do this and, as a consequence, the C++ runtime
didn't call std::terminate after an unhandled exception.

This fixes the problem reported here:

  https://cygwin.com/pipermail/cygwin/2019-October/242795.html
  https://sourceware.org/pipermail/cygwin/2020-August/245897.html

3 years agolibm/stdlib: Realloc when shrinking by 2* or more
Keith Packard via Newlib [Fri, 14 Aug 2020 00:19:02 +0000 (17:19 -0700)]
libm/stdlib: Realloc when shrinking by 2* or more

This reduces memory usage when reallocating objects much smaller.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/stdlib: don't read past source in nano_realloc
Keith Packard via Newlib [Fri, 14 Aug 2020 00:19:01 +0000 (17:19 -0700)]
libm/stdlib: don't read past source in nano_realloc

Save the computed block size and use it to avoid reading past
the end of the source block.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agoCygwin: pty: Change the timing of set_locale() call again.
Takashi Yano via Cygwin-patches [Sat, 15 Aug 2020 03:23:52 +0000 (12:23 +0900)]
Cygwin: pty: Change the timing of set_locale() call again.

- After commit 095972ce5b1d319915501a7e381802914bed790c, charset
  conversion in mintty is broken if charset is set to other than
  UTF-8. This seems to be caused because mintty does not set locale
  yet at fork() call. This patch changes the timing of set_locale()
  call again to avoid this issue.

3 years agoCygwin: pty: Change the timing of setup_locale() call.
Takashi Yano via Cygwin-patches [Thu, 13 Aug 2020 05:42:20 +0000 (14:42 +0900)]
Cygwin: pty: Change the timing of setup_locale() call.

- If native app is exec()'ed in a new pty, setup_locale() loses the
  chance to be called. For example, with "mintty -e cmd", charset
  conversion does not work as expected. This patch fixes the issue.

3 years agolibc/stdlib: Fix build failure in nano_calloc
Craig Blackmore [Wed, 12 Aug 2020 14:33:23 +0000 (15:33 +0100)]
libc/stdlib: Fix build failure in nano_calloc

commit 588a5e1ddebdf6d74391c7409680ea20e050c0e1 added a non-reentrant
call to nano_malloc which causes a build failure if INTERNAL_NEWLIB is
defined.

Here is a snippet of the error:

In file included from .../newlib/newlib/libc/stdlib/nano-mallocr.c:38:
.../newlib/newlib/libc/include/malloc.h:42:25: note: expected 'struct _reent *' but argument is of type 'ptrdiff_t' {aka 'int'}
   42 | extern void *_malloc_r (struct _reent *, size_t);
      |                         ^~~~~~~~~~~~~~~
.../newlib/newlib/libc/stdlib/nano-mallocr.c:67:22: error: too few arguments to function '_malloc_r'
   67 | #define nano_malloc  _malloc_r
      |                      ^~~~~~~~~
.../newlib/newlib/libc/stdlib/nano-mallocr.c:456:11: note: in expansion of macro 'nano_malloc'
  456 |     mem = nano_malloc(bytes);
      |           ^~~~~~~~~~~
In file included from .../newlib/newlib/libc/stdlib/nano-mallocr.c:38:
.../newlib/newlib/libc/include/malloc.h:42:14: note: declared here
   42 | extern void *_malloc_r (struct _reent *, size_t);
      |              ^~~~~~~~~
.../newlib/newlib/libc/stdlib/nano-mallocr.c:43: warning: "assert" redefined
   43 | #define assert(x) ((void)0)
      |

This patch adds a missing RCALL to the args when calling nano_malloc
from nano_calloc, so that if the call is reentrant, reent_ptr is passed
as the first argument.

The variable `bytes` (also added in 588a5e1d) has been changed from a
`ptrdiff_t` to `malloc_size_t` as it does not need to be signed. It is
used to store the product of two unsigned malloc_size_t variables and
then iff there was no overflow is it passed to malloc and memset which
both expect size_t which is unsigned.

Signed-off-by: Craig Blackmore <craig.blackmore@embecosm.com>
3 years agolibc/stdlib: Use __builtin_mul_overflow for reallocarray and calloc
Keith Packard via Newlib [Tue, 11 Aug 2020 23:05:40 +0000 (16:05 -0700)]
libc/stdlib: Use __builtin_mul_overflow for reallocarray and calloc

This built-in function (available in both gcc and clang) is more
efficient and generates shorter code than open-coding the test.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/machine/riscv: Add custom fma/sqrt functions when supported [v2]
Keith Packard via Newlib [Wed, 12 Aug 2020 02:47:17 +0000 (19:47 -0700)]
libm/machine/riscv: Add custom fma/sqrt functions when supported [v2]

Check for HW FMA and SQRT support and use those instructions in place
of software implementations.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agoCygwin: pty: Add a workaround for issue of starting a lot of mintty.
Takashi Yano [Tue, 11 Aug 2020 04:16:52 +0000 (13:16 +0900)]
Cygwin: pty: Add a workaround for issue of starting a lot of mintty.

- If a lot of mintty are started in a short time from a mintty, some
  of them hang with empty screen, crash immediately or hang on exiting
  mintty. The following report seems to be related to this issue.
    https://cygwin.com/pipermail/cygwin/2020-August/245751.html
  The cause is not clear at all, but this patch seems to solve the
  issue.

3 years agolibm/machine/arm: Add optimized fmaf and fma when available
Keith Packard via Newlib [Sat, 8 Aug 2020 22:34:13 +0000 (15:34 -0700)]
libm/machine/arm: Add optimized fmaf and fma when available

When HAVE_FAST_FMAF is set, use the vfma.f32 instruction, when
HAVE_FAST_FMA is set, use the vfma.f64 instruction.

Usually the compiler built-ins will already have inlined these
instructions, but provide these symbols for cases where that doesn't
work instead of falling back to the (inaccurate) common code versions.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm: Detect fast fmaf support
Keith Packard via Newlib [Sat, 8 Aug 2020 22:34:12 +0000 (15:34 -0700)]
libm: Detect fast fmaf support

Anything with fast FMA is assumed to have fast FMAF, along with
32-bit arms that advertise 32-bit FP support and __ARM_FEATURE_FMA

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm: ARM without HW double does not have fast FMA
Keith Packard via Newlib [Sat, 8 Aug 2020 22:34:11 +0000 (15:34 -0700)]
libm: ARM without HW double does not have fast FMA

32-bit ARM processors with HW float (but not HW double) may define
__ARM_FEATURE_FMA, but that only means they have fast FMA for 32-bit
floats.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/math: ensure that expf(-huge) sets FE_UNDERFLOW exception
Keith Packard via Newlib [Sat, 8 Aug 2020 05:40:21 +0000 (22:40 -0700)]
libm/math: ensure that expf(-huge) sets FE_UNDERFLOW exception

It was calling __math_uflow(0) instead of __math_uflowf(0), which
resulted in no exception being set on machines with exception support
for float but not double.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agoCygwin: cygserver: build with -Wimplicit-fallthrough=5
Ken Brown [Fri, 7 Aug 2020 13:48:28 +0000 (09:48 -0400)]
Cygwin: cygserver: build with -Wimplicit-fallthrough=5

Define the pseudo keyword 'fallthrough' in woutsup.h to support this.

3 years agoCygwin: Use documented QueryWorkingSetEx() in dumper
Jon Turney [Wed, 29 Jul 2020 14:19:13 +0000 (15:19 +0100)]
Cygwin: Use documented QueryWorkingSetEx() in dumper

In dumper, use the documented QueryWorkingSetEx(), rather than the
undocumented NtQueryVirtualMemory() with MemoryWorkingSetExInformation.

3 years agoMSP430: Increase the amount of main memory available in sim ld scripts
Jozef Lawrynowicz [Fri, 7 Aug 2020 10:49:54 +0000 (11:49 +0100)]
MSP430: Increase the amount of main memory available in sim ld scripts

The main memory region of the GDB simulator ends at address 0xFFBF,
but the simulator linker scripts do not make full use of this available
memory.

>From 61f3d212741acee583e21ff2c2808775584ecad6 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Mon, 3 Aug 2020 19:38:23 +0100
Subject: [PATCH 2/2] MSP430: Increase the amount of main memory available in
 sim ld scripts

The main memory region of the GDB simulator ends at address 0xFFBF,
but the simulator linker scripts do not make full use of this available
memory.

3 years agoMSP430: Word align __*_array_start symbols in sim linker scripts
Jozef Lawrynowicz [Fri, 7 Aug 2020 10:48:27 +0000 (11:48 +0100)]
MSP430: Word align __*_array_start symbols in sim linker scripts

__{preinit,init,fini}_array_start symbols must be word aligned in
linker scripts. If the section preceding the __*_array_start symbol
has an odd size, then a NULL byte will be present between the start
symbol and the .*_array section itself, when the section gets
automatically word-aligned.

This results in a branch to an invalid address when the CRT startup
code tries to run through the functions listed in the array sections.

>From de115144d05ecbaa82c9c737cc261715ca4b7d67 Mon Sep 17 00:00:00 2001
From: Jozef Lawrynowicz <jozef.l@mittosystems.com>
Date: Mon, 3 Aug 2020 19:09:46 +0100
Subject: [PATCH 1/2] MSP430: Word align __*_array_start symbols in sim linker
 scripts

__{preinit,init,fini}_array_start symbols must be word aligned in
linker scripts. If the section preceding the __*_array_start symbol
has an odd size, then a NULL byte will be present between the start
symbol and the .*_array section itself, when the section gets
automatically word-aligned.

This results in a branch to an invalid address when the CRT startup
code tries to run through the functions listed in the array sections.

3 years agoCygwin: cygserver: build with -Wimplicit-fallthrough=4 -Werror
Corinna Vinschen [Fri, 7 Aug 2020 10:33:38 +0000 (12:33 +0200)]
Cygwin: cygserver: build with -Wimplicit-fallthrough=4 -Werror

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: utils: build with -Wimplicit-fallthrough=4 -Werror
Corinna Vinschen [Fri, 7 Aug 2020 11:31:38 +0000 (13:31 +0200)]
Cygwin: utils: build with -Wimplicit-fallthrough=4 -Werror

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: utils: convert usage() to proper noreturn function throughout
Corinna Vinschen [Fri, 7 Aug 2020 11:29:43 +0000 (13:29 +0200)]
Cygwin: utils: convert usage() to proper noreturn function throughout

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: utils: cygcheck: avoid GCC warning concatenating strings
Corinna Vinschen [Fri, 7 Aug 2020 11:30:40 +0000 (13:30 +0200)]
Cygwin: utils: cygcheck: avoid GCC warning concatenating strings

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: utils: refresh tzmap
Corinna Vinschen [Fri, 7 Aug 2020 10:09:02 +0000 (12:09 +0200)]
Cygwin: utils: refresh tzmap

- update path to Unicode windowsZones.xml file
- drop Windows XP considerations
- regenerate tzmap.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agolibm: Control errno support with _IEEE_LIBM configuration parameter
Keith Packard via Newlib [Tue, 4 Aug 2020 22:22:24 +0000 (15:22 -0700)]
libm: Control errno support with _IEEE_LIBM configuration parameter

This removes the run-time configuration of errno support present in
portions of the math library and unifies all of the compile-time errno
configuration under a single parameter so that the whole library
is consistent.

The run-time support provided by _LIB_VERSION is no longer present in
the public API, although it is still used internally to disable errno
setting in some functions. Now that it is a constant, the compiler should
remove that code when errno is not supported.

This removes s_lib_ver.c as _LIB_VERSION is no longer variable.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/math: Don't modify __ieee754_pow return values in pow
Keith Packard via Newlib [Tue, 4 Aug 2020 22:22:23 +0000 (15:22 -0700)]
libm/math: Don't modify __ieee754_pow return values in pow

The __ieee754 functions already return the right value in exception
cases, so don't modify those. Setting the library to _POSIX_/_IEEE_
mode now only affects whether errno is modified.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/math: Set errno to ERANGE for pow(0, -y)
Keith Packard via Newlib [Tue, 4 Aug 2020 22:22:22 +0000 (15:22 -0700)]
libm/math: Set errno to ERANGE for pow(0, -y)

POSIX says that the errno for pow(0, -y) should be ERANGE instead of
EDOM.

https://pubs.opengroup.org/onlinepubs/9699919799/functions/pow.html

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/math: Make yx functions set errno=ERANGE for x=0
Keith Packard via Newlib [Tue, 4 Aug 2020 22:22:21 +0000 (15:22 -0700)]
libm/math: Make yx functions set errno=ERANGE for x=0

The y0, y1 and yn functions need separate conditions when x is zero as
that returns ERANGE instead of EDOM.

Also stop adjusting the return value from the __ieee754_y* functions
as that is already correct and we were just breaking it.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/math: set errno to ERANGE at gamma poles
Keith Packard via Newlib [Tue, 4 Aug 2020 22:22:20 +0000 (15:22 -0700)]
libm/math: set errno to ERANGE at gamma poles

For POSIX, gamma(i) (i non-positive integer) should set errno to
ERANGE instead of EDOM.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agoCygwin: Add 'fallthrough' pseudo keyword for switch/case use
Corinna Vinschen [Wed, 5 Aug 2020 19:58:22 +0000 (21:58 +0200)]
Cygwin: Add 'fallthrough' pseudo keyword for switch/case use

This patch has been inspired by the Linux kernel patch

  294f69e662d1 compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use

written by Joe Perches <joe AT perches DOT com> based on an idea from
Dan Carpenter <dan DOT carpenter AT oracle DOT com>.  The following text
is from the original log message:

Reserve the pseudo keyword 'fallthrough' for the ability to convert the
various case block /* fallthrough */ style comments to appear to be an
actual reserved word with the same gcc case block missing fallthrough
warning capability.

All switch/case blocks now should end in one of:

break;
fallthrough;
goto <label>;
return [expression];
continue;

In C mode, GCC supports the __fallthrough__ attribute since 7.1,
the same time the warning and the comment parsing were introduced.

Cygwin-only: add an explicit -Wimplicit-fallthrough=5 to the build
flags.

3 years agoCygwin: Fix missing breaks in switch statement
Corinna Vinschen [Wed, 5 Aug 2020 19:46:53 +0000 (21:46 +0200)]
Cygwin: Fix missing breaks in switch statement

Two switch statements in sysconf() and
fhandler_fifo::take_ownership were missing breaks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agolibm: Set math_errhandling to match library and hardware [v2]
Keith Packard via Newlib [Tue, 4 Aug 2020 15:04:39 +0000 (08:04 -0700)]
libm: Set math_errhandling to match library and hardware [v2]

math_errhandling is specified to contain two bits of information:

 1. MATH_ERRNO     -- Set when the library sets errno
 2. MATH_ERREXCEPT -- Set when math operations report exceptions

MATH_ERRNO should match whether the original math code is compiled in
_IEEE_LIBM mode and the new math code has WANT_ERRNO == 1.

MATH_ERREXCEPT should match whether the underlying hardware has
exception support. This patch adds configurations of this value for
RISC-V, ARM, Aarch64, x86 and x86_64 when using HW float.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agolibm/common: Set WANT_ERRNO based on _IEEE_LIBM value
Keith Packard via Newlib [Mon, 3 Aug 2020 17:55:03 +0000 (10:55 -0700)]
libm/common: Set WANT_ERRNO based on _IEEE_LIBM value

_IEEE_LIBM is the configuration value which controls whether the
original libm functions modify errno. Use that in the new math code as
well so that the resulting library is internally consistent.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agoCygwin: FIFO: add a third pass to raw_read
Ken Brown [Mon, 3 Aug 2020 13:44:31 +0000 (09:44 -0400)]
Cygwin: FIFO: add a third pass to raw_read

Currently raw_read makes two passes through the list of clients.  On
the first pass it tries to read from the client from which it last
read successfully.  On the second pass it tries to read from all
connected clients.

Add a new pass in between these two, in which raw_read tries to read
from all clients that are in the fc_input_avail case.  This should be
more efficient in case select was previously called and detected input
available.

Slightly tweak the first pass.  If a client is marked as having the
last successful read but reading from it now finds no input, don't
unmark it unless we successfully read from a different client on one
of the later passes.

3 years agoCygwin: FIFO: fix indentation
Ken Brown [Mon, 3 Aug 2020 13:43:36 +0000 (09:43 -0400)]
Cygwin: FIFO: fix indentation

3 years agoCygwin: FIFO: synchronize the fifo_reader and fifosel threads
Ken Brown [Mon, 3 Aug 2020 13:38:08 +0000 (09:38 -0400)]
Cygwin: FIFO: synchronize the fifo_reader and fifosel threads

The fifo_reader thread function and the function select.cc:peek_fifo()
can both change the state of a fifo_client_handler.  These changes are
made under fifo_client_lock, so there is no race, but the changes can
still be incompatible.

Add code to make sure that only one of these functions can change the
state from its initial fc_listening state.  Whichever function does
this calls the fhandler_fifo::record_connection method, which is now
public so that peek_fifo can call it.

Slightly modify that method to make it suitable for being called by
peek_fifo.

Make a few other small changes to the fifo_reader thread function to
change how it deals with the STATUS_PIPE_CLOSING value that can
(rarely) be returned by NtFsControlFile.

Add commentary to fhandler_fifo.cc to explain fifo_client connect
states and where they can be changed.

3 years agoCygwin: FIFO: don't read from pipes that are closing
Ken Brown [Mon, 3 Aug 2020 13:35:00 +0000 (09:35 -0400)]
Cygwin: FIFO: don't read from pipes that are closing

Don't try to read from fifo_client_handlers that are in the fc_closing
state.  Experiments have shown that this always yields
STATUS_PIPE_BROKEN, so it just wastes a Windows system call.

Re-order the values in enum fifo_client_connect_state to reflect the
new status of fc_closing.

3 years agoCygwin: FIFO: reorganize some fifo_client_handler methods
Ken Brown [Mon, 3 Aug 2020 13:32:30 +0000 (09:32 -0400)]
Cygwin: FIFO: reorganize some fifo_client_handler methods

Rename the existing set_state() to query_and_set_state() to reflect
what it really does.  (It queries the O/S for the pipe state.)  Add a
new set_state() method, which is a standard setter, and a
corresponding getter get_state().

3 years agoCygwin: FIFO: add a timeout to take_ownership
Ken Brown [Mon, 3 Aug 2020 13:17:06 +0000 (09:17 -0400)]
Cygwin: FIFO: add a timeout to take_ownership

fhandler_fifo::take_ownership() is called from select.cc::peek_fifo
and fhandler_fifo::raw_read and could potentially block indefinitely
if something goes wrong.  This is always undesirable in peek_fifo, and
it is undesirable in a nonblocking read.  Fix this by adding a timeout
parameter to take_ownership.

Arbitrarily use a 1 ms timeout in peek_fifo and a 10 ms timeout in
raw_read.  These numbers may have to be tweaked based on experience.

Replace the call to cygwait in take_ownership by a call to WFSO.
There's no need to allow interruption now that we have a timeout.

3 years agoCygwin: FIFO: fix timing issue with owner change
Ken Brown [Sun, 2 Aug 2020 20:38:24 +0000 (16:38 -0400)]
Cygwin: FIFO: fix timing issue with owner change

fhandler_fifo::take_ownership() tacitly assumes that the current
owner's fifo_reader_thread will be woken up from WFMO when
update_needed_evt is signaled.  But it's possible that the the current
owner's fifo_reader_thread is at the beginning of its main loop rather
than in its WFMO call when that event is signaled.

In this case the owner will never see that the event has been
signaled, and it will never update the shared fifo_client_handlers.
The reader that wants to take ownership will then spin its wheels
forever.

Fix this by having the current owner call update_shared_handlers at
the beginning of its loop, if necessary.

3 years agoCygwin: FIFO: lock fixes
Ken Brown [Fri, 31 Jul 2020 17:55:17 +0000 (13:55 -0400)]
Cygwin: FIFO: lock fixes

Add some missing locks and remove one extra unlock.  Clarify for some
functions whether caller or callee acquires lock, and add appropriate
comments.

3 years agofhandler_proc.cc(format_proc_cpuinfo): use _small_sprintf %X for microcode
Brian Inglis [Tue, 4 Aug 2020 06:51:56 +0000 (00:51 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): use _small_sprintf %X for microcode

microcode is unsigned long long, printed by _small_sprintf using %x;
Cygwin32 used last 4 bytes of microcode for next field MHz, printing 0;
use correct _small_sprintf format %X to print microcode, producing
correct MHz value under Cygwin32

3 years agofhandler_proc.cc(format_proc_cpuinfo): add SERIALIZE instruction flag
Brian Inglis [Mon, 3 Aug 2020 16:22:46 +0000 (10:22 -0600)]
fhandler_proc.cc(format_proc_cpuinfo): add SERIALIZE instruction flag

CPUID 7:0 EDX[14] serialize added in linux-next 5.8 by Ricardo Neri-Calderon:
The Intel architecture defines a set of Serializing Instructions (a
detailed definition can be found in Vol.3 Section 8.3 of the Intel "main"
manual, SDM). However, these instructions do more than what is required,
have side effects and/or may be rather invasive. Furthermore, some of
these instructions are only available in kernel mode or may cause VMExits.
Thus, software using these instructions only to serialize execution (as
defined in the manual) must handle the undesired side effects.

As indicated in the name, SERIALIZE is a new Intel architecture
Serializing Instruction. Crucially, it does not have any of the mentioned
side effects. Also, it does not cause VMExit and can be used in user mode.

This new instruction is currently documented in the latest "extensions"
manual (ISE). It will appear in the "main" manual in the future.

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/arch/x86/include/asm/cpufeatures.h?id=85b23fbc7d88f8c6e3951721802d7845bc39663d

3 years agolibm/math: Use __math_xflow in obsolete math code [v2]
Keith Packard [Thu, 30 Jul 2020 23:41:05 +0000 (16:41 -0700)]
libm/math: Use __math_xflow in obsolete math code [v2]

C compilers may fold const values at compile time, so expressions
which try to elicit underflow/overflow by performing simple
arithemetic on suitable values will not generate the required
exceptions.

Work around this by replacing code which does these arithmetic
operations with calls to the existing __math_xflow functions that are
designed to do this correctly.

Signed-off-by: Keith Packard <keithp@keithp.com>
----

v2:
libm/math: Pass sign to __math_xflow instead of muliplying result

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