]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
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>
5 years agoCygwin: document wctype changes
Corinna Vinschen [Sun, 13 Jan 2019 22:35:28 +0000 (23:35 +0100)]
Cygwin: document wctype changes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoupdate to Unicode 11.0
Thomas Wolff [Sat, 12 Jan 2019 11:35:18 +0000 (12:35 +0100)]
update to Unicode 11.0

5 years agomap WEOF to undefined rather than the control char category
Thomas Wolff [Sat, 12 Jan 2019 10:57:59 +0000 (11:57 +0100)]
map WEOF to undefined rather than the control char category

Fixes https://cygwin.com/ml/cygwin/2018-12/msg00173.html

5 years agoCygwin: signal: implement signalfd
Corinna Vinschen [Sun, 13 Jan 2019 22:13:33 +0000 (23:13 +0100)]
Cygwin: signal: implement signalfd

First cut of a signalfd implementation.

Still TODO: Non-polling select.

This should mostly work as on Linux except for missing support
for some members of struct signalfd_siginfo, namely ssi_fd,
ssi_band (both SIGIO/SIGPOLL, not fully implemented) and ssi_trapno
(HW exception, required HW support).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: proc fd: return EACCES for HANDLE-less fds
Corinna Vinschen [Sun, 13 Jan 2019 22:09:48 +0000 (23:09 +0100)]
Cygwin: proc fd: return EACCES for HANDLE-less fds

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: minor cleanups
Corinna Vinschen [Sun, 13 Jan 2019 21:48:43 +0000 (22:48 +0100)]
Cygwin: minor cleanups

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: select: fix overwriting fd sets if poll returns no fd
Corinna Vinschen [Sun, 13 Jan 2019 21:43:52 +0000 (22:43 +0100)]
Cygwin: select: fix overwriting fd sets if poll returns no fd

There's a long-standing bug in select.  If we have poll-only
descriptors in the fd set, select overwrites the incoming
fd sets with the polling result.  If none of the fds is ready,
select has to loop again.  But now the fd sets are set to all
zero and select hangs.

Fix this by utilizing the local fd sets r, w, e as storage for
the incoming fd sets and use them to initialize select_stuff.

If we have to loop, overwritung the incoming fd sets doesn't matter.

While at it, rename r, w, e to readfds_in, writefds_in, exceptfds_in.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fhandler_pipe: unify format directives
Corinna Vinschen [Sun, 13 Jan 2019 21:30:33 +0000 (22:30 +0100)]
Cygwin: fhandler_pipe: unify format directives

The format directives in sscanf/__small_sprintf are not
matching.  Fix that.

5 years agoCygwin: posix timers: implement timer_getoverrun
Corinna Vinschen [Sat, 12 Jan 2019 20:19:52 +0000 (21:19 +0100)]
Cygwin: posix timers: implement timer_getoverrun

- set DELAYTIMER_MAX to INT_MAX
- make sure to set siginfo_t::si_overrun, as on Linux

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: some cleanup
Corinna Vinschen [Sat, 12 Jan 2019 19:23:55 +0000 (20:23 +0100)]
Cygwin: posix timers: some cleanup

- use int64_t instead of long long
- make is_timer_tracker const
- improve copyright header comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: convert timer_tracker::fixup_after_fork to static method
Corinna Vinschen [Fri, 11 Jan 2019 19:36:46 +0000 (20:36 +0100)]
Cygwin: posix timers: convert timer_tracker::fixup_after_fork to static method

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: posix timers: move definition of timer_tracker class to new timer.h
Corinna Vinschen [Fri, 11 Jan 2019 18:40:03 +0000 (19:40 +0100)]
Cygwin: posix timers: move definition of timer_tracker class to new timer.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: clock_nanosleep is not supposed to crash, return EFAULT instead
Corinna Vinschen [Fri, 11 Jan 2019 14:15:32 +0000 (15:15 +0100)]
Cygwin: clock_nanosleep is not supposed to crash, return EFAULT instead

...in case rqtp or rmtp specified invalid addresses.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: timer: convert timer_tracker to a real C++ class
Corinna Vinschen [Fri, 11 Jan 2019 14:13:11 +0000 (15:13 +0100)]
Cygwin: timer: convert timer_tracker to a real C++ class

...with private members and all the jazz

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: af_unix_spinlock_t: add initializer
Ken Brown [Thu, 10 Jan 2019 17:56:55 +0000 (17:56 +0000)]
Cygwin: af_unix_spinlock_t: add initializer

