]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
5 years agoCygwin: s4uauth: make sure to fetch correct package id
Corinna Vinschen [Mon, 18 Feb 2019 16:59:56 +0000 (17:59 +0100)]
Cygwin: s4uauth: make sure to fetch correct package id

for domain accounts we try KerbS4ULogon first, MsV1_0S4ULogon
second.  But we only fetch the package id for the supporting
authentication package (Kerberos/MsV1_0) once at the start.

Duplicate LsaLookupAuthenticationPackage call and move into the
Kerb/MsV1_0 branches so that it fetches the correct package id
for the method we call next.

Curious enough this worked before.  Apparently both methods
work with the MICROSOFT_KERBEROS_NAME_A package id.  However,
requesting and using the right authentication package id is
the prudent thing to do.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCYgwin: bump API minor for MOUNT_BINARY -> MOUNT_TEXT change
Corinna Vinschen [Mon, 18 Feb 2019 10:04:38 +0000 (11:04 +0100)]
CYgwin: bump API minor for MOUNT_BINARY -> MOUNT_TEXT change

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: utils: MOUNT_BINARY -> MOUNT_TEXT
Corinna Vinschen [Mon, 18 Feb 2019 10:00:06 +0000 (11:00 +0100)]
Cygwin: utils: MOUNT_BINARY -> MOUNT_TEXT

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoRevert "Cygwin: passwd/group: allow specifying "." as local computername"
Corinna Vinschen [Mon, 18 Feb 2019 09:13:35 +0000 (10:13 +0100)]
Revert "Cygwin: passwd/group: allow specifying "." as local computername"

This reverts commit 7c34811440be0bf1e749d9f075f54320c706cb4b.

This potentially allows to circumvent OpenSSHs user/group name matching,
unless the Admin knows to add every local user twice or to use patterns,
e.g.:

  Match user MACHINE+user,.+user
  Match user *+user

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: mount: define binary mount as default
Corinna Vinschen [Mon, 18 Feb 2019 09:12:07 +0000 (10:12 +0100)]
Cygwin: mount: define binary mount as default

Commit c1023ee353705671aa9a8e4e1179022277add2aa changed the way
path_conv::binmode() works.  Rather than returning three states,
O_BINARY, O_TEXT, 0, it only returned 2 states, O_BINARY, O_TEXT.  Since
mounts are only binary if they are explicitely mounted binary by setting
the MOUNT_BINARY flag, textmode is default.

This introduced a new bug.  When inheriting stdio HANDLEs from native
Windows processes, the fhandler and its path_conv are created from a
device struct only.  None of the path or mount flags get set this way.
So the mount flags are 0 and path_conv::binmode() returned 0.

After the path_conv::binmode() change it returned O_TEXT since, as
explained above, the default mount mode is textmode.

Rather than just enforcing binary mode for path_conv's created from
device structs, this patch changes the default mount mode to binary:

Replace MOUNT_BINARY flag with MOUNT_TEXT flag with opposite meaning.
Drop all explicit setting of MOUNT_BINARY.  Drop local set_flags
function, it doesn't add any value.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: mount: remove unused method mount_info::set_flags_from_win32_path
Corinna Vinschen [Mon, 18 Feb 2019 09:03:19 +0000 (10:03 +0100)]
Cygwin: mount: remove unused method  mount_info::set_flags_from_win32_path

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: utils: kill: revert erroneously removed optind correction
Corinna Vinschen [Sun, 17 Feb 2019 21:59:36 +0000 (22:59 +0100)]
Cygwin: utils: kill: revert erroneously removed optind correction

When recognizing a negative pid, optind is off by one.  The
code correcting this has been erroneously removed by commit
8de660271fe75a6993f1c9888d24b824bb7f999d.  Revert that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fork: add PROCESS_VM_OPERATION to child process permissions
Corinna Vinschen [Sun, 17 Feb 2019 21:51:21 +0000 (22:51 +0100)]
Cygwin: fork: add PROCESS_VM_OPERATION to child process permissions

...on parent process.  This is required for successful mmap propagation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: allow specifying "." as local computername
Corinna Vinschen [Sat, 16 Feb 2019 17:36:21 +0000 (18:36 +0100)]
Cygwin: passwd/group: allow specifying "." as local computername

