Commit Graph

7962 Commits

Author SHA1 Message Date
Joe Lowe 0a9edd73e3 readdir() with mount point dentry, return mount point INO
This patch fixes a minor compatibility issue w/ cygwin mount point handling in
readdir(), compared to equivalent behavior of Linux and MacOS. dentry.d_ino
should indicate the INO of the mount point itself, not the target volume root
folder.

Changed return type from readdir_check_reparse_point to uint8_t, to avoid
unnecessarily being implicitly cast to and from a signed int.

Renamed a related local variable "attr" to "oattr" that was eclipsing a member
variable with the same name.

Joe L.
2017-06-14 10:57:02 +02:00
Corinna Vinschen 105436dead cygwin: document lrint bugfix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-06-07 11:07:52 +02:00
Corinna Vinschen e4094e49c1 cygwin: Fix lrint{f,l} to return a 64 bit long on x86_64
Mingw-w64 (where the code has been taken from) has 4 byte longs
independently of the architecture but x86_64 Cygwin has 64 bit longs.
So use fistpll instead of fistpl on x86_64 Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-06-07 11:03:16 +02:00
Corinna Vinschen 163066a1a5 cygwin: document env var crash fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-06-06 21:11:52 +02:00
Corinna Vinschen 7afc1124b6 cygwin: Fix crash if env var name starts with non-ASCII char
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-06-06 21:10:23 +02:00
Corinna Vinschen 41b7ef9e1f cygwin: document wcsxfrm fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-06-06 18:39:41 +02:00
Corinna Vinschen c0d7d3e1a2 cygwin wcsxfrm: byte swap result ourselves
Workaround a bug (or undocumented behaviour) in LCMapStringW:

It's documented(*) that the cchDest parameter is a byte count with
LCMAP_SORTKEY, but a character count otherwise.  But the docs don't
state what happens if you combine LCMAP_SORTKEY with LCMAP_BYTEREV.

Tests indicate that LCMAP_SORTKEY treats cchDest as byte count, but
then LCMAP_BYTEREV treats it as char count in the same call.  So the
latter swaps twice as much bytes in the destination buffer than the
byte count it returns, which potentially results in writing past the
end of the given output buffer.

Solution: Don't specify LCMAP_BYTEREV in the LCMapStringW(LCMAP_SORTKEY)
call, rather byte swap afterwards.

(*) https://msdn.microsoft.com/en-us/library/windows/desktop/dd318702(v=vs.85).aspx

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-06-06 18:27:47 +02:00
Jon Turney fe7a7709ef Fix transposed lines in 2.8.1 release text 2017-04-24 17:17:38 +01:00
Jon Turney 2980e76ae3 Update 2.8.1 release text 2017-04-24 17:13:04 +01:00
Corinna Vinschen fccaaee026 cygwin: add 2.8.1 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-24 17:36:54 +02:00
Corinna Vinschen 7437d656cb cygwin TEST: Add nagging debug output to pinfo
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-24 17:35:06 +02:00
Corinna Vinschen 5ef0399ddd cygwin: pinfo: do not wait for setting ppid on a transitional procinfo
This leads to excessive lag when stracing processes if the inferior
process checks the process table.  The reason is that ppid isn't set
in the procinfo memory of the dynamically loading strace itself.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-24 17:34:31 +02:00
Corinna Vinschen ffcfbf4b66 cygwin: try unprivileged symlink creation on W10 1703 and later
Add new SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE flag to
CreateSymbolicLinkW call when running on W10 1703 or later.
Don't do that on older versions to avoid ERROR_INVALID_PARAMETER.

Preliminary, needs testing.  There's an off-chance that the
flag results in the same ERROR_INVALID_PARAMETER on 1703 if the
developer settings are not enabled.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-24 17:17:29 +02:00
Corinna Vinschen e7bcf4633e cygwin: wincap: handle W10 1703
Add has_unprivileged_createsymlink flag and set to true on 1703 and
later.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-24 17:14:03 +02:00
Corinna Vinschen 63f19278b9 cygwin: wincap: fix evaluation of build number
RtlGetNtVersionNumbers returns the build number with some upper bits
set for no apparent reason.  The fact that RtlGetNtVersionNumbers is
undocumented doesn't exactly help.

Just filter out the upper WORD for now.  If build numbers are in
danger to become 6 digit numbers, re-evaluate.
2017-04-24 17:12:16 +02:00
Corinna Vinschen 3885c06c4f cygwin: remov unused winpids constructor
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-24 14:22:02 +02:00
Christian Franke b8523353d7 Fix stat.st_blocks for files compressed with CompactOS method
Always retrieve FileCompressionInformation for non-empty
files if FileStandardInformation returns 0 allocated blocks.
This fixes stat.st_blocks for files compressed with CompactOS method.

Signed-off-by: Christian Franke <franke@computer.org>
2017-04-22 16:12:36 +02:00
Corinna Vinschen bdb017b30c newlib: remove __infinity{f,ld} constants
previous commit 4c90db7bc8 introduced
a compile time error because libm/common/s_infconst.c used the remove
__fmath, __dmath, and __ldmath union types.

Since this is very old, and unused for a very long time, just drop the
file and thus the __infinity constants entirely.

Exception: Cygwin exports __infinity from the beginning.  There's a very,
VERY low probability that any existing executable or lib still uses this
constant, but we just keep it in for backward compat, nevertheless.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-18 12:17:26 +02:00
Jon Turney c84697c259 Avoid decimal point localization in /proc/loadavg
Explicitly format the contents of /proc/loadavg to avoid the decimal point
getting localized according to LC_NUMERIC. Using anything other than '.' is
wrong and breaks top.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-04-10 10:59:54 +01:00
Mark Geisert c6c7dfc493 mkvers.sh: Remove "function" to avoid dash objecting to bash-ism. 2017-04-06 18:17:08 +02:00
Corinna Vinschen 961a6909d9 Cygwin: Export reallocarray
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-04 12:23:18 +02:00
Corinna Vinschen 6f88e6b2d5 Bump Cygwin to 2.8.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-04 12:23:09 +02:00
Corinna Vinschen 577c9d55da Add latest changes to Cygwin release information
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-28 13:42:11 +02:00
Corinna Vinschen b5b03d2d5f Change CURR_SHARED_MAGIC to account for getloadavg patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-28 13:41:31 +02:00
Jon Turney d0a359f6d2 Implement getloadavg()
v2:
autoload PerfDataHelper functions
Keep loadavg in shared memory
Guard loadavg access by a mutex
Initialize loadavg to the current load

