Commit Graph

21549 Commits

Author SHA1 Message Date
Christian Franke ec5ef42f54 Cygwin: Map ERROR_NO_SUCH_DEVICE and ERROR_MEDIA_CHANGED to ENODEV
If a removable (USB) device is disconnected after opening its raw
device, R/W attempts fail with ERROR_NO_SUCH_DEVICE(433).  If the
raw device of a partition is used, ERROR_MEDIA_CHANGED(1110) is
returned instead.  Both are mapped to ENODEV(19) because <errno.h>
does not offer a value which better matches ERROR_MEDIA_CHANGED.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-24 13:12:37 +01:00
Corinna Vinschen 1f407990d2 Cygwin: add newgrp release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-24 13:12:37 +01:00
Corinna Vinschen 32024ec7f7 Cygwin: newgrp: only allow group from supplementary group list
Windows only allows to set the primary group to a group already
present in the TOKEN_GROUP list.  Cygwin OTOH fakes success at
setgid() time, to allow a subsequent call to setuid() to do
the actual account switching.  To have a sane behaviour in the
command line tool, check group membership and disallow to switch
to groups other than those already present in the user token.

Fixes: 8bd56ec873 ("Cygwin: newgrp: first full version")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-24 13:12:37 +01:00
Corinna Vinschen 08df2e23a7 Cygwin: newgrp: fix invalid usage of argv
Fix an error message accessing argv[1] even after it has been
potentially moved.  Print group name from group DB instead.

Fixes: 8bd56ec873 ("Cygwin: newgrp: first full version")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-24 13:12:37 +01:00
Corinna Vinschen 83967aa244 Cygwin: strptime: add release note
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-21 20:00:59 +01:00
Corinna Vinschen 4fe5b1d77b Cygwin: strptime: fix am/pm handling
The %p format specifier is handled immediately.  It requires
that tm_hour is already set.  This falls flat in case the am/pm
marker preceeds the time specification.  Locales with am/pm
marker preceeding time spec by default exist (e. g. ko_KR).

Also, the code expects that tm_hour might be set to an invalid
value because the %p specifier is used in conjunction with %H.
But this usage is invalid in itself and now catched as error
condition after commit 343a2a5581 ("Cygwin: strptime: make
sure to fail on invalid input digits").

Change the %H/%I/%p handling according to GLibC, i. e.

- fix tm_hour for pm only if the time value has been specified
  as 12 hour time %I, and

- perform the fixup only after the entire input has been scanned.
  This decouples the fixup from the %p position relativ to %I.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-21 20:00:59 +01:00
Corinna Vinschen f0ab27c095 Cygwin: strptime: make sure to fail on invalid input digits
conv_num returns NULL if the input is invalid, e. g., the
numbers are out of range.  However, the code fails to test
this in a lot of places.

Rather than adding checks all over the place, rename conv_num
to __conv_num and create a wrapper macro conv_num to perform
the task of error checking.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-21 20:00:59 +01:00
Corinna Vinschen 12b85bec0e Cygwin: gettimeofday: allow tv NULL pointer
Add a missing check for the struct timeval pointer being NULL.

Reported-by: 109224573 <109224573@qq.com>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-20 12:30:51 +01:00
Takashi Yano 57b9425878 Cygwin: pty: Re-fix the last bug regarding nat-pipe.
Fixes: f907b5f405 ("Cygwin: pty: Fix failure to revert from nat-pipe in disable_pcon.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 18:25:14 +09:00
Takashi Yano 384ea1f53b Cygwin: pty: Fix failure to revert from nat-pipe in disable_pcon.
Fixes: a903878948 ("Cygwin: pty: Additional fix for transferring input at exit.");
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 17:23:32 +09:00
Takashi Yano d8f6db2fff Cygwin: console: Fix a bug that 64th console cannot be handled.
Fixes: 930e553da8 ("Cygwin: console: Unify EnumWindows() callback functions.");
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 04:07:59 +09:00
Takashi Yano 577673a170 Cygwin: console: Fix a bug that cannot handle consoles more than 32.
Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-16 02:40:37 +09:00
Corinna Vinschen a85f1c3d0f
include/ansidecl.h: import from binutils-gdb
Import include/ansidecl.h version from 2024-01-04,
binutils-gdb commit fd67aa1129fd.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 10c8c1cf4f)
2024-02-15 14:06:39 +00:00
Corinna Vinschen ffdc4e39de
Cygwin: dumper: use void* in place of PTR
The definition of PTR has been dropped from newer versions
of ansidecl.h.

Convert definition of print_section_name to use void * instead,
as required by bfd_map_over_sections.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit dace0bfa6c)
2024-02-15 14:06:26 +00:00
Takashi Yano 309c199452 Cygwin: console: Unify EnumWindows() callback functions.
Previously, three similar callback fuctions were used in console
code. This patch unifies these functions to ease maintenance cost.

