]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
5 years agoFix regression in cris-elf caused by sys/stat.h change
Jeff Johnston [Mon, 19 Aug 2019 21:46:51 +0000 (17:46 -0400)]
Fix regression in cris-elf caused by sys/stat.h change

5 years agoCygwin: select: revamp non-polling code for signalfd
Corinna Vinschen [Fri, 16 Aug 2019 14:36:06 +0000 (16:36 +0200)]
Cygwin: select: revamp non-polling code for signalfd

Rather than waiting for signalfd_select_wait in a thread, which is racy,
create a global event "my_pendingsigs_evt" which is set and reset by
wait_sig depending only on the fact if blocked signals are pending or not.

This in turn allows to WFMO on this event in select as soon as signalfds
are present in the read descriptor set.  Select's peek and verify
will then check if one of the present signalfds is affected.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoRevert "Cygwin: fix potential SEGV in sigwaitinfo/signalfd scenario"
Corinna Vinschen [Fri, 16 Aug 2019 14:36:20 +0000 (16:36 +0200)]
Revert "Cygwin: fix potential SEGV in sigwaitinfo/signalfd scenario"

This reverts commit 92115a83a4579635e253be2887d3706d28b477fd.

This was utterly wrong.

5 years agostat.h: use POSIX-required timefields throughout
Corinna Vinschen [Fri, 16 Aug 2019 08:52:17 +0000 (10:52 +0200)]
stat.h: use POSIX-required timefields throughout

...except in certain SysV R4 cases for backward compat.
This is probably not required anymore, but it doesn't hurt
to keep it in.

5 years agofenv: Include documentation in generated .info file
Joel Sherrill [Wed, 14 Aug 2019 10:24:37 +0000 (11:24 +0100)]
fenv: Include documentation in generated .info file

5 years agoCygwin: ldd: Try harder to get dll names
Mark Geisert [Thu, 15 Aug 2019 05:59:43 +0000 (22:59 -0700)]
Cygwin: ldd: Try harder to get dll names

Borrow a trick from strace to lessen occurrences of "??? => ???" in ldd
output.  Specifically, if the module name isn't found in the usual place
in the mapped image, use the file handle we have to look up the name.

5 years agoCygwin: console: Fix the condition to interrupt select() by SIGWINCH
Takashi Yano [Thu, 15 Aug 2019 05:03:00 +0000 (14:03 +0900)]
Cygwin: console: Fix the condition to interrupt select() by SIGWINCH

- Add code so that select() is not interrupted by SIGWINCH if it is
  ignored (SIG_IGN or SIG_DFL).

5 years agoCygwin: console: Fix workaround for horizontal tab position
Takashi Yano [Thu, 15 Aug 2019 05:02:05 +0000 (14:02 +0900)]
Cygwin: console: Fix workaround for horizontal tab position

- The workaround commit 33a21904a702191cebf0e81b4deba2dfa10a406c
  does not work as expected if window size is changed while screen
  is alternated. Fixed.

5 years agomemmem.c and strstr.c: do not require -std=c99
Giacomo Tesio [Tue, 13 Aug 2019 00:00:07 +0000 (02:00 +0200)]
memmem.c and strstr.c: do not require -std=c99

5 years agofenv: Update makedocbook for eae68bfc
Jon Turney [Mon, 12 Aug 2019 18:27:10 +0000 (19:27 +0100)]
fenv: Update makedocbook for eae68bfc

Teach makedocbook how to handle some new things seen in the makedoc markup
since eae68bfc:
- 'link with' lines appearing in SYNOPSIS sections

Also, don't raise a NoneType exception when there's something we don't
know how to handle in a SYNOPSIS section, just exit.

5 years agofenv: Fix typo-ed variable name in documentation
Jon Turney [Mon, 12 Aug 2019 18:24:54 +0000 (19:24 +0100)]
fenv: Fix typo-ed variable name in documentation

