]> sourceware.org Git - newlib-cygwin.git/log
newlib-cygwin.git
2 years agoCygwin: cygtls: drop useless alignment directives
Corinna Vinschen [Mon, 5 Sep 2022 17:49:11 +0000 (19:49 +0200)]
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: dcab768cb93e ("Cygwin: cygtls: fix context alignment")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoDon't allocate another header when merging chunks
Torbjörn SVENSSON [Tue, 30 Aug 2022 13:56:26 +0000 (15:56 +0200)]
Don't allocate another header when merging chunks

In the nano version of malloc, when the last chunk is to be extended,
there is no need to acount for the header again as it's already taken
into account in the overall "alloc_size" at the beginning of the
function.

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 years agoUsed chunk needs to be removed from free_list
Torbjörn SVENSSON [Tue, 30 Aug 2022 13:56:25 +0000 (15:56 +0200)]
Used chunk needs to be removed from free_list

When using nano malloc and the remaning heap space is not big enough to
fullfill the allocation, malloc will attempt to merge the last chunk in
the free list with a new allocation in order to create a bigger chunk.
This is successful, but the chunk still remains in the free_list, so
any later call to malloc can give out the same region without it first
being freed.

Possible sequence to verify:

void *p1 = malloc(3000);
void *p2 = malloc(4000);
void *p3 = malloc(5000);
void *p4 = malloc(6000);
void *p5 = malloc(7000);
free(p2);
free(p4);
void *p6 = malloc(35000);
free(p6);
void *p7 = malloc(42000);
void *p8 = malloc(32000);

Without the change, p7 and p8 points to the same address.
Requirement, after malloc(35000), there is less than 42000 bytes
available on the heap.

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 years agoFix some Coverity Scan errors.
Jeff Johnston [Wed, 31 Aug 2022 19:18:08 +0000 (15:18 -0400)]
Fix some Coverity Scan errors.

2 years agoRestore _lock initialization in non-single threaded mode
Torbjörn SVENSSON [Tue, 30 Aug 2022 13:54:53 +0000 (15:54 +0200)]
Restore _lock initialization in non-single threaded mode

When __SINGLE_THREAD__ is not defined, stdin, stdout and stderr needs
to have their _lock instance initialized. The __sfp() method is not
invoked for the 3 mentioned fds thus, the std() method needs to handle
the initialization of the lock.

This is more or less a revert of 382550072b49430f8c69adee937a0ba07bd385e6

Contributed by STMicroelectronics

Signed-off-by: Torbjörn SVENSSON <torbjorn.svensson@foss.st.com>
2 years agoCygwin: testsuite: Add x86_64 code to "dynamically load cygwin" test
Jon Turney [Thu, 26 Nov 2020 16:50:43 +0000 (16:50 +0000)]
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

2 years agoCygwin: testsuite: In pathconf01 use the temporary directory instead of "/tmp"
Jon Turney [Fri, 27 Nov 2020 15:18:37 +0000 (15:18 +0000)]
Cygwin: testsuite: In pathconf01 use the temporary directory instead of "/tmp"

In pathconf01 use the temporary directory, instead of "/tmp" (which may not exist).

2 years agoCygwin: testsuite: Fix size of write to temporary file to be mmap()ed
Jon Turney [Thu, 26 Nov 2020 16:11:44 +0000 (16:11 +0000)]
Cygwin: testsuite: Fix size of write to temporary file to be mmap()ed

See ltp commit 91361378

2 years agoCygwin: testsuite: Fix TEST_RETURN for 64-bit
Jon Turney [Thu, 26 Nov 2020 15:33:44 +0000 (15:33 +0000)]
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.

2 years agoCygwin: testsuite: Remove passing tests from XFAIL list
Jon Turney [Wed, 25 Nov 2020 14:27:28 +0000 (14:27 +0000)]
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.

