]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
2 years agoCygwin: pipes: create pipes with synchronization enabled
Corinna Vinschen [Fri, 3 Sep 2021 08:32:30 +0000 (10:32 +0200)]
Cygwin: pipes: create pipes with synchronization enabled

This isn't used by Cygwin, but it might be used by Win32 processes
inheriting the handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: pipes: use NtClose when file has been opened with an NtXxx function
Corinna Vinschen [Fri, 3 Sep 2021 08:31:27 +0000 (10:31 +0200)]
Cygwin: pipes: use NtClose when file has been opened with an NtXxx function

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: pipes: always close read side pipe handle in error case
Corinna Vinschen [Fri, 3 Sep 2021 08:25:29 +0000 (10:25 +0200)]
Cygwin: pipes: always close read side pipe handle in error case

Add missing CloseHandle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: pipes: fix a bug in raw_write
Corinna Vinschen [Fri, 3 Sep 2021 08:24:15 +0000 (10:24 +0200)]
Cygwin: pipes: fix a bug in raw_write

The buffer pointer is incremented by "chunk", which is what we
typically try to write, but this isn't what actually got written.
Increment the buffer pointer by what we actually wrote, as returned
by NtWriteFile.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: move get_obj_handle_count() to miscfuncs.cc
Corinna Vinschen [Fri, 3 Sep 2021 08:15:57 +0000 (10:15 +0200)]
Cygwin: move get_obj_handle_count() to miscfuncs.cc

get_obj_handle_count() is used in flock only so far, but pipe
handling might have a usage, too, soon.  Given that this function
might be generally useful and isn't restricted to flock usage,
move it to miscfuncs.cc and make it non-static.  Add a prototype
in miscfuncs.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: _pipe: add a comment
Corinna Vinschen [Tue, 31 Aug 2021 08:50:23 +0000 (10:50 +0200)]
Cygwin: _pipe: add a comment

I wasted valuable minutes of my life just to find out why we export
this weird version of pipe.  In the pre-2000 era the idea was Cygwin
could be used as drop-in replacement for msvcrt.dll, apparently.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoRevert "Cygwin: fhandler_pipe.cc:nt_select: fix flags"
Corinna Vinschen [Tue, 31 Aug 2021 09:39:52 +0000 (11:39 +0200)]
Revert "Cygwin: fhandler_pipe.cc:nt_select: fix flags"

This reverts commit a62f4d128505481c4c683e813a3b16da641af6ff.

2 years agoRevert "Cygwin: fhandler_pipe.cc:nt_select: fix flags again"
Corinna Vinschen [Tue, 31 Aug 2021 09:39:49 +0000 (11:39 +0200)]
Revert "Cygwin: fhandler_pipe.cc:nt_select: fix flags again"

This reverts commit c35db324efb5cdc6605eac947e0d4fdeb45e8b43.

2 years agoCygwin: fhandler_pipe.cc:nt_select: fix flags again
Ken Brown [Mon, 30 Aug 2021 15:54:04 +0000 (11:54 -0400)]
Cygwin: fhandler_pipe.cc:nt_select: fix flags again

2 years agoCygwin: fhandler_pipe.cc:nt_select: fix flags
Ken Brown [Mon, 30 Aug 2021 15:11:49 +0000 (11:11 -0400)]
Cygwin: fhandler_pipe.cc:nt_select: fix flags

2 years agoRevert "Cygwin: pipe: Revert to create() rather than nt_create()."
Ken Brown [Mon, 30 Aug 2021 13:53:06 +0000 (09:53 -0400)]
Revert "Cygwin: pipe: Revert to create() rather than nt_create()."

This reverts commit 5a7a0d34c74a55aa1e76644e61bf4889051cb640.

2 years agoCygwin: pipe: Revert to create() rather than nt_create().
Takashi Yano [Sun, 29 Aug 2021 08:23:57 +0000 (17:23 +0900)]
Cygwin: pipe: Revert to create() rather than nt_create().

2 years agoCygwin: select: Improve select/poll response.
Takashi Yano [Fri, 27 Aug 2021 10:54:41 +0000 (19:54 +0900)]
Cygwin: select: Improve select/poll response.

2 years agoCygwin: add fhandler_base::npfs_handle
Ken Brown [Thu, 26 Aug 2021 22:05:53 +0000 (18:05 -0400)]
Cygwin: add fhandler_base::npfs_handle

It replaces the three identical functions of the same name in the
classes fhandler_pipe, fhandler_fifo, and fhandler_socket_unix.

2 years agoCygwin: remove the fhandler_base_overlapped class
Ken Brown [Thu, 26 Aug 2021 22:00:27 +0000 (18:00 -0400)]
Cygwin: remove the fhandler_base_overlapped class

Also remove the 'was_nonblocking' flag, which was needed only for
fhandler_base_overlapped.

2 years agoCygwin: fhandler_pipe: fix permission problem
Ken Brown [Sat, 25 May 2019 14:27:38 +0000 (10:27 -0400)]
Cygwin: fhandler_pipe: fix permission problem

The read handles of pipes created by CreateNamedPipe don't have
FILE_WRITE_ATTRIBUTES access unless the pipe is created with
PIPE_ACCESS_DUPLEX.  This causes set_pipe_non_blocking to fail on such
handles.  To fix this, add a helper function nt_create, which uses
NtCreateNamedPipeFile instead of CreateNamedPipe and gives us more
flexibility in setting access rights.

Use this helper function in fhandler_pipe::create (fhandler_pipe *[2],
unsigned, int), which is the version of fhandler_pipe::create used by
the pipe and pipe2 system calls.

For convenience, also add a static member function
fhandler_pipe::npfs_handle similar to those used by fhandler_fifo and
fhandler_socket_unix.

2 years agoCygwin: fhandler_pipe: control blocking mode of the Windows pipe
Ken Brown [Sat, 25 May 2019 17:05:49 +0000 (13:05 -0400)]
Cygwin: fhandler_pipe: control blocking mode of the Windows pipe

Add methods 'set_pipe_non_blocking' and 'fcntl' to keep the blocking
mode of the Windows pipe in sync with that of the fhandler_pipe
object.  This applies to pipes created with the 'pipe' and 'pipe2'
system calls.

2 years agoCygwin: fhandler_pipe: add raw_read and raw_write
Ken Brown [Sat, 25 May 2019 17:03:08 +0000 (13:03 -0400)]
Cygwin: fhandler_pipe: add raw_read and raw_write

2 years agoCygwin: fhandler_pipe: derive from fhandler_base
Ken Brown [Thu, 26 Aug 2021 20:57:21 +0000 (16:57 -0400)]
Cygwin: fhandler_pipe: derive from fhandler_base