5 years agofenv: Fix mangled makedoc markup
Jon Turney [Mon, 12 Aug 2019 18:18:15 +0000 (19:18 +0100)]
fenv: Fix mangled makedoc markup

See makedoc.c:657:
Variables are marked up as '<[foo]>'.
Code is marked up as '<<foo>>'.

5 years agofenv: fe_dfl_env.c doesn't contain any documentation
Jon Turney [Mon, 12 Aug 2019 18:13:33 +0000 (19:13 +0100)]
fenv: fe_dfl_env.c doesn't contain any documentation

fe_dfl_env.c doesn't contain any documentation, so drop it from makedoc
processing.

5 years agoCygwin: fix potential SEGV in sigwaitinfo/signalfd scenario
Corinna Vinschen [Mon, 12 Aug 2019 20:40:50 +0000 (22:40 +0200)]
Cygwin: fix potential SEGV in sigwaitinfo/signalfd scenario

On sigwaitinfo or reading from a signalfd, signal processing sets up
signal handling via sigdelayed even if the handler address is NULL.
This doesn't have any impact on sigwaitinfo scenarios (or at least, I
wasn't able to come up with a reproducer) but it breaks signalfd
scenarios, where eventually a call to call_signal_handler from
sigdelayed will try to call the NULL function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agosched.h: Declare affinity functions only on targets supporting them
Corinna Vinschen [Mon, 12 Aug 2019 10:13:20 +0000 (12:13 +0200)]
sched.h: Declare affinity functions only on targets supporting them

5 years agoCygwin: ps: fix a compiler warning
Corinna Vinschen [Mon, 12 Aug 2019 15:29:59 +0000 (17:29 +0200)]
Cygwin: ps: fix a compiler warning

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: console: Fix cursor position restore after screen alternation.
Takashi Yano [Mon, 12 Aug 2019 13:48:45 +0000 (22:48 +0900)]
Cygwin: console: Fix cursor position restore after screen alternation.

- If screen is alternated on console, cursor position is not restored
  correctly in the case of xterm compatible mode is enabled. For example,
  the shell prompt is shown at incorrect position after using vim.
  This patch fixes this problem.

5 years agoCygwin: console: Add workaround for windows xterm compatible mode bug.
Takashi Yano [Mon, 12 Aug 2019 13:47:42 +0000 (22:47 +0900)]
Cygwin: console: Add workaround for windows xterm compatible mode bug.

- The horizontal tab positions are broken after resizing console window.
  This seems to be a bug of xterm compatible mode of windows console.
  This workaround fixes this problem.

5 years agoCygwin: console: Fix deadlock at calling fork().
Takashi Yano [Mon, 12 Aug 2019 13:46:23 +0000 (22:46 +0900)]
Cygwin: console: Fix deadlock at calling fork().

- Calling fork() on console occasionally falls into deadlock. The reason
  is not clear, however, this patch fixes this problem anyway.

5 years agoRegenerated files from fenv.h addition
Joel Sherrill [Tue, 6 Aug 2019 19:13:18 +0000 (14:13 -0500)]
Regenerated files from fenv.h addition

5 years agoAdd default implementation of fenv.h and all methods
Joel Sherrill [Thu, 8 Aug 2019 16:27:06 +0000 (11:27 -0500)]
Add default implementation of fenv.h and all methods

The default implementation of the fenv.h methods return
-EOPNOTSUP. Some of these have implementations appropriate
        for soft-float.

The intention of the new fenv.h is that it be portable
and that architectures provide their own implementation
of sys/fenv.h.

5 years agoMiscellaneous Makefile.in regenerated
Joel Sherrill [Tue, 6 Aug 2019 19:13:16 +0000 (14:13 -0500)]
Miscellaneous Makefile.in regenerated