Convenience only.  The resulting passwd/group antry is still
fully qualified.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: bump version to 3.0.1
Corinna Vinschen [Sat, 16 Feb 2019 17:11:16 +0000 (18:11 +0100)]
Cygwin: bump version to 3.0.1

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: store account name case correct, take 2 cygwin-3_0_0-release
Corinna Vinschen [Wed, 13 Feb 2019 12:16:15 +0000 (13:16 +0100)]
Cygwin: passwd/group: store account name case correct, take 2

The solution from commit  9a3cc77b2afc52a2faa5e4daeb59dfd4506c0693
didn't work for foreign domain accounts.  Rather than calling
LookupAccountSid we now use the info when we fetch it anyway
via LDAP or Net*GetInfo.  Only in case of domain groups we have
to add an LDAP call explicitly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: ldap.cc: fix formatting
Corinna Vinschen [Wed, 13 Feb 2019 11:43:25 +0000 (12:43 +0100)]
Cygwin: ldap.cc: fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: rename get_group_name to get_account_name
Corinna Vinschen [Wed, 13 Feb 2019 11:42:56 +0000 (12:42 +0100)]
Cygwin: passwd/group: rename get_group_name to get_account_name

The function is the same for user and grou accounts.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: raise local name buffer size
Corinna Vinschen [Wed, 13 Feb 2019 11:41:55 +0000 (12:41 +0100)]
Cygwin: passwd/group: raise local name buffer size

Make sure a domain+username fits into the local name buffer.
The former buffer size didn't take adding a domain name to
a really_really_long_user_name into account.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: passwd/group: store account name case correct
Corinna Vinschen [Wed, 13 Feb 2019 10:10:55 +0000 (11:10 +0100)]
Cygwin: passwd/group: store account name case correct

When looking up valid accounts by name, LookupAccountName returns
a SID and a case-correct domain name.  However, the name was input
and LookupAccountName is case-insensitive, so the name is not
necessarily written the same way as in SAM or AD.

Fix that by doing a reverse lookup on the just fetched SID.  This
fetches the account name in the correct case.  Override the
incoming name with the case correct name from LookupAccountSid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: uinfo.cc: fix formatting
Corinna Vinschen [Wed, 13 Feb 2019 10:10:41 +0000 (11:10 +0100)]
Cygwin: uinfo.cc: fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: forkables: update doc, add release notes
Michael Haubenwallner [Fri, 8 Feb 2019 14:38:56 +0000 (15:38 +0100)]
Cygwin: forkables: update doc, add release notes

5 years agoAArch32: Fix the build for M class semihosting
Tamar Christina [Fri, 8 Feb 2019 17:13:24 +0000 (17:13 +0000)]
AArch32: Fix the build for M class semihosting

The M class cores don't support Semihosting v2 mixed mode, but we were
accidentally using the new immediates for it.  My last patch changed the
immediates which broke the build because doing a full multi-lib build
including M architectures now results in an assembler error instead of
silently doing the wrong thing.

This fixes the issue by changing the defines around such that According
to the specs any M class build uses the normal semihosting instructions.

Regtested on arm-none-eabi and no issues, using a build with m class
multilibs too.

5 years agoCygwin: disk device: stop using SetFilePointer
Corinna Vinschen [Sat, 9 Feb 2019 17:41:47 +0000 (18:41 +0100)]
Cygwin: disk device: stop using SetFilePointer

This is a really old and crappy API, as the previous commit shows.
Use NtQueryInformationFile(FilePositionInformation) here instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: execve: fix setting O_APPEND file offset for native child
Corinna Vinschen [Sat, 9 Feb 2019 14:36:02 +0000 (15:36 +0100)]
Cygwin: execve: fix setting O_APPEND file offset for native child

dtable::set_file_pointers_for_exec is called from
child_info_spawn::worker to move the file position of O_APPEND
files to EOF if the child is a native child.

However, this only works correctly for the first O_APPEND
file descriptor:

- set_file_pointers_for_exec calls SetFilePointer.  The higher
  4 bytes of the desired file offset are given to SetFilePointer
  as pointer to a DWORD value.  On return, SetFilePointer returns
  the higher 4 bytes of the new file position in this DWORD.

- So for the second and subsequent descriptors the higher 4 byte
  of the file position depend on what the actual file position
  of the previous file has been set to:

- If the file is > 2 Gigs, the high offset will not be 0 anymore.

- If the desciptor points to a non-seekable file (i.e., a pipe
  or socket), SetFilePosition returns an error and sets the high
  position to -1.

