- 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.
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).
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.htmlhttps://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.
For _REENT_GLOBAL_STDIO_STREAMS, lock/unlock all FILE objects. In the
repository, this function is only used by Cygwin during process forks. Since
Cygwin enabled _REENT_GLOBAL_STDIO_STREAMS recently, without this fix no FILE
object at all was locked.
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.
Do not initialize __sglue with the FILE objects of _GLOBAL_REENT to avoid a
double use in the !_REENT_SMALL and !_REENT_GLOBAL_STDIO_STREAMS configurations
which didn't use a thread-specific reentrancy structure.
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.
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.
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)
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.
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.
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
The __sFILE::_lock member is present if __SINGLE_THREAD__ is not defined. In
this case, it is initialized in __sfp(). It is a bug to do it sometimes also
in std().
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>
- 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.
The compiler warns the double parentheses are unnecessary in some
target, and cause fail cases when doing some testcases in regression.
gcc/testsuite/g++.dg/warn/Wstringop-overflow-6.C
Remove the unnecessary parentheses will fix it. See more details in
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85775
Same like in commit 0542583129,
Author: Maxim Blinov <maxim.blinov@embecosm.com>
Date: Thu Jul 22 22:41:42 2021 +0100
Remove unneccesary parenthesis around declarator
Thanks for Sebastian Huber's remind!
For the exit processing only members of _GLOBAL_REENT were used by default. If
the _REENT_GLOBAL_ATEXIT option was enabled, then the data structures were
provided through dedicated global objects. Make this option the default.
Remove the option. Rename struct _reent members _atexit and _atexit0 to
_reserved_6 and _reserved_7, respectively. Provide them only if
_REENT_BACKWARD_BINARY_COMPAT is defined.
Rename struct _reent::_new::_unused members _nextf and _nmalloc to _reserved_3
and _reserved_4, respectively. Rename struct _reent::_new member _unused to
_reserved_5. Provide them only if _REENT_BACKWARD_BINARY_COMPAT is defined.
Remove unused _N_LISTS define.
Add the --enable-newlib-reent-binary-compat configure option. This option is
disabled by default. If enabled, then unused members in struct _reent are
preserved to maintain the structure layout.
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>