v3:
Shared memory version bump isn't needed if we are only extending it
Remove unused autoload
Mark inititalized flags as NO_COPY for correct behaviour in fork child

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-03-27 22:03:58 +01:00
Jon Turney b568f92c50 declaration of ppoll() by poll.h should be guarded by _GNU_SOURCE
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-03-27 22:03:01 +01:00
Corinna Vinschen bbffd7ce7a Recognize Netapp mode supporting reparse points
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-27 20:28:03 +02:00
Corinna Vinschen fa4fcf7373 cygwin: Do not generate surrogate chars on netapp
Just like Samba, Netapp FSes seem to dislike invalid surrogate usage in
filenames.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-24 20:52:25 +01:00
Corinna Vinschen 0accc5332a Document cygserver changes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-24 18:13:08 +01:00
Corinna Vinschen 8259db586a dlfcn: Remove stray debug output
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-22 11:10:15 +01:00
Yaakov Selkowitz 90e35b1eb3 Rename <sys/_locale.h> to <xlocale.h>
The locale_t type is provided by <xlocale.h> on Linux, FreeBSD, and Darwin.
While, like on some of those systems, it is automatically included by
<locale.h> with the proper feature test macros, its presence under this
particular name is still presumed in real-world software.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-03-22 10:03:45 +01:00
Corinna Vinschen 33297d810d Cygwin: dlfcn: Fix reference counting
The original dll_init code was living under the wrong assumption that
dll_dllcrt0_1 and in turn dll_list::alloc will be called for each
LoadLibrary call.  The same wrong assumption was made for
cygwin_detach_dll/dll_list::detach called via FreeLibrary.

In reality, dll_dllcrt0_1 gets only called once at first LoadLibrary
and cygwin_detach_dll once at last FreeLibrary.

In effect, reference counting for DLLs was completely broken after fork:

  parent:
    l1 = dlopen ("lib1");  // LoadLibrary, LoadCount = 1
    l2 = dlopen ("lib1");  // LoadLibrary, LoadCount = 2

    fork ();               // LoadLibrary in the child, LoadCount = 1!
      child:
        dlclose (l1);      // FreeLibrary actually frees the lib
        x = dlsym (l2);    // SEGV

* Move reference counting to dlopen/dlclose since only those functions
  have to keep track of loading/unloading DLLs in the application context.

* Remove broken accounting code from dll_list::alloc and dll_list::detach.

* Fix error handling in dlclose.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-21 14:31:03 +01:00
Corinna Vinschen 778f4397f3 Add release message for commit 973f766f6
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-14 16:54:57 +01:00
Corinna Vinschen 73d3f9cf20 Revert "Add release message for commit 973f766f6"
This reverts commit 125852d77b.

Accidentally commited too much.
2017-03-14 16:52:20 +01:00
Corinna Vinschen 125852d77b Add release message for commit 973f766f6
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-14 09:24:48 +01:00
Corinna Vinschen 02011278e0 Extend 2.8.0 release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-12 12:21:40 +01:00
Corinna Vinschen dd757cc43a Implement fhandler_dev_null::write to workaround a problem with NUL
Windows NUL device returns only the lower 32 bit of the number of
bytes written.  Implement a fake write function to ignore the underlying
NUL device.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-12 12:17:43 +01:00
Corinna Vinschen a3f297d3c2 Return value from write is ssize_t, not int
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-12 12:16:23 +01:00
Yaakov Selkowitz 6c420fa494 getrandom: it's MIN, not MAX
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-11 10:03:29 +01:00
Corinna Vinschen c9e4b69e9f Belatedly bump Cygwin DLL version to 2.8.0
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-10 20:50:35 +01:00
Corinna Vinschen 45d0d75910 Drop now unused child_info_fork::from_main
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-10 20:45:19 +01:00
Corinna Vinschen 48755fb9bc fork: Don't copy _main_tls->local_clib from *_impure_ptr
So far we copy *_impure_ptr into _main_tls->local_clib if the child
process has been forked from a pthread.  But that's not required.
The local_clib area of the new thread is on the stack and the stack
gets copied from the parent anyway (in frok::parent).  So we only
have to make sure _main_tls is pointing to the right address and
do the simple post-fork thread init.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-10 20:44:53 +01:00
Corinna Vinschen 35d344babe _dll_crt0: Drop incorrect check for being started from parent main thread
This test was broken from the start.  It leads to creating a completely
new stack for the main thread of the child process when started from
the main thread of the parent.  However, the main thread of a process
can easily running on a completely different stack, if the parent's main
thread was created by calling fork() from a pthread.  For an example,
see https://cygwin.com/ml/cygwin/2017-03/msg00113.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-10 20:28:09 +01:00
Corinna Vinschen 44b1746a41 errno: Stop using _impure_ptr->_errno completely
We use errno AKA _REENT->_errno since the last century and only set
_impure_ptr->_errno for backward compat.  Stop that.  Also, remove
the last check for _impure_ptr->_errno in Cygwin code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-10 20:21:09 +01:00
Corinna Vinschen f2e6553c25 Drop redundant brackets in call to _reclaim_reent
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-10 20:16:48 +01:00
Jon Turney c8432a01c8 Implement dladdr() (partially)
Note that this always returns with dli_sname and dli_saddr set to NULL,
indicating no symbol matching addr could be found.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-03-08 17:49:08 +00:00
Corinna Vinschen 51a993c266 yield: Don't lower thread priority, it leads to starvation
...and it's not required anymore to have the same effect as the original
code post-XP.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-08 17:44:15 +01:00
Corinna Vinschen 994a4b7dcc Cygwin: Emit correct errno EAGAIN if we can't create another thread
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-08 17:43:23 +01:00
Jon Turney b9498f17f9 Export timingsafe_bcmp and timingsafe_memcmp
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-03-07 18:40:35 +00:00
Corinna Vinschen eed33fa2c4 Document pthread_cond_wait change in release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-07 15:18:03 +01:00
Corinna Vinschen 49505a907f Cygwin: pthread_cond_wait: Do as Linux and BSD do.
POSIX states as follows about pthread_cond_wait:
If a signal is delivered to a thread waiting for a condition variable,
upon return from the signal handler the thread resumes waiting for the
condition variable as if it was not interrupted, or it returns zero
due to spurious wakeup.