5 years agoCygwin: drop preliminary 3.0.8 release file
Corinna Vinschen [Fri, 9 Aug 2019 15:49:03 +0000 (17:49 +0200)]
Cygwin: drop preliminary 3.0.8 release file

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: add missing bugfix release messages for 3.1.0
Corinna Vinschen [Fri, 9 Aug 2019 15:47:32 +0000 (17:47 +0200)]
Cygwin: add missing bugfix release messages for 3.1.0

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: shmat: use mmap allocator strategy on 64 bit
Corinna Vinschen [Thu, 8 Aug 2019 08:53:58 +0000 (10:53 +0200)]
Cygwin: shmat: use mmap allocator strategy on 64 bit

This avoids collisions of shmat maps with Windows own datastructures
when allocating top-down.

This patch moves the mmap_allocator class definition into its
own files and just uses it from mmap and shmat.

5 years agoCygwin: getpriority() and top display for priority is inconsistent
Lavrentiev, Anton [Wed, 7 Aug 2019 19:27:41 +0000 (19:27 +0000)]
Cygwin: getpriority() and top display for priority is inconsistent

Fix this by aligning /proc/[PID]/stat to the values returned by getpriority().

5 years agoCygwin: build_env: fix off-by-one bug when re-adding PATH
Michael Haubenwallner [Wed, 7 Aug 2019 08:51:16 +0000 (10:51 +0200)]
Cygwin: build_env: fix off-by-one bug when re-adding PATH

Adding default winvar 'PATH=C:\cygwin64\binZ' to an environment that is
already allocated for 'SYSTEMROOT=ZWINDIR=Z', we need to count that
trailing (Z)ero as well.  Otherwise we trigger this assertion failure:

$ /bin/env -i SYSTEMROOT= WINDIR= /bin/env
assertion "(s - envblock) <= tl" failed: file "/home/corinna/src/cygwin/cygwin-3.0.7/cygwin-3.0.7-1.x86_64/src/newlib-cygwin/winsup/cygwin/environ.cc", line 1302, function: char** build_env(const char* const*, WCHAR*&, int&, bool, HANDLE)
Aborted (core dumped)

5 years agoCygwin: exec: check execute bit prior to evaluating script
Corinna Vinschen [Tue, 6 Aug 2019 08:46:31 +0000 (10:46 +0200)]
Cygwin: exec: check execute bit prior to evaluating script

When the exec family of functions is called for a script-like
file, the av::setup function handles the exec[vl]p case as
well.  The execve case for files not starting with a she-bang
is handled first by returning ENOEXEC.  Only after that, the
file's executability is checked.

This leads to the problem that ENOEXEC is returned for non-executable
files as well.  A calling shell interprets this as a file it should try
to run as script.  This is not desired for non-executable files.

Fix this problem by checking the file for executability first.  Only
after that, follow the other potential code paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoAlign libgloss/arm and libc/sys/arm sources: miscellaneous fixes
Alexander Fedotov [Fri, 2 Aug 2019 12:33:46 +0000 (07:33 -0500)]
Align libgloss/arm and libc/sys/arm sources: miscellaneous fixes

1. Trim trailing spaces
2. Align comments, function declarations and definitions

5 years agoAlign libgloss/arm and libc/sys/arm sources: Lite exit support
Alexander Fedotov [Fri, 2 Aug 2019 12:33:45 +0000 (07:33 -0500)]
Align libgloss/arm and libc/sys/arm sources: Lite exit support

Applied changes from commit 2404223:

* arm/crt0.S (_mainCRTStartup): Weak reference to atexit and _fini
when lite exit is enabled.

5 years agoAlign libgloss/arm and libc/sys/arm sources: HeapInfo and __heap_limit
Alexander Fedotov [Fri, 2 Aug 2019 12:33:44 +0000 (07:33 -0500)]
Align libgloss/arm and libc/sys/arm sources: HeapInfo and __heap_limit

Applied changes from commit 8d98f95:

* arm/crt0.S: Initialise __heap_limit when ARM_RDI_MONITOR is defined.
* arm/syscalls.c: define __heap_limit global symbol.
* arm/syscalls.c (_sbrk): Honour __heap_limit.

Applied changes from commit 8d98f95:
Fixed semihosting for ARM when heapinfo not provided by debugger

5 years agoAlign libgloss/arm and libc/sys/arm sources: Fix GetCmdLine semihosting directives
Alexander Fedotov [Fri, 2 Aug 2019 12:33:43 +0000 (07:33 -0500)]
Align libgloss/arm and libc/sys/arm sources: Fix GetCmdLine semihosting directives

Applied changes from the commit 9b11672:

When simulating arm code, the target program startup code (crt0) uses
semihosting invocations to get the command line from the simulator. The
simulator returns the command line and its size into the area passed in
parameter. (ARM 32-bit specifications :
http://infocenter.arm.com/help/topic/com.arm.doc.dui0058d/DUI0058.pdf
chapter "5.4.19 SYS_GET_CMDLINE").

The memory area pointed by the semihosting register argument is located
in .text section (usually not writtable (RX)).

If we run this code on a simulator that respects this rights properties
(qemu user-mode for instance), the command line will not be written to
the .text program memory, in particular the length of the string. The
program runs with an empty command line. This problem hasn't been seen
earlier probably because qemu user-mode is not so much used, but this can
happen with another simulator that refuse to write in a read-only segment.

With this modification, the command line can be correctly passed to the
target program.

Changes:
- newlib/libc/sys/arm/crt0.S : Arguments passed to the
AngelSWI_Reason_GetCmdLine semihosting invocation are placed into .data
section instead of .text

5 years agoCygwin: Implement CPU_SET(3) macros
Mark Geisert [Sun, 4 Aug 2019 22:45:46 +0000 (15:45 -0700)]
Cygwin: Implement CPU_SET(3) macros

This patch supplies an implementation of the CPU_SET(3) processor
affinity macros as documented on the relevant Linux man page.

There is a mostly superset implementation of cpusets under newlib's
libc/sys/RTEMS/include/sys that has Linux and FreeBSD compatibility
and is built on top of FreeBSD bitsets.  This Cygwin implementation
and the RTEMS one could be combined if desired at some future point.

5 years agoRISC-V: Fix header guard for sys/fenv.h
Kito Cheng [Fri, 2 Aug 2019 03:38:09 +0000 (11:38 +0800)]
RISC-V: Fix header guard for sys/fenv.h

5 years agoCygwin: fork: attach child not before success
Michael Haubenwallner [Wed, 31 Jul 2019 10:35:33 +0000 (12:35 +0200)]
Cygwin: fork: attach child not before success

Do not attach to the child before it was successfully initialized, or we
would need more sophisticated cleanup on child initialization failure,
like suppressing SIGCHILD delivery with multiple threads ("waitproc")
involved.

Improves "Cygwin: fork: Remember child not before success.",
commit f03ea8e1c57bd5cea83f6cd47fa02870bdfeb1c5, which leads to fork
problems if cygserver is running:

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

5 years agoCygwin: pinfo: stop remember doing reattach
Michael Haubenwallner [Wed, 31 Jul 2019 10:35:31 +0000 (12:35 +0200)]
Cygwin: pinfo: stop remember doing reattach

During fork, the child process requires the process table to be
initialized for fixup_shms_after_fork, while still allowing subsequent
dlls.load_after_fork to fail silently (for when the "forkable" hardlinks
are not created yet).
pinfo::remember not performing reattach anymore requires explicit
pinfo::reattach now where appropriate.

Prepares to improve "Cygwin: fork: Remember child not before success."
commit f03ea8e1c57bd5cea83f6cd47fa02870bdfeb1c5, which leads to fork
problems if cygserver is running:

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