Previously fhandler_pipe was derived from fhandler_base_overlapped,
which we are going to remove in a future commit.  Make minimal changes
so that the build still succeeds.

2 years agoRegenerate Makefile.in after configure.in -> configure.ac change
Corinna Vinschen [Mon, 13 Sep 2021 15:25:46 +0000 (17:25 +0200)]
Regenerate Makefile.in after configure.in -> configure.ac change

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoAdd myself to sim & general write-after-approval maintainers
Mike Frysinger [Sat, 11 Sep 2021 21:52:38 +0000 (17:52 -0400)]
Add myself to sim & general write-after-approval maintainers

There are a few files that are tied to the GNU simulator, so add myself
to match the general sim project.

Also add myself to the general write-after-approval since I've been doing
that for a long time now anyways :).

2 years agolibgloss/newlib: rename configure.in to configure.ac
Mike Frysinger [Thu, 9 Sep 2021 20:49:49 +0000 (16:49 -0400)]
libgloss/newlib: rename configure.in to configure.ac

The .in name has been deprecated for a long time in favor of .ac.

2 years agoCygwin: fix initializing MEM_EXTENDED_PARAMETER, take 2
Corinna Vinschen [Wed, 8 Sep 2021 08:07:46 +0000 (10:07 +0200)]
Cygwin: fix initializing MEM_EXTENDED_PARAMETER, take 2

In https://cygwin.com/pipermail/cygwin/2021-September/249361.html
Brian pointed out that initializing the structure would be more
future proof, should the developers at Microsoft ever decide to
split the Reserved field and use some bits of the struct for
other purposes.

Fixes: 3d322ac930ca ("Cygwin: fix initializing MEM_EXTENDED_PARAMETER")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: pty: Fix error handling of master write().
Takashi Yano [Tue, 7 Sep 2021 10:27:45 +0000 (19:27 +0900)]
Cygwin: pty: Fix error handling of master write().

- Currently, error handling of write() in pty master side is broken.
  This patch fixes that.

2 years agonano-malloc: Fix redefined compilation warning
Torbjorn SVENSSON via Newlib [Fri, 3 Sep 2021 15:54:10 +0000 (15:54 +0000)]
nano-malloc: Fix redefined compilation warning

When newlib is configured with --enable-newlib-reent-check-verify,
the assert macro is already defined in the nano-mallocr.c compile unit.

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@st.com>
2 years agoCygwin: fix initializing MEM_EXTENDED_PARAMETER
Corinna Vinschen [Mon, 6 Sep 2021 18:15:43 +0000 (20:15 +0200)]
Cygwin: fix initializing MEM_EXTENDED_PARAMETER

MEM_EXTENDED_PARAMETER consists of a 64 bit bitfield which contains
the Type and the Reserved members.  The former usage of designated
initializer lists initialized Type, but not Reserved.  Since that's
not possible anymore due to a g++ 11.2 bug, Cygwin initializes the
MEM_EXTENDED_PARAMETER structs explicitely.  This results in a
random value in Reserved, which at least VirtualAlloc2 chokes on
(ERROR_INVALID_PARAMETER).

Set Reserved explicitely to 0 for a fix.

Fixes: bdb7991db38b ("Cygwin: workaround a g++ 11.2 initialization bug")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: fix declaration of RtlInitEmptyUnicodeString
Corinna Vinschen [Fri, 3 Sep 2021 11:16:48 +0000 (13:16 +0200)]
Cygwin: fix declaration of RtlInitEmptyUnicodeString

This avoids "-Werror=maybe-uninitialized" errors due to
using WCSTR accidentally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoldexp/ldexpf: avoid assembler warning
Corinna Vinschen [Fri, 3 Sep 2021 10:52:47 +0000 (12:52 +0200)]
ldexp/ldexpf: avoid assembler warning

libm/machine/i386/f_ldexp.S:30: Warning: no instruction mnemonic suffix given and no register operands; using default for `fild'
libm/machine/i386/f_ldexpf.S:30: Warning: no instruction mnemonic suffix given and no register operands; using default for `fild'

fix this by adding the l mnemonic suffix

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agostrstr: avoid warnings
Corinna Vinschen [Fri, 3 Sep 2021 10:51:30 +0000 (12:51 +0200)]
strstr: avoid warnings

unused function warning for two_way_short_needle,
different char type warnings for standard string functions

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agonftw: fix thread cancellation support
Corinna Vinschen [Fri, 3 Sep 2021 10:25:44 +0000 (12:25 +0200)]
nftw: fix thread cancellation support

_STDIO_WITH_THREAD_CANCELLATION_SUPPORT was never defined.
Include ../stdio/local.h to get the right definition per target.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: testsuite: avoid "conflicting types" gcc warning
Corinna Vinschen [Fri, 3 Sep 2021 10:13:51 +0000 (12:13 +0200)]
Cygwin: testsuite: avoid "conflicting types" gcc warning

With gcc 11.2:

test.h:50:5: warning: conflicting types for built-in function ‘execve’; expected ‘int(const char *, char * const*)’ [-Wbuiltin-declaration-mismatch]
test.h:51:5: warning: conflicting types for built-in function ‘execv’; expected ‘int(const char *, char * const*)’ [-Wbuiltin-declaration-mismatch]
test.h:52:5: warning: conflicting types for built-in function ‘execvp’; expected ‘int(const char *, char * const*)’ [-Wbuiltin-declaration-mismatch]

Fix prototypes accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: dup: fix handle inheritence for disk file pread/pwrite handle
Corinna Vinschen [Mon, 30 Aug 2021 19:56:33 +0000 (21:56 +0200)]
Cygwin: dup: fix handle inheritence for disk file pread/pwrite handle

The handle is created non-inheritable but gets inheritable when
dup'ing the file descriptor.  Fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agolibc/include/sys/signal.h: Change __STDINT_EXP() to __SIZEOF_INT__
Joel Sherrill [Fri, 27 Aug 2021 13:39:31 +0000 (08:39 -0500)]
libc/include/sys/signal.h: Change __STDINT_EXP() to __SIZEOF_INT__

__STDINT_EXP() is provided by newlib but not by stdint-gcc.h. stdint-gcc.h
is used when the GCC argument -ffreestanding is used and this results in this
file not compiling.

2 years agoCygwin: loader script: add DWARF 5 sections
Corinna Vinschen [Fri, 27 Aug 2021 12:26:42 +0000 (14:26 +0200)]
Cygwin: loader script: add DWARF 5 sections

Modern gcc's generate additional DWARF 5 debug sections, which were
still missing in our Cygwin loader script.  With ld from binutils 2.37,
this results in diagnostic output when linking the Cygwin DLL...

  ld: cygwin0.dll:/4: section below image base
  ld: cygwin0.dll:/20: section below image base
  ld: cygwin0.dll:/36: section below image base