Cygwin so far employs the latter behaviour, while Linux and BSD employ
the former one.

Align Cygwin behaviour to Linux and BSD.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-07 15:15:47 +01:00
Corinna Vinschen 88443b0a22 cwdstuff: Don't leave from setting the CWD prematurely on init
There are certain, very obscure scenarios, which render the Windows
CWD handle inaccessible for reopening.  An easy one is, the handle can
be NULL if the permissions of the CWD changed under the parent processes
feet.

Originally we just set errno and returned, but in case of init at
process startup that left the "posix" member NULL and subsequent
calls to getcwd failed with EFAULT.

We now check for a NULL handle and change the reopen approach
accordingly.  If that doesn't work, try to duplicate the handle instead.
If duplicating fails, too, we set the dir handle to NULL and carry on.
This will at least set posix to some valid path and subsequent getcwd
calls won't fail.  A NULL dir handle is ok, because we already do this
for virtual paths.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-03 13:55:55 +01:00
David Allsopp 226f69422a Preserve order of dlopen'd modules in dll_list::topsort
This patch alters the behaviour of dll_list::topsort to preserve the
order of dlopen'd units.

The load order of unrelated DLLs is reversed every time fork is called,
since dll_list::topsort finds the tail of the list and then unwinds to
reinsert items. My change takes advantage of what should be undefined
behaviour in dll_list::populate_deps (ndeps non-zero and ndeps and deps
not initialised) to allow the deps field to be initialised prior to the
call and appended to, rather than overwritten.

All DLLs which have been dlopen'd have their deps list initialised with
the list of all previously dlopen'd units. These extra dependencies mean
that the unwind preserves the order of dlopen'd units.

The motivation for this is the FlexDLL linker used in OCaml. The FlexDLL
linker allows a dlopen'd unit to refer to symbols in previously dlopen'd
units and it resolves these symbols in DllMain before anything else has
initialised (including the Cygwin DLL). This means that dependencies may
exist between dlopen'd units (which the OCaml runtime system
understands) but which Windows is unaware of. During fork, the
process-level table which FlexDLL uses to get the symbol table of each
DLL is copied over but because the load order of dlopen'd DLLs is
reversed, it is possible for FlexDLL to attempt to access memory in the
DLL before it has been loaded and hence it fails with an access
violation. Because the list is reversed on each call to fork, it means
that a subsequent call to fork puts the DLLs back into the correct
order, hence "even" invocations of fork work!

An interesting side-effect is that this only occurs if the DLLs load at
their preferred base address - if they have to be rebased, then FlexDLL
works because at the time that the dependent unit is loaded out of
order, there is still in memory the "dummy" DONT_RESOLVE_DLL_REFERENCES
version of the dependency which, as it happens, will contain the correct
symbol table in the data section. For my tests, this initially appeared
to be an x86-only problem, but that was only because the two DLLs on x64
should have been rebased.

Signed-off-by: David Allsopp <david.allsopp@metastack.com>
2017-02-28 16:12:03 +01:00
Corinna Vinschen 45d3296d0d Add 2.7.1 release file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-24 20:57:02 +01:00
Corinna Vinschen fa9d3148bf Bump Cygwin version to 2.7.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-24 20:51:50 +01:00
Michael Haubenwallner 829aaa7352 fix parallel build for version.cc and winver.o
Creating both version.cc and winver.o at once really should run once only.
2017-02-16 21:14:39 +01:00
Yaakov Selkowitz e704ab2470 Cygwin: create separate bits/byteswap.h
Match glibc behaviour to expose the public bswap_* macros only with an
explicity #include <byteswap.h>; #include'ing <endian.h> should not expose
them.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-02-08 17:01:34 -06:00
Corinna Vinschen a9f4b71e8e Add release message for commit 609d2b2
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-03 21:54:25 +01:00
Corinna Vinschen 609d2b22af Fix limited Internet speeds caused by inappropriate socket buffering
Don't set SO_RCVBUF/SO_SNDBUF to fixed values, thus disabling autotuning.

Patch modeled after a patch suggestion from Daniel Havey <dhavey@gmail.com>
in https://cygwin.com/ml/cygwin-patches/2017-q1/msg00010.html:

At Windows we love what you are doing with Cygwin.  However, we have
been getting reports from our hardware vendors that iperf is slow on
Windows.  Iperf is of course compiled against the cygwin1.dll and we
believe we have traced the problem down to the function fdsock in
net.cc.  SO_RCVBUF and SO_SNDBUF are being manually set.  The comments
indicate that the idea was to increase the buffer size, but, this code
must have been written long ago because Windows has used autotuning
for a very long time now.  Please do not manually set SO_RCVBUF or
SO_SNDBUF as this will limit your internet speed.

I am providing a patch, an STC and my cygcheck -svr output.  Hope we
can fix this.  Please let me know if I can help further.

Simple Test Case:
I have a script that pings 4 times and then iperfs for 10 seconds to
debit.k-net.fr

With patch
$ bash buffer_test.sh 178.250.209.22
usage: bash buffer_test.sh <iperf server name>

Pinging 178.250.209.22 with 32 bytes of data:
Reply from 178.250.209.22: bytes=32 time=167ms TTL=34
Reply from 178.250.209.22: bytes=32 time=173ms TTL=34
Reply from 178.250.209.22: bytes=32 time=173ms TTL=34
Reply from 178.250.209.22: bytes=32 time=169ms TTL=34

Ping statistics for 178.250.209.22:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 167ms, Maximum = 173ms, Average = 170ms
------------------------------------------------------------
Client connecting to 178.250.209.22, TCP port 5001
TCP window size: 64.0 KByte (default)
------------------------------------------------------------
[  3] local 10.137.196.108 port 58512 connected with 178.250.209.22 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   768 KBytes  6.29 Mbits/sec
[  3]  1.0- 2.0 sec  9.25 MBytes  77.6 Mbits/sec
[  3]  2.0- 3.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  3.0- 4.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  4.0- 5.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  5.0- 6.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  6.0- 7.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  7.0- 8.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  8.0- 9.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  9.0-10.0 sec  18.0 MBytes   151 Mbits/sec
[  3]  0.0-10.0 sec   154 MBytes   129 Mbits/sec

Without patch:
dahavey@DMH-DESKTOP ~
$ bash buffer_test.sh 178.250.209.22