5 years agoAlign _end symbol to at least 4 in all MIPS scripts
Faraz Shahbazker [Tue, 30 Jul 2019 00:00:25 +0000 (00:00 +0000)]
Align _end symbol to at least 4 in all MIPS scripts

Left-over part of commit 84b2a020daa17d8ee5c9ec979c3d56f95e69573b

The _end marker must be aligned to 4-bytes to ensure that the last
element written does not reach beyond the address of _end.  This is
also necessary as the termination condition is an equality test
instead of an ordered test so (_end - _fbss) must be a multiple of
4-bytes.  The alignment is already correct for mti*.ld files, fix
it for all remaining MIPS scripts that don't already align to at
least 4.

5 years agocommon/math_errf.c: Enable compilation of __math_oflowf
Joel Sherrill [Fri, 26 Jul 2019 19:37:23 +0000 (14:37 -0500)]
common/math_errf.c: Enable compilation of __math_oflowf

This resolved linking errors when using methods such as
expm1().

5 years agohash.c: #include <reent.h>
Ken Brown [Fri, 26 Jul 2019 14:09:23 +0000 (10:09 -0400)]
hash.c: #include <reent.h>

This is needed for the prototypes of _stat64 and _fstat64 on Cygwin.

Fixes: commit 279805b2 "hash functions: use reentrant stat functions".
5 years ago[arm] remove libc/sys/arm/sys/param.h
Richard Earnshaw [Fri, 26 Jul 2019 15:08:55 +0000 (16:08 +0100)]
[arm] remove libc/sys/arm/sys/param.h

The Arm sys/param.h does not define anything differently to the
generic sys/param.h, but fails to define some things that that file
provides.  There does not appear to be any reason to keep this version
and we should revert to using the common version.

5 years agoPort ndbm - Remove Declaration of dbm_forder
Vaibhav Gupta [Thu, 25 Jul 2019 13:24:50 +0000 (18:54 +0530)]
Port ndbm - Remove Declaration of dbm_forder

5 years agoCygwin: Fix the address of myself
Corinna Vinschen [Wed, 24 Jul 2019 15:48:57 +0000 (17:48 +0200)]
Cygwin: Fix the address of myself

Introducing an independent Cygwin PID introduced a regression:

The expectation is that the myself pinfo pointer always points to a
specific address right in front of the loaded Cygwin DLL.

However, the independent Cygwin PID changes broke this.  To create
myself at the right address requires to call init with h0 set to
INVALID_HANDLE_VALUE or an existing address:

void
pinfo::init (pid_t n, DWORD flag, HANDLE h0)
{
  [...]
  if (!h0 || myself.h)
    [...]
  else
    {
      shloc = SH_MYSELF;
      if (h0 == INVALID_HANDLE_VALUE)       <-- !!!
        h0 = NULL;
    }

The aforementioned commits changed that so h0 was always NULL, this way
creating myself at an arbitrary address.

This patch makes sure to set the handle to INVALID_HANDLE_VALUE again
when creating a new process, so init knows that myself has to be created
in the right spot.  While at it, fix a potential uninitialized handle
value in child_info_spawn::handle_spawn.

Fixes: b5e1003722cb ("Cygwin: processes: use dedicated Cygwin PID rather than Windows PID")
Fixes: 88605243a19b ("Cygwin: fix child getting another pid after spawnve")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Don't change pgid to ctty pgid under debugger
Corinna Vinschen [Thu, 25 Jul 2019 08:40:03 +0000 (10:40 +0200)]
Cygwin: Don't change pgid to ctty pgid under debugger

_pinfo::set_ctty sets myself's pgid to the ctty pgid if the process has
been started from a non-Cygwin process.  This isn't the right thing to
do when started from GDB.  GDB starts the application via standard
Windows means, not via Cygwin fork/exec, so it's treated as being
a non-Cygwin parent.

But we want the app running in it's own process group.  So skip this
step when running under a debugger

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

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