]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
3 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>
3 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>
3 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>
3 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.

3 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.

3 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>
3 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>
3 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>
3 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>
3 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>
3 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()

3 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>
3 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.)

3 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.

3 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>
3 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>
3 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>
3 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.

3 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.

3 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.

3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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>
3 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.

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

3 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

3 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

3 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.

3 years agolibc/sys/rtems/crt0.c: Fix two warnings.
Joel Sherrill [Mon, 14 Jun 2021 21:31:08 +0000 (16:31 -0500)]
libc/sys/rtems/crt0.c: Fix two warnings.

__assert_func() is marked as noreturn and stub should not.
__tls_get_addr() needed to return a value..

3 years agoCygwin: Fix a stray tab in strace documentation
Mark Geisert [Sun, 13 Jun 2021 14:48:16 +0000 (15:48 +0100)]
Cygwin: Fix a stray tab in strace documentation

3 years agolibgloss: pru: Remove sim ld script
Dimitar Dimitrov [Wed, 3 Mar 2021 09:24:50 +0000 (11:24 +0200)]
libgloss: pru: Remove sim ld script

Binutils LD default linker script was recently fixed to allow memory
sizes to be set via command line. Use this feature to remove the special
sim linker script in libgloss.

It is acceptable to require newer Binutils version here because simulator
target is only used for regression testing the toolchain. Real HW
targets are not affected.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
3 years agolibgloss: pru: Place sim syscalls into their own sections
Dimitar Dimitrov [Sun, 9 May 2021 13:10:45 +0000 (16:10 +0300)]
libgloss: pru: Place sim syscalls into their own sections

This should help reduce final ELF size if using --gc-sections linker
option.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
3 years agopru: Enable -ffunction-sections and -fdata-sections
Dimitar Dimitrov [Sun, 9 May 2021 13:11:36 +0000 (16:11 +0300)]
pru: Enable -ffunction-sections and -fdata-sections

Recent binutils support --gc-sections for pru, so let's make use of
them.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
3 years agoFix rounding issues with sqrt/sqrtf
Jeff Johnston [Fri, 4 Jun 2021 18:36:38 +0000 (14:36 -0400)]
Fix rounding issues with sqrt/sqrtf

- compiler is sometimes optimizing out the rounding check in
  e_sqrt.c and ef_sqrt.c which uses two constants to create
  an inexact operation
- there is a similar constant operation in s_tanh.c/sf_tanh.c
- make the one and tiny constants volatile to stop this

3 years agoCygwin: fhandler_mqueue::mq_open: fix typo
Ken Brown [Wed, 26 May 2021 16:48:58 +0000 (12:48 -0400)]
Cygwin: fhandler_mqueue::mq_open: fix typo

3 years agoaarch64: support binary mode for opening files
Richard Earnshaw [Wed, 26 May 2021 14:17:11 +0000 (15:17 +0100)]
aarch64: support binary mode for opening files

Newlib for aarch64 uses libgloss for the backend.  One common libgloss
implementation is the 'rdimon' implementation, which uses the Arm
Semihosting protocol.  In order to support a remote host that runs on
Windows we need to know whether a file is to be opened in binary or
text mode.  That means that we need to preserve this information via
O_BINARY until we know what the libgloss binding will be.

This patch simply copies the arm implementation from sys/arm/sys and
puts it in machine/aarch64/sys, because we don't have a 'sys' subtree
on aarch64.

3 years agoCygwin: utils: enable -idirafter to fetch Cygwin headers from mingw sources
Corinna Vinschen [Wed, 26 May 2021 08:59:03 +0000 (10:59 +0200)]
Cygwin: utils: enable -idirafter to fetch Cygwin headers from mingw sources

Get rid of the last dreaded relative paths pointing to the cygwin dir.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: utils: set _WIN32_WINNT and NTDDI_VERSION via Makefile
Corinna Vinschen [Wed, 26 May 2021 08:57:47 +0000 (10:57 +0200)]
Cygwin: utils: set _WIN32_WINNT and NTDDI_VERSION via Makefile

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: set NTDDI_VERSION to enable more recent windows definitions
Corinna Vinschen [Wed, 26 May 2021 08:56:02 +0000 (10:56 +0200)]
Cygwin: set NTDDI_VERSION to enable more recent windows definitions