Pinging 178.250.209.22 with 32 bytes of data:
Reply from 178.250.209.22: bytes=32 time=168ms TTL=34
Reply from 178.250.209.22: bytes=32 time=167ms TTL=34
Reply from 178.250.209.22: bytes=32 time=170ms TTL=34
Reply from 178.250.209.22: bytes=32 time=169ms TTL=34

Ping statistics for 178.250.209.22:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 167ms, Maximum = 170ms, Average = 168ms
------------------------------------------------------------
Client connecting to 178.250.209.22, TCP port 5001
TCP window size:  208 KByte (default)
------------------------------------------------------------
[  3] local 10.137.196.108 port 58443 connected with 178.250.209.22 port 5001
[ ID] Interval       Transfer     Bandwidth
[  3]  0.0- 1.0 sec   512 KBytes  4.19 Mbits/sec
[  3]  1.0- 2.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  2.0- 3.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  3.0- 4.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  4.0- 5.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  5.0- 6.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  6.0- 7.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  7.0- 8.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  8.0- 9.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  9.0-10.0 sec  1.50 MBytes  12.6 Mbits/sec
[  3]  0.0-10.1 sec  14.1 MBytes  11.7 Mbits/sec

The output shows that the RTT from my machine to the iperf server is
similar in both cases (about 170ms) however with the patch the
throughput averages 129 Mbps while without the patch the throughput
only averages 11.7 Mbps.  If we calculate the maximum throughput using
Bandwidth = Queue/RTT we get (212992 * 8)/0.170 = 10.0231 Mbps.  This
is just about what iperf is showing us without the patch since the
buffer size is set to 212992 I believe that the buffer size is
limiting the throughput.  With the patch we have no buffer limitation
(autotuning) and can develop the full potential bandwidth on the link.

If you want to duplicate the STC you will have to find an iperf server
(I found an extreme case) that has a large enough RTT distance from
you and try a few times.  I get varying results depending on Internet
traffic but without the patch never exceed the limit caused by the
buffering.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-02-03 21:51:45 +01:00
Jon Turney 06e7f0074c Add release message for commit a1529738
Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2017-01-31 20:16:37 +00:00
Corinna Vinschen aade9a4fe1 Add release message for commit 095cac4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-31 15:40:03 +01:00
Corinna Vinschen 095cac4b8d Cygwin: Add IUTF8 termios iflag
The termios code doesn't handle erasing of multibyte characters
in canonical mode, it always erases a single byte.  When entering
a multibyte character and then pressing VERASE, the input ends up
with an invalid character.

Following Linux we introduce the IUTF8 input flag now, set by
default.  When this flag is set, VERASE or VWERASE will check
if the just erased input byte is a UTF-8 continuation byte.  If
so, it erases another byte and checks again until the entire
UTF-8 character has been removed from the input buffer.

Note that this (just as on Linux) does NOT work with arbitrary
multibyte codesets.  This only works with UTF-8.

For a discussion what happens, see
https://cygwin.com/ml/cygwin/2017-01/msg00299.html

Sidenote: The eat_readahead function is now member of fhandler_termios,
not fhandler_base.  That's necessary to get access to the terminal's
termios flags.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-31 15:36:24 +01:00
Corinna Vinschen dfbc941f7e Add release message for commit ca3e3bc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-20 10:33:12 +01:00
Corinna Vinschen ef00718487 Cleanup fhandler_console::read for readability
- Drop virtual_key_code (only used once)
- Convert macros wch and control_key_state to const vars
  unicode_char and  ctrl_key_state.
- Fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:58:05 +01:00
Corinna Vinschen dd7c87ae87 miscfuncs.cc: Revert exclusion of inclusion of exception.h
x86 still needs it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:51:38 +01:00
Corinna Vinschen 3b7b65b2f8 Simplify check for Alt-Numpad
Create two new inline functions is_alt_numpad_key(PINPUT_RECORD) and
is_alt_numpad_event(PINPUT_RECORD) which contain the actual checks.
Call these functions from fhandler_console::read and peek_console for
better readability.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:42:10 +01:00
Corinna Vinschen 9985cf66e9 miscfuncs.h: Drop now unneeded getentropy declaration
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:35:12 +01:00
Corinna Vinschen 19f9a9799f miscfuncs.cc: Drop unneeded includes and unused global variable
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:11:55 +01:00
Corinna Vinschen 946cd7df28 check_iovec: Change test to be more robust against invalid iovcnt values
Stop running wild if iovcnt is < 0 to begin with.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:11:22 +01:00
Corinna Vinschen e2ab9b71fa Don't assert on sum of iov_len overflowing an ssize_t
Rather return EINVAL per POSIX.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:08:53 +01:00
Corinna Vinschen abfcf32732 Move string functions from miscfunc.cc to strfuncs.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 21:02:16 +01:00
Corinna Vinschen bbf6993a2d Move getentropy/getrandom into own file
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 20:58:06 +01:00
Corinna Vinschen e6e66224f3 Fix copy/paste buglet in comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 19:22:47 +01:00
Corinna Vinschen dd353aa688 Add release message for commit 4652cc4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 19:01:09 +01:00
Corinna Vinschen 4652cc4384 Handle Alt+Numpad key sequences in console input and select
{p}select/{p}poll completely ignored Alt+Numpad key sequences in console
input which results in newer readline using pselect to fail handling such
sequences correctly.  See https://cygwin.com/ml/cygwin/2017-01/msg00135.html

During debugging and testing it turned out that while reading console
input, single key presses during an Alt+Numpad sequences where not
ignored, so ultimately a sequence like

  Alt-down Numpad-1 Numpad-2 Numpad-3

whihc is supposed to result in a single character in the input stream
will actually result in 4 chars in the input stream, three control
sequences and the actual character.

Both problems should be fixed by this patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-19 18:59:48 +01:00
Corinna Vinschen 411882e2fa Add release message for commit 688d943
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-14 16:47:47 +01:00
Corinna Vinschen 688d943a52 Always try to write complete incoming buffer on pipes and fifos
This patch fixes the following problem:

Commit 9636c426 refactored the pipe code especially to make sure
to call WriteFile only with chunks matching the maximum atomic write
count.  This accidentally introduced a small change in behaviour
on blocking pipes due to the success case falling through into the
error case.  Rather then writing atomic chunks until all bytes are
written, the code immediately broke from the loop after writing
the first chunk, basically the same as in case of non-blocking
writes.  This behaviour is not compliant to POSIX which requires

 "Write requests to a pipe or FIFO [...]

  * If the O_NONBLOCK flag is clear, a write request may cause the
    thread to block, but on normal completion it shall return nbyte."

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-14 16:29:06 +01:00
Corinna Vinschen 677ffdc247 Add release message for commit 6ed4753
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-12 22:46:21 +01:00
Corinna Vinschen 6ed4753e77 rename: Refactor "new file already exists and rename fails" case
If newfile already exists and is in use, trying to overwrite it with
NtSetInformationFile(FileRenameInformation) fails exactly as if we
don't have the permissions to delete it.  Unfortunately the return code
is the same STATUS_ACCESS_DENIED, so we have no way to distinguish
these cases.  What we do here so far is to start a transaction to delete
newfile.  If this open fails with a transactional error we stop the
transaction and retry opening the file without transaction.

But, here's the problem: If newfile is in use, NtOpenFile(oldfile)
naturally does NOT fail with a transactional error.  Rather, the
subsequent call to unlink_nt(newfile) does, because there's another
handle open to newfile outside a transaction.  However, the code does
not check if unlink_nt fails with a transactional error and so fails
to retry without transaction.

This patch recifies the problem and checks unlink_nt's status as well.

Refactor code to get rid of goto into another code block.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-12 22:42:11 +01:00
Johannes Schindelin e5cadbfdcd FAST_CWD: adjust the initial search scope
A *very* recent Windows build adds more code to the preamble of
RtlGetCurrentDirectory_U() so that the previous heuristic failed to find
the call to the locking routine.

This only affects the 64-bit version of ntdll, where the 0xe8 byte is
now found at offset 40, not the 32-bit version. However, let's just
double the area we search for said byte for good measure.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
2017-01-12 09:10:30 +01:00
Corinna Vinschen 171046da73 Fix formatting in pinfo.cc
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-10 16:38:01 +01:00
Corinna Vinschen 0a4ec0cc93 Document latest Cygwin changes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-10 16:33:21 +01:00
Erik M. Bray 5bebfa17c5 Add a /proc/<pid>/environ proc file handler, analogous to /proc/<pid>/cmdline. 2017-01-10 16:24:50 +01:00
Erik M. Bray 578bbc3a29 Add a _pinfo.environ() method analogous to _pinfo.cmdline(), and others.
Returns the process's environment concatenated into a single block of
null-terminated strings, along with the length of the environment block.

Adds an associated PICOM_ENVIRON commune_process handler.
2017-01-10 16:24:50 +01:00
Erik M. Bray 7fd70a9706 Move the core environment parsing of environ_init into a new win32env_to_cygenv function.
win32env_to_cygwenv handles converting wchar to char and some other
minor taks.  Optionally it handles converting any paths in variables to
posix paths.

This will be useful for implementing /proc/<pid>/environ
2017-01-10 16:24:50 +01:00
Erik M. Bray 387521976d Return the correct value for getsockopt(SO_REUSEADDR) after setting setsockopt(SO_REUSEADDR, 1). 2017-01-09 17:50:39 +01:00
Corinna Vinschen 838cfa352c Don't free statically allocated sys_privs
commit 67fd2101 introduced a bad bug.  Changing sys_privs to a static
area and just returning a pointer is nice... *if* the calling code doesn't
call free() on it.  Make sure callers check pointer for sys_privs and
refrain from calling free, if so.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-01-09 14:02:19 +01:00
Corinna Vinschen 4e75d7f504 Export getentropy and getrandom calls
getentropy per OpenBSD

  http://man.openbsd.org/cgi-bin/man.cgi/OpenBSD-current/man2/getentropy.2

getrandom per Linux

  http://man7.org/linux/man-pages/man2/getrandom.2.html

  Note that GRND_NONBLOCK is not handled
2016-12-16 23:10:19 +01:00
Corinna Vinschen 86fc4bf065 Define RtlGenRandom correctly in ntsecapi.h wrapper
Include ntsecapi.h where required and just redefine RtlGenRandom
correctly in the ntsecapi.h wrapper.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-14 14:14:28 +01:00
Corinna Vinschen 74f7872f89 Rearrange RNG code slightly
In preparation of exporting getentropy/getrandom to userspace, rearrange
code a bit:

- Define RtlGenRandom in ntdll.h.

- Drop calls to getentropy in favor of RtlGenRandom (fhandler_socket,
  fhandler_dev_random).

- Add try/except blocks in fhandler_dev_random to return EFAULT rather
  than crashing if buffer pointer is invalid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 22:59:31 +01:00
Corinna Vinschen 80f4987f02 Cygwin: Add release messages for last two checkins
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 12:49:02 +01:00
Corinna Vinschen 563dda8259 Fix incorrect path conversion on non-existent files on network shares
NtOpenFile/NtCreateFile on non-existent paths on network drives has a
bug.  Assuming a path Z:\dir\file.  Further assuming that Z:\dir does
not exist.

The first NtOpenFile("Z:\dir\file") correctly returns
STATUS_OBJECT_PATH_NOT_FOUND.  Subsequent calls incorrectly
return STATUS_OBJECT_NAME_NOT_FOUND.

This appears to be some kind of caching behaviour.  Waiting a while
before repeating the call correctly returns STATUS_OBJECT_PATH_NOT_FOUND
again.