2 years agoCygwin: testsuite: Don't write coredump in a child which is expected to segfault
Jon Turney [Sat, 17 Oct 2020 20:47:48 +0000 (21:47 +0100)]
Cygwin: testsuite: Don't write coredump in a child which is expected to segfault

2 years agoCygwin: cygtls: fix context alignment
Corinna Vinschen [Mon, 29 Aug 2022 13:18:53 +0000 (15:18 +0200)]
Cygwin: cygtls: fix context alignment

A hang was encountered, apparently triggered by commit 63b503916d42,
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>
2 years agoCygwin: fork: fix a potential hang in fork
Corinna Vinschen [Mon, 29 Aug 2022 10:25:24 +0000 (12:25 +0200)]
Cygwin: fork: fix a potential hang in fork

while debugging a problem introduced in commit
63b503916d42 ("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: 44a79a6eca3d ("Cygwin: convert malloc lock to SRWLOCK")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agolibgloss: riscv: Convert to non-recursive automake
Palmer Dabbelt [Tue, 23 Aug 2022 23:12:56 +0000 (16:12 -0700)]
libgloss: riscv: Convert to non-recursive automake

PR 29515 points out our documentation builds are broken, let's just move
over to the new non-recursive builds.

Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
2 years agoCygwin: cwd: use SRWLOCK instead of muto
Corinna Vinschen [Tue, 23 Aug 2022 09:58:38 +0000 (11:58 +0200)]
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>
2 years agoCygwin: mmap: use SRWLOCK instead of muto
Corinna Vinschen [Tue, 23 Aug 2022 09:14:12 +0000 (11:14 +0200)]
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>
2 years agoCygwin: tls_pathbuf: Use Windows heap
Corinna Vinschen [Tue, 23 Aug 2022 08:59:18 +0000 (10:59 +0200)]
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>
2 years agoFix problem with _newlib_version.h not being filled in correctly
Jeff Johnston [Mon, 22 Aug 2022 21:54:43 +0000 (17:54 -0400)]
Fix problem with _newlib_version.h not being filled in correctly

2 years agoCygwin: smallprint.cc: Drop HEAP_ZERO_MEMORY
Corinna Vinschen [Mon, 22 Aug 2022 15:58:53 +0000 (17:58 +0200)]
Cygwin: smallprint.cc: Drop HEAP_ZERO_MEMORY

Leftover from testing.

Reported-by: Noel Grandin <noelgrandin@gmail.com>
Fixes: 07ec40170a32 ("Cygwin: smallprint.cc: Convert tmpbuf to lockless")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: posix_timer: fix formatting
Corinna Vinschen [Mon, 22 Aug 2022 12:50:54 +0000 (14:50 +0200)]
Cygwin: posix_timer: fix formatting

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: push missing change to debug.h
Corinna Vinschen [Mon, 22 Aug 2022 12:53:11 +0000 (14:53 +0200)]
Cygwin: push missing change to debug.h

Fixes: 48a210a457c5 ("Cygwin: debugging: convert muto to SRWLOCK")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: debugging: convert muto to SRWLOCK
Corinna Vinschen [Mon, 22 Aug 2022 12:38:49 +0000 (14:38 +0200)]
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>
2 years agoCygwin: shm: Convert muto into SRWLOCK and avoid overlocking
Corinna Vinschen [Mon, 22 Aug 2022 12:28:11 +0000 (14:28 +0200)]
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>
2 years agoCygwin: authz: Use dedicated locks per datastructure
Corinna Vinschen [Mon, 22 Aug 2022 12:25:05 +0000 (14:25 +0200)]
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>
2 years agoCygwin: spawn: don't overallocate SECURITY_ATTRIBUTES buffer
Corinna Vinschen [Mon, 22 Aug 2022 10:37:31 +0000 (12:37 +0200)]
Cygwin: spawn: don't overallocate SECURITY_ATTRIBUTES buffer

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: smallprint.cc: Convert tmpbuf to lockless
Corinna Vinschen [Mon, 22 Aug 2022 10:01:15 +0000 (12:01 +0200)]
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>
2 years agoCygwin: profiler: Fix linking when building with -DDEBUGGING
Corinna Vinschen [Sat, 20 Aug 2022 19:14:57 +0000 (21:14 +0200)]
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>
2 years agoCygwin: wchar.h: Fix comment
Corinna Vinschen [Sat, 20 Aug 2022 18:27:37 +0000 (20:27 +0200)]
Cygwin: wchar.h: Fix comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: sigproc.cc: drop Static macro, use explicit NO_COPY instead
Corinna Vinschen [Fri, 19 Aug 2022 19:55:09 +0000 (21:55 +0200)]
Cygwin: sigproc.cc: drop Static macro, use explicit NO_COPY instead

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop __fastcall calling convention specifiers
Corinna Vinschen [Fri, 19 Aug 2022 19:52:45 +0000 (21:52 +0200)]
Cygwin: drop __fastcall calling convention specifiers

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: miscfuncs.h: fix comment
Corinna Vinschen [Fri, 19 Aug 2022 13:46:27 +0000 (15:46 +0200)]
Cygwin: miscfuncs.h: fix comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoSH: Do not build syscalls if option provided
Yilin Sun via Newlib [Sat, 13 Aug 2022 16:22:50 +0000 (00:22 +0800)]
SH: Do not build syscalls if option provided

This patch makes syscalls for SH architecture respecting the global option
"--disable-newlib-supplied-syscalls". This is useful when a bare-metal
toolchain is needed.

Signed-off-by: Yilin Sun <imi415@imi.moe>
2 years agonewlocale: fix crash when trying to write to __C_locale
Corinna Vinschen [Thu, 11 Aug 2022 17:27:48 +0000 (19:27 +0200)]
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>
2 years agoCygwin: move POSIX semaphore API functions to posix_ipc.cc
Corinna Vinschen [Wed, 10 Aug 2022 16:11:57 +0000 (18:11 +0200)]
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>
2 years agoCygwin: rename CygwinCreateThread to create_posix_thread
Corinna Vinschen [Wed, 10 Aug 2022 15:40:06 +0000 (17:40 +0200)]
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>
2 years agoCygwin: mm/malloc_wrapper.cc: fix a comment
Corinna Vinschen [Wed, 10 Aug 2022 14:56:07 +0000 (16:56 +0200)]
Cygwin: mm/malloc_wrapper.cc: fix a comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: move __caller_return_address to mm/malloc_wrapper.cc
Corinna Vinschen [Wed, 10 Aug 2022 15:07:52 +0000 (17:07 +0200)]
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>
2 years agoCygwin: make import_address a static inline function
Corinna Vinschen [Wed, 10 Aug 2022 14:55:04 +0000 (16:55 +0200)]
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>
2 years agoCygwin: make check_invalid_virtual_addr a static inline function
Corinna Vinschen [Wed, 10 Aug 2022 16:03:05 +0000 (18:03 +0200)]
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>
2 years agoCygwin: move memory management sources into mm subdir
Corinna Vinschen [Wed, 10 Aug 2022 14:09:39 +0000 (16:09 +0200)]
Cygwin: move memory management sources into mm subdir

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop building modelibs
Corinna Vinschen [Wed, 10 Aug 2022 14:28:12 +0000 (16:28 +0200)]
Cygwin: drop building modelibs

They never worked as desired anyway. Use the object files.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: fix return value of symlink_info::check
Ken Brown [Tue, 9 Aug 2022 19:14:07 +0000 (15:14 -0400)]
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

2 years agoCygwin: pthreads: merge pthread.cc into thread.cc
Corinna Vinschen [Tue, 9 Aug 2022 20:48:43 +0000 (22:48 +0200)]
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>
2 years agoCygwin: stop exporting _alloca
Corinna Vinschen [Mon, 8 Aug 2022 16:16:09 +0000 (18:16 +0200)]
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>
2 years agoCygwin: fold common.din and x86_64.din into cygwin.din
Corinna Vinschen [Mon, 8 Aug 2022 15:47:46 +0000 (17:47 +0200)]
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>
2 years agoCygwin: move mcountFunc.S to x86_64 target dir
Corinna Vinschen [Mon, 8 Aug 2022 14:48:57 +0000 (16:48 +0200)]
Cygwin: move mcountFunc.S to x86_64 target dir

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: x86_64: add wmemset assembler entry point
Corinna Vinschen [Mon, 8 Aug 2022 14:49:52 +0000 (16:49 +0200)]
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>
2 years agoCygwin: split out x86_64 memset/memcpy functions
Corinna Vinschen [Mon, 8 Aug 2022 14:25:41 +0000 (16:25 +0200)]
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>
2 years agoCygwin: fhandler/null.cc: remove redundant includes topic/split_source_dir github/topic/split_source_dir
Corinna Vinschen [Fri, 5 Aug 2022 09:51:03 +0000 (11:51 +0200)]
Cygwin: fhandler/null.cc: remove redundant includes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: update the "dirs" variable in Makefile.am
Ken Brown [Thu, 4 Aug 2022 20:59:16 +0000 (16:59 -0400)]
Cygwin: update the "dirs" variable in Makefile.am

Add the new fhandler and sec subdirs.

2 years agoCygwin: Reorganize cygwin source dir
Corinna Vinschen [Thu, 4 Aug 2022 14:58:50 +0000 (16:58 +0200)]
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>
2 years agoCygwin: mount_info::get_mounts_here: alloc temp mountpoint info on cygheap
Corinna Vinschen [Fri, 5 Aug 2022 10:01:45 +0000 (12:01 +0200)]
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>
2 years agoCygwin: drop last usage of RtlCreateUnicodeStringFromAsciiz
Corinna Vinschen [Fri, 5 Aug 2022 09:45:49 +0000 (11:45 +0200)]
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>
2 years agoCygwin: pty: Fix a small bug in is_console_app().
Takashi Yano [Fri, 5 Aug 2022 08:53:16 +0000 (17:53 +0900)]
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.

2 years agoCygwin: use locale-aware conversion to UNICODE_STRING checking mount points
Corinna Vinschen [Thu, 4 Aug 2022 21:48:19 +0000 (23:48 +0200)]
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>
2 years agoCygwin: drop all usages of NTAPI
Corinna Vinschen [Thu, 4 Aug 2022 20:13:50 +0000 (22:13 +0200)]
Cygwin: drop all usages of NTAPI

and drop unused prototypes from ntdll.h.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop all usages of WINAPI
Corinna Vinschen [Thu, 4 Aug 2022 19:16:32 +0000 (21:16 +0200)]
Cygwin: drop all usages of WINAPI

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: clock.cc: Drop redundant Windows prototypes
Corinna Vinschen [Thu, 4 Aug 2022 19:13:15 +0000 (21:13 +0200)]
Cygwin: clock.cc: Drop redundant Windows prototypes

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop obsolete _cygwin_noncygwin_dll_entry entry point
Corinna Vinschen [Thu, 4 Aug 2022 19:02:11 +0000 (21:02 +0200)]
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>
2 years agoCygwin: syscalls.cc: remove ".dll" from blessed_executable_suffixes
Ken Brown [Wed, 3 Aug 2022 20:45:23 +0000 (16:45 -0400)]
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.]