Fix this by calling SetFilePointerEx instead, which does not
modify the incoming position value.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: change CURR_CHILD_INFO_MAGIC according to previous patch
Corinna Vinschen [Fri, 8 Feb 2019 16:48:34 +0000 (17:48 +0100)]
Cygwin: change CURR_CHILD_INFO_MAGIC according to previous patch

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fix child getting another pid after spawnve
Corinna Vinschen [Fri, 8 Feb 2019 14:49:47 +0000 (15:49 +0100)]
Cygwin: fix child getting another pid after spawnve

When calling spawnve, in contrast to execve, the parent has
to create the pid for the child.  With the old technique
this was simply the Windows pid, but now we have to inform
the child about its new pid.

Add a cygpid member to class child_info_spawn.  Set it in
child_info_spawn::worker, just prior to calling CreateProcess
rather than afterwards.  Overwrite cygheap->pid in
child_info_spawn::handle_spawn before calling pinfo::thisproc.
Make sure pinfo::thisproc knows the pid is already set by
setting the handle argument to INVALID_HANDLE_VALUE.

Also set procinfo->dwProcessId to myself_initial.dwProcessId
instead of to myself_initial.pid for clarity.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoAArch32: Add support for HLT to Mixed Mode models
Tamar Christina [Wed, 6 Feb 2019 11:27:12 +0000 (11:27 +0000)]
AArch32: Add support for HLT to Mixed Mode models

The Semihosting v2 protocol requires us to output the Armv8-a HLT instruction
when in mixed mode (SEMIHOST_V2_MIXED_MODE), however it also requires this to
be done for Armv7-a and earlier architectures.

The HLT instruction is defined in the undefined encoding space for older
architectures but simulators such as QEMU already trap on it [1] for all
architectures and is a requirement for semihosting v2 [2].

Unfortunately the GAS restricts the use of HLT to Armv8-a which requires us to
use the instruction encodings we want directly in crt0.

