Commit Graph

19052 Commits

Author SHA1 Message Date
Michael Haubenwallner 8b9b514399 Cygwin: dll_list: stat_real_file_once with ntname
NtQueryVirtualMemory for MemorySectionName may return some old path even
if the process was just started, for when some directory in between was
renamed - maybe because the NT file cache is hot for the old path still.
This was seen during gcc bootstrap, returning a MemorySectionName of
".../gcc/xgcc.exe" even if started as ".../prev-gcc/xgcc.exe", where the
directory rename from "gcc" to "prev-gcc" was done the moment before.
As we stat the module's real file right after loading now, there is no
point in using NtQueryVirtualMemory with MemorySectionName any more, and
we can use what GetModuleFileName returned instead.
2020-10-14 10:53:53 -04:00
Lucio Andrés Illanes Albornoz 3564641506 Fix vfwscanf(3) assignment suppression flag handling bug
newlib's vfwscanf(3) (or specifically, __SVFWSCANF_R()) fails to correctly set
the assignment-suppressing character (`*') flag[1] which, when present in the
formatting string, results in undefined behaviour comprising retrieving and
dereferencing a pointer that was not supplied by the caller as such or at all.
When compared to the vfscanf(3) implementation, this would appear to be over
the missing goto match_failure statement preceded by the flags test seen below.
Hence, this patch (re)introduces it.

[1] <http://pubs.opengroup.org/onlinepubs/009695399/functions/fwscanf.html>

--
2020-10-14 10:53:53 -04:00
Jinke Fan 1770da2dab Add support for Hygon Dhyana processor
-Add vendor identification
-Support in get_cpu_cache

Background:
    Chengdu Haiguang IC Design Co., Ltd (Hygon) is a Joint Venture
    between AMD and Haiguang Information Technology Co.,Ltd., aims at
    providing high performance x86 processor for China server market.
    Its first generation processor codename is Dhyana, which
    originates from AMD technology and shares most of the
    architecture with AMD's family 17h, but with different CPU Vendor
    ID("HygonGenuine")/Family series number(Family 18h).

Related Hygon kernel patch can be found on:
http://lkml.kernel.org/r/5ce86123a7b9dad925ac583d88d2f921040e859b.1538583282.git.puwen@hygon.cn

Signed-off-by: Jinke Fan <fanjinke@hygon.cn>
2020-10-14 10:53:53 -04:00
Sebastian Huber 074b8a1292 Fix <sys/_types.h> issues with <stddef.h>
A commit from 2016 tried to address this GCC provided <stddef.h> issue

    #if (defined (__FreeBSD__) && (__FreeBSD__ >= 5)) \
      || defined(__DragonFly__) \
      || defined(__FreeBSD_kernel__)
    /* __size_t is a typedef on FreeBSD 5, must not trash it. */
    #elif defined (__VMS__)
    /* __size_t is also a typedef on VMS.  */
    #else
    #define __size_t
    #endif

with an include of <stddef.h> before <sys/_types.h> in <sys/types.h>.
Is is not robust enough.  Do the include of <stddef.h> in <sys/_types.h>
directly and request only the necessary types.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2020-10-14 10:53:53 -04:00
Sebastian Huber c9773e9616 Avoid <sys/cdefs.h> dependency in <sys/_types.h>
Including <sys/cdefs.h> could result in cyclic header dependencies.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2020-10-14 10:53:53 -04:00
Sebastian Huber 4eb2e29fde Avoid cyclic header dependencies
RTEMS uses a considerable part of FreeBSD kernel and user space sources.
These sources are compiled with a __FreeBSD__ define.  On 2018-06-26
Gerald Pfeifer changed the GCC provided <stddef.h> so that it includes
<sys/_types.h> if __FreeBSD__ is defined.  The Newlib <sys/_types.h>
included <sys/lock.h> which includes <sys/cdefs.h> on RTEMS which
includes <stddef.h>.  To get rid of this cyclic dependency move the
optional _flock_t definition to <sys/reent.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2020-10-14 10:53:53 -04:00
Ken Brown b990f65181 Cygwin: FIFO: respect the O_CLOEXEC flag
Set the inheritance of the Windows pipe handles according to the
O_CLOEXEC flag.  Previously the pipe was always created and opened
with OBJ_INHERIT.
2020-10-14 10:53:53 -04:00
Ken Brown de756e91cd Cygwin: FIFO: Open only one handle to NPFS
Make npfs_handle a static member function of fhandler_fifo, as in
fhandler_socket_unix.
2020-10-14 10:53:53 -04:00
Jim Wilson 42c926f621 RISC-V: Add _LITE_EXIT in crt0.S.
This patch adds _LITE_EXIT in crt0.S to enable "lite exit" technique in
RISC-V. The changes have been tested in riscv/riscv-gnu-toolchain by
riscv-dejagnu with riscv-sim.exp/riscv-sim-nano.exp.
2020-10-14 10:53:53 -04:00
Jim Wilson ca5444076a RISC-V: Add size optimized memcpy, memmove, memset and strcmp.
This patch adds implementations of memcpy, memmove, memset and strcmp
optimized for size. The changes have been tested in
riscv/riscv-gnu-toolchain by riscv-dejagnu with
riscv-sim.exp/riscv-sim-nano.exp.
2020-10-14 10:53:53 -04:00
Faraz Shahbazker 277e3f4aa7 Make .data section placement coincide with _fdata symbol
The _fdata symbol in MIPS linker scripts is aligned to a 16-byte
boundary.  The ALIGN function does not implicitly update current
location counter.  If sections positioned after the assignment
do not have the same natural alignment as the ALIGN function then
the start of the section group will not coincide with the value
of the symbol.

Given the linker command sequence:
  symbol = ALIGN (NN);
  (.section*)
where the idiom implies a desire to mark the beginning of .section
with symbol, there must be an assignment to the location counter
between the assignment to symbol and the .section pattern.

libgloss/
	* mips/array.ld: Update the location counter to match _fdata.
	* mips/cfe.ld: Likewise.
	* mips/ddb-kseg0.ld: Likewise.
	* mips/ddb.ld: Likewise.
	* mips/dve.ld: Likewise.
	* mips/idt.ld: Likewise.
	* mips/idt32.ld: Likewise.
	* mips/idt64.ld: Likewise.
	* mips/idtecoff.ld: Likewise.
	* mips/jmr3904app-java.ld: Likewise.
	* mips/jmr3904app.ld: Likewise.
	* mips/jmr3904dram-java.ld: Likewise.
	* mips/jmr3904dram.ld: Likewise.
	* mips/lsi.ld: Likewise.
	* mips/mti32.ld: Likewise.
	* mips/mti64.ld: Likewise.
	* mips/mti64_64.ld: Likewise.
	* mips/mti64_n32.ld: Likewise.
	* mips/nullmon.ld: Likewise.
	* mips/pmon.ld: Likewise.
	* mips/sde32.ld: Likewise.
	* mips/sde64.ld: Likewise.
2020-10-14 10:53:53 -04:00
Ken Brown 76d8d6b43c Cygwin: FIFO: code simplifications.
There's no longer a need to consider the connect_evt after fork/exec.
After stopping the listen_client thread, all client handlers should be
in the fc_connected or fc_invalid states, so their connect_evt members
won't be used again.

Also remove code in fhandler_fifo::dup that just repeats things
already done in stop_listen_client.
2020-10-14 10:53:53 -04:00
Ken Brown 91d5de57ff Cygwin: FIFO: make read_ready an auto-reset event
There's no point in allowing a writer to attempt to open until we've
created a pipe instance.
2020-10-14 10:53:53 -04:00
Ken Brown 9f37882918 Cygwin: FIFO: improve the check for the listen_client thread
Add a method fhandler_fifo::check_listen_client_thread that checks
whether the thread is running.  Use it in raw_read instead of just
testing the handle listen_client_thr.
2020-10-14 10:53:53 -04:00
Ken Brown 8885be8934 Cygwin: FIFO: set client handler flags more accurately
Reflect the fact that client handlers are only used for reading and
that, after connection, they are always nonblocking.
2020-10-14 10:53:53 -04:00
Ken Brown ccb1c73e9b Cygwin: FIFO: don't leave a pending listen request
On exit from the listen_client thread, make sure there's no pending
FSCTL_PIPE_LISTEN request.  Otherwise we might get a client connection
after restarting the thread, and we won't have a handle for
communicating with that client.

Remove the retry loop in the case of STATUS_PIPE_LISTENING; that case
shouldn't occur.

Remove the now-unused fc_connecting value from
fifo_client_connect_state.
2020-10-14 10:53:53 -04:00
Ken Brown 7cf9772f9d Cygwin: FIFO: add a HANDLE parameter to open_pipe
It's now up to the caller to pass a handle to open_pipe and, if
desired, to call set_handle on return.

This will be useful for a future commit, in which we will open a
client connection without setting an io_handle.
2020-10-14 10:53:52 -04:00
Ken Brown 3d5dc65104 Cygwin: FIFO: re-implement duplexers
When opening a duplexer, open a client connection to the first client
handler.  Previously we gave the duplexer a bogus write handle, which
was just a duplicate of the first client handler's handle.  This meant
that we had a pipe server with no clients connected, and all I/O
attempts failed with STATUS_PIPE_LISTENING.

Extend the last fcntl change to duplexers.

Remove a now unused fifo_client_handler constructor, as well as the
long unusued method fifo_client_handler::connect.

Don't create the pipe in duplex mode; the server handle will only be
used for reading.
2020-10-14 10:53:52 -04:00
Ken Brown 775d8d0242 Cygwin: FIFO: add 'record_connection' method
Future commits will have to re-use the code for recording a client
connection.  For convenience, factor out this code into a new method.
2020-10-14 10:53:52 -04:00
Ken Brown b26fab8cfa Cygwin: FIFO: remove incorrect duplexer code
raw_read had some code that was based on an incorrect implementation
of duplexers.
2020-10-14 10:53:52 -04:00
Ken Brown e1d5be1783 Revert "Cygwin: check for STATUS_PENDING in fhandler_base::raw_read"
This reverts commit 10bf30bebf.  It was
made because an incorrect implementation of duplex FIFOs.
2020-10-14 10:53:52 -04:00
Michael Haubenwallner 1559faf0f2 Cygwin: dll_list: drop unused read_fbi method 2020-10-14 10:53:52 -04:00
Corinna Vinschen 31f4472eff Cygwin: Add release info for 3.0.7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit 01c253a4c5)
2020-10-14 10:53:52 -04:00
Michael Haubenwallner cc6a1cbe27 Cygwin: dll_list: query dll file id at load time
NtQueryVirtualMemory for MemorySectionName does not reliable return the
changed dll file name when another process does move the file around,
and we may end up creating forkable hardlinks to wrong dll files.
So query the file id when loading the dll rather than before fork.
2020-10-14 10:53:52 -04:00
Michael Haubenwallner ecaa2c5d26 Cygwin: dll_list: stat_real_file_once as dll method
Make stat_real_file_once a method of struct dll, to be more flexible on
where to use.  Also, debug print memory section name queried for a dll.
This is a preparation to query the file id when loading the dll.
2020-10-14 10:53:52 -04:00
Michael Haubenwallner d3e84aef20 Cygwin: dll_list: drop FILE_BASIC_INFORMATION
Querying FILE_BASIC_INFORMATION is needless since using win pid+threadid
for forkables dirname rather than newest last write time.
2020-10-14 10:53:52 -04:00
Corinna Vinschen 62cd365069 Cygwin: update era and message locale data
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:53:52 -04:00
Faraz Shahbazker add5a9c033 Fix order of eh_frame sections in linker scripts
The compiler driver positions the linker script at the end of the linker
command-line, after crtend.o.  As a result, any INPUT objects and archive
GROUPs introduced by the linker script are placed after crtend.o and the
end-of-frame marker provided by crtend.o ends up in between .eh_frames
instead of being at the end.

This has always been a problem, but a binutils update to clean-up
redundant NULL markers in .eh_frame exposes it as a execution failure in
exception-handling tests.  This patch re-orders .eh_frames in all
MIPS linker scripts so that the one from crtend.o is always placed last.

libgloss/
	* mips/array.ld: Re-order to place .eh_frame from crtend.o
	after all other .eh_frame sections.
	* mips/cfe.ld: Likewise.
	* mips/ddb-kseg0.ld: Likewise.
	* mips/ddb.ld: Likewise.
	* mips/dve.ld: Likewise.
	* mips/idt.ld: Likewise.
	* mips/idt32.ld: Likewise.
	* mips/idt64.ld: Likewise.
	* mips/jmr3904app.ld: Likewise.
	* mips/lsi.ld: Likewise.
	* mips/mti32.ld: Likewise.
	* mips/mti64.ld: Likewise.
	* mips/mti64_64.ld: Likewise.
	* mips/mti64_n32.ld: Likewise.
	* mips/nullmon.ld: Likewise.
	* mips/pmon.ld: Likewise.
	* mips/sde32.ld: Likewise.
	* mips/sde64.ld: Likewise.
2020-10-14 10:53:52 -04:00
Ken Brown bd02adb85d Cygwin: FIFO: synchronize the blocking mode of a writer's pipe
The blocking mode of the Windows pipe underlying a writer is set to
match that of the writer itself when the latter is opened.  Define
fhandler_fifo::fcntl to keep the pipe and the writer in sync if the
blocking mode is changed via fcntl.
2020-10-14 10:53:52 -04:00
Ken Brown b467e93875 Cygwin: AF_UNIX: sendmsg: avoid double use of variable name
Use 'waitret' instead of 'ret' for the return value of cygwait, since
there is already a different 'ret' variable in use.  The previous
double use of 'ret' was legal because of scoping rules, but possibly
confusing.
2020-10-08 16:41:12 -04:00
Ken Brown de54d280eb Cygwin: AF_UNIX: sendmsg: handle messages that are too long
Return with errno EMSGSIZE if AF_UNIX_PKT_DATA_APPEND fails before any
data has been added to the packet to be sent.
2020-10-08 16:41:12 -04:00
Ken Brown 3eab592c22 Cygwin: AF_UNIX: sendmsg: fix return value
On a successful write, the return value is now the number of bytes of
user data written, not the total number of bytes written.
2020-10-08 16:41:12 -04:00
Ken Brown 780133d455 Cygwin: AF_UNIX: sendmsg: fix signal handling
If a blocking write is interrupted by a signal and call_signal_handler
returns nonzero, resume waiting for the write to complete.
2020-10-08 16:41:12 -04:00
Ken Brown add34a7b53 Cygwin: AF_UNIX: open_pipe: fix invalid handle error
Commit debdfb8b, "Cygwin: AF_UNIX: Rework internal methods to return
HANDLEs", removed a set_handle call.  As a result, the attempt to
exchange socket info fails with "Invalid Handle".

Fix this by moving the send_sock_info call into a new 'xchg_sock_info'
method, which is then invoked by the callers of open_pipe if
necessary, after they have called set_handle.

Also, call recv_peer_info in addition to send_sock_info when
exchanging socket information.

Remove the last argument of open_pipe, which is no longer needed.
Adjust all callers.
2020-10-08 16:37:52 -04:00
Ken Brown 0f800bf44a Cygwin: AF_UNIX: accept4: copy trailing NUL byte
If the caller has requested the peer's address, include the trailing
NUL byte of the address if possible.
2020-10-08 16:35:49 -04:00
Corinna Vinschen a0dd60f857 Cygwin: AF_UNIX: sendmsg: first cut, untested 2019-04-25 19:04:50 +02:00
Corinna Vinschen dab6ac1b33 Cygwin: AF_UNIX: introduce methods to handle ancillary data
...doing nothing for now.
2019-04-25 19:02:42 +02:00
Corinna Vinschen 3bd0df5170 Cygwin: AF_UNIX: setsockopt: align SO_RCVBUF/SO_SNDBUF to Linux
The incoming size is doubled and must not be less than 256.
Fold both options into one code block.  Fix indentation.
2019-04-25 19:02:42 +02:00
Corinna Vinschen b54240b08a Cygwin: AF_UNIX: convert AF_UNIX_PKT helpers to inline functions
add AF_UNIX_PKT_DATA_END and AF_UNIX_PKT_DATA_APPEND
2019-04-25 19:02:42 +02:00
Corinna Vinschen debdfb8bb6 Cygwin: AF_UNIX: Rework internal methods to return HANDLEs
- Return HANDLE value of just opened/created objects

- open_pipe does not set the fhandler io_handle.  The caller
  is now resonsible how to use the handle.

- Rename create_file/open_file to create_socket/open_socket

- Drop sockaddr_in validity check from connect.  It's performed
  in open_socket anyway.
2019-04-25 19:02:41 +02:00
Corinna Vinschen bd16e44f1b Cygwin: AF_UNIX: fix #ifdef __WITH_AF_UNIX spot 2019-04-25 19:02:41 +02:00
Corinna Vinschen f527171a93 Cygwin: define MSG_EOR and refuse in send(2)
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-25 19:00:08 +02:00
Erik M. Bray 489e7e2048 Minor improvements to socket error handling:
* Change default fallback for failed winsock error -> POSIX error
  mappings to EACCES, which is a valid errno for more socket-related
  syscalls.

* Added a few previously missing entries to the wsock_errmap table
  that have obvious POSIX errno.h analogues.
2019-04-23 17:20:57 +02:00
Ken Brown 9957a7895b Cygwin: FIFO: restart listen_client thread after fork/exec
This allows writers to connect immediately.  Previously the lct wasn't
restarted until the reader attempted to read.
2019-04-22 07:55:58 -04:00
Ken Brown 4443100b53 Cygwin: FIFO: stop the listen_client thread before fork/exec
Add methods need_fixup_before, init_fixup_before, and
fixup_before_fork_exec to accomplish this.  Stopping the thread makes
sure that the client handler lists of the parent and child remain in
sync while the forking/execing is in progress.
2019-04-20 14:31:07 -04:00
Ken Brown 252cd0ce2b Cygwin: FIFO: close connect_evt handles as soon as possible
Keeping them open too long can cause an attempt to close them twice
after a fork or exec.
2019-04-20 14:31:07 -04:00
Ken Brown 24c56e5a2c Cygwin: FIFO: avoid WFMO error in listen_client_thread
Don't set lct_termination_evt to NULL too early in
fhandler_fifo::stop_listen_client.  Doing so leads to an "Invalid
Handle" error in WFMO.
2019-04-20 14:31:07 -04:00
Ken Brown ef269531a9 Cygwin: FIFO: duplicate the i/o handle when opening a duplexer
Don't use the same i/o handle for the first client handler as is used
for the fhandler itself; this can lead to a later attempt to close the
same handle twice.  Instead use a duplicate.
2019-04-20 14:31:07 -04:00
Ken Brown 4ecea14a58 Cygwin: FIFO: stop the listen_client thread on an opening error
Don't just close the thread handle.
2019-04-20 14:31:07 -04:00
Corinna Vinschen 28182bca18 Cygwin: drop unsupported Windows 10 versions
* Pre-release version still reporting kernel version 6.4.
* Windows 10 1511 is out of support since 2017-10-10.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-19 18:13:02 +02:00