2 years agoCygwin: Drop outdated IsWow64Process2 prototype
Corinna Vinschen [Thu, 4 Aug 2022 18:55:52 +0000 (20:55 +0200)]
Cygwin: Drop outdated IsWow64Process2 prototype

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop outdated __MINGW64_VERSION_MAJOR checks
Corinna Vinschen [Thu, 4 Aug 2022 18:55:25 +0000 (20:55 +0200)]
Cygwin: drop outdated  __MINGW64_VERSION_MAJOR checks

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop __stdcall usage
Corinna Vinschen [Thu, 4 Aug 2022 18:53:59 +0000 (20:53 +0200)]
Cygwin: drop __stdcall usage

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: syscalls.cc: drop masking macros for standard IO functions
Corinna Vinschen [Thu, 4 Aug 2022 18:32:36 +0000 (20:32 +0200)]
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>
2 years agoCygwin: Drop export aliases and masking macros for stdio64 functions
Corinna Vinschen [Thu, 4 Aug 2022 15:30:48 +0000 (17:30 +0200)]
Cygwin: Drop export aliases and masking macros for stdio64 functions

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: create sparse errmap array
Corinna Vinschen [Thu, 4 Aug 2022 13:16:23 +0000 (15:16 +0200)]
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>
2 years agocacosh: Use approximation for large input.
Markus Mützel [Thu, 4 Aug 2022 10:55:52 +0000 (12:55 +0200)]
cacosh: Use approximation for large input.

Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agocasinh: Use approximation for large input.
Markus Mützel [Thu, 4 Aug 2022 10:55:17 +0000 (12:55 +0200)]
casinh: Use approximation for large input.