This patch does this, I have not updated newlib/libc/* as that is quite out of
date already.  A proper sync is needed in order to get things back in sync.

A different patch for this would be best.

[1] https://github.com/qemu/qemu/commit/19a6e31c9d2701ef648b70ddcfc3bf64cec8c37e
[2] https://developer.arm.com/docs/100863/latest/the-semihosting-interface

5 years agoforkables: hardlink without WRITE_ATTRIBUTES first
Michael Haubenwallner [Fri, 10 Mar 2017 10:32:54 +0000 (11:32 +0100)]
forkables: hardlink without WRITE_ATTRIBUTES first

When the current process has renamed (to bin) a readonly dll, we get
STATUS_TRANSACTION_NOT_ACTIVE for unknown reason when subsequently
creating the forkable hardlink. A workaround is to open the original
file with FILE_WRITE_ATTRIBUTES access, but that fails with permission
denied for users not owning the original file.

* forkable.cc (dll::create_forkable): Retry hardlink creation using the
original file's handle opened with FILE_WRITE_ATTRIBUTES access when the
first attempt fails with STATUS_TRANSACTION_NOT_ACTIVE.

5 years agoforkables: inline dll_list::forkables_supported
Michael Haubenwallner [Thu, 2 Mar 2017 16:26:53 +0000 (17:26 +0100)]
forkables: inline dll_list::forkables_supported

And LONG fits better for shared_info member forkable_hardlink_support.

5 years agoforkables: simplify disabling via shm
Michael Haubenwallner [Wed, 1 Mar 2017 09:19:37 +0000 (10:19 +0100)]
forkables: simplify disabling via shm

* Rename cygwin_shared->prefer_forkable_hardlinks to
  forkable_hardlink_support, with values
  0 for Unknown, 1 for Supported, -1 for Unsupported.
  Upon first dll loaded ever, dll_list::forkable_ntnamesize checks the
  /var/run/cygfork directory to both exist and reside on NTFS, setting
  cygwin_shared->forkable_hardlink_support accordingly.
* Replace enum forkables_needs by bool forkables_created: Set
  to True by request_forkables after creating forkable hardlinks.

5 years agoforkables: use dynloaded dll's IndexNumber as dirname
Michael Haubenwallner [Thu, 12 Jan 2017 09:03:52 +0000 (10:03 +0100)]
forkables: use dynloaded dll's IndexNumber as dirname

5 years agoforkables: Document hardlink creation at forktime.
Michael Haubenwallner [Wed, 7 Dec 2016 10:58:30 +0000 (11:58 +0100)]
forkables: Document hardlink creation at forktime.

* faq-api.xml: Mention hardlink creation by fork.
* highlights.xml: Describe hardlink creation.

5 years agoforkables: Keep hardlinks disabled via shared mem.
Michael Haubenwallner [Wed, 7 Dec 2016 10:58:29 +0000 (11:58 +0100)]
forkables: Keep hardlinks disabled via shared mem.

To avoid the need for each process to check the filesystem to detect
that hardlink creation is impossible or disabled, cache this fact in
shared memory.  Removing cygfork directory while in use does disable
hardlinks creation.  To (re-)enable hardlinks creation, the cygfork
directory has to exist before the first cygwin process does fork.

* forkable.cc (dll_list::forkable_ntnamesize): Short cut
forkables needs to impossible when disabled via shared memory.
(dll_list::update_forkables_needs): When detecting hardlink
creation as impossible (not on NTFS) while still (we are the
first one checking) enabled via shared memory, disable the
shared memory value.
(dll_list::request_forkables): Disable the shared memory value
when hardlinks creation became disabled, that is when the
cygfork directory was removed.
* include/cygwin/version.h: Bump CYGWIN_VERSION_SHARED_DATA 6.
* shared_info.h (struct shared_info): Add member
prefer_forkable_hardlinks.  Update CURR_SHARED_MAGIC.
* shared.cc (shared_info::initialize): Initialize
prefer_forkable_hardlinks to 1 (Yes).

5 years agoforkables: On fork failure, retry with hardlinks.
Michael Haubenwallner [Wed, 7 Dec 2016 10:58:28 +0000 (11:58 +0100)]
forkables: On fork failure, retry with hardlinks.

To support in-cygwin package managers, the fork() implementation must
not rely on .exe and .dll files to stay in their original location, as
the package manager's job is to replace these files.  Instead, when the
first fork try fails, and we have NTFS, we use hardlinks to the original
binaries in /var/run/cygfork/ to create the child process during the
second fork try, along the main.exe.local file to enable the "DotLocal
Dll Redirection" feature for the dlls.

The (probably few) users that need an update-safe fork manually have to
create the /var/run/cygfork/ directory for now, using:
mkdir --mode=a=rwxt /var/run/cygfork

* child_info.h: Bump CURR_CHILD_INFO_MAGIC.
(enum child_status): Add _CI_SILENTFAIL flag.
(struct child_info): Add silentfail setter and getter.
* winsup.h (child_copy): Add bool silentfail parameter.
* cygheap.cc: Pass silentfail parameter to child_copy.
* dcrt0.cc: Ditto.
* dll_init.h (struct dll): Define public inline method forkedntname.
(struct dll_list): Declare private method find_by_forkedntname.
* dll_init.cc (struct dll_list): Implement find_by_forkedntname.
(dll_list::alloc): Use find_by_forkedntname when in load after fork.
(dll_list::load_after_fork_impl): Load dlls using dll::forkedntname.
* fork.cc (frok::parent): Set silentfail child info flag.  Pass
silentfail parameter to child_copy.  Use forkedntname of
dlls.main_executable.
(fork): When first dofork run failed and did not use forkables,
run dofork again with_forkables set to true.
(child_copy): Use debug_printf if silentfail is true,
system_printf otherwise.

5 years agoforkables: Create forkable hardlinks, yet unused.
Michael Haubenwallner [Wed, 7 Dec 2016 10:58:27 +0000 (11:58 +0100)]
forkables: Create forkable hardlinks, yet unused.

In preparation to protect fork() against dll- and exe-updates, create
hardlinks to the main executable and each loaded dll in subdirectories
of /var/run/cygfork/, if that one exists on the NTFS file system.

The directory names consist of the user sid, the main executable's NTFS
IndexNumber, and the most recent LastWriteTime of all involved binaries
(dlls and main executable).  Next to the main.exe hardlink we create the
empty file main.exe.local to enable dll redirection.

The name of the mutex to synchronize hardlink creation/cleanup also is
assembled from these directory names, to allow for synchronized cleanup
of even orphaned hardlink directories.

The hardlink to each dynamically loaded dll goes into another directory,
named using the NTFS IndexNumber of the dll's original directory.

* Makefile.in (DLL_OFILES): Add forkable.o.
* dll_init.h (struct dll): Declare member variables fbi, fii,
forkable_ntname.  Declare methods nominate_forkable,
create_forkable.
(struct dll_list): Declare enum forkables_needs.  Declare member
variables forkables_dirx_size, forkables_dirx_ntname,
forkables_mutex_name, forkables_mutex.  Declare private methods
forkable_ntnamesize, prepare_forkables_nomination,
update_forkables_needs, update_forkables, create_forkables,
denominate_forkables, close_mutex, try_remove_forkables,
set_forkables_inheritance, request_forkables.  Declare public
static methods ntopenfile, read_fii, read_fbi.  Declare public
methods release_forkables, cleanup_forkables.  Define public
inline method setup_forkables.
* dll_init.cc (dll_list::alloc): Allocate memory to hold the
name of the hardlink in struct dll member forkable_ntname.
Initialize struct dll members fbi, fii.
(dll_list::load_after_fork): Call release_forkables method.
* fork.cc: Rename public fork function to static dofork, add
with_forkables as bool pointer parameter.  Add new fork function
calling dofork.  (struct frok): Add bool pointer member
with_forkables, add as constructor parameter.
(frok::parent): Call dlls.setup_forkables before CreateProcessW,
dlls.release_forkables afterwards.
* pinfo.cc (pinfo::exit): Call dlls.cleanup_forkables.
* syscalls.cc (_unlink_nt): Rename public unlink_nt function to
static _unlink_nt, with 'shareable' as additional argument.
(unlink_nt): New, wrap _unlink_nt for original behaviour.
(unlink_nt_shareable): New, wrap _unlink_nt to keep a binary
file still loadable while removing one of its hardlinks.
* forkable.cc: New file.
Implement static functions mkdirs, rmdirs, rmdirs_synchronized,
stat_real_file_once, format_IndexNumber, rootname, sidname,
exename, lwtimename.  Define static array forkable_nameparts.
(struct dll): Implement nominate_forkable, create_forkable.
(struct dll_list): Implement static methods ntopenfile,
read_fii, read_fbi.  Implement forkable_ntnamesize,

5 years agodll_list: Track main executable and cygwin1.dll.
Michael Haubenwallner [Wed, 7 Dec 2016 10:58:26 +0000 (11:58 +0100)]
dll_list: Track main executable and cygwin1.dll.

Even for the main executable and cygwin1.dll store the file name as full
NT path.  Create the child process using the main executable's file name
converted from the full NT path stored before.

* dll_init.cc (dll_list::alloc): Search for DLL_SELF type entry
with module name like for DLL_LINK, use full NT path to search
for DLL_LOAD type only.  For DLL_SELF type do not indicate
having a destructor to be called.
(dll_list::find): Ignore DLL_SELF type entries.
(dll_list::init): Ditto.  Call track_self method.
(dll_list::track_self): New.
(dll_list::load_after_fork): Call track_self method.
* dll_init.h (enum dll_type): Add DLL_SELF, for the main
executable and cygwin1.dll.
(struct dll_list): Declare private method track_self.  Declare
member variable main_executable.
* fork.cc (frok::parent): Use ntname from dlls.main_executable
to create child process, converted to short path using
dll_list::buffered_shortname.

5 years agodll_list: Store dll file name as full NT path.
Michael Haubenwallner [Wed, 7 Dec 2016 10:58:25 +0000 (11:58 +0100)]
dll_list: Store dll file name as full NT path.

Store loaded dll's file name as full NT path.

* dll_init.h (struct dll): Rename member variable name to ntname.
(struct dll_list): Declare private static member variable
nt_max_path_buffer.  Declare public static methods form_ntname,
form_shortname.  Define public static methods nt_max_path_buf,
buffered_shortname.
(dll_list::operator []): Use PCWCHAR rather than const PWCHAR.
(dll_list::find_by_modname): Ditto.
* dll_init.cc (in_load_after_fork): Define earlier in file.
(struct dll_list): Rename member variable name to ntname.
Define nt_max_path_buffer variable.
Implement static methods form_ntname, form_shortname.
(dll_list::operator []): Use PCWCHAR rather than const PWCHAR.
(dll_list::find_by_modname): Ditto.
(reserve_at): Ditto.
(release_at): Ditto.
(dll_list::alloc): Use nt_max_path_buf method instead of local
buffer.  Store module file name as full NT path, convert using
the form_ntname static method.
(dll_list::load_after_fork): Call load_after_fork_impl only when
reload_on_fork is set.
* fork.cc (frok::child): Call dlls.load_after_fork even without
need to dynamically load dlls.
(frok::parent): Move syscall_printf into the retry loop.

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>
This page took 0.074882 seconds and 5 git commands to generate.