]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
5 years agoCygwin: unlink: allow fallback from POSIX to default method
Corinna Vinschen [Wed, 6 Feb 2019 20:17:35 +0000 (21:17 +0100)]
Cygwin: unlink: allow fallback from POSIX to default method

Trying to delete in-use executables and DLLs using
FILE_DISPOSITION_POSIX_SEMANTICS returns STATUS_CANNOT_DELETE.
Fall back to the former method if that error occurs to allow
unlinking these files.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc fd: fix handling of pipes, sockets, etc
Corinna Vinschen [Tue, 5 Feb 2019 14:32:08 +0000 (15:32 +0100)]
Cygwin: proc fd: fix handling of pipes, sockets, etc

The symlink target of /proc/PID/fd files pointing to pipes and
sockets are just artificial filenames referencing the object using
some internal number.  The pipe open code expects a path specifying
process pid and the internal number so it access the right process
and pipe.

- Set the posix path of the pipe to the simple pipe name only,
  as it shows up in /proc/PID/fd.  A /proc/self prefix is just
  as wrong as a /dev/fd prefix.

- Revert thinko in fhandler_pipe::open expecting the name as
  /proc/self/fd/...  In fact this should never happen.

- Fix up the path before re-opening the pipe instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc fd: fix a copy/paste bug calling file_pathconv
Corinna Vinschen [Tue, 5 Feb 2019 14:20:50 +0000 (15:20 +0100)]
Cygwin: proc fd: fix a copy/paste bug calling file_pathconv

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc fd: pass along open mode when reopening file
Corinna Vinschen [Tue, 5 Feb 2019 14:20:13 +0000 (15:20 +0100)]
Cygwin: proc fd: pass along open mode when reopening file

The reopen code neglected to pass along the requested open
mode correctly.  This may end up reopening the file with
incorrect access mask, or duplicating the wrong pipe handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork: terminate child process unconditionally in error case
Corinna Vinschen [Tue, 5 Feb 2019 11:52:13 +0000 (12:52 +0100)]
Cygwin: fork: terminate child process unconditionally in error case

Move TerminateProcess call into cleanup code to make sure child
doesn't linger in some border cases.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agofork: remove cygpid.N sharedmem on fork failure
Michael Haubenwallner [Tue, 5 Jun 2018 10:40:21 +0000 (12:40 +0200)]
fork: remove cygpid.N sharedmem on fork failure

When fork finally fails although both CreateProcess and creating the
"cygpid.N" shared memory section succeeded, we have to release that
shared memory section as well - before releasing the process handle.
Otherways we leave an orphan "cygpid.N" shared memory section, and any
subsequent cygwin process receiving the same PID fails to initialize.

* fork.cc (frok::parent): Call child.allow_remove in cleanup code.

5 years agoCygwin: timerfd: drop outdated TODO comment
Corinna Vinschen [Mon, 4 Feb 2019 20:08:03 +0000 (21:08 +0100)]
Cygwin: timerfd: drop outdated TODO comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fix typo
Corinna Vinschen [Sat, 2 Feb 2019 20:15:50 +0000 (21:15 +0100)]
Cygwin: fix typo

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: tweak Cygwin PID change release note
Corinna Vinschen [Sat, 2 Feb 2019 20:13:37 +0000 (21:13 +0100)]
Cygwin: tweak Cygwin PID change release note

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: kill(1): introduce a -W option
Corinna Vinschen [Sat, 2 Feb 2019 20:02:00 +0000 (21:02 +0100)]
Cygwin: kill(1): introduce a -W option

Allow to kill processes using Windows PIDs on the command line.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: spawn: create and maintain winpid symlinks
Corinna Vinschen [Sat, 2 Feb 2019 19:01:41 +0000 (20:01 +0100)]
Cygwin: spawn: create and maintain winpid symlinks

- If the execve'ed process is a non-Cygwin process, we have to
  create the matching winpid symlink and remove the old one
  ourselves.

- If we spawn a child, the winpid symlink has to be maintained
  by the child process, otherwise it disappears if the parent
  process exits.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: pinfo: simplify create_winpid_symlink
Corinna Vinschen [Sat, 2 Feb 2019 17:11:42 +0000 (18:11 +0100)]
Cygwin: pinfo: simplify create_winpid_symlink

The arguments are not used anyway, so drop them.  When called,
procinfo->dwProcessId is already set right, so we don't have
to access myself_initial.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: kill(1): revert casts required for 32 bit to avoid spurious warnings
Corinna Vinschen [Sat, 2 Feb 2019 14:32:28 +0000 (15:32 +0100)]
Cygwin: kill(1): revert casts required for 32 bit to avoid spurious warnings

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Makefile.in: Fix previous version info generation fix
Corinna Vinschen [Sat, 2 Feb 2019 14:10:13 +0000 (15:10 +0100)]
Cygwin: Makefile.in: Fix previous version info generation fix