Fixes: 8aad3a7ede ("Cygwin: console: Fix a problem that minor ID is incorrect in ConEmu.")
Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-14 23:19:24 +09:00
Takashi Yano 79db49a184 Cygwin: pty: Make GNU screen and tmux work in ConEmu cygwin-connector.
Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-14 23:19:08 +09:00
Takashi Yano 0795afd68e Cygwin: console: Fix a problem that minor ID is incorrect in ConEmu.
Previously, minor device number of console was not assigned correctly
in ConEmu environment. This is because console window of ConEmu is
not enumerated by EnumWindows(). This patch fixes the issue.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-13 23:36:59 +09:00
Takashi Yano 02f7f6543a Cygwin: console: Make VMIN and VTIME work.
Previously, VMIN and VTIME did not work at all. This patch fixes that.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-13 23:36:43 +09:00
Takashi Yano 73cd80c976 Cygwin: pty: Fix potential handle leak regarding CallNamedPipe().
In pty master_thread, 6 handles are duplicated when CallNamedPipe()
requests that. Though some of them are not used so should be closed,
they were not. This causes handle leak potentially.

Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-13 23:36:23 +09:00
Takashi Yano a6ac7b4138 Cygwin: pty: Fix handle leak in master process.
If non-cygwin process is started in pty, closing from_master_nat
pipe handle was missing in fhandler_pty_slave::input_transfer().
This occured because the handle was duplicated but not closed.

https://github.com/msys2/msys2-runtime/issues/198

Fixes: 29431fcb5b ("Cygwin: pty: Inherit typeahead data between two input pipes.")
Reported-by: Hakkin Lain
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-13 23:36:05 +09:00
Corinna Vinschen 70371d610d Cygwin: fix typo in winjitdebug description
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-03 20:28:56 +01:00
Corinna Vinschen 10e221050f Cygwin: document new winjitdebug option
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-03 20:03:43 +01:00
Corinna Vinschen d56fb66d6f Cygwin: reorder list of CYGWIN env var options alphabetically again
This has been turned upside down for a short while.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-03 20:03:43 +01:00
Johannes Schindelin 6d6e1e354d Cygwin: Do not show Error dialogs by default
...in a non-Cygwin child process.  Backported from MSYS2.
Downstream commit message follows.

In https://github.com/msys2/msys2-runtime/pull/18, we discussed a change
that would allow default Windows error handling of spawned processes to
kick in (such as registered JIT debuggers). We even agreed that it would
make sense to hide this functionality behind a flag, `winjitdebug`.

However, when this got upstreamed as 21ec498d7f (cygwin: use
CREATE_DEFAULT_ERROR_MODE in spawn, 2020-12-09), that flag was deemed
unnecessary.

But it would appear that it _is_ necessary: As reported in
https://github.com/msys2/MSYS2-packages/pull/2414#issuecomment-810841296
this new behavior is pretty disruptive e.g. in CI scenarios.

So let's introduce that `winjitdebug` flag (settable via the environment
variable `MSYS`) at long last.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-03 20:03:43 +01:00
Takashi Yano aa392df06b Cygwin: net: Make if_nametoindex, etc. consistent with if_nameindex.
Currently, if_nametoindex() and if_indextoname() handle interface names
such as "ethernet_32777", while if_nameindex() returns the names such
as "{5AF7ACD0-D52E-4DFC-A4D0-54D3E6D6B2AC}". This patch unifies the
interface names to the latter.

Fixes: c356901f0d ("Rename if_indextoname to cygwin_if_indextoname (analag for if_nametoindex)")
Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-03 23:50:12 +09:00
Takashi Yano aa22a43ec0 Cygwin: Document recent bug fix in release note. 2024-02-03 23:44:22 +09:00
Takashi Yano 9bcfd06045 Cygwin: console: Avoid slipping past disable_master_thread check.
If disable_master_thread flag is set between the code checking that
flag not be set and the code acquiring input_mutex, input record is
processed once after setting disable_master_thread flag. This patch
prevents that.

