Commit Graph

8020 Commits

Author SHA1 Message Date
Corinna Vinschen f881942d77 Cygwin: net: Improve standars conformance comments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 16:57:24 +01:00
Corinna Vinschen 2327f01726 Cygwin: fhandler_socket: Add :: to potentially colliding WinSock calls
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 16:41:42 +01:00
Corinna Vinschen 4e04751fc7 Cygwin: socketpair: Move socketpair creation inside fhandler_socket class
Add fhandler_socket::socketpair method

Deliberately disable AF_INET socketpairs for now

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 16:36:19 +01:00
Corinna Vinschen cff85eaddc Cygwin: sockets: move common settings into set_socket_handle()
Move setting address family, socket type and descriptor flags
into fhandler_socket::set_socket_handle method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 16:23:32 +01:00
Corinna Vinschen 913c6ca2c1 Cygwin: socket: move socket creation inside fhandler_socket class
Add fhandler_socket::socket method
Add fhandler_socket::set_socket_handle method, basically duplicating
what fdsock is doing.  This is the first step in getting rid of fdsock.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-14 22:21:58 +01:00
Corinna Vinschen 7ae73be141 Cygwin: improve O_TMPFILE handling
Windows does not remove FILE_ATTRIBUTE_TEMPORARY by itself after a
file has been closed.  It's just some attribute which can be set or
removed at will, despite its purpose.

Apparently there are tools out there which use FILE_ATTRIBUTE_TEMPORARY
accidentally or wrongly, even Microsoft's own tools are affected.  In
the end, the filesystem is potentially full of files with this attribute
set.

Implement O_TMPFILE files with FILE_ATTRIBUTE_TEMPORARY and
FILE_ATTRIBUTE_HIDDEN set.  This combination is pretty unlikely.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-14 12:55:24 +01:00
Corinna Vinschen 1188d308bf Cygwin: fix file-related functions on unix sockets
* Fix an incorrect condition to recognize AF_LOCAL sockets in
  file-related functions (fchmod, fchown, fstat, fsttavfs, facl, link).

* Return successfully when called on unnamed or abstract AF_LOCAL sockets,
  except link, just as on Linux.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-14 10:54:08 +01:00
Corinna Vinschen 09d32b7480 Cygwin: improve a comment in fhandler_socket::getsockname
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-14 10:38:41 +01:00
Corinna Vinschen e113d12684 Cygwin: /proc/<pid>/stat: Fix time handling
* Use 64 bit timestamps
* Use System boot and process start time to compute starttime value per
  Linux proc.5 description.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-12 22:22:06 +01:00
Corinna Vinschen 01c643e49f Cygwin: Drop HZ usage in favor of MSPERSEC and CLOCKS_PER_SEC
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-12 22:08:42 +01:00
Corinna Vinschen 58f72783ee Cygwin: Define MSPERSEC and fix USPERSEC comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-12 21:21:58 +01:00
Corinna Vinschen 283e0137c7 Cygwin: Fix x86 compiler warning
The previous patch introduced a compiler warning on x86.

Given time_t is only 4 bytes on x86 we get a long vs. unsigned long
comparison in timeval_to_ms.  Fix it by careful casting.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-07 17:35:23 +01:00
Corinna Vinschen c51a0b74dc Cygwin: sockets: Handle SO_RCVTIMEO and SO_SNDTIMEO
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-07 16:18:07 +01:00
Corinna Vinschen 51af517cab Cygwin: setsockopt/getsockopt: Add missing optlen checks
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-07 15:37:48 +01:00
Corinna Vinschen 2af67d21b2 Cygwin: Cleanup time handling
* Redefine NSPERSEC to NS100PERSEC
* Define NSPERSEC as nanosecs per second
* Define USPERSEC as microsecs per second
* Use above constants throughout where appropriate
* Rename to_us to timespec_to_us and inline
* Rename it_bad to timespec_bad and inline

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-07 13:07:44 +01:00
Corinna Vinschen f8ce691223 Cygwin: setsockopt/getsockopt: Clean up code
Rearrange setsockopt/getsockopt into per level/per optname
preprocessing switch, actual call,  per level/per optname
postprocessing switch for better readability as well as
extensibility.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-06 18:42:00 +01:00
Corinna Vinschen b08e6690a6 Cygwin: bindresvport: Guard prototypes with __MISC_VISIBLE
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-05 21:06:29 +01:00
Corinna Vinschen e9ff2d6978 Cygwin: bindresvport: Try hard to find unused port
Workaround the problem that bind doesn't fail with EADDRINUSE
if a socket with the same local address is still in TIME_WAIT.

Use IP Helper functions to check if such a socket exist and don't
even try this port, if so.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-05 21:05:09 +01:00
Corinna Vinschen 2f61f65601 Cygwin: bindresvport: check correctness of address family
Assuming the address parameter is non-NULL, the test in
cygwin_bindresvport_sa only tests if the address family is
supported at all, which is insufficient.

Check if the incoming address family matches the socket
address family and for being AF_INET in cygwin_bindresvport
since the latter doesn't support any other family.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-05 21:00:15 +01:00
Corinna Vinschen 34f031982f Cygwin: bindresvport_sa: Ignore incoming port number
Ignore port number just like glibc, otherwise suffer EADDRINUSE
in subsequent connect calls.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-05 19:32:13 +01:00
Corinna Vinschen 9dc34cea28 Cygwin: Use SO_EXCLUSIVEADDRUSE
We're still using ~SO_REUSEADDR because SO_EXCLUSIVEADDRUSE wasn't
defined in Mingw.  But it is in Mingw-w64, so fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-05 19:22:47 +01:00
Corinna Vinschen 623d3fdf6b Cygwin: bump version to 2.10.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-02 15:32:28 +01:00
Mark Geisert 29af5b27cf Define internal function mythreadname() -- revised
This new function returns the name of the calling thread; works for both
 cygthreads and pthreads.  All calls to cygthread::name(/*void*/) replaced
 by calls to mythreadname(/*void*/).
