adding <target>_LDFLAGS overrides AM_LDFLAGS and thus fails to
build cygcheck and strace statically. Fix it.
Fixes: 8d318bf142 ("Cygwin: disable high-entropy VA for cygcheck and strace")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Previously, fhandler_dev_dsp (OSS) has a problem that fcntl() does
not take effect at all. This patch fixes the issue.
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Eventually move user heap initialization to memory_init.
The call order is not changed. Drop a now useless comment.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The new loop in open_shared has a subtil performance problem.
Next_address is bumped only if mapping at this address
failed. Every subsequent call to open_shared has a high probability
having to call MapViewOfFileEx twice, because next_address is still
set to the address of the last successful mapping.
Avoid this by bumping next_address every time.
While at it, fix a comment.
Fixes: dc0fe7742b ("Cygwin: open_shared: try harder allocating a shared region")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This implements a set of vectorized math routines to be used by the
compiler auto-vectorizer. Versions for vectors with 2 lanes up to
64 lanes (in powers of 2) are provided.
These routines are based on the scalar versions of the math routines in
libm/common, libm/math and libm/mathfp. They make extensive use of the GCC
C vector extensions and GCN-specific builtins in GCC.
With the previous commit 9ddd48ee1b ("Cygwin: /proc/<PID>/maps:
print real shared region addresses"), the real addresses of
the standard shared regions (cygwin, user, myself, shared console)
are read from the printed process itself. We don't need fixed
addresses anymore, so drop the definitions and simplify open_shared.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
So far, the addresses printed for the shared regions of a process
were faked. The assumption was that the shared regions are always
in the same place in all processes, so we just printed the addresses
of the current process. This is no safe bet. The only safe bet is
the address of the cygheap. So keep track of the addresses in the
cygheap and read the addresses from the cygheap of the observed
processes. Add output for the shared console.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
It's not a good idea to enable high-entropy VA for tools loading the
Cygwin DLL dynamically. The addresses used by HEVA tend to collide with
fixed address areas managed by Cygwin.
Fixes: 60675f1a7e ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
For fixed regions (cygwin/user/myself/shared console), try fixed
address first. Fallback to non-fixed region. Don't even try fixed
address if the Cygwin DLL gets dynamically loaded.
For non-fixed regions, try to allocate in a loop within the area
from SHARED_REGIONS_ADDRESS_LOW to SHARED_REGIONS_ADDRESS_HIGH.
Fixes: 60675f1a7e ("Cygwin: decouple shared mem regions from Cygwin DLL")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Fix comments accordingly.
This is in preparation for a change in open_shared, handling shared
regions more cleanly.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
For ages, open_shared uses the shared_locations parameter as
output to indicate if the mapping for a shared region has been
created or just opened. Split this into two parameters. Use
the shared_locations parameter as input only, return the creation
state of the mapping in a bool reference parameter.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The number of args multiplied by 4 was only required for
32 bit x86 to construct the symbol name correctly. Drop it.
In the assembler code, split the numerical values for "notimp"
and "err" into half words for cleaner layout.
Fix description accordingly.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
vmstat from proc-ps-4.0.x prints "Unable to create system stat structure"
if the /proc/cpuinfo output fails to contain topology info. While
Linux always prints topology info if the kernel has been built with
CONFIG_SMP, Cygwin only prints topology info if the CPU is known to
be multi-core (i. e., the HT feature flag is set).
Fix that by printing topology info all the time, even for single-core
CPUs.
Fixes: e0d48debed ("Fix /proc/cpuinfo topology and cache size info")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
- add '-' option
- make group argument optional
- drop ability to take a numerical group argument
- simplify usage output to bare minimum
- Add manpage and documentation
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This tool allows to change the primary group for a child process.
The new primary group MUST be part of the supplementary group list
of newgrp's user token.
The command started as child process is specified on the command line.
If it's missing, start the user's default shell with the new primary
group.
TODO: Implement '-' option.
Add command description to documentation.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Note that cygserver must be run using the same cygwin1.DLL as test
programs, as they communicate over a named pipe whose name contains the
'installation key' (which is a hash of the cygwin1.dll's path).
We run cygserver via 'cmd' to avoid the special code which handles a
cygwin parent process starting a cygwin child process, which assumes the
same version of cygwin in both.
Default mutex type is PTHREAD_MUTEX_NORMAL.
Attempting to unlock an unowned mutex of that type is specified as
undefined behaviour, not returning EPERM.
mutex7e verfies that attempting to unlock an unowned mutex of type
PTHREAD_MUTEX_ERRORCHECK returns EPERM.
Build all the testcase executables directly using automake, rather than
passing the compiler information into DejaGnu to have it build them.
(This means you get build avoidance for these executables, so they only
get built once, rather than every time you run the test, and makes it
much easier to run them in isolatation against the installed Cygwin,
which is really nice to have when trying to fix broken tests...)
Rename the 'cygrun' subdirectory to 'mingw', and build all the testsuite
MinGW executables there.
Drop sample-miscompile.c (testing that compile failure is detected is
perhaps useful, but not here...)
objdir isn't a predefined output variable in Automake (any more?), so
this was just using the absolute path /testsuite as the test's temporary
directory. Use builddir instead.
So far the capability bits were stored in the .cygwin_dll_common
R/W section because we overwrite the is_server bit. Just don't.
Move the bit to class wincapc instead and define all wincaps
bitfields const.
Fixes: 8937c103ed ("* wincap.cc (all wincaps): Store in .cygwin_dll_common section same as wincap. Add comment to explain why.")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
The libgloss port has been reaching back into newlib internals for a
single header whose contents have been frozen for almost a decade.
To break this backwards libgloss->newlib dependency, move the acle
header to the srcroot include/ so everyone can use the same copy.
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags. Save the PAC value in the jump buffer so that
longjmp can only return to the authenticated location.
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.
This patch enables PACBTI for all relevant variants of strlen:
* Newlib for armv8.1-m.main+pacbti
* Newlib for armv8.1-m.main+pacbti+mve
* Newlib-nano
Add function prologue/epilogue to conditionally add BTI landing pads
and/or PAC code generation & authentication instructions depending on
compilation flags.
This patch enables PACBTI for all relevant variants of strcmp:
* Newlib for armv8.1-m.main+pacbti
* Newlib for armv8.1-m.main+pacbti+mve
* Newlib-nano
Augment the arm_asm.h header file to simplify function prologues and
epilogues whilst adding support for PACBTI enablement via macros for
hand-written assembly functions. For PACBTI, both prologues/epilogues
as well as cfi-related directives are automatically amended
accordingly, depending on the compile-time mbranch-protection argument
values.
It defines the following preprocessor macros:
* HAVE_PAC_LEAF: Indicates whether pac-signing has been requested for
leaf functions.
* PAC_LEAF_PUSH_IP: Whether leaf functions should push the pac code
to the stack irrespective of whether the ip register is clobbered in
the function or not.
* STACK_ALIGN_ENFORCE: Whether a dummy register should be added to
the push list as necessary in the prologue to ensure stack
alignment preservation at the start of assembly function. The
epilogue behavior is likewise affected by this flag, ensuring any
pushed dummy registers also get popped on function return.
It also defines the following assembler macros:
* prologue: In addition to pushing any callee-saved registers onto
the stack, it generates any requested pacbti instructions.
Pushed registers are specified via the optional `first', `last',
`push_ip' and `push_lr' macro argument parameters.
when a single register number is provided, it pushes that
register. When two register numbers are provided, they specify a
rage to save. If push_ip and/or push_lr are non-zero, the
respective registers are also saved. Stack alignment is requested
via the `align` argument, which defaults to the value of
STACK_ALIGN_ENFORCE, unless manually overridden.
For example:
prologue push_ip=1 -> push {ip}
prologue push_ip=1, align8=1 -> push {r2, ip}
prologue push_ip=1, push_lr=1 -> push {ip, lr}
prologue 1 -> push {r1}
prologue 1, align8=1 -> push {r0, r1}
prologue 1 push_ip=1 -> push {r1, ip}
prologue 1 4 -> push {r1-r4}
prologue 1 4 push_ip=1 -> push {r1-r4, ip}
* epilogue: pops registers off the stack and emits pac key signing
instruction, if requested. The `first', `last', `push_ip',
`push_lr' and `align' function as per the prologue macro,
generating pop instead of push instructions.
Stack alignment is enforced via the following helper macro
call-chain:
{prologue|epilogue} ->_align8 -> _preprocess_reglist ->
_preprocess_reglist1 -> {_prologue|_epilogue}
Finally, the necessary cfi directives for adding debug information
to prologue and epilogue are generated via the following macros:
* cfisavelist - prologue macro helper function, generating
necessary .cfi_offset directives associated with push instruction.
Therefore, the net effect of calling `prologue 1 2 push_ip=1' is
to generate the following:
push {r1-r2, ip}
.cfi_adjust_cfa_offset 12
.cfi_offset 143, -4
.cfi_offset 2, -8
.cfi_offset 1, -12
* cfirestorelist - epilogue macro helper function, emitting
.cfi_restore instructions prior to resetting the cfa offset. As
such, calling `epilogue 1 2 push_ip=1' will produce:
pop {r1-r2, ip}
.cfi_register 143, 12
.cfi_restore 2
.cfi_restore 1
.cfi_def_cfa_offset 0
_pinfo::ctty has two special values other than the device id of
the allocated ctty:
-1: CTTY is not initialized yet. Can be associated with the TTY
which is associated with the session leader.
-2: CTTY has been released by setsid(). Can be associate only with
new TTY which is not associated with any other session as CTTY,
but cannot be associate with the TTYs already associated with
other sessions.
This patch adds the comments in some source files.
Suggested-by: Corinna Vinschen <corinna@vinschen.de>
Signedoff-by: Takashi Yano <takashi.yano@nifty.ne.jp>
The commit 25c4ad6ea5 did not fix the CTTY behavior enough. For
example, in the following test case, TTY will be associated as
a CTTY on the second open() call even though the TTY is already
CTTY of another session. This patch fixes the issue.
#include <unistd.h>
#include <sys/fcntl.h>
int main()
{
if (fork () == 0) {
char *tty = ttyname(0);
int fd;
setsid();
fd = open(tty, O_RDWR);
close(fd);
fd = open(tty, O_RDWR);
usleep (60000000L);
}
return 0;
}
Fixes: 25c4ad6ea5 ("Cygwin: pinfo: Align CTTY behavior to the
statement of POSIX.")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
After the commit 30add3e6b3, the problem:
https://cygwin.com/pipermail/cygwin/2022-December/252759.html
occurs rarely. It seems that myself_pinfo should be initialized
where the timing before child_copy() and after cygheap allocation.
This patch moves the initialization there.
Fixes: 30add3e6b3 ("Cygwin: exec: don't access cygheap before it's
initialized")
Reported-by: Brian Inglis <Brian.Inglis@Shaw.ca>
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
The code computing the mask of pending signals used the per-queued
signal TLS pointer without checking it for NULL. Fix this by using
the process-wide signal mask in that case.
Fixes: 195169186b ("Cygwin: wait_sig: allow to compute process-wide mask of pending signals")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
Since 4e7817498e, we're just running the tests against the installed
DLL. We're arranging to put the build directory on the path, but since
it doesn't contain cygwin1.dll (since it's built with a different name
and renamed on installation), that doesn't have any effect.
Arrange to place the just-built DLL into a directory which the testsuite
can place on it's path (while running the test, but not while compiling
it).
Also fix any remaining references to cygwin0.dll in testsuite,
documentation and comments.
Fixes: 4e7817498e ("Cygwin: Makefile: Drop all the "test dll" considerations")