]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
5 years agoCygwin: Export newlib ndbm functions
Corinna Vinschen [Wed, 24 Jul 2019 20:05:00 +0000 (22:05 +0200)]
Cygwin: Export newlib ndbm functions

Signed-off-by: Corinna Vinschen <corinna-cygwin@cygwin.com>
5 years agohash functions: use reentrant stat functions
Corinna Vinschen [Wed, 24 Jul 2019 20:32:18 +0000 (22:32 +0200)]
hash functions: use reentrant stat functions

_stat64 and _fstat64 are not exported from Cygwin.  Use the
reentrant analogues, like everywhere else.

Signed-off-by: Corinna Vinschen <corinna-cygwin@cygwin.com>
5 years agoMSP430: Remove .init/.fini sections
Jozef Lawrynowicz [Wed, 24 Jul 2019 09:45:49 +0000 (10:45 +0100)]
MSP430: Remove .init/.fini sections

The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.

.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.

.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.

The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.

5 years agoCygwin: document the last bug fix
Ken Brown [Wed, 24 Jul 2019 18:52:01 +0000 (14:52 -0400)]
Cygwin: document the last bug fix

5 years agoCygwin: fhandler_termios::tcsetpgrp: check that argument is non-negative
Ken Brown [Wed, 24 Jul 2019 15:29:53 +0000 (11:29 -0400)]
Cygwin: fhandler_termios::tcsetpgrp: check that argument is non-negative

Return -1 with EINVAL if pgid < 0.

Previously tcsetpgrp() would blindly go ahead and set the pgid of the
controlling terminal to a negative value, causing later calls to
various functions to fail.

For example, gdb has code like the following:

  tcsetpgrp (0, getpgid (inf->pid));

If getpgid (inf->pid) fails (returns -1), then this code would set the
pgid of fd 0 to -1, so that some later calls to getpgid() would also
return -1.  This caused the problem reported here:

  https://cygwin.com/ml/cygwin/2019-07/msg00166.html.

5 years agoRegenerate newlib/libc/search/Makefile.in for ndpm port
Corinna Vinschen [Wed, 24 Jul 2019 16:47:35 +0000 (18:47 +0200)]
Regenerate newlib/libc/search/Makefile.in for ndpm port

Signed-off-by: Corinna Vinschen <corinna-cygwin@cygwin.com>
5 years agofix compile errors for efgcvt.c
uchan-nos [Tue, 23 Jul 2019 12:15:48 +0000 (21:15 +0900)]
fix compile errors for efgcvt.c

5 years agoPort ndbm
Vaibhav Gupta [Wed, 10 Jul 2019 08:55:50 +0000 (14:25 +0530)]
Port ndbm

5 years agoStack Pointer and Stack Limit initialization refactored.
Alexander Fedotov [Mon, 22 Jul 2019 16:18:53 +0000 (11:18 -0500)]
Stack Pointer and Stack Limit initialization refactored.

SP initialization changes:
  1. set default value in semihosting case as well
  2. moved existing SP & SL init code for processor modes in separate routine and made it as "hook"
  3. init SP for processor modes in Thumb mode as well

Add new macro FN_RETURN, FN_EH_START and FN_EH_END.

5 years agoCygwin: fix one more check for positive virtual_ftype_t values
Ken Brown [Mon, 22 Jul 2019 18:00:53 +0000 (14:00 -0400)]
Cygwin: fix one more check for positive virtual_ftype_t values

Also drop more comments referring to numerical virtual_ftype_t values.

5 years agoCygwin: change virtual_ftype_t to not rely on negative values
Corinna Vinschen [Mon, 22 Jul 2019 16:40:33 +0000 (18:40 +0200)]
Cygwin: change virtual_ftype_t to not rely on negative values

So far negative values were denoting files, positive values
denoting directories.  We should prefer a less error prone
method.  Redefine virtual_ftype_t to contain only positive
values and replace checks for negativ or positive values with
inline functions virt_ftype_isfile() and virt_ftype_isdir().

Drop outdcated comments referring to numerical virtual_ftype_t
values.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fix /proc/PID/fd return value in error case
Corinna Vinschen [Mon, 22 Jul 2019 16:36:38 +0000 (18:36 +0200)]
Cygwin: fix /proc/PID/fd return value in error case

commit 2607639992f6 "Improve error handling in /proc/[pid]/
virtual files." changed the return value of the /proc/PID
formatting functions to return -1 instead of 0 in the error
case to allow a filesize of 0.

The patch neglected to change this behaviour for /proc/PID/fd
content.  This patch fixes that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: add release notes for 3.0.8
Ken Brown [Mon, 22 Jul 2019 12:18:16 +0000 (08:18 -0400)]
Cygwin: add release notes for 3.0.8

5 years agoCygwin: socket files are not lnk special files
Ken Brown [Sat, 20 Jul 2019 21:55:12 +0000 (17:55 -0400)]
Cygwin: socket files are not lnk special files

Change path_conv::is_lnk_special() so that it returns false on socket
files.

is_lnk_special() is called by rename2() in order to deal with special
files (FIFOs and symlinks, for example) whose Win32 names usually have
a ".lnk" suffix.  Socket files do not fall into this category, and
this change prevents ".lnk" from being appended erroneously when such
files are renamed.

Remove a now redundant !pc.issocket() from fhandler_disk_file::link().

5 years agoCygwin: remove path_conv::is_fs_device()
Ken Brown [Sat, 20 Jul 2019 22:35:15 +0000 (18:35 -0400)]
Cygwin: remove path_conv::is_fs_device()

It is used only once.

