Commit Graph

13577 Commits

Author SHA1 Message Date
Corinna Vinschen 762dcfc658 Cygwin: document dropping 32 bit support
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-10-27 21:45:52 +02:00
Hamish McIntyre-Bhatty b563f5974f Fix typo in faq-programming.xml 2022-10-27 13:23:40 +02:00
Brian Inglis 7f7e4e5bc5 strptime.cc(__strptime): add %q GNU quarter 2022-10-24 14:09:07 +02:00
Takashi Yano 7589034cc3 Cygwin: pty: Fix 'Bad address' error when running 'cmd.exe /c dir'
- If the command executed is 'cmd.exe /c [...]', runpath in spawn.cc
  will be NULL. In this case, is_console_app(runpath) check causes
  access violation. This case also the command executed is obviously
  console app., therefore, treat it as console app to fix this issue.

  Addresses: https://github.com/msys2/msys2-runtime/issues/108
2022-10-22 14:21:15 +09:00
Ken Brown 5781871775 Cygwin: select: don't report read ready on a FIFO never opened for writing
According to POSIX and the Linux man page, select(2) is supposed to
report read ready if a file is at EOF.  In the case of a FIFO, this
means that the pipe is empty and there are no writers.  But there
seems to be an undocumented exception, observed on Linux and other
platforms:  If no writer has ever been opened, then select(2) does not
report read ready.  This can happen if a reader is opened with
O_NONBLOCK before any writers have opened.

This commit makes Cygwin consistent with those other platforms by
introducing a special EOF test, fhandler_fifo::select_hit_eof, which
returns false if there's never been a writer opened.

To implement this we use a new variable '_writer_opened' in the FIFO's
shared memory, which is set to 1 the first time a writer opens.  New
methods writer_opened() and set_writer_opened() are used to test and
set this variable.

Addresses: https://cygwin.com/pipermail/cygwin/2022-September/252223.html
2022-10-19 08:17:50 -04:00
Corinna Vinschen 783133b753 Cygwin: cygtls: drop useless alignment directives
The patch fixing the alignment of _cygtls::context accidentally
pushed the desperate attempt to automate the alignment by using
another, non-working variation of attribute((aligned)).  Drop it.

Fixes: dcab768cb9 ("Cygwin: cygtls: fix context alignment")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-09-05 19:52:28 +02:00
Jon Turney b4561c2363
Cygwin: testsuite: Add x86_64 code to "dynamically load cygwin" test
This still needs some more voudou to actually work.

Also update how-cygtls-works.txt a bit
2022-08-29 17:53:48 +01:00
Jon Turney 6e843f7750
Cygwin: testsuite: In pathconf01 use the temporary directory instead of "/tmp"
In pathconf01 use the temporary directory, instead of "/tmp" (which may not exist).
2022-08-29 17:53:46 +01:00
Jon Turney f1d7ef46f7
Cygwin: testsuite: Fix size of write to temporary file to be mmap()ed
See ltp commit 91361378
2022-08-29 17:53:45 +01:00
Jon Turney 19b3b814bc
Cygwin: testsuite: Fix TEST_RETURN for 64-bit
The result of a function call won't fit in an int if it's e.g. a pointer.
2022-08-29 17:53:44 +01:00
Jon Turney 6ca056eec9
Cygwin: testsuite: Remove passing tests from XFAIL list
Remove ltp/fcntl05.c from XFAIL list, since it now PASSes.
Remove ltp/dup03.c from XFAIL list, since it now PASSes.
2022-08-29 17:53:42 +01:00
Jon Turney 5cea46d309
Cygwin: testsuite: Don't write coredump in a child which is expected to segfault 2022-08-29 17:53:41 +01:00
Corinna Vinschen dcab768cb9 Cygwin: cygtls: fix context alignment
A hang was encountered, apparently triggered by commit 63b503916d,
changing tls_pathbufs from malloc'ed to HeapAlloc'ed memory.  After
lengthy debugging it transpired that adding the heap handle to the
tls_pathbuf struct added 8 bytes to the cygtls area, thus moving
the "context" member by 8 bytes, too, so it was suddently unaligned.

Fix this for now by changing the alignment.

Fix this once and for all, by adding code to the gentls_offsets script
to check if the alignment of the "context" member is 16 bytes.  If not,
print a matching error message, remove the just generated file, and exit
with error.

FIXME: It would be really nice to find a way to auomate the correct
alignment of the "context" member, but I don't see any way to use
alignment attributes to get what we need here.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-29 15:18:53 +02:00
Corinna Vinschen 717c36c0a4 Cygwin: fork: fix a potential hang in fork
while debugging a problem introduced in commit
63b503916d ("Cygwin: tls_pathbuf: Use Windows heap")
a hang in fork was encountered using the original implementation
of tls_pathbuf:

Using tmp_pathbuf inside the code block guarded by __malloc_trylock
may call malloc from tmp_pathbuf::w_get and thus trying to lock an
exclusive SRW lock recursively, which results in a deadlock.

Allocate a small SECURITY_ATTRIBUTES block on the stack rather than
allocating a 64K tmp_pathbuf.  This avoids the potential malloc call.

Drop the __malloc_trylock call entirely.  There must not be a malloc
call inside the frok::parent block guarded by __malloc_lock, and
just trying to lock is too dangerous inside fork while other threads
might actually chage the content of the heap.  Additionally, add a
comment frowning on malloc usage inside tis code block.

