Commit Graph

8306 Commits

Author SHA1 Message Date
Mark Geisert b1952c03a8 Fix return value on aio_read/write success
Internally track resultant byte counts as ssize_t, but return 0 as int
for success indication, per POSIX.
2018-08-07 09:49:18 +02:00
Corinna Vinschen f16b198c3b Cygwin: Document fegetenv patch
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-08-03 09:35:31 +02:00
J.H. van de Water d79069d2ff Cygwin: fegetenv() should not disable exceptions
fnstenv MUST be followed by fldenv in fegetenv(), as the former disables all
exceptions in the x87 FPU, which is not appropriate here (fegetenv() ).
fldenv after fnstenv should reload the x87 FPU w/ the configuration that was
saved by fnstenv, i.e. a configuration that might have exceptions enabled.

Note: x86_64 uses SSE for floating-point, not the x87 FPU. However, because
feraiseexcept() attempts to provoke an exception using the x87 FPU, the bug
in fegetenv() will make this attempt futile here (x86_64).

Note: WoW uses the x87 FPU for floating-point, not SSE. Here anything that
would normally result in triggering an exception, not only feraiseexcept(),
will not be able to, as result of the bug in fegetenv().
2018-08-03 09:33:49 +02:00
Yaakov Selkowitz 7e09931ad9 Cygwin: fpathconf: update _PC_ASYNC_IO return value
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-07-25 15:00:43 -05:00
Yaakov Selkowitz f6417be2aa Cygwin: define _POSIX_ASYNCHRONOUS_IO
This feature is now available as of the recent AIO commits.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-07-25 10:48:55 -05:00
Mark Geisert 7f32efbf73 POSIX Asynchronous I/O support: other files
Updates to misc files to integrate AIO into the Cygwin source tree.
Much of it has to be done when adding any new syscalls.  There are
some updates to limits.h for AIO-specific limits.  And some doc mods.
2018-07-25 09:36:24 +02:00
Mark Geisert 87253cbe38 POSIX Asynchronous I/O support: fhandler files
This code is where the AIO implementation is wired into existing Cygwin
mechanisms for file and device I/O: the fhandler* functions.  It makes
use of an existing internal routine prw_open to supply a "shadow fd"
that permits asynchronous operations on a file the user app accesses
via its own fd.  This allows AIO to read or write at arbitrary locations
within a file without disturbing the app's file pointer.  (This was
already the case with normal pread|pwrite; we're just adding "async"
to the mix.)
2018-07-25 09:36:24 +02:00
Mark Geisert a9ffa71a15 POSIX Asynchronous I/O support: aio files
This is the core of the AIO implementation: aio.cc and aio.h.  The
latter is used within the Cygwin DLL by aio.cc and the fhandler* modules,
as well as by user programs wanting the AIO functionality.
2018-07-25 09:36:22 +02:00
Corinna Vinschen e9f223877f Cygwin: move FP environment exports to common.din
We only have the symbols defined for i686 by accident since 2013...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-07-20 13:55:26 +02:00
Mark Geisert 3e51cc478d fix duration handling in sigtimedwait 2018-07-19 13:18:49 +02:00
Corinna Vinschen 5ed8f2354f Cygwin: Treat PROCESSOR_ARCHITECTURE_INTEL as running under WOW64 on ARM64
Bug in current ARM64 WOW64: GetNativeSystemInfo returns
PROCESSOR_ARCHITECTURE_INTEL rather than PROCESSOR_ARCHITECTURE_ARM64.
Provide for this.

Make code better readable.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-07-12 15:28:13 +02:00
Corinna Vinschen a4f1f59bc7 Cygwin: Don't print FAST_CWD warning in WOW64 on ARM64 systems
No way to test this, yet.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-07-10 14:45:52 +02:00
Corinna Vinschen 698d93c4b4 Cygwin: fix a race in the FAST_CWD fallback code
Guard the entire operation with the FastPebLock critical section
used by RtlSetCurrentDirectory_U as well, thus eliminating the
race between concurrent chdir/fchdir/SetCurrentDirectory calls.

Streamline comment explaining the fallback method.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-07-10 14:13:15 +02:00
Takashi Yano 8e782bbd94 Fix a problem that connection to syslogd fails.
* fhandler_socket_local.cc (get_inet_addr_local): Change type from
  'static int' to 'int' to be callable from syslog.cc.
* syslog.cc (connect_syslogd): Use get_inet_addr_local() instead of
  getsockname() to retrieve name information of the syslogd socket.