Also fix a typo.

5 years agoCygwin: try_to_bin: don't check recycler filename all the time
Corinna Vinschen [Wed, 9 Jan 2019 20:14:58 +0000 (21:14 +0100)]
Cygwin: try_to_bin: don't check recycler filename all the time

So far we check the recycler name all the time, and the last interation
also only managed to handle two ways to write the recycler.  However,
an adventurous user might change the case of the recycler arbitrarily.

Fix this problem by keeping track of the name in a somewhat relaxed
fashion.  Use camel back on drive C by default, all upper case elsewhere.
Only if the rename op fails do we fix the recycler name on the fly
when trying to create it, and it turns out it already existed.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: try_to_bin: fix rootdir handle after reopening
Corinna Vinschen [Wed, 9 Jan 2019 20:41:48 +0000 (21:41 +0100)]
Cygwin: try_to_bin: fix rootdir handle after reopening

If the first rename fails, we reopen the rootdir for creating a subdir.
The rootdir handle can change its value at this point, but the code
doesn't take this into account.  The subsequent rename then fails with
STATUS_INVALID_HANDLE.  Fix this by copying the new rootdir value to
pfri->RootDirectory.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: rename: use FILE_RENAME_POSIX_SEMANTICS if available
Corinna Vinschen [Wed, 9 Jan 2019 14:47:43 +0000 (15:47 +0100)]
Cygwin: rename: use FILE_RENAME_POSIX_SEMANTICS if available

starting with W10 1709 on local NTFS drives

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: rename: rename incoming flags argument to at2flags
Corinna Vinschen [Wed, 9 Jan 2019 13:45:37 +0000 (14:45 +0100)]
Cygwin: rename: rename incoming flags argument to at2flags

Avoid name confusion with later used flags variable

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: try_to_bin: don't reopen the file
Corinna Vinschen [Tue, 8 Jan 2019 20:43:25 +0000 (21:43 +0100)]
Cygwin: try_to_bin: don't reopen the file

So far we reopened the file if it was opened case sensitive to
workaround the problem that the recycler could be named in
camel back or all upper case, depending on who created it.
That's a problem for O_TMPFILE on pre-W10.  As soon as the
original HANDLE gets closed, delete-on-close is converted to full
delete disposition and all useful operations on the file cease to
work (STATUS_ACCESS_DENIED or STATUS_FILE_DELETED).

To avoid that problem drop the reopen code and check for the exact
recycler filename, either $Recycle.Bin or $RECYCLE.BIN, if the file
has been opened case sensitive.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: open: workaround reopen file w/ delete disposition set
Corinna Vinschen [Tue, 8 Jan 2019 20:37:43 +0000 (21:37 +0100)]
Cygwin: open: workaround reopen file w/ delete disposition set

On pre-W10 systems there's no way to reopen a file by handle if
the delete disposition is set.  We try to get around with
duplicating the handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: open: handle O_CLOEXEC when opening file from handle
Corinna Vinschen [Tue, 8 Jan 2019 17:50:11 +0000 (18:50 +0100)]
Cygwin: open: handle O_CLOEXEC when opening file from handle

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fhandler_process_fd: Fix spacing
Corinna Vinschen [Tue, 8 Jan 2019 20:38:04 +0000 (21:38 +0100)]
Cygwin: fhandler_process_fd: Fix spacing

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: remove unused tmpbuf.h
Corinna Vinschen [Tue, 8 Jan 2019 17:49:29 +0000 (18:49 +0100)]
Cygwin: remove unused tmpbuf.h

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agofcntl.h: expose AT_EMPTY_PATH with _GNU_SOURCE only
Corinna Vinschen [Mon, 7 Jan 2019 19:09:20 +0000 (20:09 +0100)]
fcntl.h: expose AT_EMPTY_PATH with _GNU_SOURCE only

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: linkat: support Linux-specific AT_EMPTY_PATH flag
Corinna Vinschen [Mon, 7 Jan 2019 18:36:37 +0000 (19:36 +0100)]
Cygwin: linkat: support Linux-specific AT_EMPTY_PATH flag

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: open: support Linux-specific O_PATH flag
Corinna Vinschen [Mon, 7 Jan 2019 18:33:11 +0000 (19:33 +0100)]
Cygwin: open: support Linux-specific O_PATH flag

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: rename pipe.cc to fhandler_pipe.cc
Corinna Vinschen [Mon, 7 Jan 2019 11:31:28 +0000 (12:31 +0100)]
Cygwin: rename pipe.cc to fhandler_pipe.cc