Fixes: 44a79a6eca ("Cygwin: convert malloc lock to SRWLOCK")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-29 12:25:24 +02:00
Corinna Vinschen 0819679a7a Cygwin: cwd: use SRWLOCK instead of muto
To reduce thread contention, use reader/writer locks as required.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-23 12:09:44 +02:00
Corinna Vinschen ee54cabad9 Cygwin: mmap: use SRWLOCK instead of muto
To reduce thread contention, use reader/writer locks as required.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-23 12:09:44 +02:00
Corinna Vinschen 63b503916d Cygwin: tls_pathbuf: Use Windows heap
Rather than using malloc/free for the buffers, we're now using
HeapAlloc/HeapFree on a HEAP_NO_SERIALIZE heap created for this
thread.

Advantages:
- Less contention. Our malloc/free doesn't scale well in
  multithreaded scenarios
- Even faster heap allocation by using a non serialized heap.
- Internal, local, temporary data not cluttering the user heap.
- Internal, local, temporary data not copied over to child process
  at fork().

Disadvantage:
- A forked process has to start allocating temporary buffers from
  scratch.  However, this should be alleviated by the fact that
  buffer allocation usually reaches its peak very early in process
  runtime, so the longer the proceess runs, the less buffers have
  to allocated, and, only few processes don't exec after fork
  anyway.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-23 12:09:44 +02:00
Corinna Vinschen c3e92052bb Cygwin: smallprint.cc: Drop HEAP_ZERO_MEMORY
Leftover from testing.

Reported-by: Noel Grandin <noelgrandin@gmail.com>
Fixes: 07ec40170a ("Cygwin: smallprint.cc: Convert tmpbuf to lockless")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 17:58:53 +02:00
Corinna Vinschen 88e2f2aad1 Cygwin: posix_timer: fix formatting
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 14:53:30 +02:00
Corinna Vinschen 74983727c0 Cygwin: push missing change to debug.h
Fixes: 48a210a457 ("Cygwin: debugging: convert muto to SRWLOCK")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 14:53:30 +02:00
Corinna Vinschen 48a210a457 Cygwin: debugging: convert muto to SRWLOCK
this avoids having to call debug_init, because the SRWLOCK
is statically initialized.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 14:38:49 +02:00
Corinna Vinschen d6c50e630a Cygwin: shm: Convert muto into SRWLOCK and avoid overlocking
shmat may call shmget.  shmget locks by itself as necessary,
so there's no reason to keep the lock active and recurse into
the lock.  Use SRWLOCK and only lock  as required.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 14:28:11 +02:00
Corinna Vinschen 2e03e5a040 Cygwin: authz: Use dedicated locks per datastructure
So far we use a single muto to guard three different datastructures
inside class authz_ctx: the authz HANDLE, the user context HANDLE
and the context cache list.  Split the single muto into three
independent SRWLOCKs and guard all datastrcutures as necessary to
avoid thread contention.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 14:25:05 +02:00
Corinna Vinschen e0cc4ea929 Cygwin: spawn: don't overallocate SECURITY_ATTRIBUTES buffer
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 12:37:31 +02:00
Corinna Vinschen 07ec40170a Cygwin: smallprint.cc: Convert tmpbuf to lockless
The old technique was from a time when we had to reduce stack pressure
by moving 64K buffers elsewhere.  It was implemented using a static
global buffer, guarded by a muto. However, that adds a lock which may
unnecessarily serialize threads.

Use Windows heap buffers per invocation instead.  HeapAlloc/HeapFree are
pretty fast, scale nicely in multithreaded scenarios and don't serialize
threads unnecessarily.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-22 12:01:15 +02:00
Corinna Vinschen 1b3a0effd4 Cygwin: profiler: Fix linking when building with -DDEBUGGING
CloseHandle gets redefined to a macro calling an internal function
in debug.h when building with -DDEBUGGING, but profiler has no access
to that function.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-20 21:14:57 +02:00
Corinna Vinschen c1f8a7b502 Cygwin: wchar.h: Fix comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-20 20:27:37 +02:00
Corinna Vinschen 2ec96890db Cygwin: sigproc.cc: drop Static macro, use explicit NO_COPY instead
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-19 21:55:09 +02:00
Corinna Vinschen 1b2d3d1f94 Cygwin: drop __fastcall calling convention specifiers
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-19 21:52:45 +02:00
Corinna Vinschen 2b9d98d083 Cygwin: miscfuncs.h: fix comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-19 15:51:49 +02:00
Corinna Vinschen 85be74f295 newlocale: fix crash when trying to write to __C_locale
This simple testcase:

  locale_t st = newlocale(LC_ALL_MASK, "C", (locale_t)0);
  locale_t st2 = newlocale(LC_CTYPE_MASK, "en_US.UTF-8", st);

is sufficient to reproduce a crash in _newlocale_r.  After the first call
to newlocale, `st' points to __C_locale, which is const.  When using `st'
as locale base in the second call, _newlocale_r tries to set pointers
inside base to NULL.  This is bad if base is __C_locale, obviously.