This patch works around the observed misbehaviour.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 12:48:05 +01:00
Corinna Vinschen 937a2d92e2 Check for .exe file in cygwin_conv_path
So far, when converting from POSIX to Windows notation, cygwin_conv_path
fails to check for .exe suffix, so /path/foo did not return /path/foo.exe
even if this file exists.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-13 12:21:27 +01:00
Corinna Vinschen 72ee64045b Cygwin 2.6.1: Add missing release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-12-06 16:11:04 +01:00
Corinna Vinschen f0ae353a4f path_conv: When encountering a ".(/)+" sequence, skip *all* slashes
The original code only skipped the "./", but missed to test if more
trailing slashes are present.  This in turn leads to invalid conversion.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-28 12:33:40 +01:00
Corinna Vinschen 1c54541172 regex: Fix typo in CHaddrange
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 16:09:31 +01:00
Corinna Vinschen 59ab07f170 _pinfo::set_ctty: Check potential NULL pointer in debug_printf statement
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 15:06:51 +01:00
Corinna Vinschen 1dfffe8ef4 Eliminate unused parameter from path_conv::eq_worker
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 15:06:05 +01:00
Corinna Vinschen 6a6ae087e8 Remove redundant check for NULL pointer in cygwin_exception::dump_exception
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:46:57 +01:00
Corinna Vinschen 284bec3174 Fix copy/paste typo in fhandler_console::scroll_buffer_screen
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:43:52 +01:00
Corinna Vinschen f993cb708b Don't allow sending invalid signals from user space
Don't allow signal 0 in signal(2), sigaction(2), siginterrupt(3).
Don't allow any signal in sigqueue(3) but explicitely handle
signal 0 as in kill(2).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:24:07 +01:00
Corinna Vinschen e1913d218d raise: Add missing extern "C"
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 14:03:11 +01:00
Corinna Vinschen d3becf4318 login_tty: Rewrite following FreeBSD's traces
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 12:06:29 +01:00
Corinna Vinschen b56179f83a fcwd_access_t: Add missing breaks in f_cwd pointer computation
Fixes Coverity CIDs 59893/59894

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 10:53:08 +01:00
Corinna Vinschen 5d09711b1d Add comments to intentional switch fallthroughs
Clarify Coverity "Missing break in switch" messages.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 10:51:32 +01:00
Corinna Vinschen 40668dcc7c Add length check creating domain\group strings
Fix Coverity CID 153932

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-24 10:40:14 +01:00
Sebastian Huber 9fbd510569 Provide <memory.h>
Provide <memory.h> for all standard Newlib targets and remove
Cygwin-specific header.  Most POSIX like systems provide this historic
header.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-11-22 14:21:35 +01:00
Sebastian Huber e655d3d34b Move pthread types to <sys/_pthreadtypes.h>
This makes it possible provide operating system specific types for
<pthread.h>.  It is in line with the FreeBSD header file structure and
allows a future cleanup of <pthread.h> to not expose unrelated things
via <sys/types.h> and <unistd.h>.  Glibc uses the similar
<bits/pthreadtypes.h> for this purpose.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2016-11-17 11:33:15 +01:00
Corinna Vinschen ff3d980d32 Add release note for commit 8a32c24
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-11-17 11:11:11 +01:00
Erik M. Bray 8a32c24a7b Use allocation granularity as the 'page_size' in /proc/<pid>/status as well, for consistency with /proc/<pid>/statm 2016-11-16 15:58:15 +01:00
Erik M. Bray 6477a48cd1 statm should report memory as multiples of allocation_granularity instead of page_size
that ensures that values in statm mupltiplied by POSIX _SC_PAGESIZE give the correct values
2016-11-16 15:58:08 +01:00
Corinna Vinschen 11b7f94212 Fix ShellExecuteW comment
ShellExecuteW long path behaviour is now stable: It doesn't work since
Windows 8.1.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-24 11:23:55 +02:00
Ken Brown dda82d1a7b Add _PC_CASE_INSENSITIVE to [f]pathconf
Update the getconf utility to support the new flag as well as
_PC_POSIX_PERMISSIONS and _PC_POSIX_SECURITY.  These were previously
unsupported, probably as an oversight.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-21 13:39:02 +02:00
Jon Turney 93374181cb Fix SetThreadName with gdb 7.10 on x86
Additionally to eccefd97, we need to ensure the exception handler is
installed for the _ljfault used to implement _try/_except to get called.

Also use the correct macro for x86 conditional compilation.

Addresses https://cygwin.com/ml/cygwin/2016-09/msg00143.html

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-10-20 13:12:20 +01:00
Corinna Vinschen e3ccb68610 Don't check directories always case-insensitive in rename(2)
Long-standing problem in one of the corner cases of rename(2):
If we rename a directory a check is performed to see if newpath is
identical to oldpath or a subdir of oldpath. This check is
(accidentally? no hints anywhere in ChangeLogs or code) performed
case-insensitive for as long as we use Unicode paths and NT functions.
This leads to the problems described in
https://cygwin.com/ml/cygwin/2016-09/msg00264.html

Change this to be conditional case-sensitive as all other checks but
let's take this with a grain of salt.  There may be corner-cases in
this corner-case which require to chek parts of the path always
case-insensitive.  Off the top of my head I can't construct such a
case but that's no proof they don't exist :}

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 13:26:03 +02:00
Corinna Vinschen e1824aea27 Add release msg for 5a3496c
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:53:58 +02:00
Corinna Vinschen 5a3496c3e3 Fix regression in console charset handling
Commit d16a5630 dropped usage of cygheap's locale functions
	in favor of local on-the-fly usage of UTF-8 instead of ASCII.
	This allowed to use the current local rather than a fixed
	system-wide locale set at startup time.  d16a5630 just missed
	to add the ASCII->UTF-8 conversion in the console as well.

	Fixes https://cygwin.com/ml/cygwin/2016-10/msg00000.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:52:14 +02:00
Corinna Vinschen ba2851eeca Bump Cygwin version to 2.6.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-10-19 12:52:14 +02:00
Michael Haubenwallner f763e2dc88 dlopen: on x/lib search x/bin if exe is in x/bin
On 09/02/2016 11:03 AM, Corinna Vinschen wrote:
> On Sep  2 10:46, Michael Haubenwallner wrote:
>> On 09/01/2016 03:32 PM, Corinna Vinschen wrote:
>>> You could just use the global variable program_invocation_name.  If in
>>> doubt, use the Windows path global_progname and convert it to full POSIX
>>> via cygwin_conv_path.
>>
>> Patch updated, using global_progname now.
>
> Looks good and you're right to do it this way since I just noticed
> that program_invocation_name may return a relative pathname.

Yep.

> Btw., in other calls which require the full POSIX path we use
> mount_table->conv_to_posix_path instead of cygwin_conv_path (see
> e. g. fillout_pinfo()).  It's a bit faster.  Maybe something for a
> followup patch.

No problem - attached.
This renders the original patch 4/4 valid again.

> Note for some later improvement:  I really wonder why we don't store
> the absolute POSIX path of the current executable globally yet...

Same here.

Thanks!
/haubi/

>From f7255edd33cb4abe34f27188aab8dccdfa5dd2a0 Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date: Wed, 31 Aug 2016 18:05:11 +0200
Subject: [PATCH 3/4] dlopen: on x/lib search x/bin if exe is in x/bin