move pipe syscalls to syscalls.cc

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: move fhandler_cygdrive methods into own source file
Corinna Vinschen [Mon, 7 Jan 2019 11:29:07 +0000 (12:29 +0100)]
Cygwin: move fhandler_cygdrive methods into own source file

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: drop redundant includes from fhandler_process_fd.cc
Corinna Vinschen [Sun, 6 Jan 2019 21:40:17 +0000 (22:40 +0100)]
Cygwin: drop redundant includes from fhandler_process_fd.cc

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fix regression in O_TMPFILE | O_EXCL case
Corinna Vinschen [Sun, 6 Jan 2019 21:39:45 +0000 (22:39 +0100)]
Cygwin: fix regression in O_TMPFILE | O_EXCL case

The new proc fd code accidentally allowed to linkat an O_TMPFILE
even if the file has been opened with O_EXCL.  This patch fixes it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: document proc fd changes
Corinna Vinschen [Sun, 6 Jan 2019 19:28:48 +0000 (20:28 +0100)]
Cygwin: document proc fd changes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: introduce fhandler_process_fd and add stat(2) handling
Corinna Vinschen [Sun, 6 Jan 2019 19:18:14 +0000 (20:18 +0100)]
Cygwin: introduce fhandler_process_fd and add stat(2) handling

move special fd symlink code into own fhandler_process_fd class
to simplify further additions to /proc/PID/fd/DESCRIPTOR symlink
handling.

Add a method to handle stat(2) on such a proc fd symlink by handle.
This allows correct reply from stat(2) if the target file has been
deleted.  This eventually fixes `awk -f /dev/fd/3 3<<eof'.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: path_conv: add PATH_RESOLVE_PROCFD path_types flag
Corinna Vinschen [Sun, 6 Jan 2019 19:13:52 +0000 (20:13 +0100)]
Cygwin: path_conv: add PATH_RESOLVE_PROCFD path_types flag

path_conv now sets the PATH_RESOLVE_PROCFD flag in path_flags if
the PC_SYM_NOFOLLOW_PROCFD pathconv_arg flag has been set on input
*and* the file is actually a proc fd symlink.

Add matching path_conv::follow_fd_symlink method for checking and
use it in open(2).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: path_conv: decouple path_types from mount types
Corinna Vinschen [Sun, 6 Jan 2019 16:44:20 +0000 (17:44 +0100)]
Cygwin: path_conv: decouple path_types from mount types

- Remove another unfortunate amalgamation: Mount flags (MOUNT_xxx)
  are converted to path_types (PATH_xxx) and mixed with non-mount
  path_types flags in the same storage, leading to a tangled,
  pell-mell usage of mount flags and path flags in path_conv and
  symlink_info.

- There's also the case of PC_NONULLEMPTY.  It's used in exactly
  one place with a path_conv constructor only used in this single
  place, just to override the automatic PC_NULLEMPTY addition
  when calling the other path_conv constructors.  Crazily,
  PC_NONULLEMPTY is a define, no path_types flag, despite its
  name.

- It doesn't help that the binary flag exists as mount and path
  flag, while the text flag only exists as path flag.  This leads
  to mount code using path flags to set text/binary.  Very confusing
  is the fact that a text mount/path flag is not actually required;
  the mount code sets the text flag on non binary mounts anyway, so
  there are only two states.  However, to puzzle people a bit more,
  path_conv::binary wrongly implies there's a third, non-binary/non-text
  state.

Clean up this mess:

- Store path flags separately from mount flags in path_conv and
  symlink_info classes and change all checks and testing inline
  methods accordingly.

- Make PC_NONULLEMPTY a simple path_types flag and drop the
  redundant path_check constructor.

- Clean up the definition of pathconv_arg, path_types, and mount flags.
  Use _BIT expression, newly define in cygwin/bits.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: path_conv: decouple pathconv_flags from path_types
Corinna Vinschen [Sun, 6 Jan 2019 13:29:53 +0000 (14:29 +0100)]
Cygwin: path_conv: decouple pathconv_flags from path_types

There's an unfortunate amalgamation of caller-provided pathconv_arg
flags with path_types flags which in turn are mostly mount flags.

This leads to a confusion of flag values in sylink_info::pflags and,
in turn, in path_conv::path_flags.

This patch decouples pathconv_flags from the other flags by making
sure that a pathconv_flag is never copied into a variable used for
path_types flags.  Also, remove PATH_NO_ACCESS_CHECK since it's
not necessary.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Mark all O_TMPFILEs as deleted
Corinna Vinschen [Sat, 5 Jan 2019 21:16:30 +0000 (22:16 +0100)]
Cygwin: Mark all O_TMPFILEs as deleted

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Move O_TMPFILE to bin and allow linkat by handle
Corinna Vinschen [Sat, 5 Jan 2019 21:15:58 +0000 (22:15 +0100)]
Cygwin: Move O_TMPFILE to bin and allow linkat by handle

Along the same lines as the previous patch: By reopening an
O_TMPFILE by handle, we can now move the file to the bin at
open time and thus free'ing up the parent dir and *still*
open the file as /proc/PID/fd/DESCRIPTOR by linkat(2).

5 years agoCygwin: try_to_bin: allow to move O_TMPFILE files into bin
Corinna Vinschen [Sat, 5 Jan 2019 20:44:12 +0000 (21:44 +0100)]
Cygwin: try_to_bin: allow to move O_TMPFILE files into bin

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: implement /proc/PID/fd/DESCRIPTOR reopening by handle
Corinna Vinschen [Sat, 5 Jan 2019 21:13:42 +0000 (22:13 +0100)]
Cygwin: implement /proc/PID/fd/DESCRIPTOR reopening by handle

Allows expressions along the lines of `cat /proc/self/fd/0 <<EOF'.
The problem here is that the temporary file used for the here script
has already been deleted by the shell.  Opening by filename, as
implemented so far, doesn't work because the file has been moved
to the bin.