...and the section addresses given to these sections (.debug_loclists,
.debug_rnglists, debug_line_str) will be wrong.

Fix this by adding the missing DWARF 5 sections to our linker script
template cygwin.sc.in.  Add a comment in terms of the deprecated
DWARF 4 section .debug_types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2 years agoCygwin: Allow using CFLAGS also for C++ files
Corinna Vinschen [Thu, 26 Aug 2021 20:21:21 +0000 (22:21 +0200)]
Cygwin: Allow using CFLAGS also for C++ files

This was used before switching to automake to allow easy tweaking
of optimization and debugging settings from the command line during
testing.  Reenable.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: workaround a g++ 11.2 initialization bug
Corinna Vinschen [Thu, 26 Aug 2021 20:19:20 +0000 (22:19 +0200)]
Cygwin: workaround a g++ 11.2 initialization bug

trying to use aggregate initialization syntax on a member of a
nameless union member failes in g++ 11.2.

Workaround this by using explicit initialization.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: dumper: fix up GCC pragma for g++ 11.2
Corinna Vinschen [Thu, 26 Aug 2021 20:15:49 +0000 (22:15 +0200)]
Cygwin: dumper: fix up GCC pragma for g++ 11.2

The GCC diagnostic ignored "-Wstringop-overflow" pragma doesn't work
as expected anymore.  Use the still working expression.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: C++17: register keyword is deprecated
Corinna Vinschen [Thu, 26 Aug 2021 20:14:11 +0000 (22:14 +0200)]
Cygwin: C++17: register keyword is deprecated

The register keyword was already deprecated with C++11, but
with C++17 it has been entirely removed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agonvptx: Emulate clock and other machine stubs.
Roger Sayle [Tue, 24 Aug 2021 16:24:19 +0000 (17:24 +0100)]
nvptx: Emulate clock and other machine stubs.

This patch to the libc/machine/nvptx port of newlib implements an
approximation of "clock" and provides some additional stub routines.
These changes not only reduce the number of (link) failures in the GCC
testsuite when targeting nvptx-none, but also allow the NIST scimark4
benchmark to compile and run without modification.

newlib already contains support for backends to provide their own
clock implementations via -DCLOCK_PROVIDED.  That functionality is
used here to return an approximate elapsed time based on the NVidia
GPU's clock64 cycle counter.  Although not great, this is better than
the current behaviour of link error from the unresolved symbol
_times_r.

The other part of the patch is to add a small number of stub functions
to nvptx's misc.c.  Adding isatty, for example, resolves linking
problems in libc from the dependency in __smakebuf_r, and the sync
stub, for example, fixes the failure with GCC's
testsuite/gfortran.dg/ISO_Fortran_binding_14.f90 [which simply tests
that gfortran can call a/any C function].

newlib/
        configure.host: Add -DCLOCK_PROVIDED to newlib_cflags on nvptx*.

newlib/libc/machine/nvptx
        Makefile.am: Add clock.c to lib_a_SOURCES.
        clock.c: New source file to implement/approximate clock().
        misc.c: Add stubs for fstat, isatty, open, sync and unlink.

2 years agofix race condition in List_insert
Aleksand Malikov [Mon, 23 Aug 2021 14:27:48 +0000 (17:27 +0300)]
fix race condition in List_insert

Revert mx parameter and mutex lock while operating the list.
Mutex was removed with 94d24160 informing that:
'Use InterlockedCompareExchangePointer to ensure race safeness
without using a mutex.'

But it does not.

Calling pthread_mutex_init and pthread_mutex_destroy from two or
more threads occasionally leads to hang in pthread_mutex_destroy.

To not change the behaviour of other cases where List_insert was called,
List_insert_nolock is added.

2 years agostdlib: conditionalize locale usage
Corinna Vinschen [Mon, 23 Aug 2021 07:56:22 +0000 (09:56 +0200)]
stdlib: conditionalize locale usage

_strtod_l as well as the gethex function both fetch the decimal point
from the current LC_NUMERIC locale info.  This pulls in _C_numeric_locale
unconditionally even on targets not supporting locales at all.

Another problem is that strtod.c and gdtoa-gethex.c are ELIX 1, while
locale information in general isn't.  This leads to potential build
breakage on bare metal targets.

Fix this by setting the decimal point to "." on all targets not
defining __HAVE_LOCALE_INFO__.

While at it, const'ify the entire local decimal point info in the
affected functions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: fhandler_procsys::readdir: fix NtQueryDirectoryObject usage
Corinna Vinschen [Thu, 19 Aug 2021 19:17:11 +0000 (21:17 +0200)]
Cygwin: fhandler_procsys::readdir: fix NtQueryDirectoryObject usage

As outlined in the previous patch, the non-atomicity of iterating
over a directory in the NT namespace via NtQueryDirectoryObject
one entry each, results in potential duplication of directory entries.

Fix this for fhandler_procsys::readdir as well by fetching the entire
dir inside fhandler_procsys::opendir, storing it in a buffer, and just
return buffer content from fhandler_procsys::readdir.