5 years agoCygwin: remove path_conv::is_auto_device()
Ken Brown [Sat, 20 Jul 2019 20:21:43 +0000 (16:21 -0400)]
Cygwin: remove path_conv::is_auto_device()

It is used only once, and the name is supposed to suggest "device that
is not based on the filesystem".  This intended meaning is clearer if
we just replace is_auto_device() by its definition at the place where
it's used.

5 years agoCygwin: fhandler_*: remove isdevice() and is_auto_device()
Ken Brown [Fri, 19 Jul 2019 19:39:35 +0000 (15:39 -0400)]
Cygwin: fhandler_*: remove isdevice() and is_auto_device()

isdevice() is used only in the definition of is_auto_device().  And
the latter is used only once, in a context where isdevice() always
returns true.

5 years agoCygwin: unbreak the build with GCC 7
Ken Brown [Fri, 19 Jul 2019 18:14:33 +0000 (14:14 -0400)]
Cygwin: unbreak the build with GCC 7

The recent port to GCC 8 used the 'nonstring' attribute, which is
unknown to GCC 7.  Define and use an 'ATTRIBUTE_NONSTRING' macro
instead.

5 years agoCygwin: fix GCC 8.3 'local external declaration' errors
Ken Brown [Mon, 15 Jul 2019 21:11:02 +0000 (17:11 -0400)]
Cygwin: fix GCC 8.3 'local external declaration' errors

Move external declarations out of function definition.

5 years agoCygwin: fix GCC 8.3 'asm volatile' errors
Ken Brown [Mon, 15 Jul 2019 19:59:41 +0000 (15:59 -0400)]
Cygwin: fix GCC 8.3 'asm volatile' errors

Remove the volatile qualifier, which is no longer allowed outside of
the function body.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89585 for discussion.

5 years agoCygwin: suppress GCC 8.3 errors with -Warray-bounds
Ken Brown [Mon, 15 Jul 2019 20:50:54 +0000 (16:50 -0400)]
Cygwin: suppress GCC 8.3 errors with -Warray-bounds

5 years agoCygwin: avoid GCC 8.3 errors with -Werror=stringop-truncation
Ken Brown [Mon, 15 Jul 2019 19:02:00 +0000 (15:02 -0400)]
Cygwin: avoid GCC 8.3 errors with -Werror=stringop-truncation

5 years agoCygwin: avoid GCC 8.3 errors with -Werror=class-memaccess
Ken Brown [Mon, 15 Jul 2019 18:22:07 +0000 (14:22 -0400)]
Cygwin: avoid GCC 8.3 errors with -Werror=class-memaccess

5 years agoCygwin: sigpending: don't report pending signals for other threads
Corinna Vinschen [Fri, 12 Jul 2019 15:18:48 +0000 (17:18 +0200)]
Cygwin: sigpending: don't report pending signals for other threads

The sigpending mechanism failed to check if the pending signal was a
process-wide signal, or a signal for the curent thread.  Fix that by
adding a matching conditional to wait_sig's __SIGPENDING code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: return full sigset_t from sig_send
Corinna Vinschen [Fri, 12 Jul 2019 14:32:45 +0000 (16:32 +0200)]
Cygwin: return full sigset_t from sig_send

So far sig_send's return type is int.  The problem with this is
that sig_send returns a sigset_t on __SIGPENDING, and sigset_t
is defined as long type.  So the function only returns the lower
32 bit of sigset_t, which is fine on 32 bit, but casts away the
pending RT signals on 64 bit.

Fix this by changing the return type of sig_send to sigset_t, so
as not to narrow down the sigset when returning from handling
__SIGPENDING.  Make sure to cast correctly in all invocations
of sig_send.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoSet errno in expm1{,f} / log1p{,f}
Jeff Johnston [Tue, 9 Jul 2019 17:06:59 +0000 (13:06 -0400)]
Set errno in expm1{,f} / log1p{,f}

2019-07-09  Joern Rennecke  <joern.rennecke@riscy-ip.com>

* libm/common/s_expm1.c ("math_config.h"): Include.
(expm1): Use __math_oflow to set errno.
* libm/common/s_log1p.c ("math_config.h"): Include.
(log1p): Use __math_divzero and __math_invalid to set errno.
* libm/common/sf_expm1.c ("math_config.h"): Include.
(expm1f): Use __math_oflow to set errno.
* libm/common/sf_log1p.c ("math_config.h"): Include.
(log1pf): Use __math_divzero and __math_invalid to set errno.

5 years agoCygwin: Fix return value of sched_getaffinity
Mark Geisert [Wed, 26 Jun 2019 09:44:56 +0000 (02:44 -0700)]
Cygwin: Fix return value of sched_getaffinity

Have sched_getaffinity() interface like glibc's, and provide an
undocumented internal interface __sched_getaffinity_sys() like the Linux
kernel's sched_getaffinity() for benefit of taskset(1).

5 years agosched: Move Cygwin cpuset definitions into Cygwin-specific header
Corinna Vinschen [Wed, 26 Jun 2019 13:08:57 +0000 (15:08 +0200)]
sched: Move Cygwin cpuset definitions into Cygwin-specific header

This avoids build breakage on RTEMS.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: honor the O_PATH flag when opening a FIFO
Ken Brown [Thu, 27 Jun 2019 11:46:14 +0000 (07:46 -0400)]
Cygwin: honor the O_PATH flag when opening a FIFO

Previously fhandler_fifo::open would treat the FIFO as a reader and
would block, waiting for a writer.

5 years agoor1k: Avoid write outside setjmp buf & shrink buf
Martin Erik Werner [Thu, 27 Jun 2019 08:03:48 +0000 (10:03 +0200)]
or1k: Avoid write outside setjmp buf & shrink buf