Add a test to avoid trying to overwrite pointer values inside base if
base is __C_locale.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-12 12:29:26 +02:00
Corinna Vinschen bf1d972d5c Cygwin: move POSIX semaphore API functions to posix_ipc.cc
This way, the sem API is all in the same place, even if the
underlying semaphore class is still in thread.cc.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:11:57 +02:00
Corinna Vinschen 782ef53619 Cygwin: rename CygwinCreateThread to create_posix_thread
Rename CygwinCreateThread to create_posix_thread and move
from miscfuncs.cc to create_posix_thread.cc, inbcluding all
related functions.  Analogue for the prototypes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:06:28 +02:00
Corinna Vinschen 86d2126173 Cygwin: mm/malloc_wrapper.cc: fix a comment
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen afa7117999 Cygwin: move __caller_return_address to mm/malloc_wrapper.cc
It's used in this file only anyway, so make it static inline.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen 5851a633bd Cygwin: make import_address a static inline function
It's used in malloc_init only and we never need it anywhere else,
hopefully.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen 56b7fd620f Cygwin: make check_invalid_virtual_addr a static inline function
move it to mm/mmap.cc which uses it exclusively.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen 9fbfccff71 Cygwin: move memory management sources into mm subdir
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:12 +02:00
Corinna Vinschen 719224492a Cygwin: drop building modelibs
They never worked as desired anyway. Use the object files.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-10 18:05:11 +02:00
Ken Brown 5cdf8ade28 Cygwin: fix return value of symlink_info::check
Currently it is possible for symlink_info::check to return -1 in case
we're searching for foo and find foo.lnk that is not a Cygwin symlink.
This contradicts the new meaning attached to a negative return value
in commit 19d59ce75d.  Fix this by setting "res" to 0 at the beginning
of the main loop and not seting it to -1 later.

Also fix the commentary preceding the function definition to reflect
the current behavior.

Addresses: https://cygwin.com/pipermail/cygwin/2022-August/252030.html
2022-08-09 16:58:08 -04:00
Corinna Vinschen 34872ce1a1 Cygwin: pthreads: merge pthread.cc into thread.cc
provide entire internal and external pthread API from inside the
same file.

While I dislike to have another even larger file, this is basically
cleaning up the source and grouping the external API into useful
chunks. Splitting the file cleanly is tricky due to usage of inline
methods is_good_object and verifyable_object_isvalid.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-09 22:48:43 +02:00
Corinna Vinschen 1556b96b1b Cygwin: stop exporting _alloca
This is a remnant from 32 bit times, mindlessly copied into
the 64 bit export table.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-08 18:16:09 +02:00
Corinna Vinschen 3ba050dfcd Cygwin: fold common.din and x86_64.din into cygwin.din
We don't need a target-specific DEF file anymore

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-08 17:47:46 +02:00
Corinna Vinschen 5858c23015 Cygwin: move mcountFunc.S to x86_64 target dir
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-08 16:50:04 +02:00
Corinna Vinschen 188d5f6c9a Cygwin: x86_64: add wmemset assembler entry point
So far, wmemset used the C implemantation from newlib.  Let's use
the optimized assembler code instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-08 16:50:04 +02:00
Corinna Vinschen 3e13d93554 Cygwin: split out x86_64 memset/memcpy functions
move the assembler memset and memcpy functions into their own
assembler files.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-08 16:25:41 +02:00
Corinna Vinschen 4d6c88e030 Cygwin: fhandler/null.cc: remove redundant includes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 12:02:11 +02:00
Ken Brown 1213f7bf15 Cygwin: update the "dirs" variable in Makefile.am
Add the new fhandler and sec subdirs.
2022-08-05 12:02:11 +02:00
Corinna Vinschen 007e23d639 Cygwin: Reorganize cygwin source dir
Create subdirs and move files accordingly:

- DevDocs:  doc files
- fhandler: fhandler sources, split fhandler.cc into base.cc and null.cc
- local_includes: local include files
- scripts:  scripts called during build
- sec:      security sources

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 12:02:11 +02:00
Corinna Vinschen 1e428bee1c Cygwin: mount_info::get_mounts_here: alloc temp mountpoint info on cygheap
That *should* be slightly faster than allocating on the user heap.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 12:01:45 +02:00
Corinna Vinschen d097a96e6e Cygwin: drop last usage of RtlCreateUnicodeStringFromAsciiz
This function is just bad.  It really only works for ASCII
chars, everything else is broken after the conversion.

Introduce new helper function sys_mbstouni to replace
RtlCreateUnicodeStringFromAsciiz in hash_path_name.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-05 11:45:49 +02:00
Takashi Yano 249f42d07a Cygwin: pty: Fix a small bug in is_console_app().
- Previsouly, there was potential risk of buffer over run in
  is_console_app(). This patch fixes the issue.
2022-08-05 17:59:40 +09:00
Corinna Vinschen 58e981a5a4 Cygwin: use locale-aware conversion to UNICODE_STRING checking mount points
mount_info::get_mounts_here used RtlCreateUnicodeStringFromAsciiz
which translates bytes into wide chars verbatim.

Create a new function sys_mbstouni_alloc which can be used from
mount_info::get_mounts_here to convert multibyte mount point
strings to UNICODE_STRINGS in a locale-aware way.

For symmetry, create a function mount_info::free_mounts_here,
so the knwoledge how to free the UNICODE_STRING buffers is
encapsulated in the same class.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 23:48:19 +02:00
Corinna Vinschen 35c5017438 Cygwin: drop all usages of NTAPI
and drop unused prototypes from ntdll.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Corinna Vinschen b28edc7b86 Cygwin: drop all usages of WINAPI
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Corinna Vinschen 73aefcb5c2 Cygwin: clock.cc: Drop redundant Windows prototypes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Corinna Vinschen e71628b889 Cygwin: drop obsolete _cygwin_noncygwin_dll_entry entry point
This was obsoleted more than 22 years ago. Time to drop it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 22:13:59 +02:00
Ken Brown c2aa5b6d74 Cygwin: syscalls.cc: remove ".dll" from blessed_executable_suffixes
This reverts commit d9e9c7b5a7.  The latter added ".dll" to the
blessed_executable_suffixes array because on 32-bit Windows, the
GetBinaryType function would report that a 64-bit DLL is an
executable, contrary to the documentation of that function.