Fixes: 43f65cdd7dae ("fhandler_procsys.cc: New file.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: fix all usages of NtQueryDirectoryObject
Corinna Vinschen [Thu, 19 Aug 2021 14:42:23 +0000 (16:42 +0200)]
Cygwin: fix all usages of NtQueryDirectoryObject

Due to reports on the Cygwin mailing list[1][2], it was uncovered
that a NtOpenDirectoryObject/NtQueryDirectoryObject/NtClose sequence
with NtQueryDirectoryObject iterating over the directory entries,
one entry per invocation, is not running atomically.  If new entries
are inserted into the queried directory, other entries may be moved
around and then accidentally show up twice while iterating.

Change (almost) all NtQueryDirectoryObject invocations so that it gets
a really big buffer (64K) and ideally fetches all entries at once.
This appears to work atomically.

"Almost" all, because fhandler_procsys::readdir can't be easily changed.

[1] https://cygwin.com/pipermail/cygwin/2021-July/248998.html
[2] https://cygwin.com/pipermail/cygwin/2021-August/249124.html

Fixes: e9c8cb31930bd ("(format_proc_partitions): Revamp loop over existing harddisks by scanning the NT native \Device object directory and looking for Harddisk entries.")
Fixes: a998dd7055766 ("Implement advisory file locking.")
Fixes: 3b7cd74bfdf56 ("(winpids::enum_processes): Fetch Cygwin processes from listing of shared cygwin object dir in the native NT namespace.")
Fixes: 0d6f2b0117aa7 ("syscalls.cc (sync_worker): Rewrite using native NT functions.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: return better inode numbers for block device entries in /proc/sys
Corinna Vinschen [Thu, 19 Aug 2021 14:08:34 +0000 (16:08 +0200)]
Cygwin: return better inode numbers for block device entries in /proc/sys

Commit 3434d35a64736f0b77a12f61784c2caa33ac44cf fixed a problem when
accessing block devices via their /proc/sys/Device entries.  This
changed the way stat info is generated for these devices, resulting
in identical inode numbers for all block devices under /proc/sys/Device.

This patch fixes that by faking a device number for these devices, just as
before.

Fixes: 3434d35a6473 ("Cygwin: Fix access to block devices below /proc/sys.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agosvfwscanf: Simplify _sungetwc_r to eliminate apparent buffer overflow
Keith Packard [Tue, 17 Aug 2021 18:51:52 +0000 (11:51 -0700)]
svfwscanf: Simplify _sungetwc_r to eliminate apparent buffer overflow

svfwscanf replaces getwc and ungetwc_r. The comments in the code talk
about avoiding file operations, but they also need to bypass the
mbtowc calls as svfwscanf operates on wchar_t, not multibyte data,
which is a more important reason here; they would not work correctly
otherwise.

The ungetwc replacement has code which uses the 3 byte FILE _ubuf
field, but if wchar_t is 32-bits, this field is not large enough to
hold even one wchar_t value. Building in this mode generates warnings
about array overflow:

In file included from ../../newlib/libc/stdio/svfiwscanf.c:35:
../../newlib/libc/stdio/vfwscanf.c: In function '_sungetwc_r.isra':
../../newlib/libc/stdio/vfwscanf.c:316:12: warning: array subscript 4294967295 is above array bounds of 'unsigned char[3]' [-Warray-bounds]
  316 |   fp->_p = &fp->_ubuf[sizeof (fp->_ubuf) - sizeof (wchar_t)];
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from ../../newlib/libc/stdio/stdio.h:46,
 from ../../newlib/libc/stdio/vfwscanf.c:82,
 from ../../newlib/libc/stdio/svfiwscanf.c:35:
../../newlib/libc/include/sys/reent.h:216:17: note: while referencing '_ubuf'
  216 |   unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */
      |                 ^~~~~

However, the vfwscanf code *never* ungets data before the start of the
scanning operation, and *always* ungets data which matches the input
at that point, so the code always hits the block which backs up over
the input data and never hits the block which uses the _ubuf field.

In addition, the svfwscanf code will always start with the unget
buffer empty, so the ungetwc replacement never needs to support an
unget buffer at all.

Simplify the code by removing support for everything other than
backing up over the input data, leaving the check to make sure it
doesn't get underflowed in case the vfscanf code has a bug in it.

Signed-off-by: Keith Packard <keithp@keithp.com>
2 years agolibc: Added prototypes for new POSIX APIs
Matt Joyce [Fri, 6 Aug 2021 20:04:42 +0000 (22:04 +0200)]
libc: Added prototypes for new POSIX APIs

Added function prototypes to newlib/libc/include/pthread.h
for the following Issue 8 Standard APIs:
pthread_cond_clockwait()
pthread_mutex_clocklock()
pthread_rwlock_clockrdlock()
pthread_rwlock_clockwrlock()

2 years agoRISC-V: Reliably initialize t0 in _times()
Christoph Muellner [Mon, 2 Aug 2021 16:46:16 +0000 (18:46 +0200)]
RISC-V: Reliably initialize t0 in _times()

The current implementation does not reliably initialize t0 once.
Additionally the initialization requires two calls to _gettimeofday().
Let's sacrifice a byte to keep the initialization status
and reduce the maximum number of calls to _gettimeofday().

This has caused issues in an application that invokes clock().
The problematic situation is as follows:

1) The program calls clock() which calls _times().
2) _gettimeofday(&t0, 0) puts 0 in t0.tv_usec (because less than 1 us has
   elapsed since the beginning of time).
3) _gettimeofday(&t, 0) puts 1 in t.tv_usec (since now more than 1 us has
   elapsed since the beginning of time).
4) That call to clock() returns 1 (the value from step 3 minus the value in
   step 2).
5) The program does a second call to clock().
6) The code above still sees 0 in t0 so it tries to update t0 again and
   _gettimeofday(&t0, 0) puts 1 in t0.tv_usec.
7) The _gettimeofday(&t, 0) puts 1 in t.tv_usec (since less than 1us has
   elapsed since step 3).
8) clock() returns 0 (step 7 minus step 6) and indicates that time is
   moving backwards.

Signed-off-by: Christoph Muellner <cmuellner@gcc.gnu.org>
2 years agoCygwin: More profiler format + small issue fixes
Mark Geisert [Mon, 2 Aug 2021 06:52:31 +0000 (23:52 -0700)]
Cygwin: More profiler format + small issue fixes

Make sure to cast to ulong all DWORD values displayed with format "%lu".
More instances are fixed here than in either my earlier unused patch or
Corinna's patch. I decided to use typedef..ulong for more compact code.

Address jturney's reported small issues:
- Remove explicit external ref for cygwin_internal() as it is already
  provided by <sys/cygwin.h>.
- Leave intact ref for cygwin_dll_path[] as it is required by function(s)
  in path.cc that profiler uses. Added comment to that effect.
- Delete existing main() wrapper. Rename main2() to main(). This because
  profiler is now a Cygwin program and doesn't need to dynamically load
  cygwin1.dll.
- Documentation issues will be addressed in a separate xml patch.