Set to WDK_NTDDI_VERSION since that enables all the latest.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: fhandler_mqueue: add missing __reg2 for 32 bit build
Corinna Vinschen [Wed, 26 May 2021 09:01:20 +0000 (11:01 +0200)]
Cygwin: fhandler_mqueue: add missing  __reg2 for 32 bit build

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: fhandler_mqueue: disable more methods, add fcntl
Corinna Vinschen [Tue, 25 May 2021 21:00:32 +0000 (23:00 +0200)]
Cygwin: fhandler_mqueue: disable more methods, add fcntl

Unsupported functionality returns EPERM, fcntl supports
only F_GETFD and F_GETFL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: fhandler_mqueue::mq_open: set all required fhandler flags
Corinna Vinschen [Tue, 25 May 2021 20:43:41 +0000 (22:43 +0200)]
Cygwin: fhandler_mqueue::mq_open: set all required fhandler flags

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: disable creating directories below /dev/mqueue
Corinna Vinschen [Tue, 25 May 2021 20:05:13 +0000 (22:05 +0200)]
Cygwin: disable creating directories below /dev/mqueue

...as on Linux.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: fhandler_mqueue: fix method declarations
Corinna Vinschen [Tue, 25 May 2021 20:04:43 +0000 (22:04 +0200)]
Cygwin: fhandler_mqueue: fix method declarations

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: path_conv: fix mqueue path check
Corinna Vinschen [Tue, 25 May 2021 20:03:36 +0000 (22:03 +0200)]
Cygwin: path_conv: fix mqueue path check

The check for a file or dir within /dev/mqueue is accidentally using
the incoming path, which could be a relative path.  Make sure to
restore the absolute POSIX path in path_copy and only then test the
path.

Also, move the actual check for a valid path below /dev/mqueue into
the fhandler_mqueue class.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: cwdstuff: check if /dev exists
Corinna Vinschen [Tue, 25 May 2021 19:46:13 +0000 (21:46 +0200)]
Cygwin: cwdstuff: check if /dev exists

/dev has been handled as virtual dir in cwdstuff, thus not allowing
to start native apps from /dev as CWD, even if /dev actually exists
on disk.  Unfortunately this also affects Cygwin executables started
from a debugger.

When chdir'ing to /dev, check if /dev exists on disk.  If so, treat
it as any other existing path.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: implement read(2)/lseek(2)
Corinna Vinschen [Tue, 25 May 2021 18:19:19 +0000 (20:19 +0200)]
Cygwin: POSIX msg queues: implement read(2)/lseek(2)

reuse fhandler_virtual implementation to implement read and lseek.
The output from read(2) is modelled after the output when reading
from an mq file on Linux.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: implement ioctl(2)
Corinna Vinschen [Tue, 25 May 2021 18:17:07 +0000 (20:17 +0200)]
Cygwin: POSIX msg queues: implement ioctl(2)

Call into fhandler_base::ioctl immediately, thus only allowing
FIONBIO to manipulate blocking behaviour.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: move all mq_* functionality into fhandler_mqueue
Corinna Vinschen [Tue, 25 May 2021 18:15:16 +0000 (20:15 +0200)]
Cygwin: POSIX msg queues: move all mq_* functionality into fhandler_mqueue

The POSIX entry points are just wrappers now, calling into
fhandler_mqueue.  While at it, eliminate mqi_flags, replace with
standard fhandler nonblocking flag.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: allocate section views top down
Corinna Vinschen [Tue, 25 May 2021 14:55:38 +0000 (16:55 +0200)]
Cygwin: POSIX msg queues: allocate section views top down

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: Implement dup
Corinna Vinschen [Tue, 25 May 2021 14:50:16 +0000 (16:50 +0200)]
Cygwin: POSIX msg queues: Implement dup

Create a private method fhandler_mqueue::_dup and call it from
dup and fixup_after_fork methods.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: implement open/mq_open entirely in fhandler
Corinna Vinschen [Tue, 25 May 2021 14:49:04 +0000 (16:49 +0200)]
Cygwin: POSIX msg queues: implement open/mq_open entirely in fhandler