Update the offsets used to save registers into the stejmp jmp_buf
structure in order to:

* Avoid writing the supervision register outside the buffer and thus
  clobbering something on the stack. Previously the supervision register
  was written at offset 124 while the buffer was of length 124.

* Shrink the jmp_buf down to the size actually needed, by avoiding holes
  at the locations of omitted registers.

5 years agoCygwin: Build cygwin-console-helper with correct compiler
Mark Geisert [Tue, 25 Jun 2019 07:54:41 +0000 (00:54 -0700)]
Cygwin: Build cygwin-console-helper with correct compiler

5 years agoCygwin: Use correct string conversion
Mark Geisert [Thu, 27 Jun 2019 05:31:56 +0000 (22:31 -0700)]
Cygwin: Use correct string conversion

Correct the string conversion calls so both argv elements get converted
at full precision.

5 years agoor1k: Correct longjmp return value
Martin Erik Werner [Wed, 26 Jun 2019 15:44:54 +0000 (17:44 +0200)]
or1k: Correct longjmp return value

Invert equality check instruction to correct the return value handling
in longjmp.

The return value should be the value of the second argument to longjmp,
unless the argument value was 0 in which case it should be 1.

Previously, longjmp would set return value 1 if the second argument was
non-zero, and 0 if it was 0, which was incorrect.

5 years agoCygwin: FIFO: fix a thinko in raw_write
Ken Brown [Tue, 25 Jun 2019 21:14:50 +0000 (17:14 -0400)]
Cygwin: FIFO: fix a thinko in raw_write

Remove a line that has no effect.

5 years agoTweak release message
Ken Brown [Tue, 25 Jun 2019 20:38:39 +0000 (16:38 -0400)]
Tweak release message

5 years agoCygwin: timerfd: avoid a deadlock
Ken Brown [Mon, 24 Jun 2019 16:28:48 +0000 (12:28 -0400)]
Cygwin: timerfd: avoid a deadlock

Add a function timerfd_tracker::enter_critical_section_cancelable,
which is like enter_critical_section but honors a cancel event.  Call
this when a timer expires while the timerfd thread is in its inner
loop.  This avoids a deadlock if timerfd_tracker::dtor has entered its
critical section and is trying to cancel the thread.  See
https://cygwin.com/ml/cygwin/2019-06/msg00096.html.

5 years agoArm: Use lrdimon-v2m_nano when semihosting v2 and nano selected respectively
Alexander Fedotov [Mon, 24 Jun 2019 14:40:17 +0000 (17:40 +0300)]
Arm: Use lrdimon-v2m_nano when semihosting v2 and nano selected respectively

5 years agoSupport calculation of pointer size for __int20__ type in _intsup.h
Jozef Lawrynowicz [Tue, 25 Jun 2019 10:45:02 +0000 (11:45 +0100)]
Support calculation of pointer size for __int20__ type in _intsup.h

GCC r272640 modifies the MSP430 target to use "__int20__" for
PTRDIFF_TYPE (and therefore INTPTR_TYPE) instead of "__int20".

To support the calculation of pointer size in
newlib/libc/include/sys/_intsup.h, definitions for __int20__ need to be
added.

5 years agoCygwin: Implement sched_[gs]etaffinity()
Mark Geisert [Sun, 23 Jun 2019 21:51:06 +0000 (14:51 -0700)]
Cygwin: Implement sched_[gs]etaffinity()

This patch set implements the Linux syscalls sched_getaffinity,
sched_setaffinity, pthread_getaffinity_np, and pthread_setaffinity_np.
Linux has a straightforward view of the cpu sets used in affinity masks.
They are simply long (1024-bit) bit masks.  This code emulates that view
while internally dealing with Windows' distribution of available CPUs among
processor groups.

5 years agoCygwin: FIFO: minor cleanup
Ken Brown [Sat, 22 Jun 2019 15:49:44 +0000 (11:49 -0400)]
Cygwin: FIFO: minor cleanup

Don't use a label with the same name as a variable.

Also fix indentation in fhandler.h.

5 years agoCygwin: FIFO: slightly change the use of write_ready
Ken Brown [Wed, 19 Jun 2019 15:14:37 +0000 (11:14 -0400)]
Cygwin: FIFO: slightly change the use of write_ready

Make it a manual reset event.  It's only used once to allow a reader
to open, and there's no reason to ever reset it.  Defensively set it
when a client connection is recorded, even though it should be set by
the writer that connected.

5 years agoCygwin: FIFO: remove fifo_client_handler::connect_evt
Ken Brown [Thu, 20 Jun 2019 19:14:47 +0000 (15:14 -0400)]
Cygwin: FIFO: remove fifo_client_handler::connect_evt

It's not needed.  Instead just create and use an event in
fhandler_fifo::listen_client_thread.

5 years agoCygwin: FIFO: simplify raw_read
Ken Brown [Fri, 21 Jun 2019 21:33:30 +0000 (17:33 -0400)]
Cygwin: FIFO: simplify raw_read

Call NtReadFile directly instead of calling fhandler_base::raw_read.
In addition to being simpler, this gives us access to the return value
from NtReadFile.

5 years agoCygwin: FIFO: improve termination of the listen_client thread
Ken Brown [Fri, 21 Jun 2019 22:49:11 +0000 (18:49 -0400)]
Cygwin: FIFO: improve termination of the listen_client thread

Add a method fifo_client_handler::pipe_state that queries Windows for
the state of a pipe instance.  Use this to help terminate the
listen_client thread cleanly.

If the last client handler is useless, delete it instead of declaring
it invalid.