Signed-off-by: Martin Storsjö <martin@martin.st>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: net.cc: convert wsock_errmap into a simple array of error codes
Corinna Vinschen [Thu, 4 Aug 2022 09:45:58 +0000 (11:45 +0200)]
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>
2 years agoCygwin: net.cc: create own type host_errmap_t for host_errmap
Corinna Vinschen [Thu, 4 Aug 2022 09:37:58 +0000 (11:37 +0200)]
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>
2 years agoCygwin: net.cc: constify gai_errmap
Corinna Vinschen [Thu, 4 Aug 2022 09:36:24 +0000 (11:36 +0200)]
Cygwin: net.cc: constify gai_errmap

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: fix/drop a few comments
Corinna Vinschen [Wed, 3 Aug 2022 16:14:39 +0000 (18:14 +0200)]
Cygwin: fix/drop a few comments

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: __WORDSIZE: Drop 32 bit considerations
Corinna Vinschen [Wed, 3 Aug 2022 15:48:20 +0000 (17:48 +0200)]
Cygwin: __WORDSIZE: Drop 32 bit considerations

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_DLL_EPOCH
Corinna Vinschen [Wed, 3 Aug 2022 14:16:14 +0000 (16:16 +0200)]
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>
2 years agoCygwin: drop unused CYGWIN_VERSION_CYGWIN_CONV macro
Corinna Vinschen [Wed, 3 Aug 2022 14:09:00 +0000 (16:09 +0200)]
Cygwin: drop unused CYGWIN_VERSION_CYGWIN_CONV macro

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: version.h: document API_VERSION of the first 64 bit build
Corinna Vinschen [Wed, 3 Aug 2022 14:04:42 +0000 (16:04 +0200)]
Cygwin: version.h: document API_VERSION of the first 64 bit build

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_USE_PSEUDO_RELOC_IN_DLL
Corinna Vinschen [Wed, 3 Aug 2022 14:01:29 +0000 (16:01 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_USE_PSEUDO_RELOC_IN_DLL

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE
Corinna Vinschen [Wed, 3 Aug 2022 13:59:37 +0000 (15:59 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_CTYPE

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ
Corinna Vinschen [Wed, 3 Aug 2022 13:57:30 +0000 (15:57 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_IFREQ

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES
Corinna Vinschen [Wed, 3 Aug 2022 13:53:41 +0000 (15:53 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_WINSOCK1_VALUES

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR
Corinna Vinschen [Wed, 3 Aug 2022 13:52:07 +0000 (15:52 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_USING_ANCIENT_MSGHDR

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop unused CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES macro
Corinna Vinschen [Wed, 3 Aug 2022 13:50:52 +0000 (15:50 +0200)]
Cygwin: drop unused CYGWIN_VERSION_CHECK_FOR_USING_BIG_TYPES macro

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK
Corinna Vinschen [Wed, 3 Aug 2022 13:48:56 +0000 (15:48 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_CHECK_FOR_OLD_O_NONBLOCK

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop unused CYGWIN_VERSION_CHECK_FOR_S_IEXEC macro
Corinna Vinschen [Wed, 3 Aug 2022 13:39:14 +0000 (15:39 +0200)]
Cygwin: drop unused CYGWIN_VERSION_CHECK_FOR_S_IEXEC macro

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_OLD_STDIO_CRLF_HANDLING
Corinna Vinschen [Wed, 3 Aug 2022 13:38:11 +0000 (15:38 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_OLD_STDIO_CRLF_HANDLING

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_DLL_MALLOC_ENV
Corinna Vinschen [Wed, 3 Aug 2022 13:35:07 +0000 (15:35 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_DLL_MALLOC_ENV

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop macro and code for CYGWIN_VERSION_DLL_IS_OLD_TERMIOS
Corinna Vinschen [Wed, 3 Aug 2022 13:33:58 +0000 (15:33 +0200)]
Cygwin: drop macro and code for CYGWIN_VERSION_DLL_IS_OLD_TERMIOS

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: drop requirement to build newlib's stdio64
Corinna Vinschen [Wed, 3 Aug 2022 11:41:35 +0000 (13:41 +0200)]
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>
2 years agoCygwin: path: Make some symlinks to /cygdrive/* work.
Takashi Yano [Mon, 1 Aug 2022 00:02:23 +0000 (09:02 +0900)]
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

2 years agoCygwin: console: Modify ConEmu cygwin connector hook.
Takashi Yano [Mon, 1 Aug 2022 22:42:53 +0000 (07:42 +0900)]
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.

2 years agoCygwin: pty: Treat *.bat and *.cmd as a non-cygwin console app.
Takashi Yano [Sun, 31 Jul 2022 08:42:00 +0000 (17:42 +0900)]
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.

2 years agoCygwin: console: Avoid accessing NULL pointer via cygheap->ctty.
Takashi Yano [Fri, 29 Jul 2022 12:40:18 +0000 (21:40 +0900)]
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.

2 years agoCygwin: Set threadnames with SetThreadDescription()
Jon Turney [Thu, 19 May 2022 16:27:39 +0000 (17:27 +0100)]
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

2 years agoCygwin: uname: drop useless support for unsupported CPU arches
Corinna Vinschen [Fri, 29 Jul 2022 10:19:54 +0000 (12:19 +0200)]
Cygwin: uname: drop useless support for unsupported CPU arches

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: gmon.h: drop 32 bit considerations
Corinna Vinschen [Fri, 29 Jul 2022 10:19:18 +0000 (12:19 +0200)]
Cygwin: gmon.h: drop 32 bit considerations

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: profile.c: drop i686 register access
Corinna Vinschen [Fri, 29 Jul 2022 10:17:43 +0000 (12:17 +0200)]
Cygwin: profile.c: drop i686 register access

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2 years agoCygwin: rename __cygwin_environ and drop env redirection via cur_environ()
Corinna Vinschen [Thu, 28 Jul 2022 20:00:40 +0000 (22:00 +0200)]
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>
2 years agoCygwin: perl scripts: drop support for i686
Corinna Vinschen [Thu, 28 Jul 2022 18:05:55 +0000 (20:05 +0200)]
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>
2 years agoCygwin: console: Add workaround for ConEmu cygwin connector.
Takashi Yano [Thu, 28 Jul 2022 12:58:04 +0000 (21:58 +0900)]
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.

2 years agoCygwin: console: Add missing input_mutex guard.
Takashi Yano [Thu, 28 Jul 2022 12:52:39 +0000 (21:52 +0900)]
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.

This page took 0.061914 seconds and 5 git commands to generate.