2018-07-06 10:41:21 +02:00
Takashi Yano 0ce27ecd08 Cygwin: Include local ntsecapi.h
Our local ntsecapi.h wrapper corrects a bug in the definition of
SystemFunction036 which otherwise leads to crashes on 32 bit when
using RtlGenRandom.  The fhandler_socket_local.cc file accidentally
included the incorrect w32api version of that file, rather than the
local wrapper.  Fix it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-07-04 14:17:28 +02:00
Takashi Yano 1c1cec9cdf Fix a bug of psiginfo() that changes the orientation of stderr.
* strsig.cc (psiginfo): Fix the problem that psiginfo() changes
  the orientation of stderr to byte-oriented mode if stderr is
  not oriented yet.
2018-07-03 15:38:47 +02:00
Corinna Vinschen 995d2a824a Cygwin: tape: Handle non-standard "no medium" error code
Certain tape drives (known example: QUANTUM_ULTRIUM-HH6) return
the non-standard ERROR_NOT_READY rather than ERROR_NO_MEDIA_IN_DRIVE
if no media is present.  ERROR_NOT_READY is not documented as valid
return code from GetTapeStatus.  Without handling this error code
Cygwin's tape code can't report an offline state to user space.

Fix this by converting ERROR_NOT_READY to ERROR_NO_MEDIA_IN_DRIVE
where appropriate.

Add a debug_printf to mtinfo_drive::get_status to allow requesting
user info without having to rebuild the DLL.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-29 15:31:15 +02:00
Corinna Vinschen 4b97244d12 Cygwin: define pthread_tryjoin_np/pthread_timedjoin_np _GNU_VISIBLE
These functions are GNU extensions.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-27 18:20:47 +02:00
Corinna Vinschen cb3ddf9e2a Cygwin: pthread_timedjoin_np: return ETIMEDOUT, not EBUSY
pthread_timedjoin_np returns ETIMEDOUT if a thread is still running,
not EBUSY as pthread_tryjoin_np.

