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
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>
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>
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>
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>
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.]
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>
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>
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>
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>
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>
- 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.