5 years agoCygwin: FIFO: avoid deadlock when closing
Ken Brown [Sat, 22 Jun 2019 17:58:12 +0000 (13:58 -0400)]
Cygwin: FIFO: avoid deadlock when closing

fhandler_fifo::close could be called from a signal handler or another
thread at a time when another function is holding the fifo_client
lock.  This could prevent the listen_client thread from acting on the
thread termination event.  Avoid a deadlock by calling
fifo_client_unlock at the beginning of fhandler_fifo::close.

5 years agoCygwin: FIFO: clean up locks
Ken Brown [Sat, 22 Jun 2019 14:07:48 +0000 (10:07 -0400)]
Cygwin: FIFO: clean up locks

Make sure to use the fifo_client lock when (and only when) it is
needed.

5 years agoCygwin: FIFO: add some error checking
Ken Brown [Sat, 22 Jun 2019 15:46:49 +0000 (11:46 -0400)]
Cygwin: FIFO: add some error checking

Change the return type of fhandler_fifo::delete_client_handler from
void to int so that we can report errors.

5 years agoCygwin: FIFO: fix signal handling in raw_read and raw_write
Ken Brown [Sat, 8 Jun 2019 15:05:39 +0000 (11:05 -0400)]
Cygwin: FIFO: fix signal handling in raw_read and raw_write

cygwait wasn't being called correctly.

Also do some minor cleanup in raw_read and raw_write.

5 years agoRename <xlocale.h> back to <sys/_locale.h>
Corinna Vinschen [Wed, 12 Jun 2019 20:31:14 +0000 (22:31 +0200)]
Rename <xlocale.h> back to <sys/_locale.h>

libX11 provides <X11/Xlocale.h>.  The build of libX11 itself adds
include/X11 to the compiler's include path.  This results in a name
collision with /usr/include/xlocale.h on case-insensitive filesystems.

Commit 90e35b1eb3df renamed sys/_locale.h to xlocale.h in March 2017 under
the assumption that we should provide the locale_t type in the same file
as on Linux, FreeBSD, and Darwin.

A few weeks later (June 2017), glibc removed the xlocale.h file in favor
of bits/types/locale_t.h, which shouldn't be included directly anyway.

For reference and the reasoning, see
https://sourceware.org/git/?p=glibc.git;a=commit;h=f0be25b6336d

Given the above, revert 90e35b1eb3df4070e68afc5e7060665214d586be and
fix additional usage of xlocale.h.

5 years agoRevert "Cygwin: fork: Remember child not before success."
Ken Brown [Tue, 11 Jun 2019 12:11:01 +0000 (08:11 -0400)]
Revert "Cygwin: fork: Remember child not before success."

This reverts commit f03ea8e1c57bd5cea83f6cd47fa02870bdfeb1c5.  That
commit leads to fork problems if cygserver is running:

https://cygwin.com/ml/cygwin-patches/2019-q2/msg00155.html

5 years agoFix __getreent stack calculations for AMD GCN
Jeff Johnston [Fri, 7 Jun 2019 17:57:45 +0000 (13:57 -0400)]
Fix __getreent stack calculations for AMD GCN

From: Andrew Stubbs <ams@codesourcery.com>

Fix a bug in which the high-part of 64-bit values are being corrupted, leading
to erroneous stack overflow errors. The problem was only that the mixed-size
calculations are being treated as signed when they should be unsigned.

5 years agoAdd gfortran support for AMD GCN
Jeff Johnston [Fri, 7 Jun 2019 17:55:43 +0000 (13:55 -0400)]
Add gfortran support for AMD GCN

From: Kwok Cheung Yeung <kcy@codesourcery.com>

This patch adds enough support for constructors/destructors and OS functions
to be able to link and run gfortran programs on AMD GCN.

There's no actual ability to do I/O operations on this targets, besides
"write" to stdout and stderr, so most of the functions are just stubs.

5 years agoMark inline functions with __unused;
trasz [Wed, 8 May 2019 18:47:00 +0000 (18:47 +0000)]
Mark inline functions with __unused;

prevents compiler warning when they end up being unused.

Reviewed by: kib
Obtained from: OpenBSD
MFC after: 2 weeks
Sponsored by: Klara Inc.
Differential Revision: https://reviews.freebsd.org/D20185

5 years agosys/sys: further adoption of SPDX licensing ID tags.
pfg [Mon, 27 Nov 2017 15:01:59 +0000 (15:01 +0000)]
sys/sys: further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

5 years agoCygwin: map beyond EOF on 64 bit and WOW64 as well
Corinna Vinschen [Wed, 5 Jun 2019 18:08:34 +0000 (20:08 +0200)]
Cygwin: map beyond EOF on 64 bit and WOW64 as well

32 bit Cygwin performs a POSIX-compatible mapping after EOF which
is not supported in this form on Windows.  The 64 bit Windows
kernel never supported the AT_ROUND_TO_PAGE mapping flag, so we
couldn't page-aligned map the space right after the file's EOF.
So mapping beyond EOF was disabled in 64 bit Windows and WOW64.

However,  if mmap works, a matching munmap should work as well,
*and* it should not accidentally unmap unrelated memory.

Therefore we enable mapping beyond EOF on 64 bit as well.  Since
that mapping is always 64K aligned, the are between the last file
page and the next 64K allocation boundary will be unallocated.
There's no way around that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agomkdir: always check-for-existence
Ben Wijen [Mon, 3 Jun 2019 18:15:50 +0000 (20:15 +0200)]
mkdir: always check-for-existence

When using NtCreateFile when creating a directory that already exists,
it will correctly return 'STATUS_OBJECT_NAME_COLLISION'.