Allow reopening files by handle the same way from another process
as long as we have sufficient permissions on the foreign process.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: pinfo: add method to send a serialized path_conv and HANDLE
Corinna Vinschen [Sat, 5 Jan 2019 20:57:03 +0000 (21:57 +0100)]
Cygwin: pinfo: add method to send a serialized path_conv and HANDLE

To allow reopening a file open in another process by HANDLE, introduce
a matching file_pathconv method, taking a file descriptor as parameter.
The result is a serialized path_conv and a HANDLE value.  The HANDLE is
valid in the foreign process and MUST be duplicated into the target
process before usage.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: path_conv: add serialization/deserialization facility
Corinna Vinschen [Sat, 5 Jan 2019 20:50:48 +0000 (21:50 +0100)]
Cygwin: path_conv: add serialization/deserialization facility

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: path_conv: reorder private method declarations
Corinna Vinschen [Sat, 5 Jan 2019 20:51:51 +0000 (21:51 +0100)]
Cygwin: path_conv: reorder private method declarations

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: fhandler_base::open: allow to reopen file from handle
Corinna Vinschen [Sat, 5 Jan 2019 20:49:16 +0000 (21:49 +0100)]
Cygwin: fhandler_base::open: allow to reopen file from handle

So far io_handle is NULL when calling fhandler_base::open to
open or create a file.  Add a check for io_handle to allow
priming the fhandler with a HANDLE value so we can reopen a
file from a HANDLE on file systems supporting it.  This allows
to open already deleted files for further action.  This will
be used by open("/proc/PID/fd/DESCRIPTOR") scenarios.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: pipe: use /proc/PID/fd/... or /proc/self/fd/... name
Corinna Vinschen [Sat, 5 Jan 2019 20:42:33 +0000 (21:42 +0100)]
Cygwin: pipe: use /proc/PID/fd/... or /proc/self/fd/... name

Don't emit /dev/fd/... filename.  This simplifies pipe path handling
and avoids another symlink redirection.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: introduce virt_fdsymlink to simplify /proc/PID/fd symlink handling
Corinna Vinschen [Sat, 5 Jan 2019 20:41:01 +0000 (21:41 +0100)]
Cygwin: introduce virt_fdsymlink to simplify /proc/PID/fd symlink handling

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: return correct FH_PROCESSFD for files under /proc/PID/fd subdir
Corinna Vinschen [Sat, 5 Jan 2019 20:36:34 +0000 (21:36 +0100)]
Cygwin: return correct FH_PROCESSFD for files under /proc/PID/fd subdir

This allows easier handling of fd symlinks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: try_to_bin: fix typos in comments
Corinna Vinschen [Sat, 5 Jan 2019 10:32:23 +0000 (11:32 +0100)]
Cygwin: try_to_bin: fix typos in comments

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: path_conv: nobody cares if a path had symlinks after the fact
Corinna Vinschen [Sat, 5 Jan 2019 10:31:52 +0000 (11:31 +0100)]
Cygwin: path_conv: nobody cares if a path had symlinks after the fact