Commit 231ad6941f9ade7bde67d27929da5a776ebd9457 looks good...
as long as you never build Cygwin from scratch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: kill(1): disallow killing process using raw Windows PID
Corinna Vinschen [Sat, 2 Feb 2019 14:00:39 +0000 (15:00 +0100)]
Cygwin: kill(1): disallow killing process using raw Windows PID

This may end up killing the wrong process.  Only allow Cygwin PID.

Slightly clean up code: Remove outdated W95 considerations.  Fix
a bug in commandline argument processing.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: processes: fix handling of native Windows processes
Corinna Vinschen [Sat, 2 Feb 2019 11:23:39 +0000 (12:23 +0100)]
Cygwin: processes: fix handling of native Windows processes

Since commit b5e1003722cb14235c4f166be72c09acdffc62ea, native
Windows processes not started by Cygwin processes don't have a
Cygwin PID anymore.  This breaks ps -W and kill -f <WINPID>.

Introduce MAX_PID (65536 for now).

Cygwin processes as well as native Windows processes started
from a Cygwin process get a PID < MAX_PID.  All other native
Windows processes get a faked Cygwin PID >= MAX_PID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Makefile.in: Fix another dependency problem in version info
Corinna Vinschen [Sat, 2 Feb 2019 10:13:17 +0000 (11:13 +0100)]
Cygwin: Makefile.in: Fix another dependency problem in version info

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: processes: use dedicated Cygwin PID rather than Windows PID
Corinna Vinschen [Thu, 31 Jan 2019 20:19:03 +0000 (21:19 +0100)]
Cygwin: processes: use dedicated Cygwin PID rather than Windows PID

Using the Windows PID as Cygwin PID has a few drawbacks:

- the PIDs on Windows get reused quickly.  Some POSIX applications choke
  on that, so we need extra code to avoid too quick PID reuse.

- The code to avoid PID reuse keeps parent process handles and
  (depending on a build option) child processes open unnecessarily.

- After an execve, the process has a split personality:  Its Windows PID
  is a new PID, while its Cygwin PID is the PID of the execve caller
  process.  This requires to keep two procinfo shared sections open, the
  second just to redirect process info requests to the first, correct
  one.

This patch changes the way Cygwin PIDs are generated:

- Cygwin PIDs are generated independently of the Windows PID, in a way
  expected by POSIX processes.  The PIDs are created incrementally in
  the range between 2 and 65535, round-robin.

- On startup of the first Cygwin process, choose a semi-random start PID
  for the first process in the lower PID range to make the PIDs slightly
  unpredictable.  This may not be necessary but it seems kind of inviting
  to know that the first Cygwin process always starts with PID 2.

- Every process not only creates the shared procinfo section, but also a
  symlink in the NT namespace, symlinking the Windows PID to the Cygwin
  PID.  This drops the need for the extra procinfo section after execve.

- Don't keep other process handles around unnecessarily.

- Simplify the code creating/opening the shared procinfo section and
  make a clear distinction between interfaces getting a Cygwin PID and
  interfaces getting a Windows PID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: remove outdated vfork doc
Corinna Vinschen [Fri, 1 Feb 2019 12:36:27 +0000 (13:36 +0100)]
Cygwin: remove outdated vfork doc

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: /proc: don't exit prematurely from /proc/PID/status
Corinna Vinschen [Fri, 1 Feb 2019 12:18:15 +0000 (13:18 +0100)]
Cygwin: /proc: don't exit prematurely from /proc/PID/status

If a process is just exiting, requesting memory info may fail
with STATUS_PROCESS_IS_TERMINATING.  Right now the code just bails
out if fetching mem info fails.  However, the rest of the info is
still valuable for procps, so just carry on.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Add pthread exception handling patch to release notes
Corinna Vinschen [Wed, 30 Jan 2019 21:21:46 +0000 (22:21 +0100)]
Cygwin: Add pthread exception handling patch to release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoscandir: Add support for struct dirent::d_type
Sebastian Huber [Thu, 31 Jan 2019 10:48:12 +0000 (11:48 +0100)]
scandir: Add support for struct dirent::d_type

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoa) Use strcoll() in opendir() and alphasort()
ache [Mon, 18 Jan 2010 10:17:51 +0000 (10:17 +0000)]
a) Use strcoll() in opendir() and alphasort()

as POSIX 2008 requires. It also matches now how our 'ls' works for years.

b) Remove comment expressed 2 fears:
 1) One just simple describe how strcoll() works in _any_ context,
 not for directories only. Are we plan to remove strcoll() from everything
 just because it is little more complex than strcmp()? I doubt, and
 directories give nothing different here. Moreover, strcoll() used
 in 'ls' for years and nobody complaints yet.

 2) Plain wrong statement about undefined strcoll() behaviour. strcoll()
 always gives predictable results, falling back to strcmp() on any
 trouble, see strcoll(3).