The mq_open call is just a framework now.  This patch moves the
entire functionality into fhandler_mqueue.  To support standard
OS calls (as on Linux), make fhandler_mqueue a derived class from
fhandler_disk_file and keep the base handle the handle to the
default stream, to allow implementing O_PATH functionlaity as well
as reading from the file and NOT reading binary message queue data.

Implement a standard fhandler_mqueue::open method, allowing, for
instance, to touch a file under /dev/mqueue and if it doesn't exist,
to create a message queue file.

FIXME: This introduces a BAD HACK into path_conv::check, which needs
reviewing.

Keep the posix path intact in the fhandler, and change get_proc_fd_name
accordingly to return only the basename plus leading slash for
/proc/<PID>/fd.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: slightly rephrase get_mqinfo
Corinna Vinschen [Tue, 25 May 2021 14:42:44 +0000 (16:42 +0200)]
Cygwin: POSIX msg queues: slightly rephrase get_mqinfo

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: simplify mq_close
Corinna Vinschen [Tue, 25 May 2021 14:36:09 +0000 (16:36 +0200)]
Cygwin: POSIX msg queues: simplify mq_close

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: get_nt_native_path: allow to append suffix
Corinna Vinschen [Tue, 25 May 2021 14:24:58 +0000 (16:24 +0200)]
Cygwin: get_nt_native_path: allow to append suffix

POSIX message queues will be moved into NTFS streams.
Extend get_nt_native_path to provide a filename suffix which is not
subject to special character transposition, to allow specifying
a colon.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: move definition of struct msg_hdr
Corinna Vinschen [Tue, 25 May 2021 14:17:58 +0000 (16:17 +0200)]
Cygwin: POSIX msg queues: move definition of struct msg_hdr

...to mqueue_types.h header.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: improve error output in fixup_after_fork
Corinna Vinschen [Fri, 21 May 2021 15:47:14 +0000 (17:47 +0200)]
Cygwin: POSIX msg queues: improve error output in fixup_after_fork

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: Ensure PSAPI_VERSION is 1 when building ldd
Jon Turney [Thu, 20 May 2021 17:28:01 +0000 (18:28 +0100)]
Cygwin: Ensure PSAPI_VERSION is 1 when building ldd

The default PSAPI_VERSION is controlled by WIN32_WINNT, which we set to
0x0a00 when building ldd, which gets PSAPI_VERSION=2.

This causes K32GetModuleFileNameEx to be used for GetModuleFileNameEx,
which isn't available on Windows Vista.

Define PSAPI_VERSION as 1 for the built executable to work on Windows
Vista.

3 years agoCygwin: POSIX msg queues: destroy msg queue fhandler in case of error
Corinna Vinschen [Fri, 21 May 2021 13:26:51 +0000 (15:26 +0200)]
Cygwin: POSIX msg queues: destroy msg queue fhandler in case of error

...and don't leave a descriptor dangling

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: move handling of memory map into fhandler
Corinna Vinschen [Fri, 21 May 2021 13:25:37 +0000 (15:25 +0200)]
Cygwin: POSIX msg queues: move handling of memory map into fhandler

This encapsulated creation, duplication, and closing of all
Windows objects connected to the message queue in the fhandler.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX ipc: fix evaluation of naming rules
Corinna Vinschen [Fri, 21 May 2021 13:21:29 +0000 (15:21 +0200)]
Cygwin: POSIX ipc: fix evaluation of naming rules

The function evaluating correctness of ipc object names was a
bit half-hearted.  Fix the tests to follow more closely the
desriptions in the Linux man pages.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: posix_ipc.cc: fix typo
Corinna Vinschen [Fri, 21 May 2021 13:18:38 +0000 (15:18 +0200)]
Cygwin: posix_ipc.cc: fix typo

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
3 years agoCygwin: POSIX msg queues: create fhandler with object name
Corinna Vinschen [Fri, 21 May 2021 11:42:40 +0000 (13:42 +0200)]
Cygwin: POSIX msg queues: create fhandler with object name

build_fh_dev can take the POSIX object name as parameter anyway,
so use that and drop from mqinfo call.

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