remove set_has_symlinks/has_symlinks/PATH_HAS_SYMLINKS.  Nobody's
asking for this information.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: drop disabled O_TMPFILE POSIX unlink code
Corinna Vinschen [Fri, 4 Jan 2019 10:00:57 +0000 (11:00 +0100)]
Cygwin: drop disabled O_TMPFILE POSIX unlink code

The commit message of commit 07e0a9584f9a5b2668c767ede0482a5fba498731
and the expectation set therein, are wrong.

There's no POSIX semantics allowing to link a file with a link
count of 0 and making it available in the file system again.
In fact, the Linux linkat extension AT_EMPTY_PATH explicitely
disallows to link a file descriptor to a file with a link count
of 0, except for O_TMPFILE without O_EXCL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoImprove performance of memmem
Wilco Dijkstra [Mon, 31 Dec 2018 18:01:52 +0000 (18:01 +0000)]
Improve performance of memmem

This patch significantly improves performance of memmem using a novel
modified Horspool algorithm.  Needles up to size 256 use a bad-character
table indexed by hashed pairs of characters to quickly skip past mismatches.
Long needles use a self-adapting filtering step to avoid comparing the whole
needle repeatedly.

By limiting the needle length to 256, the shift table only requires 8 bits
per entry, lowering preprocessing overhead and minimizing cache effects.
This limit also implies worst-case performance is linear.

Small needles up to size 2 use a dedicated linear search.  Very long needles
use the Two-Way algorithm (to avoid increasing stack size inlining is now disabled).

The performance gain is 6.6 times on English text on AArch64 using random
needles with average size 8 (this is even faster than the recently improved strstr
algorithm, so I'll update that in the near future).

The size-optimized memmem has also been rewritten from scratch to get a
2.7x performance gain.

Tested against GLIBC testsuite and randomized tests.

Message-Id: <DB5PR08MB1030649D051FA8532A4512C883B20@DB5PR08MB1030.eurprd08.prod.outlook.com>

5 years agoBump release to 3.1.0 for yearly snapshot newlib-3.1.0 newlib-snapshot-20181231
Jeff Johnston [Tue, 1 Jan 2019 04:40:11 +0000 (23:40 -0500)]
Bump release to 3.1.0 for yearly snapshot

5 years agoCygwin: open(2): Change comment in disabled O_TMPFILE POSIX unlink code
Corinna Vinschen [Wed, 26 Dec 2018 20:51:13 +0000 (21:51 +0100)]
Cygwin: open(2): Change comment in disabled O_TMPFILE POSIX unlink code

- Turns out, the definition of POSIX unlink semantics is half-hearted
  so far: It's not possible to link an open file HANDLE if it has
  been deleted with POSIX semantics, nor is it possible to remove
  the delete disposition.  This breaks linkat on an O_TMPFILE.

  Tested with W10 1809.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Change /proc/$PID/fd/<fd> symlink target for deleted files
Corinna Vinschen [Wed, 26 Dec 2018 20:22:40 +0000 (21:22 +0100)]
Cygwin: Change /proc/$PID/fd/<fd> symlink target for deleted files

- As on Linux, print the file name with an attached " (deleted)"

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Add Christmas hacking release notes
Corinna Vinschen [Wed, 26 Dec 2018 10:36:22 +0000 (11:36 +0100)]
Cygwin: Add Christmas hacking release notes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Add documentation for chattr and lsattr
Corinna Vinschen [Wed, 26 Dec 2018 10:22:06 +0000 (11:22 +0100)]
Cygwin: Add documentation for chattr and lsattr

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Add lsattr and chattr tools
Corinna Vinschen [Tue, 25 Dec 2018 22:39:11 +0000 (23:39 +0100)]
Cygwin: Add lsattr and chattr tools

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: Add FS_IOC_GETFLAGS and FS_IOC_SETFLAGS ioctls
Corinna Vinschen [Tue, 25 Dec 2018 22:38:52 +0000 (23:38 +0100)]
Cygwin: Add FS_IOC_GETFLAGS and FS_IOC_SETFLAGS ioctls

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
5 years agoCygwin: mkdir: create case-sensitive dirs
Corinna Vinschen [Tue, 25 Dec 2018 00:09:12 +0000 (01:09 +0100)]
Cygwin: mkdir: create case-sensitive dirs

On Windows 10 1803 and later, create dirs under the Cygwin
installation dir as case sensitive, if WSL is installed.

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