No objections from -current list discussion.

5 years agoscandir(3) previously used st_size
das [Sun, 16 Mar 2008 19:08:53 +0000 (19:08 +0000)]
scandir(3) previously used st_size

to obtain an initial estimate of the array length needed to store all
the directory entries. Although BSD has historically guaranteed that
st_size is the size of the directory file, POSIX does not, and more to
the point, some recent filesystems such as ZFS use st_size to mean
something else.

The fix is to not stat the directory at all, set the initial
array size to 32 entries, and realloc it in powers of 2 if that
proves insufficient.

PR: 113668

5 years agoRemove __P and convert to ANSI prototypes.
obrien [Fri, 1 Feb 2002 01:32:19 +0000 (01:32 +0000)]
Remove __P and convert to ANSI prototypes.

* Fix SCM ID's.

5 years agoClean up the vcs ID strings
jhb [Tue, 3 Jul 2018 17:31:45 +0000 (17:31 +0000)]
Clean up the vcs ID strings

in libc's gen/ directory.

- Move CSRG IDs into __SCCSID().
- When a file has been copied, consistently use 'From: <tag>' for strings
  referencing the version of the source file copied from in the license
  block comment.
- Some of the 'From:' tags were using $FreeBSD$ that was being expanded on
  each checkout.  Fix those to hardcode the FreeBSD tag from the file that
  was copied at the time of the copy.
- When multiple strings are present list them in "chronological" order,
  so CSRG (__SCCSID) before FreeBSD (__FBSDID).  If a file came from
  OtherBSD and contains a CSRG ID from the OtherBSD file, use the order
  CSRG -> OtherBSD -> FreeBSD.

Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D15831

5 years agoRenumber copyright clause 4
imp [Tue, 28 Feb 2017 23:42:47 +0000 (23:42 +0000)]
Renumber copyright clause 4

Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by: Jan Schaumann <jschauma@stevens.edu>
Pull Request: https://github.com/freebsd/freebsd/pull/96

5 years agoscandir: Update copyright notice from FreeBSD
Sebastian Huber [Thu, 31 Jan 2019 10:42:29 +0000 (11:42 +0100)]
scandir: Update copyright notice from FreeBSD

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
5 years agoGeneral further adoption of SPDX licensing ID tags.
pfg [Mon, 20 Nov 2017 19:49:47 +0000 (19:49 +0000)]
General further adoption of SPDX licensing ID tags.

Mainly focus on files that use BSD 3-Clause license.

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.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.

5 years agoCygwin: x86_64: pthreads: Install exception handler after switching stack
Corinna Vinschen [Wed, 30 Jan 2019 19:05:39 +0000 (20:05 +0100)]
Cygwin: x86_64: pthreads: Install exception handler after switching stack

After creating a pthread, the stack gets moved to the desired memory
location.  While the 32 bit thread wrapper copies the exception handler
information to the new stack (so we have at least *some* exception
handler present), the x86_64 code didn't perform any exception handler
magic.  Fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: document W10 1803 per-directory case-sensitivity behaviour
Corinna Vinschen [Wed, 30 Jan 2019 15:16:25 +0000 (16:16 +0100)]
Cygwin: document W10 1803 per-directory case-sensitivity behaviour

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork: fix child process permissions, take 2
Corinna Vinschen [Wed, 30 Jan 2019 11:18:03 +0000 (12:18 +0100)]
Cygwin: fork: fix child process permissions, take 2

VirtualQueryEx, called by fixup_mmaps_after_fork, requires
PROCESS_QUERY_INFORMATION permissions per MSDN.  However, testing
shows that PROCESS_QUERY_LIMITED_INFORMATION is sufficient when
running the same code on Windows 8.1 or Windows 10.  Fix the code
to give the forked child always PROCESS_QUERY_INFORMATION perms
on Windows Vista/7 and respective server releases.

Revert now unneeded patch to check_token_membership as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: raise: change to call pthread_kill
Corinna Vinschen [Wed, 30 Jan 2019 10:36:45 +0000 (11:36 +0100)]
Cygwin: raise: change to call pthread_kill

POSIX requires that raise(3) is equivalent to

  pthread_kill(pthread_self(), sig);

in multi-threaded applications.  Our raise just called kill(sig).
Fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: execve: reduce parent handle to non-inheritable SYNCHRONIZE
Corinna Vinschen [Tue, 29 Jan 2019 19:37:00 +0000 (20:37 +0100)]
Cygwin: execve: reduce parent handle to non-inheritable SYNCHRONIZE

Keeping an inheritable handle open results in that handle being
spilled over into grandchild processes, which is not desired.
Duplicate original parent handle into a non-inheritable one with
minimal SYNCHRONIZE permissions and close the original handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork/exec: fix child process permissions
Corinna Vinschen [Tue, 29 Jan 2019 15:26:45 +0000 (16:26 +0100)]
Cygwin: fork/exec: fix child process permissions