Also, clean up initializing timeout in pthread_tryjoin_np.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-27 18:19:18 +02:00
Corinna Vinschen 732e0b395d Cygwin: Implement pthread_tryjoin_np and pthread_timedjoin_np
- Move pthread_join to thread.cc to have all `join' calls in
  the same file (pthread_timedjoin_np needs pthread_convert_abstime
  which is static inline in thread.cc)
- Bump API version

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-27 17:56:59 +02:00
Corinna Vinschen 6c55be9dbb Cygwin: Allow to build without experimental AF_UNIX code by default
Introduce __WITH_AF_UNIX preprocessor flag to enable the new code

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-26 16:31:17 +02:00
Corinna Vinschen 17918cc6a6 Cygwin: add Unicode patch to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-26 10:21:18 +02:00
Corinna Vinschen dbe905c140 Cygwin: exceptions: fix FPE exception flags
The FPE flags for divisions by zero were not implemented

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-26 10:12:19 +02:00
Corinna Vinschen 3dc89bbafe Cygwin: signal.h: improve exception flags definition
- add numbers for readability
- add a preprocessor macro for each flag

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-06-26 10:12:10 +02:00
Takashi Yano 9c84bfd479 Fix the handling of out-of-band (OOB) data in a socket.
* fhandler.h (class fhandler_socket_inet): Add variable bool oobinline.
* fhandler_socket_inet.cc (fhandler_socket_inet::fhandler_socket_inet):
  Initialize variable oobinline.
(fhandler_socket_inet::recv_internal): Make the handling of OOB data
  as consistent with POSIX as possible. Add simulation of inline mode
  for OOB data as a workaround for broken winsock behavior.
(fhandler_socket_inet::setsockopt): Ditto.
(fhandler_socket_inet::getsockopt): Ditto.
(fhandler_socket_wsock::ioctl): Fix return value of SIOCATMARK command.
  The return value of SIOCATMARK of winsock is almost opposite to
  expectation.
* fhandler_socket_local.cc (fhandler_socket_local::recv_internal):
  Remove the handling of OOB data from AF_LOCAL domain socket. Operation
  related to OOB data will result in an error like Linux does.
(fhandler_socket_local::sendto): Ditto.
(fhandler_socket_local::sendmsg): Ditto.

This fixes the issue reported in following post.
https://cygwin.com/ml/cygwin/2018-06/msg00143.html
2018-06-22 10:20:08 +02:00
Ken Brown ebc9171ede Bump Cygwin DLL version to 2.11.0 2018-06-07 09:42:36 +02:00
Ken Brown 2ea436b433 Cygwin: Document clearenv and bump API minor
Also add earlier "What changed" items to new-features.xml.
2018-06-07 09:42:36 +02:00
Ken Brown 3a049236db Cygwin: Remove workaround in environ.cc
Commit ebd645e on 2001-10-03 made environ.cc:_addenv() add unneeded
space at the end of the environment block to "work around problems
with some buggy applications."  This clutters the code and is
presumably no longer needed.
2018-06-07 09:42:36 +02:00
Ken Brown defaa2ca31 Cygwin: Implement the GNU extension clearenv 2018-06-07 09:42:36 +02:00
Ken Brown 9234545e3d Cygwin: Allow the environment pointer to be NULL
Following glibc, interpret this as meaning the environment is empty.
2018-06-07 09:42:36 +02:00
Ken Brown 1ecbb8d7b7 Cygwin: Clarify some code in environ.cc 2018-06-07 09:42:36 +02:00
Ken Brown a7c23d109f Cygwin: Add pthread_rwlock_* fix to release notes 2018-06-01 21:59:42 +02:00
Ken Brown 59847b5d73 Declare the pthread_rwlock_* functions if __cplusplus >= 201402L
Some of these functions are used in the <shared_mutex> C++ header.
2018-06-01 12:09:12 +02:00
Corinna Vinschen 8ac6b15487 Cygwin: Add stack alignment crash after fork fix to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-05-29 18:43:20 +02:00
Sergejs Lukanihins 06797545b3 Cygwin: Fixing the math behind rounding down ch.stacklimit to page size. 2018-05-29 18:37:33 +02:00
Corinna Vinschen efade43bd5 Cygwin: Add buffer underrun fix to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-05-29 18:31:07 +02:00
Corinna Vinschen 35998fc2fa Cygwin: normalize_win32_path: Avoid buffer underruns
Thanks to Ken Harris <Ken.Harris@mathworks.com> for the diagnosis.

When backing up tail to handle a "..", the code only checked that
it didn't underrun the destination buffer while removing path
components.  It did *not* take into account that the first backslash
in the path had to be kept intact.  Example path to trigger the
problem: "C:\A..\..\..\B'

Fix this by moving the dst pointer to the first backslash so subsequent
tests cannot underrun this position.  Also make sure that we always
*have* a backslash.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-05-29 18:23:14 +02:00
Corinna Vinschen 7d00a5e320 Cygwin: TEST only: Add a buffer underrun assertion to symlink_info::check
Thanks to Ken Harris <Ken.Harris@mathworks.com> for the diagnosis
which led to a buffer underrun in this loop.

Revert before release.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-05-29 18:23:14 +02:00
Yaakov Selkowitz 67609efeb0 Cygwin: fix build with GCC 7
GCC 7 is able to see straight through this trick, so use a more formal
method to avoid the warning.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-04-16 22:46:11 -05:00
Corinna Vinschen e206c39bb6 Cygwin: fix guard checking for current user's AuthZ context
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-04-12 09:43:12 +02:00
Corinna Vinschen 5d99256613 Cygwin: add cuinof changes to release text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-04-11 12:46:18 +02:00
Corinna Vinschen cef1070bcb Cygwin: cpuinfo: Use active CPU count per group
There are systems with a MaximumProcessorCount not
reflecting the actually available CPUs.  The ActiveProcessorCount
is correct though.  So we use ActiveProcessorCount rather than
MaximumProcessorCount per group to set group affinity correctly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-04-11 12:45:57 +02:00
Corinna Vinschen 92f4e0500b Cygwin: wincap: expose more SYSTEM_INFO members and use as appropriate
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-04-11 11:59:35 +02:00
Corinna Vinschen 402d68af1a Cygwin: cpuinfo: report L3 cache on Intel CPUs
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-04-11 10:06:25 +02:00
Corinna Vinschen 8a91646183 Cygwin: add strtod fix to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-04-09 11:48:33 +02:00
Corinna Vinschen ee49870a7d Cygwin: AF_LOCAL: fix identifing abstract sockets in FS-related functions
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-26 18:11:23 +02:00
Corinna Vinschen cfe5d362fe Cygwin: fix typo in accept on inet and local sockets
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-26 17:21:30 +02:00
Corinna Vinschen 23b5ecdaf3 Cygwin: delete /dev/kmsg and thus fhandler_mailslot without substitution
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-25 12:38:14 +02:00
Corinna Vinschen 4fe086c84f Cygwin: AF_UNIX: Redesign various aspects
* Change set_socket_type/get_socket_type to virtual methods
* Move various variables into af_unix_shmem_t
* Change sun_name_t to match new usage pattern
* Move shut_state definition and add a name for the 0 value
* Allow marking packet as administrative packet.  This allows
  filtering out info packets exchange between peers and tweak
  data accordingly.
* Rename send_my_name to send_sock_info and send credentials
  if not called from bind (so the socket was already connected)
* Handle SO_PASSCRED in setsockopt/getsockopt
* Add input size checking to setsockopt/getsockopt
* Use NT functions where appropriate

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-18 20:46:43 +01:00
Corinna Vinschen a366a8fc42 Cygwin: ntdll.h: Define FSCTL_PIPE_PEEK and NtWaitForSingleObject
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-18 20:07:35 +01:00
Corinna Vinschen 848d5b70db Cygwin: AF_UNIX: Add state_lock to guard manipulating shared state info
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-18 20:06:43 +01:00
Corinna Vinschen 60ca1c1359 Cygwin: AF_UNIX: Use spinlock rather than SRWLOCKs
We need to share socket info between threads *and* processes.
SRWLOCKs are single-process only, unfortunately.  Provide a
sharable low-profile spinlock instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-18 18:46:15 +01:00
Corinna Vinschen 1f41bc16f1 Cygwin: tags: drop _EXFUN regex
_EXFUN has been removed a while back

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-17 16:55:22 +01:00
Corinna Vinschen edcf783dc2 Revert "ctype: align size of category bit fields to small targets needs"
This reverts commit e98d3eb3eb.

It has accidentally included some work in progress.
2018-03-14 11:36:06 +01:00
Corinna Vinschen e98d3eb3eb ctype: align size of category bit fields to small targets needs
E.g. arm ABI requires -fshort-enums for bare-metal toolchains.
Given there are only 29 category enums, the compiler chooses an
8 bit enum type, so a size of 11 bits for the bitfield leads to
a compile time error:

  error: width of 'cat' exceeds its type
    enum category cat: 11;
                  ^~~

Fix this by aligning the size of the category members to byte
borders.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-14 10:36:38 +01:00
Corinna Vinschen 4d1a356f7b Cygwin: mark muto object as NO_COPY
muto in smallprint.cc is missing a NO_COPY.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-12 22:13:20 +01:00
Corinna Vinschen 725176612d Cygwin: AF_UNIX: store per-socket info in shared memory
Per-socket info in fhandler isn't correctly shared between multiple
instances of th same descriptor.  Implement a basic shared info which
is shared between all instances of a socket.

This also requires to move the fhandler_socket status bits into
fhandler_socket_wsock since the data is moved to the shared region
for AF_UNIX sockets.

Also, drop backing file requirement for socketpair server socket.
This will be handled differently in recvmsg/sendmsg.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-12 15:26:12 +01:00
Corinna Vinschen 99796906ab Cygwin: AF_UNIX: fix up thread parameter block allocation
* don't abort on failing allocation, just return with error
* make sure the allocation is restricted to a single process

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-11 14:56:02 +01:00
Corinna Vinschen de29476ed5 Cygwin: AF_UNIX: use get_unique_id to create pipe name
It's the same as get_plain_ino in this case, but it's cleaner
and easier to understand.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-11 14:54:20 +01:00
Corinna Vinschen 4f1ee1a3e7 Cygwin: AF_UNIX: fix dup
Reorder so fhandler_socket::dup is called first.  Add missing
duplication of backing_file_handle.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-10 21:12:27 +01:00
Corinna Vinschen 7b1028974b Cygwin: AF_UNIX: Add fixup_after_exec method
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-10 21:09:28 +01:00
Corinna Vinschen 1bb3d65182 Cygwin: AF_UNIX: fix creating abstract socket symlink name
Add missing NUL termination when creating symlink representing
abstract socket.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-10 21:07:46 +01:00
Corinna Vinschen 8b6804b8a8 Cygwin: don't skip O_TMPFILE files in readdir
Bad idea.  A file hidden from directory listings is not seen by
rm either, so it never calls unlink for the file and a recursive
removal of the parent directory fails with "directory not empty".

Fix comments accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-09 21:13:28 +01:00
Corinna Vinschen b194d65615 Cygwin: AF_UNIX: Implemant socketpair
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-09 14:19:36 +01:00
Corinna Vinschen f4a1a186f9 Cygwin: fix socketpair prototype
Last parameter is a vector of 2 ints, not a pointer to int

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-09 14:17:39 +01:00
Corinna Vinschen 7d525c171f Cygwin: AF_UNIX: implement getsockopt SO_RCVBUF/SO_SNDBUF
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:56:42 +01:00
Corinna Vinschen 483cbf8954 Cygwin: AF_UNIX: define AF_UNIX_CONNECT_TIMEOUT
Use macro AF_UNIX_CONNECT_TIMEOUT instead of numerical constant
for connect timeout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:55:34 +01:00
Corinna Vinschen 2f48ddb1ca Cygwin: Define FSCTL_PIPE_FLUSH
This fsctl might come in handy at one point...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:54:46 +01:00
Corinna Vinschen 5bb4cc1e6c Cygwin: AF_UNIX: Implement read, readv, recvfrom, write, writev, sendto
All of these functions just call recvfrom/sendmsg which are still TODO

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:53:56 +01:00
Corinna Vinschen d7f7d292d8 Cygwin: reorder read/write calls in fhandler_socket_unix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 21:52:29 +01:00
Corinna Vinschen 855e5d7e14 Cygwin: AF_UNIX: fix accept behaviour
* Use correct cygwait/WFSO invocation to not die on cancel and signals
  uncontrolled.
* Manage io handles under io_lock.
* Copy peer address to user space under SEH to avoid a resource leak.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:23:44 +01:00
Corinna Vinschen cde2648c22 Cygwin: AF_UNIX: make sure connect wait thread is cleanly interruptible
Using TerminateThread potentially leaks resources.  In our case,
the connect wait thread may be forcefully terminated after
having successfully opened a client side pipe handle.  If this
occurs, we have a stale pipe server instance, so the pipe will
never be closed as long as the process lives.

Avoid this by changing the npfs handle to non-blocking, so we can
wait on a termination event object from inside the thread itself
and cleanly exit from the thread instead of terminating.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:19:43 +01:00
Corinna Vinschen 27a63d4ef2 Cygwin: AF_UNIX: some pipe errors may have multiple status codes
Depending on the exact circumstances, some erros are indicated
by different status codes.  Add helper macros to handle them
together.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:12:55 +01:00
Corinna Vinschen 4de52a0fe1 Cygwin: AF_UNIX: fix SEGV when sending an empty socket name from connect
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:08:15 +01:00
Corinna Vinschen 2f2a75b7bb Cygwin: AF_UNIX: fix creation of npfs handle
The handle to the device is never needed.  As the name impies,
FSCTL_PIPE_WAIT works on the file system, not on the device level.

Drop opening the device and make sure to open only one handle to NPFS.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:06:57 +01:00
Corinna Vinschen d69bcdd671 Cygwin: AF_UNIX: Add create_event helper and use throughout
Minimize overhead in creating a nameless event object.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 16:04:26 +01:00
Corinna Vinschen e94fa4ebf3 Cygwin: AF_UNIX: fix comments and move a macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-07 15:43:26 +01:00
Corinna Vinschen 4cd57934be Cygwin: AF_UNIX: Implement listen, accept4, connect, and others
* Implement helper functions
* Improve bind
* Implement setting blocking, ioctl(FIONBIO), fcntl(F_SETFL)
* Implement close_on_exec and fixup_after_fork
* Allow overriding sun_path and peer_sun_path
* Improve comments

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 19:10:54 +01:00
Corinna Vinschen e2909e2805 Cygwin: AF_UNIX: fix a couple of thinkos and typos
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:42:12 +01:00
Corinna Vinschen cabfef78e9 Cygwin: AF_UNIX: create/open pipes relativ to NPFS rootdir handle
Only store and manipulate pipe basename.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:37:09 +01:00
Corinna Vinschen c502700231 Cygwin: AF_UNIX: initialize rmem/wmem to 256K and use in pipe creation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:28:15 +01:00
Corinna Vinschen c0df506b83 Cygwin: ntdll.h: Add some missing pipe-related definitions
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:24:13 +01:00
Corinna Vinschen f6ce72e623 Cygwin: sys/socket.h: define MSG_CMSG_CLOEXEC
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:23:48 +01:00
Corinna Vinschen 6d2f1d79a8 Cygwin: export hires counter ntod
Needed it new AF_UNIX socket code

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-06 18:23:23 +01:00
Corinna Vinschen ae67198d55 Cygwin: move sun_name_t constructors into fhandler_socket_unix.cc
They are only used there anyway and it allows to use the AF_UNIX
macro without tweaking header files.  While at it, improve
both constructors.  The default constructor now creates the name
of an unnamed socket, the constructor taking parameters carefully
checks its input.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 18:08:47 +01:00
Corinna Vinschen a2c02d78be Cygwin: sockets: add bind state, and split out connect state to allow atomic operation
The connect state was stored in a bitfield which is not safe
to do atomic operations on.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 17:59:04 +01:00
Corinna Vinschen fe8e2c9b1f Cygwin: drop debug_printf statement from start_transaction
start_transaction is now defined in ntdll.h and we can't rely
on debug_printf being available

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 17:50:52 +01:00
Corinna Vinschen 011fc3b508 Cygwin: cygwait.cc: fix formatting of debug statement
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-05 17:49:50 +01:00
Corinna Vinschen df14d97fff Cygwin: AF_UNIX: drop try/except block in bind method
The caller already does it anyway.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 23:40:36 +01:00
Corinna Vinschen be6da79713 Cygwin: AF_UNIX: create pipes with file attribute R/W access
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 23:39:15 +01:00
Corinna Vinschen 00e8707830 Cygwin: accept4: Fix resource leak
The new implementation neglected to release the file descriptor
in case of error.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 23:33:05 +01:00
Corinna Vinschen 984c8beeff Cygwin: remove outdated comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:22:45 +01:00
Corinna Vinschen 97b7aaaeb7 Cygwin: fhandler_socket_unix: implement socket, bind, and close
...plus lots of helper functions.  Add comment to explain how everything
works.  This comment will be improved while implementing the yet missing
parts.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:17 +01:00
Corinna Vinschen 7d260cfac4 Cygwin: add transform_chars_af_unix helper
This function is going to be used for transposing sun_path of
abstract sockets.  This also adds a transposition of the NUL
character to tfx_chars since NUL-bytes in abstract socket names
are perfectly valid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:17 +01:00
Corinna Vinschen 488221cf5c Cygwin: small_s[w]printf: add '_' modifier to print lower case hex digits
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:17 +01:00
Corinna Vinschen 1949db7829 Cygwin: drop CYGWIN_SOCKET_UUID, define CYGWIN_SOCKET_GUID as GUID pointer
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:17:13 +01:00
Corinna Vinschen d87ef0dac9 Cygwin: ntdll.h: add definitions required for pipe-based AF_UNIX
Also remove redundant declaration of RtlInitEmptyUnicodeString

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-02 18:08:05 +01:00
Corinna Vinschen dc3928fc75 Cygwin: convert sun_name_t into class
Add constructors and new/delete operators to make sure sun_name_t
objects are allocated on the cygheap.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 18:14:23 +01:00
Corinna Vinschen aa467e6e33 Cygwin: add AF_UNIX reparse points to path handling
* check_reparse_point_target returns a path flag mask, rather than
  just 1.  Return PATH_SYMLINK | PATH_REP for symlinks and directory
  mount points, PATH_SOCKET | PATH_REP for AF_UNIX sockets.

* Define Cygwin AF_UNIX socket reparse tag and GUID in ntdll.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:54:57 +01:00
Corinna Vinschen 65267a9a34 Cygwin: move transaction helpers into ntdll.h
We'll need them elsewhere in future.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de
2018-03-01 16:51:12 +01:00
Corinna Vinschen 3e16fd6986 Cygwin: ntdll.h: drop macros available in mingw-w64 headers
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:50:41 +01:00
Corinna Vinschen 28cf818c2e Cygwin: path.cc: clean up includes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:44:09 +01:00
Corinna Vinschen 7ae89fe708 Cygwin: path_conv: rename is_rep_symlink to is_known_reparse_point
...in preparation of reusing this flag for other types of
reparse points, not only symlinks.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-03-01 16:41:45 +01:00
Corinna Vinschen a27a7752ec Cygwin: improve storage and handling of AF_UNIX socket path
Define new struct sun_name_t and use throughout internally.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-28 19:06:53 +01:00
Corinna Vinschen 892efccb25 Cygwin: fhandler_socket_unix: store peer credentials in ucred member
* Split out cygwin/_ucred.h file
* drop local credentials

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-28 19:01:29 +01:00
Corinna Vinschen 25ea6af172 Cygwin: cleanup header including within network-releated files
* Rearrange includes and drop unneccessary ones.

* Don't pull in cygwin/socket.h into sys/un.h just to get
  sa_family_t.  Include sys/types.h and use __sa_family_t instead.

* start including Windows headers using the w32api/ path prefix

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-28 18:56:13 +01:00
Corinna Vinschen d02f3a1238 Cygwin: sockets: Fix fstat on unnamed sockets
Calling fhandler_socket::fstat from fhandler_socket::fstat recursively
is not a good idea...

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-27 15:30:13 +01:00
Corinna Vinschen fbdae2c216 Cygwin: reduce size of fhandler_cygdrive
fhandler_cygdrive has a size of 696 bytes on x86_64, while the next
biggest fhandler type, fhandler_pty_master, is 584 bytes.  The members
responsible for the size are private to opendir/readdir/closedir usage.
fhandler_disk_file stores private readdir data in DIR->__d_internal
instead.  Use equivalent method with fhandler_cygdrive.  This drops
the size to 464 bytes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 20:39:48 +01:00
Corinna Vinschen b995936ab5 Cygwin: sockets: Add missing cleanup if socket/socketpair creation fails
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 18:02:36 +01:00
Corinna Vinschen 4d75035244 Cygwin: fhandler_socket_unix: Tiny cleanup
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 17:58:46 +01:00
Corinna Vinschen d35bd22992 Cygwin: sockets: move type and proto checks into fhandler_socket classes
Encapsulation required

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 17:56:47 +01:00
Corinna Vinschen 1e5e44a9a5 Cygwin: fhandler_socket: define socketpair as virtual function
...in preparation of moving the type and protocol test into the
actual classes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-26 17:56:09 +01:00
Corinna Vinschen c70761df66 Cygwin: Define SO_PASSCRED and SCM_CREDENTIALS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 21:00:43 +01:00
Corinna Vinschen 7f7532fafb Cygwin: Create empty fhandler_socket_unix
* Make distinct from AF_LOCAL for testing purposes.  This will have
  to be reverted as soon as fhandler_socket_unix goes life.

* Move saw_reuseaddr flag back to fhandler_socket status

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 21:00:43 +01:00
Corinna Vinschen 5acadbe8af Cygwin: fix upcalls in some fhandler_socket_local methods
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 21:00:43 +01:00
Corinna Vinschen eaf359574d Cygwin: Introduce FH_SOCKET for generic socket file ops
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 19:45:59 +01:00
Corinna Vinschen b79018ee3a Cygwin: encapsulate Winsock based fhandler_socket classes
Insert another class fhandler_socket_wsock between fhandler_socket
and fhandler_socket_inet/fhandler_socket_local.

Also, add a new method fhandler::is_wsock_socket to allow asking
for sockets in general (is_socket) vs. Winsock-based sockets
(is_wsock_socket).

This allows to develop a new handler_socket_unix class as derived
class from fhandler_socket without any trace of wsock code left
in fhandler_socket.

While this is basically a temporary measure at this time, it may
prove useful for later interoperability with the upcoming Windows 10
AF_UNIX implementation at one point.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 15:24:18 +01:00
Corinna Vinschen cc9fe2c716 Cygwin: eliminate unused fhandler method hclose
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 14:56:30 +01:00
Corinna Vinschen 7bcab422e5 Cygwin: fix fhandler_socket_local::fchmod
Rather than just returning 0, return the result of calling
the base class fchmod.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 13:34:08 +01:00
Corinna Vinschen b89b6f4349 Cygwin: socket.h: Add SIOCINQ, equivalent to FIONREAD
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 13:33:23 +01:00
Corinna Vinschen 03f380c2bc Cygwin: drop unused device nodes and clean up socket devices
* Rename DEV_TCP_MAJOR to DEV_SOCK_MAJOR
* Drop FH_TCP, FH_UDP, FH_ICMP in favor of single FH_INET
* Drop FH_UNIX, FH_STREAM, FH_DGRAM in favor of single FH_LOCAL

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-23 13:32:51 +01:00
Corinna Vinschen b8a57a2d2a Cygwin: fhandler_socket: Move select functions into derived classes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:59:55 +01:00
Corinna Vinschen 479080baec Cygwin: fhandler_socket: Rearrange methods
Follow the same pattern in all fhandler_socket classes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:54:08 +01:00
Corinna Vinschen 9c593d9b39 Cygwin: fhandler_socket: Add derived fcntl methods
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:37:12 +01:00
Corinna Vinschen 79598f94f7 Cygwin: fhandler_socket: Add derived ioctl methods
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:31:07 +01:00
Corinna Vinschen 233bde3125 Cygwin: fhandler_socket: Move shutdown and close methods into derived classes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:28:14 +01:00
Corinna Vinschen 84c5e0fd3d Cygwin: make socketpair an AF_LOCAL-only method
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-22 16:25:28 +01:00
Corinna Vinschen a5dfbc6940 Cygwin: inline get_socket_flags()
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-21 22:00:04 +01:00
Corinna Vinschen 8906a4d335 Cygwin: fix whitespaces in socket code
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-21 21:43:44 +01:00
Corinna Vinschen 859d215b7e Cygwin: split out fhandler_socket into inet and local classes
First cut, still incomplete

* fhandler_socket is now base class for other socket classes
* fhandler_socket_inet handles AF_INET and AF_INET6 sockets
* fhandler_socket_local handles AF_LOCAL/AF_UNIX sockets
* finally get rid of fdsock by using set_socket_handle in accept4
* align file-related calls (fstat,  fstatvfs, fchown, fchmod, facl)
  to Linux.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-21 21:40:01 +01:00
Corinna Vinschen dff3bc9a86 Cygwin: net.cc: drop redundant declarations
Replace cygwin_inet_aton call with cygwin_inet_pton

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 18:14:57 +01:00
Corinna Vinschen ea1e5318d5 Cygwin: set/getsockopt: Move implementation into fhandler_socket class
This requires to export find_winsock_errno from net.cc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 18:01:40 +01:00
Corinna Vinschen 044ab77dcc Cygwin: clean error mapping
- Move definition of windows to POSIX error mapping struct into
  cygerrno.h
- Move declaration of winsock errno functions to cygerrno.h
- Input to error mapping functions is DWORD

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 17:59:53 +01:00
Corinna Vinschen 0a3f4e6087 Cygwin: Make sure fraction of seconds constants enforce 64 bit computation
Dropping the 'LL' specifier leads to 32 bit truncation during timestamp
computation.  Revert it.  Exempt MSPERSEC which is used for 32 bit values.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-20 15:05:31 +01:00
Corinna Vinschen ea543d3ffa Cygwin: fix declaration of fhandler_socket::socketpair
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 17:34:57 +01:00
Corinna Vinschen 26bcedda20 Cygwin: fix utils path handling in case cygdrive path is just '/'
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-16 17:21:48 +01:00
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
Yaakov Selkowitz 6a848db442 cygwin: export SSP functions
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29 11:25:48 -06:00
Yaakov Selkowitz f2b27ce620 cygwin: define _POSIX_TIMEOUTS
Since commit 8128f5482f, we have all the
non-tracing functions listed in posixoptions(7).  The tracing functions
are gated by their own option, and are obsolecent anyway.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-28 10:26:00 -06:00
Corinna Vinschen 76bd5cab33 cygwin: don't allow empty strings in __ASMNAME tags
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-28 13:31:20 +01:00
Corinna Vinschen df75aedc20 cygwin: improve _EXFUN tags generation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-28 13:26:37 +01:00
Corinna Vinschen 2d2833dfab cygwin: remove accidentally committed debug statments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-28 13:12:07 +01:00
Corinna Vinschen 662740b3d0 cygwin: further improve tags generation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-28 13:10:34 +01:00
Yaakov Selkowitz 032aa2dba5 Feature test macros overhaul: Cygwin limits.h, part 2
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
https://sourceware.org/ml/newlib/2017/msg01133.html

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-28 04:11:33 -06:00
Corinna Vinschen 76f06705be cygwin: convert most #ifndef __x86_64__ to #ifdef __i386__
Address the real offender

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-27 14:36:06 +01:00
Corinna Vinschen bc14f1c174 cygwin: improve tags generation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-27 14:34:40 +01:00
Corinna Vinschen 9789cdffde cygwin: cleanup fhandler_socket::release_events
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-27 13:38:21 +01:00
Corinna Vinschen 57732f9b4b Cygwin: pipe_data_available: cleanup code
* Don't use a bool var to store three states (-1, 0, 1).
* Correctly check for NT_SUCCESS of a function returning NTSTATUS.
* Straighten out code for better readability.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-15 21:49:28 +01:00
Corinna Vinschen 0d57ef9de5 Cygwin: open: Remove unused code to handle HIDDEN and SYSTEM files
Commit 603ef545bd broke this snippet and
commit 5b312b4747 didn't help at all since
FILE_CREATE is exactly *not* the situation the test was originally
supposed to handle.

In fact, none of the open flags used by fhandler_base::open actually
hits this problem anymore, so just drop the code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-14 21:50:32 +01:00
Corinna Vinschen 0b0b2b96f2 Cygwin: link: Simplify an expression
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-14 21:45:32 +01:00
Corinna Vinschen ce0b11f9c4 Cygwin: Bump DLL version to 2.10.0, bump API minor to 319
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-14 21:45:32 +01:00