citing https://cygwin.com/ml/cygwin-developers/2016-08/msg00020.html
> Consider the file /usr/bin/cygz.dll:
> - dlopen (libz.so)            success
> - dlopen (/usr/bin/libz.so)   success
> - dlopen (/usr/lib/libz.so)   fails

* dlfcn.c (dlopen): For dlopen("x/lib/N"), when the application
executable is in "x/bin/", search for "x/bin/N" before "x/lib/N".
2016-09-08 13:36:32 +02:00
Michael Haubenwallner b37c3ed5e5 dlopen (pathfinder): try each basename per dir
Rather than searching all search dirs per one basename,
search for all basenames within per one search dir.

pathfinder.h (check_path_access): Interchange dir- and basename-loops.
2016-09-08 13:36:31 +02:00
Michael Haubenwallner 97974e3076 dlopen: switch to new pathfinder class
Instead of find_exec, without changing behaviour use new pathfinder
class with new allocator_interface around tmp_pathbuf and new vstrlist
class.
* pathfinder.h (pathfinder): New file.
* vstrlist.h (allocator_interface, allocated_type, vstrlist): New file.
* dlfcn.cc (dlopen): Avoid redundant GetModuleHandleExW with RTLD_NOLOAD
and RTLD_NODELETE.  Switch to new pathfinder class, using
(tmp_pathbuf_allocator): New class.
(get_full_path_of_dll): Drop.
2016-09-08 13:36:29 +02:00
Corinna Vinschen 472e5439e7 Fix passwd getting error 1265 when running on newer Windows
On Windows 8.1 and later, the NetUserChangePassword call apparently
doesn't accept the usual "\\server" string anymore, but requires to
use the "domain" instead, otherwise it emits en error code 1265,
ERROR_DOWNGRADE_DETECTED.  Since this is accepted by pre-8.1 as well,
use the domain indiscriminately when calling NetUserChangePassword
from passwd(1).

While at it, do some minor cleanup in passwd.c.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-31 12:08:34 +02:00
Yaakov Selkowitz abd37f0c79 Add release message for commit 3d3ab82
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2016-08-30 10:53:35 -05:00
Corinna Vinschen e97109184a Drop global __ctype_ptr__ entirely in favor of using locale_t::ctype_ptr
Keep __ctype_ptr__ available on Cygwin only, for backward compatibility
with existing apps referencing it via the ctype macros.

Otherwise initialize __global_locale.ctype_ptr and __C_locale.ctype_ptr
and use them throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-25 14:18:31 +02:00
Corinna Vinschen 988629da1d Fix formatting
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-25 12:06:17 +02:00
Jon Turney eccefd9704 Fix SetThreadName with current gdb
Wrap SetThreadName()'s call to RaiseException() in __try/__except/__endtry,
so that if the attached debugger doesn't know about MS_VC_EXCEPTION (e.g.
current gdb and probably strace as well) and continues exception processing,
we ignore it, rather than dying due an unhandled exception.

Also remove an unnecessary cast in the RaiseException() invocation.

Signed-off-by: Jon Turney <jon.turney@dronecode.org.uk>
2016-08-25 10:06:47 +01:00
Corinna Vinschen 2fd2f308e2 Include winsup.h prior to including other headers
Otherwise _GNU_SOURCE is not set when needed in sys/features.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-24 10:19:53 +02:00
Corinna Vinschen 801fffcb7e Add missing LF in release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 18:57:16 +02:00
Corinna Vinschen 2ea3993619 Export and document strerror_l, strptime_l, wcsftime_l from Cygwin
Bump Cygwin API minor number.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen 0ecb846d2b Implement GNU extension strptime_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen e636fe3d48 Implement GNU extension wcsftime_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Corinna Vinschen 463a8afaa5 Implement missing POSIX-1.2008 function strerror_l
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 17:51:14 +02:00
Jon Turney 9e0f9ec7ae Send thread names to debugger
GDB since commit 24cdb46e [1] can report and use these names.

Add utility function SetThreadName(), which sends a thread name to the
debugger.

Use that:
- to set the default thread name for main thread and newly created pthreads.
- in pthread_setname_np() for user thread names.
- for helper thread names in cygthread::create()
- for helper threads which are created directly with CreateThread.

Note that there can still be anonymous threads, created by system or
injected DLLs.

[1] https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=24cdb46e9f0a694b4fbc11085e094857f08c0419
2016-08-23 15:07:42 +01:00
Jon Turney fdb7df230d Add pthread_getname_np and pthread_setname_np
This patch adds pthread_getname_np and pthread_setname_np.

These were added to glibc in 2.12[1] and are also present in some form on
NetBSD and several UNIXes.

The code is based on NetBSD's implementation with changes to better match
Linux behaviour.

Implementation quirks:

* pthread_setname_np with a NULL pointer segfaults (as linux)

* pthread_setname_np returns ERANGE for names longer than 16 characters (as
linux)

* pthread_getname_np with a NULL pointer returns EFAULT (as linux)

* pthread_getname_np with a buffer length of less than 16 returns ERANGE (as
linux)

* pthread_getname_np truncates the thread name to fit the buffer length.
This guarantees success even when the default thread name is longer than 16
characters, but means there is no way to discover the actual length of the
thread name. (Linux always truncates the thread name to 16 characters)

* Changing program_invocation_short_name changes the default thread name (on
linux, it has no effect on the default thread name)

I'll leave it up to you to decide if any of these matter.

This is implemented via class pthread_attr to make it easier to add
pthread_attr_[gs]etname_np (present in NetBSD and some UNIXes) should it
ever be added to Linux (or we decide we want it anyway).

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=NEWS
2016-08-23 15:07:42 +01:00
Corinna Vinschen 2fb5e3dfb2 Reference __global_locale only via __get_global_locale.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-23 12:38:28 +02:00
David Wohlferd 113abc27a6 Avoid truncating from long double to double in sinhl().
This routine makes a call to fabs instead of fabsl(), causing truncation.

Clang complains (warning: absolute value function 'fabs' given an argument of type 'long double' but has parameter of type 'double' which may cause truncation of value).

Signed-off-by: David Wohlferd <dw@LimeGreenSocks.com>
2016-08-22 14:18:39 +02:00
Ray Donnelly 96fc528397 sqrt: Fix NaN propagation for IEEE Std 754-2008
The R language has some hacks specifically for mingw-w64 that
were caused by our handling of NaNs in sqrt(x). R uses a
special valued NaN to mean 'Not Available' and expects it to
be retained through various calculations. Our sqrt(x) doesn't
do this, instead it normalises such a NaN (retaining sign).