- Exec'ed/spawned processes don't need PROCESS_DUP_HANDLE.  Remove that
  permission from the parent handle.

- PROCESS_QUERY_LIMITED_INFORMATION doesn't work for Windows 7 if the
  process is started as a service.  Add PROCESS_QUERY_INFORMATION for
  pre-Windows 8 in that case.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Makefile.in: Improve dependency for version info
Corinna Vinschen [Tue, 29 Jan 2019 16:33:59 +0000 (17:33 +0100)]
Cygwin: Makefile.in: Improve dependency for version info

The version info only depends on the object files.  This results
in the version info not being rebuild immediately if a source
file is changed.  Rather, the version info is only rebuilt on the
next make run.

Fix that by making the version info build rule dependent on the
source files.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: procfd: improve debug output
Corinna Vinschen [Mon, 28 Jan 2019 09:23:59 +0000 (10:23 +0100)]
Cygwin: procfd: improve debug output

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: seteuid: disable unused funcs and lsaauth subdir
Corinna Vinschen [Sun, 27 Jan 2019 12:32:44 +0000 (13:32 +0100)]
Cygwin: seteuid: disable unused funcs and lsaauth subdir

If S4U proves to be usable alone, remove this code entirely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: spawn: revert incorrect restriction of permissions
Corinna Vinschen [Sun, 27 Jan 2019 21:42:41 +0000 (22:42 +0100)]
Cygwin: spawn: revert incorrect restriction of permissions

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork: restrict parent handle perms and drop handle after use
Corinna Vinschen [Sun, 27 Jan 2019 12:15:15 +0000 (13:15 +0100)]
Cygwin: fork: restrict parent handle perms and drop handle after use

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: seteuid: use Kerberos/MsV1_0 S4U authentication by default
Corinna Vinschen [Sat, 26 Jan 2019 17:33:41 +0000 (18:33 +0100)]
Cygwin: seteuid: use Kerberos/MsV1_0 S4U authentication by default

- This simple and official method replaces cyglsa and "create token"
  methods.  No network share access, same as before.

- lsaauth and create_token are disabled now.  If problems crop up,
  they can be easily reactivated.  If no problems crop up, they
  can be removed in a while, together with the lsaauth subdir.

- Bump Cygwin version to 3.0.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: uname: Raise size of utsname fields and revamp uname(2) output
Corinna Vinschen [Thu, 24 Jan 2019 11:01:01 +0000 (12:01 +0100)]
Cygwin: uname: Raise size of utsname fields and revamp uname(2) output

New format:

  sysname:      CYGWIN_NT-${osversion}-${os_build_number}[-WOW64]
  nodename:     `gethostname`
  release:      ${cygwin_version}-${API minor}.${arch}[.snap]
  version:      YYYY-MM-DD HH:MM UTC
  machine:      ${arch}
_GNU_SOURCE:
  domainname:   `getdomainname`
!_GNU_SOURCE:
  __domainname: `getdomainname`

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: netdb.h: fix __GNU_VISIBLE tests
Corinna Vinschen [Sat, 26 Jan 2019 17:26:56 +0000 (18:26 +0100)]
Cygwin: netdb.h: fix __GNU_VISIBLE tests

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: create_token: Return NULL, not INVALID_HANDLE_VALUE
Corinna Vinschen [Fri, 25 Jan 2019 18:58:21 +0000 (19:58 +0100)]
Cygwin: create_token: Return NULL, not  INVALID_HANDLE_VALUE

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: syscalls.cc: fix formatting
Corinna Vinschen [Fri, 25 Jan 2019 19:02:03 +0000 (20:02 +0100)]
Cygwin: syscalls.cc: fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: lsaauth: Drop outdated test for loading Secur32.dll
Corinna Vinschen [Fri, 25 Jan 2019 19:01:11 +0000 (20:01 +0100)]
Cygwin: lsaauth: Drop outdated test for loading Secur32.dll

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: seteuid: work with password-less user switch as well
Corinna Vinschen [Thu, 24 Jan 2019 20:19:40 +0000 (21:19 +0100)]
Cygwin: seteuid: work with password-less user switch as well

The previous patch failed with password-less auth because in
that case the return code from get_server_groups wasn't tested.
Fix that.  Also make sure that get_server_groups does not
check if the account is disabled or locked out when just fetching
the group list for initgroups or getgrouplist.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: seteuid: refuse changing uid to disabled or locked out user
Corinna Vinschen [Thu, 24 Jan 2019 15:22:49 +0000 (16:22 +0100)]
Cygwin: seteuid: refuse changing uid to disabled or locked out user

So far seteuid could change uid to any existing account, given
sufficient permissions of the caller.  This is kind of bad since
it disallows admins to refuse login to disabled or locked out
accounts.

