summaryrefslogtreecommitdiffstats
Commit message (Collapse)AuthorAgeFilesLines
* Cygwin: FIFO: close connect_evt handles as soon as possibleKen Brown2019-04-201-7/+10
| | | | | Keeping them open too long can cause an attempt to close them twice after a fork or exec.
* Cygwin: FIFO: avoid WFMO error in listen_client_threadKen Brown2019-04-201-5/+7
| | | | | | 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.
* Cygwin: FIFO: duplicate the i/o handle when opening a duplexerKen Brown2019-04-201-1/+8
| | | | | | 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.
* Cygwin: FIFO: stop the listen_client thread on an opening errorKen Brown2019-04-201-1/+1
| | | | Don't just close the thread handle.
* Cygwin: drop unsupported Windows 10 versionsCorinna Vinschen2019-04-191-31/+1
| | | | | | | * 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>
* Cygwin: FIFO: avoid hang after execKen Brown2019-04-182-0/+10
| | | | | | | Define fhandler:fifo::fixup_after_exec, which sets listen_client_thr and lct_termination_evt to NULL. This forces the listen_client thread to restart on the first attempt to read after an exec. Previously the exec'd process could hang in fhandler_fifo::raw_read.
* MSP430: Make the inclusion of run_*_array fns depend on defined assembler ↵Jozef Lawrynowicz2019-04-183-22/+74
| | | | | | | | | | | | | | | | | | | | | | symbols Many of the MSP430 crt functions (e.g. to initialize bss) are linked "dynamically", based on symbols defined in the program. The GNU assembler defines the symbols corresponding to the crt functions by examining the section names in the input file. If GCC has been configured with --enable-initfini-array, then .init_array and .fini_array will hold pointers to global constructors/destructors. These sections can also hold functions that need to be executed for other purposes. The attached patch puts the __crt0_run_{preinit,init,fini}_array and __crt0_run_array functions in their own object files, so they will only be linked when needed. Successfully regtested the DejaGNU GCC testsuite using the binutils and newlib changes together with GCC trunk configured with --enable-initfini-array.
* Fix incorrect assembly code in _msp430_run_arrayJozef Lawrynowicz2019-04-161-2/+2
|
* Cygwin: FIFO: fix and simplify listen_client_threadKen Brown2019-04-162-153/+109
| | | | | | | | | | | | | | | | | | | | | | | | | | Remove fifo_client_handler::connect and move its code into listen_client_thread. That way we can check the return status when a client handler's connect_evt is signaled. Previously we incorrectly assumed there was a successful connection. Also simplify listen_client_thread in the following ways: - Replace fhandler_fifo::disconnect_and_reconnect by a new delete_client_handler method. Now we just delete invalid client handlers rather than trying to re-use them. - Try to maintain a client handler list that consists of connected client handlers and exactly one that is listening for a connection. This allows us to call WaitForMultipleObjects with only two wait objects. - Remove 'dummy_evt' from the fifo_client_handler struct; it is no longer needed. - On exit from listen_client_thread, delete the "extra" (listening) client handler. Otherwise there could be a connection that doesn't get recorded in the client handler list. This could happen when a file descriptor is being duplicated.
* Cygwin: FIFO: improve raw_writeKen Brown2019-04-163-20/+80
| | | | | | | | | | | | | | | Don't set the write end of the pipe to non-blocking mode if the FIFO is opened in blocking mode. In fhandler_fifo::raw_write in blocking mode, wait for the write to complete rather than returning -1 with EAGAIN. If the amount to write is large, write in smaller chunks (of size determined by a new data member max_atomic_write), as in fhandler_base_overlapped. For convenience, add two new NTSTATUS codes, STATUS_THREAD_SIGNALED and STATUS_THREAD_CANCELED, to ntdll.h.
* Cygwin: FIFO: start the listen_client thread when duping a readerKen Brown2019-04-161-9/+13
| | | | | Otherwise it doesn't get started until the dup'd fd tries to read, which delays client connections.
* Cygwin: FIFO: fix cloneKen Brown2019-04-162-5/+21
| | | | | | | | | | | | | | | After copyto is called, make the new fhandler's pipe_name point to the new fhandler's pipe_name_buf, which is a *copy* of the old fhandler's pipe_name_buf. Previously, get_pipe_name would return the wrong result after a clone/dup, causing create_pipe_instance and open_pipe to fail. Also, stop the listen_client thread when cloning. Otherwise the thread can keep accepting connections that the cloned fhandler won't know about. Do this via a new method fhandler_fifo::stop_listen_client, extracted from fhandler_fifo::close.
* Cygwin: FIFO: use a retry loop when opening a writerKen Brown2019-04-161-21/+31
| | | | | There may be short periods when there's no pipe instance available. Keep trying.
* Cygwin: FIFO: fix the use of the read_ready eventKen Brown2019-04-161-35/+16
| | | | | | | | | | Make read_ready a manual reset event. It should always be set shortly after startup of the listen_client thread and remain set until the thread terminates. (We don't want writers to connect without being recorded in the client handler list.) Remove the unnecessary code that checks for read_ready when a reader is opening.
* Cygwin: FIFO: fix fifo_client_handler::closeKen Brown2019-04-161-1/+4
| | | | | | Make sure that fhandler_base::close rather than fhandler_fifo::close is called on the fhandler. Also, delete the fhandler, since we allocated it.
* Cygwin: FIFO: code simplification: don't overload get_handleKen Brown2019-04-162-4/+5
| | | | | Rename fhandler_fifo::get_handle(int) to get_fc_handle(int), and remove fhandler_fifo::get_handle(void).
* Cygwin: check for STATUS_PENDING in fhandler_base::raw_readKen Brown2019-04-161-1/+13
| | | | | | If NtReadFile returns STATUS_PENDING, wait for the read to complete. This can happen, for instance, in the case of a FIFO opened with O_RDRW.
* Cygwin: FIFO: fix the error checking in raw_readKen Brown2019-04-161-8/+5
| | | | | If the pipe is empty, we can get either ERROR_NO_DATA or ERROR_PIPE_LISTENING.
* Cygwin: FIFO: fix a thinko in listen_client_threadKen Brown2019-04-161-1/+4
|
* Cygwin: FIFO: remember the type of the fhandlerKen Brown2019-04-162-11/+5
| | | | | | | | Add data members 'reader', 'writer', and 'duplexer' to the fhandler_fifo class. Set them in fhandler_fifo::open. ('duplexer' replaces the previous '_duplexer'.) This will be useful in later commits.
* Cygwin: FIFO: hit_eof: add a call to fifo_client_lockKen Brown2019-04-161-8/+13
| | | | | The second check of nconnected needs to be protected by a lock as well as the first.
* Cygwin: FIFO: rename client[] to fc_handler[]Ken Brown2019-04-163-59/+59
| | | | | | | The word "client" suggests something that holds a handle to the client side of the pipe (in Windows terminology). But our fifo_client_handlers hold a handle the server side of the pipe, and they *connect* to clients.
* Implement reduced code size "tiny" printf and putsJozef Lawrynowicz2019-04-156-428/+132
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | "tiny" printf is derived from _vfprintf_r in libc/stdio/nano-vfprintf.c. "tiny" puts has been implemented so that it just calls write, without any other processing. Support for buffering, reentrancy and streams has been removed from these functions to achieve reduced code size. This reduced code size implementation of printf and puts can be enabled in an application by passing "--wrap printf" and "--wrap puts" to the GNU linker. This will replace references to "printf" and "puts" in user code with "__wrap_printf" and "__wrap_puts" respectively. If there is no implementation of these __wrap* functions in user code, these "tiny" printf and puts implementations will be linked into the final executable. The wrapping mechanism is supposed to be invisible to the user: - A GCC wrapper option such as "-mtiny-printf" will be added to alias these wrap commands. - If the user is unaware of the "tiny" implementation, and chooses to implement their own __wrap_printf and __wrap_puts, their own implementation will be automatically chosen over the "tiny" printf and puts from the library. Newlib must be configured with --enable-newlib-nano-formatted-io for the "tiny" printf and puts functions to be built into the library. Code size reduction examples: printf("Hello World\n") baseline - msp430-elf-gcc gcc-8_3_0-release text data bss 5638 214 26 "tiny" puts enabled text data bss 714 90 20 printf("Hello %d\n", a) baseline - msp430-elf-gcc gcc-8_3_0-release text data bss 10916 614 28 "tiny" printf enabled text data bss 4632 280 20
* Copy prerequisite file for "tiny" printf implementationJozef Lawrynowicz2019-04-151-0/+661
| | | | Use newlib/libc/stdio/nano-vfprintf.c as baseline for tiny-printf.c
* Fix definition of write() to use const char * for the type of the bufferJozef Lawrynowicz2019-04-151-4/+5
|
* Cygwin: use win pid+threadid for forkables dirnameMichael Haubenwallner2019-04-121-19/+7
| | | | | | | | Rather than newest last write time of all dlls loaded, use the forking process' windows pid and windows thread id as directory name to create the forkable hardlinks into. While this may create hardlinks more often, it does avoid conflicts between dlls not having the newest last write time.
* Align comments and spaces in libgloss/arm/crt0.S and ↵Alexander Fedotov2019-04-122-75/+78
| | | | newlib/libc/sys/arm/crt0.S to ease further code alignment.
* Include code in trap.S for APCS only.Christophe Lyon2019-04-112-2/+2
| | | | | | | | | | The code in trap.S is to support the old APCS chunked stack variant, which dates back to the Acorn days, so put it under #ifndef __ARM_EABI__. * libgloss/arm/trap.S: Use __ARM_EABI rather than PREFER_THUMB. * newlib/libc/sys/arm/trap.S: Use __ARM_EABI rather than __thumb2__.
* Make more macro checks ARMv8-M baseline proof.Christophe Lyon2019-04-111-4/+4
| | | | | | | | | | | | Commit 69f4c4029183fb26d2fcae00790881620c1978a3 improved most macro checks to be ARMv8-M baseline proof, but missed a few occurrences which otherwise fail to build when using a CPU setting such as cortex-m0 or cortex-m23. This patch brings the same changes as the ones that were committed to libgloss at that time. newlib: * libc/sys/arm/crt0.S: Use THUMB1_ONLY rather than __ARM_ARCH_6M__.
* Improve error handling in /proc/[pid]/ virtual files.Erik M. Bray2019-04-101-7/+28
| | | | | | | | | | | | | | | | | * Changes error handling to allow /proc/[pid]/ virtual files to be empty in some cases (in this case the file's formatter should return -1 upon error, not 0). * Better error handling of /proc/[pid]/stat for zombie processes: previously trying to open this file on zombie processes resulted in an EINVAL being returned by open(). Now the file can be read, and fields that can no longer be read are just zeroed. * Similarly for /proc/[pid]/statm for zombie processes. * Similarly for /proc/[pid]/maps for zombie processes (in this case the file can be read but is zero-length, which is consistent with observed behavior on Linux.
* Cygwin: add latest signal handling fixes to release notesCorinna Vinschen2019-04-063-2/+15
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: signals: setcontext: fix setting sigmaskCorinna Vinschen2019-04-051-1/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: follow context if changed inside SA_SIGINFO signal handlerCorinna Vinschen2019-04-051-1/+10
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: signals: make setcontext work from signal handlersCorinna Vinschen2019-04-041-0/+1
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: console: fix key input for native console applicationTakashi Yano2019-04-031-0/+17
| | | | | | - After 24 bit color support patch, arrow keys and function keys do not work properly in native console applications if they are started in cygwin console. This patch fixes this issue.
* Cygwin: signals: restore sigmask from context given to signal handlerCorinna Vinschen2019-04-031-1/+2
| | | | | | | | | | | | | | | | In case SA_SIGINFO flag is given, the signal handler may change the context and the application is supposed to pick up from the changed context. So far we don't do that, so the context given to the signal handler is basically read-only, unless the signal handler calls setcontext or swapcontext. For a start, restore the thread's signal mask from the uc_sigmask value of the context given to the signal handler. If that's feasible for Cygwin, we restore the entire context from the context changed by the signal handler in a followup patch. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Add a dummy interrupt handler to nios2 crt0.s.Sandra Loosemore2019-04-031-1/+13
| | | | | | The location of the handler at offset 0x20 from the start of memory, immediately after the 32-byte reset vector, matches the expectations of real hardware (e.g., a 3c120 board).
* Cygwin: winpids: Fix getting process multiple times, take 2Corinna Vinschen2019-04-023-8/+21
| | | | | | | | | | | | | | | | | | | | | | commit d1be0a59d48222d8ea6261ee3e59de2bc3d149e4, "Cygwin: winpids: Fix getting process multiple times" fixed duplicate processes in ps -W output, but it fixed the symptom, not the cause. It also didn't fix the problem that the `ps' process itself may show up twice in its own output. This patch fixes it. The spawn worker only deleted the "winpid.PID" symlink of the current process if the child is a non-Cygwin process, under the assumption that the exec'ing process exits anyway. However, the Window in which both winpid.PID symlinks point to the same cygpid.PID area is just too long. The spawn worker now also deletes its own winpid.PID symlink if the exec'ed process is a Cygwin process. Additionally the fix from d1be0a59d48222d8ea6261ee3e59de2bc3d149e4 is now performed on the calling process, too. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: Add console patches to release notesCorinna Vinschen2019-03-312-0/+15
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: console: Make I/O functions thread-safeTakashi Yano2019-03-313-12/+165
| | | | | | - POSIX states I/O functions shall be thread-safe, however, cygwin console I/O functions were not. This patch makes console I/O functions thread-safe.
* Cygwin: console: fix select() behaviourTakashi Yano2019-03-313-425/+462
| | | | | | - Previously, select() would return when only one key is typed even in canonical mode. With this patch, it returns after one line is completed.
* Cygwin: console: support 24 bit colorTakashi Yano2019-03-316-34/+227
| | | | | | | - Add 24 bit color support using xterm compatibility mode in Windows 10 1703 or later. - Add fake 24 bit color support for legacy console, which uses the nearest color from 16 system colors.
* Cygwin: document ps -W duplication bug fixCorinna Vinschen2019-03-311-0/+4
| | | | Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* Cygwin: [gs]et_io_handle(): renamed to [gs]et_handle().Takashi Yano2019-03-3014-86/+87
| | | | | | - Unify get_io_handle() and get_handle() to get_handle(). Both of them returned same value; io_handle. - Rename set_io_handle() to set_handle().
* Cygwin: fork: reserve dynloaded dll areas earlierMichael Haubenwallner2019-03-282-6/+6
| | | | | | In dll_crt0_0, both threadinterface->Init and sigproc_init allocate windows object handles using unpredictable memory regions, which may collide with dynamically loaded dlls when they were relocated.
* Cygwin: FIFO: implement clear_readaheadKen Brown2019-03-281-1/+7
| | | | | | Make fhandler_base::clear_readahead virtual, and implement fhandler_fifo::clear_readahead. This is called by dtable::fixup_after_exec; it clears the readahead in each client.
* Cygwin: document the recent FIFO changesKen Brown2019-03-272-0/+26
|
* Cygwin: fix: seteuid32() must return EPERM if privileges are not held.J.H. van de Water2019-03-271-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Starting w/ the intro of S4U, seteuid32() calls lsaprivkeyauth(), then s4uauth(). s4uauth calls LsaRegisterLogonProcess(). LsaRegisterLogonProcess fails w/ STATUS_PORT_CONNECTION_REFUSED, if the proper privileges are not held. Because of RtlNtStatusToDosError(), this status would be mapped to ERROR_ACCESS_DENIED, which in turn would map to EACCES. Therefore it is useless to add this status to errmap[] (errno.cc), as s4auauth() should return EPERM as errno here (i.e. if process is not privileged). Hence the kludge. Before the intro of S4U, seteuid32() called lsaprivkeyauth(), then lsaauth(), then create_token(). Before the intro of Vista, the latter would have called NtCreateToken(). NtCreateToken() would have failed w/ STATUS_PRIVILEGE_NOT_HELD for a process w/o the proper privileges. In that case, calling seteuid32() would have returned EPERM (as required). Since the intro of Vista, and if the process had been started from an UNelevated shell, create_token() does NOT reach NtCreateToken()! As create_token() failed to properly set errno in that case, calling seteuid32() would return errno as set by lsaauth(), i.e. EACCES, not in agreement w/ Posix (a bug which was present for years). (lsaauth() called LsaRegisterLogonProcess() which would fail)
* Cygwin: FIFO: add support for the duplex caseKen Brown2019-03-272-11/+73
| | | | | | | | | If a FIFO is opened with O_RDWR access, create the pipe with read/write access, and make the first client have the handle of that pipe as its I/O handle. Adjust fhandler_fifo::raw_read to account for the result of trying to read from that client if there's no data.
* Cygwin: FIFO: avoid crashes when cloning a clientKen Brown2019-03-271-1/+1
| | | | | | | | | | | fhandler_fifo::clone called fhandler_base::clone on each client fhandler. But those fhandlers are actually fhandler_fifo objects, so when fhandler_base::clone calls copyto, it's actually fhandler_fifo::copyto that gets called. This can lead to mysterious crashes. Fix this by simply calling clone (which translates to fhandler_fifo::clone) on each client fhandler.