2018-01-24 10:57:12 +01:00
Corinna Vinschen c17b0f0082 cygwin: 2.10.0 release text: fix formatting
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-01-22 15:32:29 +01:00
Yaakov Selkowitz 8810f929fc cygwin: Declare pthread_rwlock_timedrdlock, pthread_rwlock_timedwrlock
These were added in commit 8128f5482f but
without their public declarations.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-22 15:04:11 +01:00
Yaakov Selkowitz 00bf01789e cygwin: update docs for 2.10.0
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-19 13:19:22 -06:00
Yaakov Selkowitz cadc12f695 cygwin: add catopen, catgets, catclose
The implementation is taken from FreeBSD with #ifdef __CYGWIN__ modifications.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-19 13:19:21 -06:00
Yaakov Selkowitz 061710370c cygwin: make <sys/socket.h> completely visible from <netinet/in.h>
While POSIX mandates that certain socket types shall be defined by the
inclusing of <netinet/in.h>, it also says that this header may also make
visible all <sys/socket.h> symbols.  Glibc does this, and without out it,
some packages end up requiring an additional #include <sys/socket.h>.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-19 12:08:27 -06:00
Yaakov Selkowitz fa47495755 cygwin: remove inclusion of <sys/time.h> from <sys/socket.h>
POSIX does not mention the inclusion of <sys/time.h> in <sys/socket.h>
or <netinet/in.h>, nor is there anything in the latter two that would
require the former.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-19 12:08:26 -06:00
Yaakov Selkowitz 70ee6b17df ansification: remove _EXFUN, _EXFUN_NOTHROW
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:29 -06:00
Yaakov Selkowitz e6321aa6a6 ansification: remove _PTR
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:16 -06:00
Yaakov Selkowitz eea249da3b ansification: remove _PARAMS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:13 -06:00
Yaakov Selkowitz 0bda30e1ff ansification: remove _CONST
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:08 -06:00
Yaakov Selkowitz 1e39db3062 cygwin: add asm/bitsperlong.h, dummy asm/posix_types.h headers
These changes are necessary for cross-compiling the Linux kernel.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 03:09:35 -06:00
Yaakov Selkowitz 2cb24159fb cygwin: add LFS_CFLAGS etc. to confstr/getconf
These are used, for instance, when cross-compiling the Linux kernel.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-16 12:12:45 -06:00
Corinna Vinschen eb4bfe4621 cygwin: block devices: fix file offset after short writes
When reading/writing block devices, Cygwin emulates Linux, providing
a byte-exact file position, albeit the underlying device drivers don't.

Unfortunately this only worked correctly for reading.  The raw_write
method failed to revalidate the buffer after the read-modify-write
cycle in case len is not a multiple of the sector length.  This in
turn resulted in lseek reporting a wrong file pointer.

Also, fix a condition for invalidating the buffer after writing from
a remaining read buffer.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-19 18:58:06 +01:00
Corinna Vinschen d5abcdd5a7 Cygwin: document sigtimedwait and ftell{o} patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-18 20:21:15 +01:00
Corinna Vinschen 7af691a784 Cygwin: rearrange sigwait functions, convert sigwait_common to inline
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-18 19:46:35 +01:00
Mark Geisert 24ff42d79a Cygwin: Implement sigtimedwait
Abstract out common code from sigwait/sigwaitinfo/sigtimedwait to
implement the latter.
2017-12-18 19:46:18 +01:00
Corinna Vinschen 32988bd409 cygwin: add mmap fork fix to 2.10.0 release test
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-10 14:32:34 +01:00
Corinna Vinschen 0c201166f5 cygwin: mmap: fix comment and formatting, drop unused code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-10 14:14:28 +01:00
Corinna Vinschen 67a657cb1d cygwin: mmap: fix a fork failure with private, anonymous mappings
Rounddown incoming addr on a page boundary. Without this, we may end
up with a fork error for private, anonymous maps.  The reason is, we
use VirtualAlloc in this case which will potentially overcommit if
addr is not on a page boundary.  This isn't taken into account in
bookkeeping, but fixup_mmaps_after_fork will eventually stumble over
this when trying to reproduce the copy-on-write pages: VirtualQuery
returns a region reaching beyond the supposedly allocated address
range and from there it goes downhill.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-10 14:14:24 +01:00
Corinna Vinschen 08d77e5154 cygwin: document %l[ and bump API minor
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-12-01 18:21:59 +01:00
Corinna Vinschen 10b57ba8d0 cygwin: Document latest changes, bump API minor
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 21:57:16 +01:00
Corinna Vinschen 27c1a7972c cygwin: [w]mempcpy: fix global symbol
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 21:34:29 +01:00
Corinna Vinschen aea710b5fb cygwin: x86_64: implement mempcpy/wmempcpy in assembler
* change memcpy to internal _memcpy not setting the return value in %rax
* implement all memcpy-like functions as caller to _memcpy, setting %rax
  to correct return value beforehand.  This is possible because _memcpy
  does not use %rax at all

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-30 21:15:28 +01:00
Yaakov Selkowitz f636eae26f cygwin: export wmempcpy
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-30 04:06:51 -06:00
Yaakov Selkowitz da4839ec18 cygwin: add Object Size Checking to sys/socket.h
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-30 04:06:48 -06:00
Yaakov Selkowitz b3281de25f cygwin: add Object Size Checking to sys/poll.h
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-30 04:06:47 -06:00
Yaakov Selkowitz 552a20ab4e cygwin: create libssp compatibility import library
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29 11:25:49 -06:00