Add check for the account's UF_ACCOUNTDISABLE or UF_LOCKOUT flags
and don't let the user in, if one of the flags is set.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: net: unify gethostname/getdomainname
Corinna Vinschen [Thu, 24 Jan 2019 13:22:09 +0000 (14:22 +0100)]
Cygwin: net: unify gethostname/getdomainname

Use info from same source (GetNetworkParams).
Also move getdomainname near gethostname in source.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: gethostname: fix fetching hostname from non-winsock function
Corinna Vinschen [Thu, 24 Jan 2019 13:01:59 +0000 (14:01 +0100)]
Cygwin: gethostname: fix fetching hostname from non-winsock function

If gethostname() fails we call GetComputerNameEx with
ComputerNameDnsFullyQualified.  This is wrong, gethostname should return
the hostname only, not the FQDN.  Fix this by calling GetComputerNameEx
with ComputerNameDnsHostname.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: version: Use UTC timestamp as build time
Corinna Vinschen [Thu, 24 Jan 2019 10:39:43 +0000 (11:39 +0100)]
Cygwin: version: Use UTC timestamp as build time

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: cygthread: set thread name before calling thread func
Corinna Vinschen [Wed, 23 Jan 2019 20:39:19 +0000 (21:39 +0100)]
Cygwin: cygthread: set thread name before calling thread func

When reusing a cygthread, the stub method fails to set the thread name
to the new name.  The name is only set when actually creating the
thread.  Fix that by moving the SetThreadName call right in front of the
thread function call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoUse nanf() instead of nan() in single-precision float libm math functions
Jozef Lawrynowicz [Tue, 22 Jan 2019 10:40:18 +0000 (10:40 +0000)]
Use nanf() instead of nan() in single-precision float libm math functions

This patch reduces code size for a few single-precision float math
functions, by using nanf() instead of nan() where required.

5 years agoUse HUGE_VALF instead of HUGE_VAL in single-precision float libm math functions
Jozef Lawrynowicz [Tue, 22 Jan 2019 10:39:38 +0000 (10:39 +0000)]
Use HUGE_VALF instead of HUGE_VAL in single-precision float libm math functions

This patch replaces instances of "(float).*HUGE_VAL" with a direct usage of
HUGE_VALF, which is also defined in math.h.

5 years agoRemove HUGE_VAL definition from libm math functions
Jozef Lawrynowicz [Tue, 22 Jan 2019 10:38:37 +0000 (10:38 +0000)]
Remove HUGE_VAL definition from libm math functions

This patch removes the definitions of HUGE_VAL from some of the float math
functions. HUGE_VAL is defined in newlib/libc/include/math.h, so it is not
necessary to have a further definition in the math functions.

5 years agoRemove matherr, and SVID and X/Open math library configurations
Jozef Lawrynowicz [Thu, 6 Dec 2018 16:14:01 +0000 (16:14 +0000)]
Remove matherr, and SVID and X/Open math library configurations

Default math library configuration is now IEEE

5 years agoCygwin: posix timers: fix overrun count always being 1 too big
Corinna Vinschen [Tue, 22 Jan 2019 17:20:18 +0000 (18:20 +0100)]
Cygwin: posix timers: fix overrun count always being 1 too big

Combine with a bit of cleanup:
- Drop overrun_event_running in favor of overrun_count being -1.
- Fix include guard in posix_timer.h.
- Drop ununsed function timespec_to_us.
- Don't use Interlocked functions without need.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: fix error handling in public API
Corinna Vinschen [Tue, 22 Jan 2019 15:37:15 +0000 (16:37 +0100)]
Cygwin: posix timers: fix error handling in public API

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: allocate timer_tracker on system heap.
Corinna Vinschen [Tue, 22 Jan 2019 15:22:45 +0000 (16:22 +0100)]
Cygwin: posix timers: allocate timer_tracker on system heap.