That anomaly does not exist on 64-bit Windows, so we can remove ".dll"
from the list.  Reverting the commit does, however, change the
behavior of the rename(2) syscall in the following unlikely situation:
Suppose we have an executable foo.exe and we make the call

  rename ("foo", "bar.dll");

Previously, foo.exe would be renamed to bar.dll.  So bar.dll would
then be an executable without the .exe extension.  The new behavior is
that foo.exe will be renamed to bar.dll.exe.  [Exception: If there
already existed an executable (not a DLL!) with the name bar.dll, then
.exe will not be appended.]
2022-08-04 15:51:39 -04:00
Corinna Vinschen 288788f91e Cygwin: Drop outdated IsWow64Process2 prototype
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:55:52 +02:00
Corinna Vinschen 12a3b696a4 Cygwin: drop outdated __MINGW64_VERSION_MAJOR checks
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:55:25 +02:00
Corinna Vinschen 7073ef4e8f Cygwin: drop __stdcall usage
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:54:09 +02:00
Corinna Vinschen 7718cb70d4 Cygwin: syscalls.cc: drop masking macros for standard IO functions
The actual reason for these wrappers are lost in time, there's no
hint even in the pre-2000 ChangeLog files.  Apparently they were
masking the prototypes or, alternatively, macros from newlib to
clash with the definitions in syscalls.cc.

They are not needed anymore, so just drop them.

This uncovered that the buffer pointer to pwrite is erronously
non-const.  Fix this on the way out.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 20:32:49 +02:00
Corinna Vinschen 9f6057d203 Cygwin: Drop export aliases and masking macros for stdio64 functions
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 17:30:48 +02:00
Corinna Vinschen cc88ef77e7 Cygwin: create sparse errmap array
To avoid linear searches for error codes, autogenerate errmap as
simple array of errno values indexed by Windows error codes.
Restrict to the first 9000 Windows error codes, we don't care for
most of them anyway.

Define errmap in its own file errmap.h to clean up errno.cc.