However using this function to create a directory (and all its parents)
a normal use would be to start with mkdir(‘/cygdrive/c’) which translates
to ‘C:\’ for which it'll instead return ‘STATUS_ACCESS_DENIED’.

5 years agocygcheck: expand common_apps list
Yaakov Selkowitz [Thu, 23 May 2019 15:47:36 +0000 (11:47 -0400)]
cygcheck: expand common_apps list

An increasing number of tools are being included in Windows which have the
same names as those included in Cygwin packages.  Indicating which one is
first in PATH can be helpful in diagnosing behavioural discrepencies
between them.

Also, fix the alphabetization of ssh.

5 years agoCygwin: Allow accessing 48 bit address space in Windows 8.1 or later
Corinna Vinschen [Tue, 4 Jun 2019 14:58:53 +0000 (16:58 +0200)]
Cygwin: Allow accessing 48 bit address space in Windows 8.1 or later

64 bit Windows started out with a 44 bit address space due to a
restriction of the AMD64 CPUs at the time.  Starting with Windows
8.1, these CPUs are not supported anymore and Windows switched to
the full 48 bit address space supported by AMD64.

Cygwin didn't follow suit yet so mmaps are still restricted to
the lower 44 bit address space.  Fix that by using a system-specific
upper address for mmap allocations, 44 bit up to Windows 8, 48 bit
starting with Windows 8.1.

While at it, move the heap by another 8 Gigs to leave some space
for a potential extension of DLL address space, and restrict the
mmap lower address so the heap can grow to 32 Gigs before colliding
with mmaps.

5 years agoCygwin: fork: Remember child not before success.
Michael Haubenwallner [Thu, 2 May 2019 10:12:44 +0000 (12:12 +0200)]
Cygwin: fork: Remember child not before success.

Do not remember the child before it was successfully initialized, or we
would need more sophisticated cleanup on child initialization failure,
like cleaning up the process table and suppressing SIGCHILD delivery
with multiple threads ("waitproc") involved.  Compared to that, the
potential slowdown due to an extra yield () call should be negligible.

5 years agoCygwin: fork: Always pause child after fixups.
Michael Haubenwallner [Tue, 30 Apr 2019 07:09:13 +0000 (09:09 +0200)]
Cygwin: fork: Always pause child after fixups.

Pause the child process after performing fork fixups even if there were
no dynamically loaded dlls with extra data/bss transfers to wait for.
This allows the parent process to cancel the current fork call even if
the child process was successfully initialized already.

This is a preparation for when the parent does remember the child no
earlier than after successful child initialization.

5 years agoCygwin: dll_list: no recursive use of nt_max_path_buf
Michael Haubenwallner [Mon, 13 May 2019 14:36:23 +0000 (16:36 +0200)]
Cygwin: dll_list: no recursive use of nt_max_path_buf

Querying the ntlength and existence of the /var/run/cygfork directory in
the very first Cygwin process should not use nt_max_path_buf, as that
one is used by dll_list::alloc already.

5 years agoCygwin: dll_list: stat_real_file_once with ntname
Michael Haubenwallner [Fri, 3 May 2019 14:14:14 +0000 (16:14 +0200)]
Cygwin: dll_list: stat_real_file_once with ntname

NtQueryVirtualMemory for MemorySectionName may return some old path even
if the process was just started, for when some directory in between was
renamed - maybe because the NT file cache is hot for the old path still.
This was seen during gcc bootstrap, returning a MemorySectionName of
".../gcc/xgcc.exe" even if started as ".../prev-gcc/xgcc.exe", where the
directory rename from "gcc" to "prev-gcc" was done the moment before.
As we stat the module's real file right after loading now, there is no
point in using NtQueryVirtualMemory with MemorySectionName any more, and
we can use what GetModuleFileName returned instead.

5 years agoFix vfwscanf(3) assignment suppression flag handling bug
Lucio Andrés Illanes Albornoz [Sat, 1 Jun 2019 08:33:19 +0000 (10:33 +0200)]
Fix vfwscanf(3) assignment suppression flag handling bug