Fixes: d4aacd50e6 ("Cygwin: console: Add missing input_mutex guard.")
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-03 01:20:13 +09:00
Takashi Yano aa73e11524 Cygwin: console: Fix exit code for non-cygwin process.
If non-cygwin process is executed in console, the exit code is not
set correctly. This is because the stub process for non-cygwin app
crashes in fhandler_console::set_disable_master_thread() due to NULL
pointer dereference. This bug was introduced by the commit:
3721a756b0 ("Cygwin: console: Make the console accessible from
other terminals."), that the pointer cons is accessed before fixing
when it is NULL. This patch fixes the issue.

Fixes: 3721a756b0 ("Cygwin: console: Make the console accessible from other terminals.")
Reported-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-02-02 14:26:23 +09:00
Corinna Vinschen 23737b04cc bump DLL version to 3.5.1
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-02-01 11:09:16 +01:00
Christian Franke 31f7cd1e43 Hide itoa, utoa, __itoa and __utoa in stdlib.h on Cygwin only
These functions are non-standard and not exported by Cygwin.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-31 20:06:38 +01:00
Corinna Vinschen 6252fd0265 Cygwin: machine/_arc4random.h: Fix copy/paste bug
Remove a stray  __END_DECLS.  It didn't hurt in the only
(plain C) file including this header, but still...

Fixes: 030a762535 ("Cygwin: fix arc4random after fork(2)")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-29 16:42:50 +01:00
Christian Franke 497e6eb2c0 ssp: add support for _FORTIFY_SOURCE=3
If specified, use __builtin_dynamic_object_size() instead of
__builtin_object_size() if supported (GCC 12.0 or later).
This enables buffer overflow checks if the buffer size is non-const
but known during runtime.
Use new macro __ssp_bos_known() instead of the (bos(p) != (size_t)-1)
checks.  The latter is no longer a compile time constant in all cases.
This avoids the generation of unused code.

Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-29 14:03:37 +01:00
Corinna Vinschen 030a762535 Cygwin: fix arc4random after fork(2)
After using fork(), arc4random does not reseed itself, which
causes the results to become predictable.  Activate droppingfork-recognition

Fixes: e0fc33322d ("Delete Cygwin's arc4random in favor of new Newlib implementation")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-29 13:43:36 +01:00
Corinna Vinschen 1f68e88f0d Cygwin: redefine how to recognize forkee state
So far the global variable in_forkee only indicated if the
process is the child process during fork(2) itself.

However, we need an indicator accessible from plain C code
in newlib, allowing to check for a process being a forked
process all the time, after fork(2) succeeded.

Redefine bool in_forkee to int __in_forkee to allow exposing
it to newlib.  Redefine how it indicates fork state (not
forked, forking, forked).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-29 13:33:05 +01:00
Jon Turney 1c13ca67b5
Cygwin: Add a timeout to ensure we don't wait forever for dumper 2024-01-25 14:32:00 +00:00
Mike Frysinger 4d9808d404 libgloss: start a MAINTAINERS file 2024-01-24 17:15:35 -05:00
Takashi Yano 2c5433e5da Cygwin: pthread: Fix handle leak in pthread_once.
If pthread_once() is called with pthread_once_t initialized using
PTREAD_ONCE_INIT, pthread_once does not release pthread_mutex used
internally. This patch fixes that by calling pthread_mutex_destroy()
in the thread which has called init_routine.

Reviewed-by: Corinna Vinschen <corinna@vinschen.de>
Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2024-01-24 22:42:49 +09:00
Jon Turney 15140d6df6
Cygwin: Don't terminate via dumper
A process which is exiting due to a core dumping signal doesn't
propagate the correct exist status after dumping core, because 'dumper'
itself forcibly terminates the process.

Use 'dumper -n' to avoid killing the dumped process, so we continue to
the end of signal_exit(), to exit with the 128+signal exit status.

Busy-wait in exec_prepared_command() in an attempt to reliably notice
the dumper attaching, so we don't get stuck there.

Also: document these important facts for custom uses of error_start.
2024-01-23 16:07:50 +00:00
Mike Frysinger 752489c76e libgloss: merge cr16 into top-level Makefile
Avoid a recursive make to speed things up a bit.
A cr16-elf build shows installed objects & libs produce same code.

The test targets were dropped as they didn't actually work -- there
is no test.o rule in here.
2024-01-23 08:19:54 -05:00
Neal Frager 90d6966b88 configure.ac: configurable tooldir install path
This patch is required to fix how the newlib headers are installed
when using a sysroot install directory.

The cross compiler expects headers to be in
.../host/usr/arm-none-eabi/sysroot/usr/include/newlib.h
by default newlib installed the headers into
.../host/usr/arm-none-eabi/sysroot/usr/arm-none-eabi/include/newlib.h

${exec_prefix} provides the .../host/usr/arm-none-eabi/sysroot path
${target_noncanonical} provides an extra arm-none-eabi/ that must be removed.

With this patch, users can specify the tooldir path that is needed.

Signed-off-by: Neal Frager <neal.frager@amd.com>
Co-developed-by: Chris Wardman <cjwfirmware@vxmdesign.com>
2024-01-23 09:49:03 +01:00
Dimitar Dimitrov 276dd12f69 libgloss: pru: Trim crt0-minrt.o
Strip a few more instructions from crt0-minrt.S:
  - Remove "halt" and rely on the infinite loop after main()'s return.
  - Remove main()'s argc and argv argument initialization.  Host loader
    does not set them, and typical firmware does not use them, either.
  - Remove the __dso_handle symbol.

This should be safe because the default crt0.S is fully standards
compliant.  Whereas crt0-minrt.S has been documented from the beginning
to intentionally miss features in order to reduce firmware size, while
still enabling typical PRU firmware to operate.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2024-01-23 09:49:02 +01:00
Dimitar Dimitrov d5c4edca81 libgloss: merge pru into top-level Makefile
Avoid a recursive make to speed things up a bit.  This change was
inspired by the recent similar patch for c6x:
https://sourceware.org/pipermail/newlib/2023/020869.html

While at it, fork crt0-minrt.S into a separate source file instead of
relying on a predefined macro to generate two different object files.
This improves clarity, simplifies the build rules, and would allow
further optimization in crt0-minrt.S to be implemented more cleanly.

Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2024-01-23 09:49:02 +01:00
Corinna Vinschen 02572ff089 Cygwin: seekdir: don't set errno
Commit 3f3bd10104 ("* Throughout, use __try/__except/__endtry blocks [...]")
introduced setting EINVAL, marked as "Diagnosis".  The reason
for this is lost in time and space, but looks very much like
a debug helper which was supposed to be removed before release.
It's rather pointless, so remove it.

Fixes: 3f3bd10104 ("* Throughout, use __try/__except/__endtry blocks [...]")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-23 09:49:02 +01:00
Mike Frysinger 72b6105518 newlib: docs: add "Function " to every function node
When creating a split manual with one-node-per-page, the main index.html
ends up getting clobbered by the page for the index() function because
it uses "@node index" which, for html, also creates an index.html page.
To remedy this, add "Function " to every function node so now we output
"Function-index.html" and avoid clobbering.  It also namespaces every
other function and helps make sure we don't clobber anything else.

Otherwise, there isn't really much rendering difference as @node text
is mostly internal.  Node title text comes from @section instead.
2024-01-22 21:58:58 -05:00
Mike Frysinger 613267aa6e newlib: docs: print the function index
The generated function documentation makes sure to include entries for
every function in the function index via @findex, but then the manuals
forget to actually print the index.
2024-01-22 21:58:58 -05:00
Mike Frysinger 5a8c23a73a libgloss: doc: unify duplicate copyright/license content
Use @copying & @insertcopying directives to define the copyright &
license block only once, and then inserted at the same places as it
was before.
2024-01-22 20:41:22 -05:00
Mike Frysinger fd4e96f1af libgloss: doc: fix dir info entry usage
Wrapping the dir info with @ifnottex means it's included in all other
outputs like html which makes no sense.  Switch to @direntry which is
specific for this content and is automatically written to the output
that makes sense, and omitted from the rest.
2024-01-22 20:41:22 -05:00
Jeff Johnston 6f6427b053 Add Dimitar Dimitrov as maintainer for pru 2024-01-22 13:58:32 -05:00
Mike Frysinger 40b1b5c7a9 libgloss: xc16x: drop old stub port
First off, afaict, xc16x support has never been merged into gcc.
Upstream merge isn't strictly required for new ports, but it seems
like people should merge eventually in some shape, and considering
the libgloss port was merged in 2009, ~14 years seems like plenty
of leeway.  Which is to say, no one else can seem to build this
which makes updating & testing things very difficult.

Ignoring that, from what I can tell, this port has only ever built
and installed a crt0.o file.  It defines libeval.a & libcygmon.a
targets, but nothing depends on them.  The SCRIPTS & BSP variables
are always empty.  The original port merge define these in the
configure script as substitutes, but never set the vars, so they
were always replaced with nothing.

I actually broke this build 2 years ago when merging the configure
up a level in commit 30f244155b
("libgloss: merge subdirs that have unique makefile_frags up a
level").  I saw that it was exporting a bunch of vars in the
configure script, but never set them, so I incorrectly assumed
they weren't used.  Which means the Makefile has been setting them
to invalid values like literal @bsp_list@ and @script_list@.

Considering no one has complained, I have to assume no one cares
about this port, and we can all stop wasting time on it.
2024-01-19 22:47:00 -05:00
Mike Frysinger 2f0cd375f3 libgloss: merge microblaze into top-level Makefile
Avoid a recursive make to speed things up a bit.
A microblaze-elf build shows installed objects & libs produce same code.
2024-01-19 22:23:48 -05:00