Change geterrno_from_win_error accordingly.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 15:16:48 +02:00
Markus Mützel ab31794e8a cacosh: Use approximation for large input.
Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 12:55:52 +02:00
Markus Mützel d939b16adc casinh: Use approximation for large input.
Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 12:55:17 +02:00
Corinna Vinschen 70c7e8c1ba Cygwin: net.cc: convert wsock_errmap into a simple array of error codes
Avoid linear searches for error codes by converting wsock_errmap
to a ordered array, indexed by WinSock error code (subtracted by
WSABASEERR.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 11:45:58 +02:00
Corinna Vinschen a8c1dd2ce0 Cygwin: net.cc: create own type host_errmap_t for host_errmap
This decouples host_errmap from the errmap_t definition which is
about to be changed in a followup patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 11:37:58 +02:00
Corinna Vinschen 8053ccd44b Cygwin: net.cc: constify gai_errmap
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-04 11:36:24 +02:00
Corinna Vinschen f418195dc9 Cygwin: fix/drop a few comments
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 18:14:39 +02:00
Corinna Vinschen b226e4228a Cygwin: __WORDSIZE: Drop 32 bit considerations
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 17:48:20 +02:00
Corinna Vinschen 7ad791c1ee Cygwin: drop macro and code for CYGWIN_VERSION_DLL_EPOCH
fix a comment in check_sanity_and_sync() on the way

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:16:14 +02:00
Corinna Vinschen c41f0e700a Cygwin: drop unused CYGWIN_VERSION_CYGWIN_CONV macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:09:00 +02:00
Corinna Vinschen dad3dd33ab Cygwin: version.h: document API_VERSION of the first 64 bit build
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:04:42 +02:00
Corinna Vinschen 12360f10ff Cygwin: drop macro and code for CYGWIN_VERSION_USE_PSEUDO_RELOC_IN_DLL
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 16:01:29 +02:00
Corinna Vinschen c874161ec5 Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:59:37 +02:00
Corinna Vinschen fee7b24beb Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:57:30 +02:00
Corinna Vinschen 57c3ca8d51 Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:53:41 +02:00
Corinna Vinschen 741f9a61c6 Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:52:07 +02:00
Corinna Vinschen dcd78ece45 Cygwin: drop unused CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:50:52 +02:00
Corinna Vinschen c2743614bf Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:48:56 +02:00
Corinna Vinschen 7de1be0472 Cygwin: drop unused CYGWIN_VERSION_CHECK_FOR_S_IEXEC macro
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:39:14 +02:00
Corinna Vinschen 8883f0ea39 Cygwin: drop macro and code for CYGWIN_VERSION_OLD_STDIO_CRLF_HANDLING
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:38:11 +02:00
Corinna Vinschen efa6611982 Cygwin: drop macro and code for CYGWIN_VERSION_DLL_MALLOC_ENV
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:35:34 +02:00
Corinna Vinschen 02b273a688 Cygwin: drop macro and code for CYGWIN_VERSION_DLL_IS_OLD_TERMIOS
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 15:35:29 +02:00
Corinna Vinschen 2902b3a09e Cygwin: drop requirement to build newlib's stdio64
Given that 64 bit Cygwin defines all file access types (off_t,
fpos_t, and derived types) as 64 bit anyway, there's no reason
left to rely on the stdio64 part of newlib.  Use base functions
and base types.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-08-03 13:41:35 +02:00
Takashi Yano 8b502d8635 Cygwin: path: Make some symlinks to /cygdrive/* work.
- Previously, some symbolic links to /cygdrive/* (e.g. /cygdrive/C,
  /cygdrive/./c, /cygdrive//c, etc.) did not work. This patch fixes
  the issue.
  Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251994.html
2022-08-03 13:36:09 +09:00
Takashi Yano bfee9c6ab0 Cygwin: console: Modify ConEmu cygwin connector hook.
- Previously, LoadLibraryA() is hooked for ConEmu cygwin connector.
  With this patch, GetProcAddress() for "RequestTermConnector" is
  hooked instead which is more essential for ConEmu cygwin connector.
2022-08-02 07:52:52 +09:00
Takashi Yano d5229f8211 Cygwin: pty: Treat *.bat and *.cmd as a non-cygwin console app.
- If *.bat or *.cmd is executed directly from cygwin shell, pty
  failed to switch I/O pipe to that for native apps. This patch
  fixes the issue.
2022-07-31 17:55:42 +09:00
Takashi Yano 8d564b62b7 Cygwin: console: Avoid accessing NULL pointer via cygheap->ctty.
- Recent commit "Cygwin: console: Add missing input_mutex guard."
  has a problem that causes NULL pointer access if cygheap->ctty
  is NULL. This patch fixes the issue.
2022-07-29 21:59:11 +09:00
Jon Turney d4689b99c6
Cygwin: Set threadnames with SetThreadDescription()
gdb master recently learnt how to use GetThreadDescription() [1], so set
threadnames using SetThreadDescription() [available since Windows 10
1607] as well.

This is superior to using a special exception to indicate the thread
name to the debugger, because the thread name isn't missed if you don't
have a debugger attached at the time it's set.

It's not clear what the encoding of a thread name string is, we assume
UTF8 for the moment.

For the moment, continue to use the old method as well, for the benefit
of older gdb versions etc.

[1] https://sourceware.org/pipermail/gdb-patches/2022-April/187833.html
2022-07-29 11:58:43 +01:00
Corinna Vinschen f145174f80 Cygwin: uname: drop useless support for unsupported CPU arches
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-29 12:19:54 +02:00
Corinna Vinschen 87a9ca4a95 Cygwin: gmon.h: drop 32 bit considerations
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-29 12:19:18 +02:00
Corinna Vinschen 20adacdca2 Cygwin: profile.c: drop i686 register access
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-29 12:17:43 +02:00
Corinna Vinschen 7f42498be6 Cygwin: rename __cygwin_environ and drop env redirection via cur_environ()
Back in early Cygwin development a function based access to the
environment was exported, the internal environ in Cygwin was called
__cygwin_environ and cur_environ() was used to access the environment
indirectly .  The history of that necessity is not documented,
but kept in i686 for backward compatibility.

The x86_64 port eventually used __cygwin_environ directly and exported
it as DATA under the usual name environ.

We don't need the i686 workaround anymore, so just rename
__cygwin_environ to environ, drop the cur_environ() macro and
simply export environ under its own name.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-28 22:00:40 +02:00
Corinna Vinschen cea26c7570 Cygwin: perl scripts: drop support for i686
- rename "is64bit" to "is_x86_64"
- Always set sym_prefix to empty string and add a FIXME
- speclib: rename uscore to sym_prefix and fix bug in string handling

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-28 20:28:45 +02:00
Takashi Yano f2e39d5230 Cygwin: console: Add workaround for ConEmu cygwin connector.
- ConEmu cygwin connector conflicts with cons_master_thread since
  it does not use read() to read console input. With this patch,
  cons_master_thread is disabled in ConEmu cygwin connector.
2022-07-28 23:56:42 +09:00
Takashi Yano d4aacd50e6 Cygwin: console: Add missing input_mutex guard.
- Setting con.disable_master_thread flag should be guarded by
  input_mutex, however, it was not. This patch fixes that.
2022-07-28 23:56:34 +09:00
Corinna Vinschen 33395637a1 Cygwin: Fix previous attempt to drop i386 targets from hookapi
Somehow this patch looks like it was pushed before having been
finished.  Let's try again...

Fixes: e46f15c2d1 ("Cygwin: hookapi: drop handling i386 targets")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-28 16:38:01 +02:00
Corinna Vinschen 5192d5ea51 Cygwin: _dll_crt0: minimize target-specific conditional code
Only the assembler snippet is really x86_64-specific, so minimize the
conditional code block to this snippet.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 20:08:58 +02:00
Corinna Vinschen e46f15c2d1 Cygwin: hookapi: drop handling i386 targets
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 20:06:09 +02:00
Corinna Vinschen 1f962581ff Cygwin: fix or delete a few comments to drop 32 bit references
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 18:32:53 +02:00
Corinna Vinschen 4ce1a1ddc4 Cygwin: drop cyglsa.h. LSA subauth is not supported anymore
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 12:48:39 +02:00
Corinna Vinschen cb4b49470f Cygwin: drop 32 bit target from linker script
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 12:33:21 +02:00
Corinna Vinschen f25e61dfea Cygwin: drop tmpfile export alias for 32 bit systems
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-07-14 11:41:01 +02:00
Matt Joyce f89ce35d83 Add _REENT_CLEANUP(ptr)
Add a _REENT_CLEANUP() macro to encapsulate access to the
__cleanup member of struct reent. This will help to replace the
struct member with a thread-local storage object in a follow up
patch.
2022-07-13 06:55:46 +02:00
Matt Joyce f3b8138239 Add _REENT_ERRNO(ptr)
Add a _REENT_ERRNO() macro to encapsulate the access to the
_errno member of struct reent. This will help to replace the
structure member with a thread-local storage object in a follow
up patch.

Replace uses of __errno_r() with _REENT_ERRNO().  Keep __errno_r() macro for
potential users outside of Newlib.
2022-07-13 06:55:41 +02:00
Jon Turney 56d5a57e5f
Update FAQs which are out of date on the details of setup UI 2022-07-12 13:58:59 +01:00
Jon Turney b441bad182
Update FAQs for removal of 32-bit Cygwin
Update FAQs for removal of 32-bit Cygwin
Also update FAQs for dropping support for Windows Vista/Server 20008
2022-07-12 13:58:58 +01:00
Takashi Yano 9193f6efde Cygwin: clipboard: Add workaround for setting clipboard failure.
- OpenClipboard() just after CloseClipboard() sometimes fails. Due
  to this, /dev/clipboard sometimes fails to set CF_UNICODETEXT
  data. This patch add a workaround for this issue.
2022-07-12 19:59:38 +09:00
Takashi Yano 421dcf72fb Cygwin: console: Fix an issue which causes when realloc() fails. 2022-07-09 14:43:24 +09:00
Ken Brown 5d4f405d3b Cygwin: redefine some macros for Linux compatibility
Define FD_SETSIZE (<sys/select.h>) to be 1024 by default, and define
NOFILE (<sys/param.h>) to be OPEN_MAX (== 3200) by default.

Remove the comment in <sys/select.h> that FD_SETSIZE should be >=
NOFILE.

Bump API minor.

Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251839.html
2022-07-07 08:22:40 -04:00
Christian Franke d908a30fdc winsup/doc/faq-setup.xml: align help text with setup 2.919 2022-07-07 13:10:46 +02:00
Takashi Yano fc74dbf22f Cygwin: spawn: Treat empty path as the current directory.
- With this patch, the empty path (empty element in PATH or PATH is
  absent) is treated as the current directory as Linux does. This
  feature is added for Linux compatibility, but it is deprecated.
  POSIX notes that a conforming application shall use an explicit
  pathname to specify the current working directory.
Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251730.html
2022-07-05 13:44:56 +09:00
Takashi Yano b3e25f0bc1 Cygwin: console: Fix issue of pasting very long text input again.
- The recent commit "Cygwin: console: Allow pasting very long text
  input." did not fix the issue enough. This patch adds fixes for
  that.
2022-07-05 11:48:40 +09:00
Ken Brown 72f855f32b Cygwin: implement getfacl(1) for socket files
Do this by defining the acl_get method for the fhandler_socket_local
and fhandler_socket_unix classes.  Also define acl_set for these
classes.

Partially addresses: https://cygwin.com/pipermail/cygwin/2022-July/251768.html
2022-07-04 18:55:19 -04:00
Ken Brown 1503d14af1 Cygwin: stdio: don't try again to read after EOF
This reverts commit 1f8f7e2d54, "* libc/stdio/refill.c (__srefill):
Try again after EOF on Cygwin."  If EOF is set on a file, the stdio
input functions will now immediately return EOF rather than trying
again to read.  This aligns Cygwin's behavior to that of Linux.

Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251672.html
2022-07-04 18:55:08 -04:00
Takashi Yano 2c2c2b631b Cygwin: console: Fix new bugs in cons_master_thread().
- The previous commit for console introduced new bugs in error
  handling in cons_master_thread(). This patch fixes that.
2022-07-03 11:02:28 +09:00
Takashi Yano 746c8116dd Cygwin: console: Allow pasting very long text input.
- Currently, if the text longer than 1024 byte is pasted in console,
  some of the text is discarded. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251764.html
2022-07-02 11:24:11 +09:00
Takashi Yano 54930ae7d7 Cygwin: poll: Fix a bug on inquiring same fd with different events.
- poll() has a bug that it returns event which is not inquired if
  events are inquired in multiple pollfd entries on the same fd at
  the same time. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251732.html
2022-06-27 10:54:24 +09:00
Takashi Yano fe10e8f03a Cygwin: console: Handle setting very long window title correctly.
- Previously, the console code could not handle escape sequence
  setting window title longer than 256 byte correctly. This patch
  fixes the issue.
  Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251662.html
2022-06-19 18:02:09 +09:00
Takashi Yano fdbd153932 Cygwin: console: Retain ENABLE_VIRTUAL_TERMIANL_PROCESSING flag.
- Currently, ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is disabled
  unconditionally when exiting from cygwin. This causes ANSI escape
  sequence disabled in Windows Terminal where it is enables by
  default. This patch retains that flag if it is originally enabled.
2022-06-14 21:11:56 +09:00
Ken Brown ddce45112d Cygwin: restore one more '#ifdef __x86_64__' 2022-06-11 08:56:08 -04:00
Ken Brown bbfe79fb72 Cygwin: restore '#ifdef __x86_64__' for CPU-specific code
Commit e1ce752a1d, "Cygwin: remove miscellaneous 32-bit code", removed
most occurrences of '#ifdef __x86_64__'.  Restore those occurrences
that guarded code specific to the AMD64 processor, and #error out if
the processor is different.  This will make it easier to find
AMD64-specific code if we ever want to add support for a different
64-bit processor (e.g., ARM64).
2022-06-10 16:38:34 -04:00
Sebastian Huber b0cb9f85ca Use global stdio streams for all configurations
The _REENT_GLOBAL_STDIO_STREAMS was introduced by commit
668a4c8722 in 2017.  Since then it was enabled by
default for RTEMS.  Recently, the option was enabled for Cygwin which
previously used an alternative implementation to use global stdio streams.

In Newlib, the stdio streams are defined to thread-specific pointers
_reent::_stdin, _reent::_stdout and _reent::_stderr.  If the option is disabled
(the default for most systems), then these pointers are initialized to
thread-specific FILE objects which use file descriptors 0, 1, and 2,
respectively.  There are at least three problems with this:

(1) The thread-specific FILE objects are closed by _reclaim_reent().  This
    leads to problems with language run-time libraries that provide wrappers to
    the C/POSIX stdio streams (for example C++ and Ada), since they use the
    thread-specific FILE objects of the initialization thread.  In case the
    initialization thread is deleted, then they use freed memory.

(2) Since thread-specific FILE objects are used with a common output device via
    file descriptors 0, 1 and 2, the locking at FILE object level cannot ensure
    atomicity of the output, e.g. a call to printf().

(3) There are resource managment issues, see:

    https://sourceware.org/pipermail/newlib/2022/019558.html

    https://bugs.linaro.org/show_bug.cgi?id=5841

This patch enables the _REENT_GLOBAL_STDIO_STREAMS behaviour for all Newlib
configurations and removes the option.  This removes a couple of #ifdef blocks.
2022-06-10 20:13:52 +02:00
Mark Geisert aa460cc0ca Cygwin: Have gmondump support ssp-generated gmon.out
Cygwin tool ssp generates gmon.out files with different address
resolution than other tools do. Two address bytes per bucket rather than
the usual four address bytes. Gprof can deal with the difference but
gmondump can't because the latter's gmon.out header validation fails.

- Remove the offending portion of the header validation code.
- Make sure all code can handle differing address resolutions.
- Display address resolution in verbose data dumps.
- Change "rawarc" to "struct rawarc" in certain sizeof expressions to
  avoid buffer overrun faults.
- When "-v" (verbose) is specified, note when there is missing bucket
  data or rawarc data.
2022-06-10 12:12:26 +02:00
Ken Brown 07cf763095 Cygwin: restore two instances of __stdcall
In the previous commit, __stdcall was removed from _dll_crt0 in
winsup.h and dcrt0.cc but not in lib/cygwin_crt0.c.  For consistency,
restore the first two occurrences of __stdcall.  We could instead
remove it from the declaration in lib/cygwin_crt0.c, but this might
appear to affect binary compatibility, even though it really doesn't.
2022-06-07 13:46:31 -04:00
Ken Brown 30c5411d07 Cygwin: remove most occurrences of __stdcall and __cdecl
These have no effect on x86_64.  Retain a few occurrences of __cdecl
in files imported from other sources.

Also retain all occurrences of WINAPI, even though the latter is
simply a macro that expands to __stdcall.  Most of these occurrences
are associated with Windows API functions, and removing them might
make the code confusing instead of simpler.
2022-06-06 12:00:45 -04:00
Ken Brown cb4b4548c8 Cygwin: remove ntsecapi.h
This was a wrapper for w32api/ntsecapi.h.  It was introduced to fix a
bug that only affected 32-bit Cygwin, so it is no longer needed.
2022-06-06 10:44:01 -04:00
Ken Brown 1f8235f6ba Cygwin: child_info.h: remove declaration of init_child_info
The function was removed long ago, but its declaration remained.
2022-06-06 10:16:48 -04:00
Jon Turney f36dd40275
Cygwin: Drop use of loadlib.h in regtool
Link directly with RegDeleteKeyExW(), available since Vista.

(It's unclear the LoadLibrary wrapper was ever doing anything useful
here, as (i) DLL lookup in PATH was avoided as advapi32 is already
loaded into the process, and (ii) advapi32 is a 'known DLL' which is
only ever loaded from system directory)
2022-06-06 11:21:44 +01:00
Jon Turney f344134a19
Cygwin: Drop pointless loadlib.h includes in utilities
These utilities used to LoadLibrary()/GetProcAddress(), but don't
anymore.
2022-06-06 11:21:43 +01:00
Ken Brown e1ce752a1d Cygwin: remove miscellaneous 32-bit code 2022-05-29 17:54:32 -04:00
Ken Brown b1e304cbd3 Cygwin: remove 32-bit only clipboard code 2022-05-29 17:45:52 -04:00
Ken Brown f6bb8bfaa0 Cygwin: remove some 32-bit only environment code 2022-05-29 17:45:52 -04:00
Ken Brown 3e917daec1 Cygwin: remove some 32-bit only path conversion functions 2022-05-29 17:45:52 -04:00
Ken Brown 2126f966ae Cygwin: remove regparm.h
This file defines the macros __reg1, __reg2, and __reg3, which are
defined to be empty on 64-bit Cygwin.  Remove all occurrences of these
macros.
2022-05-29 17:45:52 -04:00
Ken Brown 2d9b48760c Cygwin: simplify some function names
Remove "32" or "64" from each of the following names: acl32,
aclcheck32, aclfrommode32, aclfrompbits32, aclfromtext32, aclsort32,
acltomode32, acltopbits32, acltotext32, facl32, fchown32, fcntl64,
fstat64, _fstat64, _fstat64_r, ftruncate64, getgid32, getgrent32,
getgrgid32, getgrnam32, getgroups32, getpwuid32, getpwuid_r32,
getuid32, getuid32, initgroups32, lseek64, lstat64, mknod32, mmap64,
setegid32, seteuid32, setgid32, setgroups32, setregid32, setreuid32,
setuid32, stat64, _stat64_r, truncate64.

Remove prototypes and macro definitions of these names.

Remove "#ifndef __INSIDE_CYGWIN__" from some headers so that the new
names will be available when compiling Cygwin.

Remove aliases that are no longer needed.

Include <unistd.h> in fhandler_clipboard.cc for the declarations of
geteuid and getegid.
2022-05-29 17:45:52 -04:00
Ken Brown 7c0de0af97 Cygwin: remove some 32-bit-only function definitions
Remove the definitions of the following: acl, aclcheck, aclfrommode,
aclfrompbits, aclfromtext, aclsort, acltomode, acltopbits, acltotext,
chown, fchown, _fcntl, fstat, _fstat_r, ftruncate, getegid, geteuid, getgid,
getgrent, getgrgid, getgrnam, getgroups, getpwduid, getpwuid,
getpwuid_r, getuid, initgroups, lacl, lacl32, lchown, lseek, lstat,
mknod, mmap, setegid, seteuid, setgid, setgroups, setregid, setreuid,
setuid, stat, _stat_r, truncate.

[For most of these, the corresponding 64-bit entry points are obtained
by exporting aliases.  For example, acl is an alias for acl32, and
truncate is an alias for truncate64.]

Remove the following structs and all code using them (which is 32-bit
only): __stat32, __group16, __flock32, __aclent16_t.

Remove the typedefs of __blkcnt32_t __dev16_t, __ino32_t, which are
used only in code that has been removed.

Put the typedefs of __uid16_t and __gid16_t in one header, instead of
one header if __INSIDE_CYGWIN__ is defined and a different header
otherwise.
2022-05-29 17:45:52 -04:00
Ken Brown 98180795de Cygwin: document last bug fix 2022-05-29 17:42:06 -04:00
Takashi Yano 871ca7ba64 Cygwin: cygheap: Fix the issue of cygwin1.dll in the root directory.
- After the commit 6d898f43, cygwin fails to start if cygwin1.dll
  is placed in the root directory. This patch fixes the issue.
Addresses: https://cygwin.com/pipermail/cygwin/2022-May/251548.html
2022-05-28 23:16:21 +09:00
Brian Inglis 9af21ada23 fhandler_proc.cc(format_proc_cpuinfo): add Linux 5.18 cpuinfo flags
0x80000008:0 EBX:31 brs		AMD Branch Sampling available
0x80000022:0 EAX:0  perfmon_v2	AMD ExtPerfMonAndDbg Performance Monitoring Version 2
0x00000021:0 EBX|EDX|ECX=="IntelTDX    " tdx_guest Intel Trust Domain Extensions- Guest Support
2022-05-25 13:11:40 -04:00
Ken Brown 2f8ba40046 Cygwin: fix mknod (64-bit only)
The current definition of mknod in syscalls.cc has a third argument of
type __dev16_t instead of dev_t.  Fix this on 64-bit Cygwin by making
the existing mknod 32-bit only and then exporting mknod as an alias
for mknod32.  (No fix is needed on 32-bit because mknod is redirected
to mknod32 via NEW_FUNCTIONS in Makefile.am.)

Addresses: https://cygwin.com/pipermail/cygwin-developers/2022-May/012589.html
2022-05-23 08:16:40 -04:00
Corinna Vinschen 1b86dd7d8c Cygwin: make sure exec'ed process exists early in process list
killpg(pgid, 0) (or kill_pgrp(pgid, si_signo=0), in signal.cc)
fails (returns -1) even when there is a process in the process
group pgid, if the process is in the middle of spawnve(), see

  https://cygwin.com/pipermail/cygwin/2022-May/251479.html

When exec'ing a process the assumption is that the exec'ed process creates its
own symlink (in pinfo::thisproc() in pinfo.cc). If the exec'ing process
calls NtClose on it's own winpid symlink, but the exec'ed process didn't
progress enough into initialization, there's a slim chance that neither
the exec'ing process, nor the exec'ed process has a winpid symlink
attached.

Always create the winpid symlink in spawn.cc, even for exec'ed Cygwin
processes.  Make sure to dup the handle into the new process, and stop
creating the winpid symlink in exec'ed processes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-19 10:46:41 +02:00
Takashi Yano 1559f7f458 Cygwin: Use two pass parse for tlsoffsets generation.
- The commit "Cygwin: fix new sigfe.o generation in optimized case"
  fixed the wrong tlsoffsets generation by adding -O0 to compile
  options. Current gentls_offsets expects entry of "start_offset"
  is the first entry in the assembler code. However, without -O0,
  entry of "start_offset" goes to the last entry for some reason.
  Currently, -O0 can prevents assembler code from reversing the
  order of the entries, however, there is no guarantee that it will
  retain the order of the entries in the future.

  This patch makes gentls_offsets parse the assembler code in the
  two pass to omit -O0 option dependency.
2022-05-19 04:03:16 +09:00
Sebastian Huber 4a00cbcefe Cygwin: Enable backward binary compatibility 2022-05-18 07:45:09 +02:00
Corinna Vinschen 93bea9f538 Cygwin: drop i686 exception handling
Leave x86_64 CPU-specific code and #error out when trying to build
for another target. Access special registers CPU-agnostic.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-17 14:12:32 +02:00
Corinna Vinschen 830a9b707c Cygwin: drop PROCESSOR_ARCHITECTURE_INTEL from uname
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-16 18:17:06 +02:00
Corinna Vinschen 83f8e24f0b Cygwin: document why we can't drop the _pei386_runtime_relocator dummy
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-16 18:17:06 +02:00
Corinna Vinschen b3b9e231de Cygwin: drop i386 refs from header files where source isn't affected
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-05-16 18:17:06 +02:00