newlib's vfwscanf(3) (or specifically, __SVFWSCANF_R()) fails to correctly set
the assignment-suppressing character (`*') flag[1] which, when present in the
formatting string, results in undefined behaviour comprising retrieving and
dereferencing a pointer that was not supplied by the caller as such or at all.
When compared to the vfscanf(3) implementation, this would appear to be over
the missing goto match_failure statement preceded by the flags test seen below.
Hence, this patch (re)introduces it.

[1] <http://pubs.opengroup.org/onlinepubs/009695399/functions/fwscanf.html>

--

5 years agoAdd support for Hygon Dhyana processor
Jinke Fan [Fri, 17 May 2019 03:29:11 +0000 (11:29 +0800)]
Add support for Hygon Dhyana processor

-Add vendor identification
-Support in get_cpu_cache

Background:
    Chengdu Haiguang IC Design Co., Ltd (Hygon) is a Joint Venture
    between AMD and Haiguang Information Technology Co.,Ltd., aims at
    providing high performance x86 processor for China server market.
    Its first generation processor codename is Dhyana, which
    originates from AMD technology and shares most of the
    architecture with AMD's family 17h, but with different CPU Vendor
    ID("HygonGenuine")/Family series number(Family 18h).

Related Hygon kernel patch can be found on:
http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cn

Signed-off-by: Jinke Fan <fanjinke@hygon.cn>
5 years agoFix <sys/_types.h> issues with <stddef.h>
Sebastian Huber [Thu, 16 May 2019 12:40:34 +0000 (14:40 +0200)]
Fix <sys/_types.h> issues with <stddef.h>

A commit from 2016 tried to address this GCC provided <stddef.h> issue

    #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
      || defined(__DragonFly__) \
      || defined(__FreeBSD_kernel__)
    /* __size_t is a typedef on FreeBSD 5, must not trash it. */
    #elif defined (__VMS__)
    /* __size_t is also a typedef on VMS.  */
    #else
    #define __size_t
    #endif

with an include of <stddef.h> before <sys/_types.h> in <sys/types.h>.
Is is not robust enough.  Do the include of <stddef.h> in <sys/_types.h>
directly and request only the necessary types.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoAvoid <sys/cdefs.h> dependency in <sys/_types.h>
Sebastian Huber [Thu, 16 May 2019 12:40:33 +0000 (14:40 +0200)]
Avoid <sys/cdefs.h> dependency in <sys/_types.h>

Including <sys/cdefs.h> could result in cyclic header dependencies.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoAvoid cyclic header dependencies
Sebastian Huber [Thu, 16 May 2019 12:40:32 +0000 (14:40 +0200)]
Avoid cyclic header dependencies

RTEMS uses a considerable part of FreeBSD kernel and user space sources.
These sources are compiled with a __FreeBSD__ define.  On 2018-06-26
Gerald Pfeifer changed the GCC provided <stddef.h> so that it includes
<sys/_types.h> if __FreeBSD__ is defined.  The Newlib <sys/_types.h>
included <sys/lock.h> which includes <sys/cdefs.h> on RTEMS which
includes <stddef.h>.  To get rid of this cyclic dependency move the
optional _flock_t definition to <sys/reent.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoCygwin: FIFO: respect the O_CLOEXEC flag
Ken Brown [Tue, 28 May 2019 19:50:05 +0000 (15:50 -0400)]
Cygwin: FIFO: respect the O_CLOEXEC flag

Set the inheritance of the Windows pipe handles according to the
O_CLOEXEC flag.  Previously the pipe was always created and opened
with OBJ_INHERIT.

5 years agoCygwin: FIFO: Open only one handle to NPFS
Ken Brown [Thu, 23 May 2019 12:34:09 +0000 (08:34 -0400)]
Cygwin: FIFO: Open only one handle to NPFS

Make npfs_handle a static member function of fhandler_fifo, as in
fhandler_socket_unix.

5 years agoRISC-V: Add _LITE_EXIT in crt0.S.
Jim Wilson [Thu, 23 May 2019 00:41:25 +0000 (17:41 -0700)]
RISC-V: Add _LITE_EXIT in crt0.S.

This patch adds _LITE_EXIT in crt0.S to enable "lite exit" technique in
RISC-V. The changes have been tested in riscv/riscv-gnu-toolchain by
riscv-dejagnu with riscv-sim.exp/riscv-sim-nano.exp.

5 years agoRISC-V: Add size optimized memcpy, memmove, memset and strcmp.
Jim Wilson [Thu, 23 May 2019 00:36:57 +0000 (17:36 -0700)]
RISC-V: Add size optimized memcpy, memmove, memset and strcmp.

This patch adds implementations of memcpy, memmove, memset and strcmp
optimized for size. The changes have been tested in
riscv/riscv-gnu-toolchain by riscv-dejagnu with
riscv-sim.exp/riscv-sim-nano.exp.

5 years agoMake .data section placement coincide with _fdata symbol
Faraz Shahbazker [Thu, 2 May 2019 16:16:44 +0000 (16:16 +0000)]
Make .data section placement coincide with _fdata symbol

The _fdata symbol in MIPS linker scripts is aligned to a 16-byte
boundary.  The ALIGN function does not implicitly update current
location counter.  If sections positioned after the assignment
do not have the same natural alignment as the ALIGN function then
the start of the section group will not coincide with the value
of the symbol.

Given the linker command sequence:
  symbol = ALIGN (NN);
  (.section*)
where the idiom implies a desire to mark the beginning of .section
with symbol, there must be an assignment to the location counter
between the assignment to symbol and the .section pattern.

libgloss/
* mips/array.ld: Update the location counter to match _fdata.
* mips/cfe.ld: Likewise.
* mips/ddb-kseg0.ld: Likewise.
* mips/ddb.ld: Likewise.
* mips/dve.ld: Likewise.
* mips/idt.ld: Likewise.
* mips/idt32.ld: Likewise.
* mips/idt64.ld: Likewise.
* mips/idtecoff.ld: Likewise.
* mips/jmr3904app-java.ld: Likewise.
* mips/jmr3904app.ld: Likewise.
* mips/jmr3904dram-java.ld: Likewise.
* mips/jmr3904dram.ld: Likewise.
* mips/lsi.ld: Likewise.
* mips/mti32.ld: Likewise.
* mips/mti64.ld: Likewise.
* mips/mti64_64.ld: Likewise.
* mips/mti64_n32.ld: Likewise.
* mips/nullmon.ld: Likewise.
* mips/pmon.ld: Likewise.
* mips/sde32.ld: Likewise.
* mips/sde64.ld: Likewise.

5 years agoCygwin: FIFO: code simplifications.
Ken Brown [Thu, 9 May 2019 16:35:58 +0000 (12:35 -0400)]
Cygwin: FIFO: code simplifications.

There's no longer a need to consider the connect_evt after fork/exec.
After stopping the listen_client thread, all client handlers should be
in the fc_connected or fc_invalid states, so their connect_evt members
won't be used again.

Also remove code in fhandler_fifo::dup that just repeats things
already done in stop_listen_client.

5 years agoCygwin: FIFO: make read_ready an auto-reset event
Ken Brown [Thu, 9 May 2019 16:32:17 +0000 (12:32 -0400)]
Cygwin: FIFO: make read_ready an auto-reset event

There's no point in allowing a writer to attempt to open until we've
created a pipe instance.

5 years agoCygwin: FIFO: improve the check for the listen_client thread
Ken Brown [Thu, 9 May 2019 16:28:21 +0000 (12:28 -0400)]
Cygwin: FIFO: improve the check for the listen_client thread

Add a method fhandler_fifo::check_listen_client_thread that checks
whether the thread is running.  Use it in raw_read instead of just
testing the handle listen_client_thr.

5 years agoCygwin: FIFO: set client handler flags more accurately
Ken Brown [Thu, 9 May 2019 16:04:14 +0000 (12:04 -0400)]
Cygwin: FIFO: set client handler flags more accurately

Reflect the fact that client handlers are only used for reading and
that, after connection, they are always nonblocking.

5 years agoCygwin: FIFO: don't leave a pending listen request
Ken Brown [Thu, 9 May 2019 15:55:30 +0000 (11:55 -0400)]
Cygwin: FIFO: don't leave a pending listen request

On exit from the listen_client thread, make sure there's no pending
FSCTL_PIPE_LISTEN request.  Otherwise we might get a client connection
after restarting the thread, and we won't have a handle for
communicating with that client.

Remove the retry loop in the case of STATUS_PIPE_LISTENING; that case
shouldn't occur.

Remove the now-unused fc_connecting value from
fifo_client_connect_state.

5 years agoCygwin: FIFO: add a HANDLE parameter to open_pipe
Ken Brown [Thu, 9 May 2019 15:36:26 +0000 (11:36 -0400)]
Cygwin: FIFO: add a HANDLE parameter to open_pipe

It's now up to the caller to pass a handle to open_pipe and, if
desired, to call set_handle on return.

This will be useful for a future commit, in which we will open a
client connection without setting an io_handle.

5 years agoCygwin: FIFO: re-implement duplexers
Ken Brown [Thu, 9 May 2019 15:23:44 +0000 (11:23 -0400)]
Cygwin: FIFO: re-implement duplexers

When opening a duplexer, open a client connection to the first client
handler.  Previously we gave the duplexer a bogus write handle, which
was just a duplicate of the first client handler's handle.  This meant
that we had a pipe server with no clients connected, and all I/O
attempts failed with STATUS_PIPE_LISTENING.

Extend the last fcntl change to duplexers.

Remove a now unused fifo_client_handler constructor, as well as the
long unusued method fifo_client_handler::connect.

Don't create the pipe in duplex mode; the server handle will only be
used for reading.

5 years agoCygwin: FIFO: add 'record_connection' method
Ken Brown [Thu, 9 May 2019 14:58:29 +0000 (10:58 -0400)]
Cygwin: FIFO: add 'record_connection' method

Future commits will have to re-use the code for recording a client
connection.  For convenience, factor out this code into a new method.

5 years agoCygwin: FIFO: remove incorrect duplexer code
Ken Brown [Thu, 9 May 2019 14:47:47 +0000 (10:47 -0400)]
Cygwin: FIFO: remove incorrect duplexer code

raw_read had some code that was based on an incorrect implementation
of duplexers.

5 years agoRevert "Cygwin: check for STATUS_PENDING in fhandler_base::raw_read"
Ken Brown [Thu, 9 May 2019 14:41:41 +0000 (10:41 -0400)]
Revert "Cygwin: check for STATUS_PENDING in fhandler_base::raw_read"

This reverts commit 10bf30bebf7feebbc3e376cbcac62a242cc240f3.  It was
made because an incorrect implementation of duplex FIFOs.

5 years agoCygwin: dll_list: drop unused read_fbi method
Michael Haubenwallner [Thu, 2 May 2019 08:05:25 +0000 (10:05 +0200)]
Cygwin: dll_list: drop unused read_fbi method

5 years agoCygwin: Add release info for 3.0.7
Corinna Vinschen [Tue, 30 Apr 2019 16:47:02 +0000 (18:47 +0200)]
Cygwin: Add release info for 3.0.7

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 01c253a4c58b6c1da01615431bdc4c88fcba48ea)

5 years agoCygwin: dll_list: query dll file id at load time
Michael Haubenwallner [Tue, 30 Apr 2019 14:15:30 +0000 (16:15 +0200)]
Cygwin: dll_list: query dll file id at load time

NtQueryVirtualMemory for MemorySectionName does not reliable return the
changed dll file name when another process does move the file around,
and we may end up creating forkable hardlinks to wrong dll files.
So query the file id when loading the dll rather than before fork.

5 years agoCygwin: dll_list: stat_real_file_once as dll method
Michael Haubenwallner [Tue, 30 Apr 2019 14:14:55 +0000 (16:14 +0200)]
Cygwin: dll_list: stat_real_file_once as dll method

Make stat_real_file_once a method of struct dll, to be more flexible on
where to use.  Also, debug print memory section name queried for a dll.
This is a preparation to query the file id when loading the dll.

5 years agoCygwin: dll_list: drop FILE_BASIC_INFORMATION
Michael Haubenwallner [Tue, 30 Apr 2019 14:14:09 +0000 (16:14 +0200)]
Cygwin: dll_list: drop FILE_BASIC_INFORMATION

Querying FILE_BASIC_INFORMATION is needless since using win pid+threadid
for forkables dirname rather than newest last write time.

5 years agoCygwin: update era and message locale data
Corinna Vinschen [Tue, 30 Apr 2019 09:52:29 +0000 (11:52 +0200)]
Cygwin: update era and message locale data

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoFix order of eh_frame sections in linker scripts
Faraz Shahbazker [Sun, 28 Apr 2019 18:17:14 +0000 (18:17 +0000)]
Fix order of eh_frame sections in linker scripts

The compiler driver positions the linker script at the end of the linker
command-line, after crtend.o.  As a result, any INPUT objects and archive
GROUPs introduced by the linker script are placed after crtend.o and the
end-of-frame marker provided by crtend.o ends up in between .eh_frames
instead of being at the end.

This has always been a problem, but a binutils update to clean-up
redundant NULL markers in .eh_frame exposes it as a execution failure in
exception-handling tests.  This patch re-orders .eh_frames in all
MIPS linker scripts so that the one from crtend.o is always placed last.

libgloss/
* mips/array.ld: Re-order to place .eh_frame from crtend.o
after all other .eh_frame sections.
* mips/cfe.ld: Likewise.
* mips/ddb-kseg0.ld: Likewise.
* mips/ddb.ld: Likewise.
* mips/dve.ld: Likewise.
* mips/idt.ld: Likewise.
* mips/idt32.ld: Likewise.
* mips/idt64.ld: Likewise.
* mips/jmr3904app.ld: Likewise.
* mips/lsi.ld: Likewise.
* mips/mti32.ld: Likewise.
* mips/mti64.ld: Likewise.
* mips/mti64_64.ld: Likewise.
* mips/mti64_n32.ld: Likewise.
* mips/nullmon.ld: Likewise.
* mips/pmon.ld: Likewise.
* mips/sde32.ld: Likewise.
* mips/sde64.ld: Likewise.

5 years agoCygwin: FIFO: synchronize the blocking mode of a writer's pipe
Ken Brown [Thu, 25 Apr 2019 22:21:11 +0000 (18:21 -0400)]
Cygwin: FIFO: synchronize the blocking mode of a writer's pipe

The blocking mode of the Windows pipe underlying a writer is set to
match that of the writer itself when the latter is opened.  Define
fhandler_fifo::fcntl to keep the pipe and the writer in sync if the
blocking mode is changed via fcntl.

5 years agoCygwin: define MSG_EOR and refuse in send(2)
Corinna Vinschen [Thu, 25 Apr 2019 16:49:32 +0000 (18:49 +0200)]
Cygwin: define MSG_EOR and refuse in send(2)

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoMinor improvements to socket error handling:
Erik M. Bray [Tue, 23 Apr 2019 14:55:33 +0000 (16:55 +0200)]
Minor improvements to socket error handling:

* Change default fallback for failed winsock error -> POSIX error
  mappings to EACCES, which is a valid errno for more socket-related
  syscalls.

* Added a few previously missing entries to the wsock_errmap table
  that have obvious POSIX errno.h analogues.

5 years agoCygwin: FIFO: restart listen_client thread after fork/exec
Ken Brown [Sat, 20 Apr 2019 15:46:09 +0000 (11:46 -0400)]
Cygwin: FIFO: restart listen_client thread after fork/exec

This allows writers to connect immediately.  Previously the lct wasn't
restarted until the reader attempted to read.

5 years agoCygwin: FIFO: stop the listen_client thread before fork/exec
Ken Brown [Sat, 20 Apr 2019 15:41:12 +0000 (11:41 -0400)]
Cygwin: FIFO: stop the listen_client thread before fork/exec

Add methods need_fixup_before, init_fixup_before, and
fixup_before_fork_exec to accomplish this.  Stopping the thread makes
sure that the client handler lists of the parent and child remain in
sync while the forking/execing is in progress.

5 years agoCygwin: FIFO: close connect_evt handles as soon as possible
Ken Brown [Sat, 20 Apr 2019 15:31:08 +0000 (11:31 -0400)]
Cygwin: FIFO: close connect_evt handles as soon as possible

Keeping them open too long can cause an attempt to close them twice
after a fork or exec.

5 years agoCygwin: FIFO: avoid WFMO error in listen_client_thread
Ken Brown [Sat, 20 Apr 2019 15:22:29 +0000 (11:22 -0400)]
Cygwin: FIFO: avoid WFMO error in listen_client_thread

Don't set lct_termination_evt to NULL too early in
fhandler_fifo::stop_listen_client.  Doing so leads to an "Invalid
Handle" error in WFMO.

5 years agoCygwin: FIFO: duplicate the i/o handle when opening a duplexer
Ken Brown [Sat, 20 Apr 2019 15:49:35 +0000 (11:49 -0400)]
Cygwin: FIFO: duplicate the i/o handle when opening a duplexer

Don't use the same i/o handle for the first client handler as is used
for the fhandler itself; this can lead to a later attempt to close the
same handle twice.  Instead use a duplicate.

5 years agoCygwin: FIFO: stop the listen_client thread on an opening error
Ken Brown [Sat, 20 Apr 2019 15:44:01 +0000 (11:44 -0400)]
Cygwin: FIFO: stop the listen_client thread on an opening error

Don't just close the thread handle.

5 years agoCygwin: drop unsupported Windows 10 versions
Corinna Vinschen [Fri, 19 Apr 2019 16:01:44 +0000 (18:01 +0200)]
Cygwin: drop unsupported Windows 10 versions

* Pre-release version still reporting kernel version 6.4.
* Windows 10 1511 is out of support since 2017-10-10.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: FIFO: avoid hang after exec
Ken Brown [Thu, 18 Apr 2019 15:39:52 +0000 (15:39 +0000)]
Cygwin: FIFO: avoid hang after exec

Define fhandler:fifo::fixup_after_exec, which sets listen_client_thr
and lct_termination_evt to NULL.  This forces the listen_client thread
to restart on the first attempt to read after an exec.  Previously the
exec'd process could hang in fhandler_fifo::raw_read.

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