From:

http://wwwf.imperial.ac.uk/~drmii/M3SC_2016/IEEE_2008_4610935.pdf

"6.2.3 NaN propagation

An operation that propagates a NaN operand to its result and
has a single NaN as an input should produce a NaN with the
payload of the input NaN if representable in the destination
format."

There might even be a slight speed-up from this too.

Thanks to Duncan Murdoch for finding the reference.
2016-08-22 14:17:58 +02:00
Corinna Vinschen 0df76cbd63 Document nl_langinfo_l and separate POSIX from GNU extensions in release message
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:24:16 +02:00
Corinna Vinschen 216054fa77 Implement missing POSIX function nl_langinfo_l
Change nl_langinfo to nl_langinfo_l using locale given as argument.
Remove outdated TRANSITION_PERIOD_HACK.  The codeset is stored in
the locale for quite some time now.  For !MB_CAPABLE targets, just
return "US_ASCII" as codeset.

Implement nl_langinfo by calling nl_langinfo_l.  Export nl_langinfo_l
from Cygwin DLL and bump minor API version number.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:22:41 +02:00
Corinna Vinschen 7630e38462 Introduce __current_locale_charset/__locale_charset
The former __locale_charset always fetched the current locale's charset.
We need the per-locale charset, too, in future. Rename __locale_charset
to __current_locale_charset and change __locale_charset to take a
locale_t as parameter.  Accommodate througout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:14:56 +02:00
Corinna Vinschen 06ac671811 Only define __getreent inline function when building newlib or Cygwin
Commit 6f3943b erroneously removed the `#ifdef _COMPILING_NEWLIB'
guarding the __getreent inline function.  This patch ignored the
fact that config.h is included when building applications, and the
code in question requires internal, auto-generated headers to be
available which are not exposed to user-space.

Reinstantiate defined(_COMPILING_NEWLIB) test and alternatively
check for defined (__INSIDE_CYGWIN__), otherwise we'd have to
reinstantiate the __getreent macro in cygtls.h which is really
confusing.

While testing it turned out that a low number of source codes inside
Cygwin won't see the inline __getreent due to a missing __INSIDE_CYGWIN__
definition.  For malloc.cc this was actually deliberate to get different
definitions from including cygmalloc.h.  Change this by defining
__INSIDE_CYGWIN__ in malloc.cc but changing the test in cygmalloc.h
to test for defined(DLMALLOC_VERSION).  This might need a change if we
ever get around to replace dlmalloc with a newer, more threading-aware
malloc implementation.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-20 17:14:55 +02:00
Corinna Vinschen 5e9b414e1c Add release message for commit eb61113
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 17:25:31 +02:00
Corinna Vinschen 3a2f654379 Add release message for commit a871644
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 16:54:56 +02:00
Corinna Vinschen a8716448ce Simplify "Windows-standard-like" permissions
Commit 97d0449 left a bit to be desired.  First, the fact that any
new-style ACL couldn't be "standard ACL" anymore was very much over
the top.  On one hand Admins and SYSTEM ACEs are not supposed to be
masked, but on the other hand we *must* create the CLASS_OBJ
because otherwise we don't have information about masking the
execute perms for both groups.  The ACL would also fail aclcheck.

And while get_posix_access now returns the "is standard acl" flag,
it hasn't been utilized by set_created_file_access.  Rather,
set_created_file_access has simply continued to check for
nentries > MIN_ACL_ENTRIES, which led to all kinds of weird group
and CLASS_OBJ perms.  The new code now always manipulates CLASS_OBJ
perms if a CLASS_OBJ is present, and it always manipulates group perms
if the ACL has been marked as "standard" ACL.

Another problem (not related to commit 97d0449) is the order
get_posix_access adds missing perms.  CLASS_OBJ perms are computed
*before* missing GROUP_OBJ perms have been added.  Thus the CLASS_OBJ
perms could be too tight and led to additional, buggy DENY ACEs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 16:50:15 +02:00
Corinna Vinschen 3e8f833df0 Fix outdated S_JUSTCREATED comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-19 16:27:07 +02:00
Corinna Vinschen 6f3943bca1 Reinstantiate Cygwin function called `__getreent'
This partially reverts commit 10a30e7 as far as the Cygwin version of
the __getreent function is concerned.  Remove _COMPILING_NEWLIB guard
only allowing to use __getreent inline function when building newlib,
since we wan to use it in Cygwin as well.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Stefan Assmann <sassmann@redhat.com>
2016-08-18 15:24:42 +02:00
Corinna Vinschen 3bbc40af2a Revert "Fix __getreent function for Cygwin"
This reverts commit 4de8596.  It worked around a problem which was
actually introduced by patch 10a30e7 a few weeks ago.  Rather than
adding special code to the newlib version of __getreent, the followup
patch reinstantiates the original, Cygwin-only implementation of
__getreent.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Stefan Assmann <sassmann@redhat.com>
2016-08-18 15:24:18 +02:00
Corinna Vinschen eb61113daf Workaround AzureAD shortcomings
No real domain, no DC, no infos via NetUserGetInfo... nothing.  Just nothing.

Use fixed uid 0x1000 (4096) for AzureAD user and gid 0x1001 (4097) for
AzureAD group.  Note that this group is part of the user token, but it's
not the primary group.  The primary group SID is, unfortunately, the
user's SID.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-18 10:27:28 +02:00
Corinna Vinschen 4de8596b8e Fix __getreent function for Cygwin
So far the lib function __getreent always returned _impure_ptr.  On Cygwin
this is only correct after _impure_ptr got initialized.  The inline
function in include/cygwin/config.h always returns the right _reent ptr,
though.

After introducing per-thread locales, the __getreent function is called
prior to initialization of _impure_ptr (from dll_crt0_0) to access the
locale pointer, which leads to a crash.

Fix the __getreent lib function for Cygwin to return the correct _reent
pointer all the time.  Rename inline function to __inline_getreent
and introduce a macro __getreent calling the inline function.  Change
the lib function __getreent to call __inline_getreent on Cygwin.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-18 10:27:14 +02:00
Corinna Vinschen 8443fcd625 Add release message for commit c02ac89
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-08-17 11:17:26 +02:00