Commit Graph

13520 Commits

Author SHA1 Message Date
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