Allocating on the cygheap would copy information of the tracker into
the child process.  A forked child knows the timer id and could simply
still access the (free'd but still valid) timer_tracker on the heap,
which is dangerous and very certainly doesn't reflect POSIX semantics.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: Add support for CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM
Corinna Vinschen [Tue, 22 Jan 2019 14:46:17 +0000 (15:46 +0100)]
Cygwin: timerfd: Add support for CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: Add support for CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM
Corinna Vinschen [Tue, 22 Jan 2019 14:45:58 +0000 (15:45 +0100)]
Cygwin: posix timers: Add support for CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: clocks: Add CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM clocks
Corinna Vinschen [Tue, 22 Jan 2019 14:42:07 +0000 (15:42 +0100)]
Cygwin: clocks: Add CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM clocks

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agotime.h: Add CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM
Corinna Vinschen [Tue, 22 Jan 2019 14:39:39 +0000 (15:39 +0100)]
time.h: Add CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM

Slightly reshuffle and add comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: reimplement using OS timer
Corinna Vinschen [Tue, 22 Jan 2019 14:23:05 +0000 (15:23 +0100)]
Cygwin: posix timers: reimplement using OS timer

- Rename files timer.* to posix_timer.*.
- Reimplement using an OS timer rather than a handcrafted wait loop.
- Use a Slim R/W Lock for synchronization.
- Drop timer chaining.  It doesn't server a purpose since all timers
  are local only.
- Rename ttstart to itimer_tracker to better reflect its purpose.
  It's not the anchor for a timer chain anymore anyway.
- Drop fixup_timers_after_fork.  Everything is process-local, nothing
  gets inherited.
- Rename timer_tracker::disarm_event to disarm_overrun_event for
  better readability.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: another overrun computation fix and drop useless variable
Corinna Vinschen [Tue, 22 Jan 2019 14:06:51 +0000 (15:06 +0100)]
Cygwin: timerfd: another overrun computation fix and drop useless variable

- When correcting the next expiration timestamp, the number of
  expirations gets computed correctly, just the expiration timestamp
  itself is then only incremented by a single interval, rather than
  the just computed expired intervals.  Fix that.

- drop the local clock variable in timerfd_tracker::create.  It doesn't
  serve any purpose.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: reset expiry counter in settime
Corinna Vinschen [Mon, 21 Jan 2019 21:54:26 +0000 (22:54 +0100)]
Cygwin: timerfd: reset expiry counter in settime

As on Linux, reset the expiry counter when the timer gets rearmed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: fix gettime
Corinna Vinschen [Mon, 21 Jan 2019 21:52:39 +0000 (22:52 +0100)]
Cygwin: timerfd: fix gettime

- split into to __try/__except blocks to make sure
  leave_critical_section is always called when required.

- Actually fill time_spec in settime so it_interval is returned
  correctly.

- Return all 0 if timer is disarmed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: move ioctl error handling into timerfd_tracker
Corinna Vinschen [Mon, 21 Jan 2019 11:41:00 +0000 (12:41 +0100)]
Cygwin: timerfd: move ioctl error handling into timerfd_tracker

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: rename overrun_count to expiration_count
Corinna Vinschen [Mon, 21 Jan 2019 11:26:51 +0000 (12:26 +0100)]
Cygwin: timerfd: rename overrun_count to expiration_count

The value returned by reading from a timerfd is not an overrun
count in the same sense as for posix timers, it's an expiry counter.
Reflect that in the name.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: fix overrun computation
Corinna Vinschen [Mon, 21 Jan 2019 10:14:16 +0000 (11:14 +0100)]
Cygwin: timerfd: fix overrun computation

- Drop erroneous initial computation of overrun count in settime
  for absolute non-realtime clocks.  It's repeated in thread_func
  and thus counted twice.

- Fix overrun computation for timestamp offsets being a multiple of
  the timer interval.  The timestamp has to be corrected after the
  first offset, otherwise the correction loop counts the intervals
  again.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: settime: fix computing DueTime on non-realtime clocks
Corinna Vinschen [Mon, 21 Jan 2019 09:05:13 +0000 (10:05 +0100)]
Cygwin: timerfd: settime: fix computing DueTime on non-realtime clocks

Non-CLOCK_REALTIME counters always use a relative DueTime in NtSetTimer.
However, relative DueTime has to be negative, but the code

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: Handle gettime error in settime
Corinna Vinschen [Sun, 20 Jan 2019 23:14:51 +0000 (00:14 +0100)]
Cygwin: timerfd: Handle gettime error in settime

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: fill out it_interval on timerfd_gettime
Corinna Vinschen [Sun, 20 Jan 2019 23:14:09 +0000 (00:14 +0100)]
Cygwin: timerfd: fill out it_interval on timerfd_gettime

Might not be such a bad idea, after all...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: implement TFD_TIMER_CANCEL_ON_SET
Corinna Vinschen [Sun, 20 Jan 2019 21:47:52 +0000 (22:47 +0100)]
Cygwin: timerfd: implement TFD_TIMER_CANCEL_ON_SET

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: convert expiry timestamp to LONG64
Corinna Vinschen [Sun, 20 Jan 2019 21:46:44 +0000 (22:46 +0100)]
Cygwin: timerfd: convert expiry timestamp to LONG64

Turns out we never need it as LARGE_INTEGER.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: Fix entering critical section
Corinna Vinschen [Sun, 20 Jan 2019 21:19:27 +0000 (22:19 +0100)]
Cygwin: timerfd: Fix entering critical section

Getting an abandonded mutex is just as well and must be handled.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: fix read(2) running wild
Corinna Vinschen [Sun, 20 Jan 2019 21:18:17 +0000 (22:18 +0100)]
Cygwin: timerfd: fix read(2) running wild

- On systems with inexact realtime clock, the current timestamp may
  be fractionally smaller than the desired timestamp.  This breaks the
  computation for incrementing overrun_count so overrun_count may end
  up as 0.  Expiring the timer with an overrun_count of 0 is a no-go.
  Make sure we always increment overrun_count by at least one after
  timer expiry.

- Do not expire the timer when another process deletes its timer_tracker.
  This, too, may result in a 0 overrun_count.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: prepare for TFD_TIMER_CANCEL_ON_SET
Corinna Vinschen [Sat, 19 Jan 2019 19:53:38 +0000 (20:53 +0100)]
Cygwin: timerfd: prepare for TFD_TIMER_CANCEL_ON_SET

Also drop debugging sleep and make sure overrun count is positive.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fhandler_pipe: fix comment
Corinna Vinschen [Sat, 19 Jan 2019 19:02:54 +0000 (20:02 +0100)]
Cygwin: fhandler_pipe: fix comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: reimplement from scratch
Corinna Vinschen [Sat, 19 Jan 2019 18:53:48 +0000 (19:53 +0100)]
Cygwin: timerfd: reimplement from scratch

Using posix timers "timer_tracker" as base class for timerfd was flawed.
Posix timers are not inherited by child processes and don't survive
execve.  The method used by posix timers didn't allow to share timers
between processes. The timers were still per-process timers and worked
entirely separate from each other.  Reading from these timers via
different descriptors was only synchronized within the same process.

This does not reflect the timerfd semantics in Linux: The per-file
timers can be dup'ed and survive fork and execve.  They are still just
descriptors pointing to the same timer object originally created by
timerfd_create.  Synchronization is performed between all descriptor
instances of the same timer, system-wide.

Thus, reimplement timerfd using a timer instance in shared memory,
a kernel timer, and a handful of sync objects.

Every process maintains a per-process timerfd struct on the cygheap
maintaining a per-process thread.  Every process sharing the same
timerfd will run this thread checking the state of the timer, similar
to the posix timer thread, just working on the shared objects and
synchronizing its job with each other thread.

Drop the timerfd implementation in the posix timer code and move the
public API to fhandler_timerfd.c.  Keep the ttstart timer_tracker
anchor out of "NO_COPY" since the fixup_after_fork code should run to
avoid memory leakage.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: clock.h: add valid_timespec() to check timespec for validity
Corinna Vinschen [Fri, 18 Jan 2019 13:31:01 +0000 (14:31 +0100)]
Cygwin: clock.h: add valid_timespec() to check timespec for validity

Use throughout, drop local timespec_bad() in timer.cc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd/signalfd: return EINVAL from write
Corinna Vinschen [Thu, 17 Jan 2019 10:51:11 +0000 (11:51 +0100)]
Cygwin: timerfd/signalfd: return EINVAL from write

Linux returns EINVAL, "fd is attached to an object which is unsuitable
for writing".  If we don't handle write locally, write returns EBADF.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: implement TFD_IOC_SET_TICKS ioctl
Corinna Vinschen [Wed, 16 Jan 2019 17:40:53 +0000 (18:40 +0100)]
Cygwin: timerfd: implement TFD_IOC_SET_TICKS ioctl

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: implement execve semantics
Corinna Vinschen [Wed, 16 Jan 2019 17:40:26 +0000 (18:40 +0100)]
Cygwin: timerfd: implement execve semantics

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd: implement fork semantics
Corinna Vinschen [Wed, 16 Jan 2019 14:33:15 +0000 (15:33 +0100)]
Cygwin: timerfd: implement fork semantics

- Puzzeling: Commit ec98d19a08c2e4678e8a6f40fea0c9bbeaa4a2c7
  changed ttstart to NO_COPY but kept all the code to handle
  fixup after fork.  Revert to not-NO_COPY and make timerfd
  fork work.

- On fixup_after_fork, keep timerfd timers and restart thread
  if they were armed in the parent.

- Move timerfd timer_trackers to cygheap.  Overload timer_tracker
  new and delete methods to handle timers accordingly.  This is not
  exactly required for fork, but exec will be grateful.

- Give up on TFD_TIMER_CANCEL_ON_SET for now.  There's no easy way
  to recognize a discontinuous change in a clock.

- Be paranoid when cleaning out ttstart.

- Fix some minor issues.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork: move extern declarations to appropriate headers
Corinna Vinschen [Wed, 16 Jan 2019 11:59:27 +0000 (12:59 +0100)]
Cygwin: fork: move extern declarations to appropriate headers

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: fix overrun computation
Corinna Vinschen [Tue, 15 Jan 2019 23:11:03 +0000 (00:11 +0100)]
Cygwin: posix timers: fix overrun computation

- Drop initial overrun computation from timer_tracker::settimer.
  It's performed in timer_tracker::thread_func anyway.

- Fix regression in returning correct overrun count narrowed down to
  int from timer_getoverrun.  This has been introduced by changing
  overrun_count_curr to LONG64.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timerfd_create: add missing type
Corinna Vinschen [Wed, 16 Jan 2019 08:24:55 +0000 (09:24 +0100)]
Cygwin: timerfd_create: add missing type

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timers: implement timerfd
Corinna Vinschen [Tue, 15 Jan 2019 21:02:33 +0000 (22:02 +0100)]
Cygwin: timers: implement timerfd

First cut of a timerfd implementation.

Still TODO:
- fork/exec semantics
- timerfd_settime TFD_TIMER_CANCEL_ON_SET flag
- ioctl(TFD_IOC_SET_TICKS)
- bug fixes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: signalfd: set st_mode in fhandler_signalfd::fstat
Corinna Vinschen [Tue, 15 Jan 2019 20:49:52 +0000 (21:49 +0100)]
Cygwin: signalfd: set st_mode in fhandler_signalfd::fstat

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: signalfd: fix comment
Corinna Vinschen [Tue, 15 Jan 2019 14:32:15 +0000 (15:32 +0100)]
Cygwin: signalfd: fix comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoUpdate config.guess, config.sub to gcc master branch versions
Jeff Johnston [Tue, 15 Jan 2019 19:13:30 +0000 (14:13 -0500)]
Update config.guess, config.sub to gcc master branch versions

5 years agoAMD GCN Port contributed by Andrew Stubbs <ams@codesourcery.com>
Jeff Johnston [Tue, 15 Jan 2019 15:36:50 +0000 (10:36 -0500)]
AMD GCN Port contributed by Andrew Stubbs <ams@codesourcery.com>

Add support for the AMD GCN GPU architecture.  This is primarily intended for
use with OpenMP and OpenACC offloading.  It can also be used for stand-alone
programs, but this is intended mostly for testing the compiler and is not
expected to be useful in general.

The GPU architecture is highly parallel, and therefore Newlib must be
configured to use dynamic re-entrancy, and thread-safe malloc.

The only I/O available is a via a shared-memory interface provided by libgomp
and the gcn-run tool included with GCC.  At this time this is limited to
stdout, argc/argv, and the return code.

5 years agoCygwin: gentls_offsets: Remove obsolte 'o' regex option
Corinna Vinschen [Tue, 15 Jan 2019 12:19:41 +0000 (13:19 +0100)]
Cygwin: gentls_offsets: Remove obsolte 'o' regex option

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: tlsoffsets64.h: regenerate
Corinna Vinschen [Tue, 15 Jan 2019 11:25:12 +0000 (12:25 +0100)]
Cygwin: tlsoffsets64.h: regenerate

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: signalfd: drop incorrect handling of EINTR in read(2)
Corinna Vinschen [Tue, 15 Jan 2019 08:58:30 +0000 (09:58 +0100)]
Cygwin: signalfd: drop incorrect handling of EINTR in read(2)

In case sigwait_common returns EINTR, read wrongly ignores it,
so read can't be interrupt by a signal.  Fix that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: document POSIX rename semantics availability with W10 1809 only
Corinna Vinschen [Mon, 14 Jan 2019 20:57:38 +0000 (21:57 +0100)]
Cygwin: document POSIX rename semantics availability with W10 1809 only

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: wincap: split has_posix_file_info
Corinna Vinschen [Mon, 14 Jan 2019 19:38:24 +0000 (20:38 +0100)]
Cygwin: wincap: split has_posix_file_info

While FileRenameInformationEx is defined starting with Windows
10 1709 per MSDN, it only starts working in W10 1809, apparently.
Users of 1803 report "Function not implemented".

Introduce wincap_10_1809 and change the version check in
wincapc::init accordingly.  Split has_posix_file_info into
has_posix_unlink_semantics and has_posix_rename_semantics.
Enable the latter only starting with W10 1809.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: signalfd: implement non-polling select
Corinna Vinschen [Mon, 14 Jan 2019 16:19:37 +0000 (17:19 +0100)]
Cygwin: signalfd: implement non-polling select

Allow the signal thread to recognize we're called in consequence of
select on a signalfd.  If the signal is part of the wait mask, don't
call any signal handler and don't remove the signal from the queue,
so a subsequent read (or sigwaitinfo/sigtimedwait) still gets the
signal.  Instead, just signal the event object at
_cygtls::signalfd_select_wait for the thread running select.

The addition of signalfd_select_wait to _cygtls unearthed the alignment
problem of the context member again.  To make sure this doesn't get lost,
improve the related comment in the header file so that this (hopefully)
doesn't get lost (again).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: select: always store the running thread's TLS into select_record
Corinna Vinschen [Mon, 14 Jan 2019 16:03:39 +0000 (17:03 +0100)]
Cygwin: select: always store the running thread's TLS into select_record

This allows select threads to access our current tls if required.

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