(I would have linked message-ids of Corinna's and Jon's messages for
proper theading but I no longer have their original emails and the mail
archives don't show msgids any more.)

2 years agoCygwin: Make gmondump conform to its doc + adjust doc
Mark Geisert [Mon, 2 Aug 2021 09:25:53 +0000 (02:25 -0700)]
Cygwin: Make gmondump conform to its doc + adjust doc

The doc for gmondump says 1 or more FILENAME are expected, but 0 is
handled. That's an oversight. Make invocation with 0 FILENAMEs print a
one-line help message.

Reword the beginning of profiler's description doc to clarify target's
child processes are run but only optionally profiled.

2 years agolibc: Fix compilation for new sig2str/str2sig implementation
Christoph Muellner [Mon, 2 Aug 2021 14:00:58 +0000 (16:00 +0200)]
libc: Fix compilation for new sig2str/str2sig implementation

A recent patch introduced new code for sig2str/str2sig.
This code does not properly exclude code that requires
SIGRTMIN/SIGRTMAX to be defined and triggers the following
compile error:

  newlib/libc/signal/sig2str.c:199:8: error: 'SIGRTMIN' undeclared
  newlib/libc/signal/sig2str.c:200:29: error: 'SIGRTMAX' undeclared

Let's add the missing guards.

Fixes: 2b50ec0cd205 ("libc: Fix compilation for new sig2str/str2sig implementation")
Signed-off-by: Christoph Muellner <cmuellner@gcc.gnu.org>
2 years agoCygwin: export new sig2str/str2sig
Corinna Vinschen [Mon, 2 Aug 2021 11:57:03 +0000 (13:57 +0200)]
Cygwin: export new sig2str/str2sig

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: clarify importance of new GNU-specifc API
Corinna Vinschen [Mon, 2 Aug 2021 11:53:38 +0000 (13:53 +0200)]
Cygwin: clarify importance of new GNU-specifc API

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agolibc: Added implementation for sig2str/str2sig.
Matt Joyce [Sat, 31 Jul 2021 13:22:05 +0000 (15:22 +0200)]
libc: Added implementation for sig2str/str2sig.

Added implementations for sig2str() and str2sig() in libc/signal
in order to improve POSIX compliance. Added fucntion prototypes
in libc/include/sys/signal.h.

2 years agoCygwin: Add winsymlinks:sys
Jon Turney [Sat, 17 Jul 2021 14:51:11 +0000 (15:51 +0100)]
Cygwin: Add winsymlinks:sys

Add winsymlinks:sys, to explicitly select always using plain files with
the system attribute containing a magic cookie to represent a symlink.

2 years agoCygwin: Rename WSYM_sysfile to WSYM_default
Jon Turney [Sat, 17 Jul 2021 14:47:34 +0000 (15:47 +0100)]
Cygwin: Rename WSYM_sysfile to WSYM_default

Rename WSYM_sysfile to WSYM_default, since it selects more than just
sysfile with magic cookie now.

2 years agoCygwin: add release msg for previous getaddrinfo patch
Corinna Vinschen [Fri, 30 Jul 2021 10:43:26 +0000 (12:43 +0200)]
Cygwin: add release msg for previous getaddrinfo patch

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: getaddrinfo: return valid ai_socktype and ai_protocol values
Corinna Vinschen [Fri, 30 Jul 2021 10:40:35 +0000 (12:40 +0200)]
Cygwin: getaddrinfo: return valid ai_socktype and ai_protocol values

If a service is supported as TCP and UDP service, GetAddrInfo does not
return two entries, one for TCP, one for UDP, as on Linux.  Rather, it
just returns a single entry with ai_socktype and ai_protocol set to 0.
If the service only exists as TCP or UDP service, then ai->ai_socktype
is set, but ai_protocol isn't.

Fortunately we copy over the result from Windows into local storage
anyway, so this patch adds code to fix up the fields neglected by
Windows.  In case ai_socktype as well as ai_protocol are 0, duplicate
the entry with valid values for ai_socktype and ai_protocol.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: bump API minor and set DLL version to 3.3.0
Corinna Vinschen [Thu, 29 Jul 2021 15:44:20 +0000 (17:44 +0200)]
Cygwin: bump API minor and set DLL version to 3.3.0

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: implement pthread_rwlock_clockrdlock/pthread_rwlock_clockwrlock
Corinna Vinschen [Thu, 29 Jul 2021 15:31:31 +0000 (17:31 +0200)]
Cygwin: implement pthread_rwlock_clockrdlock/pthread_rwlock_clockwrlock

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: pthread.h: clean namespace
Corinna Vinschen [Thu, 29 Jul 2021 15:27:41 +0000 (17:27 +0200)]
Cygwin: pthread.h: clean namespace

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: implement pthread_mutex_clocklock
Corinna Vinschen [Thu, 29 Jul 2021 15:22:11 +0000 (17:22 +0200)]
Cygwin: implement pthread_mutex_clocklock

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: implement pthread_cond_clockwait
Corinna Vinschen [Thu, 29 Jul 2021 15:21:01 +0000 (17:21 +0200)]
Cygwin: implement pthread_cond_clockwait

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: implement sem_clockwait
Corinna Vinschen [Thu, 29 Jul 2021 15:13:47 +0000 (17:13 +0200)]
Cygwin: implement sem_clockwait

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: semaphore.h: clean namespace
Corinna Vinschen [Thu, 29 Jul 2021 14:53:15 +0000 (16:53 +0200)]
Cygwin: semaphore.h: clean namespace

use underscored identifiers

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: utils: refresh tzmap.h
Corinna Vinschen [Wed, 28 Jul 2021 20:19:37 +0000 (22:19 +0200)]
Cygwin: utils: refresh tzmap.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: utils: tzmap-from-unicode.org: enforce sorting order for LANG=C
Corinna Vinschen [Wed, 28 Jul 2021 20:18:38 +0000 (22:18 +0200)]
Cygwin: utils: tzmap-from-unicode.org: enforce sorting order for LANG=C

Generating the tzmap.h file requires to use the default sorting order.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: Convert gmondump and profiler synopses to <cmdsynopsis>
Jon Turney [Wed, 21 Jul 2021 14:00:49 +0000 (15:00 +0100)]
Cygwin: Convert gmondump and profiler synopses to <cmdsynopsis>

Convert gmondump and profiler synopses to <cmdsynopsis>, since
addition of these crossed with e6b667f1.

2 years agoCygwin: document getifaddrs fixes
Ken Brown [Wed, 28 Jul 2021 11:44:25 +0000 (07:44 -0400)]
Cygwin: document getifaddrs fixes

2 years agoCygwin: getifaddrs: don't return a zero IPv4 address
Ken Brown [Mon, 26 Jul 2021 14:27:53 +0000 (10:27 -0400)]
Cygwin: getifaddrs: don't return a zero IPv4 address

If an interface is disconnected, net.cc:get_ifs tries to fetch IPv4
addresses from the registry.  If it fails, it currently returns
pointers to sockaddr structs with zero address.  Return a NULL pointer
instead, to signal the caller of getifaddrs that we do not have a
valid struct sockaddr.

Partially addresses: https://cygwin.com/pipermail/cygwin/2021-July/248970.html

2 years agoCygwin: getifaddrs: fix address family for IPv6 netmasks
Ken Brown [Mon, 26 Jul 2021 12:59:09 +0000 (08:59 -0400)]
Cygwin: getifaddrs: fix address family for IPv6 netmasks

The code in net.cc:get_ifs that sets the netmask omitted setting the
address family in the IPv6 case.  Fix this by setting it to AF_INET6.

Partially addresses: https://cygwin.com/pipermail/cygwin/2021-July/248970.html

2 years agoRemove unneccesary parenthesis around declarator
Maxim Blinov [Thu, 22 Jul 2021 21:41:42 +0000 (22:41 +0100)]
Remove unneccesary parenthesis around declarator

riscv64-unknown-elf-g++-11.1.0 regression suite reports the following
failures for

$ make check-gcc-c++ RUNTESTFLAGS='dg.exp=Wstringop-overflow-6.C'

```
FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++14 (test for excess errors)
FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++17 (test for excess errors)
FAIL: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++2a (test for excess errors)
UNSUPPORTED: g++.dg/warn/Wstringop-overflow-6.C  -std=gnu++98
```

The "excess errors" being

```
output is In file included from /home/maxim/prj/riscv-upstream/install/riscv64-unknown-elf/include/wchar.h:6,
                 from /home/maxim/prj/riscv-upstream/build/gcc-stage2/riscv64-unknown-elf/libstdc++-v3/include/cwchar:44,
                 from /home/maxim/prj/riscv-upstream/build/gcc-stage2/riscv64-unknown-elf/libstdc++-v3/include/bits/postypes.h:40,
                 from /home/maxim/prj/riscv-upstream/build/gcc-stage2/riscv64-unknown-elf/libstdc++-v3/include/iosfwd:40,
                 from /home/maxim/prj/riscv-upstream/build/gcc-stage2/riscv64-unknown-elf/libstdc++-v3/include/ios:38,
                 from /home/maxim/prj/riscv-upstream/build/gcc-stage2/riscv64-unknown-elf/libstdc++-v3/include/ostream:38,
                 from /home/maxim/prj/riscv-upstream/build/gcc-stage2/riscv64-unknown-elf/libstdc++-v3/include/iostream:39,
                 from /home/maxim/prj/riscv-upstream/gcc-11.1.0/gcc/testsuite/g++.dg/warn/Wstringop-overflow-6.C:6:
/home/maxim/prj/riscv-upstream/install/riscv64-unknown-elf/include/sys/reent.h:685:11: warning: unnecessary parentheses in declaration of '_sig_func' [-Wparentheses]
```

3 years agoEnsure nanosleep(2) never returns negative rem
David Allsopp [Tue, 20 Jul 2021 15:07:00 +0000 (16:07 +0100)]
Ensure nanosleep(2) never returns negative rem

It appears to be the case that NtQueryTimer can return a negative time
remaining for an unsignalled timer. The value appears to be less than
the timer resolution.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
3 years agolibc/include/sys/config.h: Undef _REENT_SMALL for RTEMS on MicroBlaze
Alex White [Wed, 21 Jul 2021 18:00:34 +0000 (13:00 -0500)]
libc/include/sys/config.h: Undef _REENT_SMALL for RTEMS on MicroBlaze

RTEMS does not expect _REENT_SMALL.

3 years agoCygwin: profiler: Fix formatting warnings
Corinna Vinschen [Wed, 21 Jul 2021 08:07:16 +0000 (10:07 +0200)]
Cygwin: profiler: Fix formatting warnings

DWORD has different types on 32 and 64 bit.  Use a common cast to
unsigned long to use %lu format for DWORD values throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agolibm: Fixing overflow handling issue for scalbnf and scalbn
Kito Cheng [Mon, 19 Jul 2021 08:50:22 +0000 (16:50 +0800)]
libm: Fixing overflow handling issue for scalbnf and scalbn

cc Aldy Hernandez <aldyh@redhat.com> and Andrew MacLeod <amacleod@redhat.com>,
they are author of new VRP analysis for GCC, just to make sure I didn't
mis-understanding or mis-interpreting anything on GCC site.

GCC 11 have better value range analysis, that give GCC more confidence
to perform more aggressive optimization, but it cause scalbn/scalbnf get
wrong result.

Using scalbn to demostrate what happened on GCC 11, see comments with VRP
prefix:

```c
double scalbn (double x, int n)
{
/* VRP RESULT: n = [-INF, +INF] */
        __int32_t  k,hx,lx;
        ...
        k = (hx&0x7ff00000)>>20;
/* VRP RESULT: k = [0, 2047] */
        if (k==0) {
    /* VRP RESULT: k = 0 */
    ...
    k = ((hx&0x7ff00000)>>20) - 54;
            if (n< -50000) return tiny*x;       /*underflow*/
    /* VRP RESULT: k = -54 */
}
/* VRP RESULT: k = [-54, 2047] */
        if (k==0x7ff) return x+x;               /* NaN or Inf */
/* VRP RESULT: k = [-54, 2046] */
        k = k+n;
        if (k > 0x7fe) return huge*copysign(huge,x); /* overflow  */
/* VRP RESULT: k = [-INF, 2046] */
/* VRP RESULT: n = [-INF, 2100],
   because k + n <= 0x7fe is false, so:
   1. -INF < [-54, 2046] + n <= 0x7fe(2046) < INF
   2. -INF < [-54, 2046] + n <= 2046 < INF
   3. -INF < n <= 2046 - [-54, 2046] < INF
   4. -INF < n <= [0, 2100] < INF
   5. n = [-INF, 2100] */
        if (k > 0)                              /* normal result */
            {SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20)); return x;}
        if (k <= -54) {
    /* VRP OPT: Evaluate n > 50000 as true...*/
            if (n > 50000)      /* in case integer overflow in n+k */
                return huge*copysign(huge,x);   /*overflow*/
            else return tiny*copysign(tiny,x);  /*underflow*/
}
        k += 54;                                /* subnormal result */
        SET_HIGH_WORD(x,(hx&0x800fffff)|(k<<20));
        return x*twom54;
}
```

However give the input n = INT32_MAX, k = k+n will overflow, and then we
expect got `huge*copysign(huge,x)`, but new VRP optimization think
`n > 50000` is never be true, so optimize that into `tiny*copysign(tiny,x)`.

so the solution here is to moving the overflow handle logic before `k = k + n`.

3 years agoCygwin: updates to wire in profiler, gmondump
Mark Geisert [Fri, 16 Jul 2021 04:49:57 +0000 (21:49 -0700)]
Cygwin: updates to wire in profiler, gmondump

These are updates to wire into the build tree the new tools profiler and
gmondump, and to supply documentation for the tools.

The documentation for profiler and ssp now mention each other but do not
discuss their similarities or differences.  That will be handled in a
future update to the "Profiling Cygwin Programs" section of the Cygwin
User's Guide, to be supplied.

3 years agoCygwin: New tool: gmondump
Mark Geisert [Fri, 16 Jul 2021 04:49:56 +0000 (21:49 -0700)]
Cygwin: New tool: gmondump

This new tool was formerly part of 'profiler' but was spun out thanks to
Jon T's reasonable review comment.  Gmondump is more of a debugging tool
than something users might have need for.  Users would more likely use
gprof to make use of symbolic info like function names and source line
numbers.

3 years agoCygwin: New tool: profiler
Mark Geisert [Fri, 16 Jul 2021 04:49:55 +0000 (21:49 -0700)]
Cygwin: New tool: profiler

The new tool formerly known as cygmon is renamed to 'profiler'.  For the
name I considered 'ipsampler' and could not think of any others.  I'm open
to a different name if any is suggested.

I decided that a discussion of the pros and cons of this profiler vs the
existing ssp should probably be in the "Profiling Cygwin Programs" section
of the Cygwin User's Guide rather than in the help for either.  That
material will be supplied at some point.

CONTEXT buffers are made child-specific and thus thread-specific since
there is one profiler thread for each child program being profiled.

The SetThreadPriority() warning comment has been expanded.

chmod() works on Cygwin so the "//XXX ineffective" comment is gone.

I decided to make the "sample all executable sections" and "sample
dynamically generated code" suggestions simply expanded comments for now.

The profiler program is now a Cygwin exe rather than a native exe.

3 years agoCygwin: cfsetspeed: allow speed to be a numerical baud rate
Ken Brown [Sun, 11 Jul 2021 11:04:58 +0000 (07:04 -0400)]
Cygwin: cfsetspeed: allow speed to be a numerical baud rate

The Linux man page for cfsetspeed(3) specifies that the speed argument
must be one of the constants Bnnn (e.g., B9600) defined in termios.h.
But Linux in fact allows the speed to be the numerical baud rate
(e.g., 9600).  For consistency with Linux, we now do the same.

Addresses: https://cygwin.com/pipermail/cygwin/2021-July/248887.html

3 years agoMinimal support for ISO/IEC TS 18661-3.
Kito Cheng [Mon, 12 Jul 2021 09:17:21 +0000 (17:17 +0800)]
Minimal support for ISO/IEC TS 18661-3.

 - GCC will set __FLT_EVAL_METHOD__ to 16 if __fp16 supported, e.g.
   cortex-a55/aarch64.
   - $ aarch64-unknown-elf-gcc -v 2>&1 |grep version
     gcc version 9.2.0 (GCC)
   - $ aarch64-unknown-elf-gcc  -E -dM -mcpu=cortex-a55 - < /dev/null  |grep FLT_EVAL_METHOD
     #define __FLT_EVAL_METHOD__ 16
     #define __FLT_EVAL_METHOD_TS_18661_3__ 16
     #define __FLT_EVAL_METHOD_C99__ 16
 - The behavior of __FLT_EVAL_METHOD__ == 16 is same as
   __FLT_EVAL_METHOD__ == 0 except for float16_t, but newlib didn't
   support float16_t.

ISO/IEC TS 18661-3:
http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2405.pdf

V2 Changes:
- List Howland, Craig D as co-author since he provide the draft of comment
  in math.h.

Co-authored-by: "Howland, Craig D" <howland@LGSInnovations.com>
3 years agoCygwin: Define PSAPI_VERSION as 1 before including psapi.h
Jon Turney [Thu, 20 May 2021 17:28:01 +0000 (18:28 +0100)]
Cygwin: Define PSAPI_VERSION as 1 before including psapi.h

The default PSAPI_VERSION is controlled by WIN32_WINNT, which we set to
0x0a00 when building utils since 48a76190 (and is the default in w32api
>= 9.0.0)

In order for the built executables to run on Windows Vista, we must also
define PSAPI_VERSION as 1 (otherwise '#define GetModuleFileNameExA
K32GetModuleFileNameExA' causes a 'The procedure entry point
K32GetModuleFilenameExA could not be located in the dynamic link library
kernel32.dll' error at run time).

Also drop uneeded psapi.h from dlfcn.cc (31ddf45d), resource.cc
(34a6eeab) and ps.cc (1def2148).

3 years agoCygwin: Use cmdsynopsis element in utils documentation
Jon Turney [Mon, 14 Jun 2021 12:51:41 +0000 (13:51 +0100)]
Cygwin: Use cmdsynopsis element in utils documentation

Use <cmdsynopsis> element markup in utils docbook documentation, rather
than some preformatted text inside <screen>.

(This didn't happen as part of 646745cb, when we first started using
refentry elements to make it possible to generate manpages)

This helps produce better looking manpages:

* uses bold (for command names) and italic (for replaceable items)
* different output formats inconsistently treat tabs inside <screen>
(so we have to be careful to not use them in that preformatted text)

Also clean up various issues:

* Replace '[OPTIONS]' with a real synopsis of the options
* Consistently use 'ITEM...' rather than 'ITEM1 [ITEM2...]' for an item
which should appear 1 or more times (cygcheck -f, getfacl, kill)
* Consistently document the '-h | -V' invocation form
* Since replaceable items are now marked up so they have some formatting
indicating they are replaceable, we can drop wrapping them in angle
brackets, as is done in some places
* Add missing '-W' and '-p PID' options to ps synopsis
* Adjust cygpath synopsis to show that only one 'System information'
option is allowed, possibly modified by -A

Future work:
* Sync up the actual help emitted by the util, where it's been improved
* Also don't use <screen> for formatting 'OPTIONS' section of manpage
* pldd inconsistently uses '-?' rather than '-h'!

3 years agoCygwin: Various minor fixes to utils documentation
Jon Turney [Mon, 14 Jun 2021 20:18:49 +0000 (21:18 +0100)]
Cygwin: Various minor fixes to utils documentation

* Drop duplicate 'Options:' headers (mkgroup, mkpassword)
* Add missing indication that MACHINE is optional with -L (mkgroup, mkpassword)
* Tweak some <refpurpose> which try to be a synopsis, rather than a decription (passwd, ssp)
* Drop some stray '\n' in setfacl options
* Move 'Original Author' note in ssp to an AUTHORS section
* Use <para> to improve formatting of tzset manpage

3 years agostdlib: Make strtod/strtof set ERANGE consistently for underflow.
Keith Packard [Tue, 22 Jun 2021 17:26:26 +0000 (10:26 -0700)]
stdlib: Make strtod/strtof set ERANGE consistently for underflow.

The C standard says that errno may acquire the value ERANGE if the
result from strtod underflows. According to IEEE 754, underflow occurs
whenever the value cannot be represented in normalized form.

Newlib is inconsistent in this, setting errno to ERANGE only if the
value underflows to zero, but not for denorm values, and never for hex
format floats.

This patch attempts to consistently set errno to ERANGE for all
'underflow' conditions, which is to say all values which are not
exactly zero and which cannot be represented in normalized form.

This matches glibc behavior, as well as the Linux, Mac OS X, OpenBSD,
FreeBSD and SunOS strtod man pages.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agotty/pty: support TIOCSWINSZ pixel-size-only change notification
Thomas Wolff [Fri, 2 Jul 2021 22:00:00 +0000 (00:00 +0200)]
tty/pty: support TIOCSWINSZ pixel-size-only change notification

xterm 368 and mintty 3.5.1 implement a new feature to support
notification of terminal scaling via font zooming also if the terminal
text dimensions (rows/columns) stay unchanged, using
ioctl(TIOCSWINSZ), raising SIGWINCH;
this patches cygwin to support that scenario

3 years agoCygwin: respect PC_SYM_FOLLOW and PC_SYM_NOFOLLOW_REP with inner links.
Jeremy Drake [Sat, 29 May 2021 18:48:11 +0000 (11:48 -0700)]
Cygwin: respect PC_SYM_FOLLOW and PC_SYM_NOFOLLOW_REP with inner links.

The new GetFinalPathNameW handling for native symlinks in inner path
components is disabled if caller doesn't want to follow symlinks, or
doesn't want to follow reparse points.

3 years agoRevert "Cygwin: Handle virtual drives as non-symlinks"
Jeremy Drake [Sat, 29 May 2021 20:17:08 +0000 (13:17 -0700)]
Revert "Cygwin: Handle virtual drives as non-symlinks"

This reverts commit c8949d04001e3dbc03651475b6cd1c5623400835.

3 years agoFix builds on iq2000 and visium
Jeff Law [Tue, 6 Jul 2021 14:46:09 +0000 (10:46 -0400)]
Fix builds on iq2000 and visium

visium and iq2000 have libgloss configure bits that reference
target_makefile_frag, but it's never set. This leads to failures during the
configure process and an empty libgloss/<target>/Makefile.  Naturally bad
things happen with an empty Makefile.

This patch initializes target_makefile_frag for both targets in their
configure.in files and updates the generated configure files.  This fixes the
build failures.  I've been using it in my tester for about a week and both
targets have flipped from consistently failing to consistently passing.

    * libgloss/visium/configure.in (target_makefile_frag): Define.
    * libgloss/visium/configure: Regenerated.
    * libgloss/iq2000/configure.in (target_makefile_frag): Define.
    * libgloss/iq2000/configure: Regenerated.

3 years agoformat_proc_cpuinfo: add Linux 5.13 AMD/Hygon rapl
Brian Inglis [Tue, 29 Jun 2021 17:09:24 +0000 (11:09 -0600)]
format_proc_cpuinfo: add Linux 5.13 AMD/Hygon rapl

Linux 5.13 Opossums on Parade added features and changes:
add AMD 0x80000007 EDX:14 rapl runtime average power limit

3 years agoCygwin: console: Fix garbled input for non-ASCII chars.
Takashi Yano [Thu, 24 Jun 2021 03:40:58 +0000 (12:40 +0900)]
Cygwin: console: Fix garbled input for non-ASCII chars.

- After the commit ff4440fc, non-ASCII input may sometimes be garbled.
  This patch fixes the issue.

  Addresses: https://cygwin.com/pipermail/cygwin/2021-June/248775.html

3 years agoRevert "Cygwin: console: Fix garbled input for non-ASCII chars."
Corinna Vinschen [Tue, 6 Jul 2021 14:04:22 +0000 (16:04 +0200)]
Revert "Cygwin: console: Fix garbled input for non-ASCII chars."

This reverts commit 1b242c12aa7f34d89d57023f3c33f5f88d89d476.

3 years agoCygwin: console: Fix garbled input for non-ASCII chars.
Takashi Yano [Wed, 23 Jun 2021 08:42:16 +0000 (17:42 +0900)]
Cygwin: console: Fix garbled input for non-ASCII chars.

- After the commit ff4440fc, non-ASCII input may sometimes be garbled.
  This patch fixes the issue.

  Addresses: https://cygwin.com/pipermail/cygwin/2021-June/248775.html

3 years agofix and amend scripts and makefile rules to generate Unicode data
Thomas Wolff [Fri, 16 Apr 2021 22:00:00 +0000 (00:00 +0200)]
fix and amend scripts and makefile rules to generate Unicode data

3 years agoupdate to Unicode 13.0
Thomas Wolff [Thu, 15 Apr 2021 22:00:00 +0000 (00:00 +0200)]
update to Unicode 13.0

3 years agolibgloss/or1k: Correct the IMMU SXE and UXE flags
Stafford Horne [Thu, 1 Jul 2021 21:24:57 +0000 (06:24 +0900)]
libgloss/or1k: Correct the IMMU SXE and UXE flags

These have been defined incorrectly, as per specification and CPU
implementations SXE is bit 6 and UXE is bit 7.  This was noticed when
tracking down our test suite mmu test failures.

 Test Suite: https://github.com/openrisc/or1k-tests/blob/master/native/or1k/or1k-mmu.c#L68-L72
 Spec: https://raw.githubusercontent.com/openrisc/doc/master/openrisc-arch-1.3-rev1.pdf

See section 8.4.8 Instruction Translation Lookaside Buffer Way y Translate
Registers where these are defined.

Signed-off-by: Stafford Horne <shorne@gmail.com>
3 years agoCygwin: Zero out gmon header before use
Mark Geisert [Wed, 23 Jun 2021 08:56:14 +0000 (01:56 -0700)]
Cygwin: Zero out gmon header before use

Tools that process gmon.out files can be confused by gmon header fields
with garbage in them due to lack of initialization.  Repair that.

3 years agointtypes.h: Use reserved names for function parameters
Jonathan Wakely [Fri, 25 Jun 2021 20:44:22 +0000 (16:44 -0400)]
inttypes.h: Use reserved names for function parameters

3 years agostdio: Parse 0x0p+00 correctly in scanf
Keith Packard [Fri, 18 Jun 2021 18:09:48 +0000 (11:09 -0700)]
stdio: Parse 0x0p+00 correctly in scanf

The scanf code was skipping the '0' after the 'x' causing the
resulting buffer to contain an invalid number when passed to strtod.

Signed-off-by: Keith Packard <keithp@keithp.com>
3 years agonewlib/doc/makedoc.c: if realloc() fails, exit with an error message.
Joel Sherrill [Thu, 17 Jun 2021 21:48:47 +0000 (16:48 -0500)]
newlib/doc/makedoc.c: if realloc() fails, exit with an error message.

3 years agonewlib/doc/makedoc.c: Fix memory leak identified by Coverity.
Joel Sherrill [Thu, 17 Jun 2021 21:27:49 +0000 (16:27 -0500)]
newlib/doc/makedoc.c: Fix memory leak identified by Coverity.

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