Commit Graph

18961 Commits

Author SHA1 Message Date
Jozef Lawrynowicz cca3349527 MSP430: Remove .init/.fini sections
The .init/.fini sections are not required for msp430-elf, and add unnecessary
code bloat to the CRT library. These sections are specified as "unused" by
the MSP430 EABI.

.init existed to call __crt0_run_{init,preinit}_array which run through
the functions in .{init,preinit}_array.
__crt0_run_{init,preinit}_array are already dynamically included like the
other crt0 functions, so these can be placed before the call to main,
which ensures they are still called if needed.
With these functions moved, .init has no purpose and can be removed.

.fini existed to call __crt0_run_fini_array.
However, the "__msp430_fini" symbol which marks the start of .fini has
never been used, so no termination routines have ever been run for
msp430. On returning from main(), _exit() is called which just loops
forever.
So there is no current expectation that __crt0_run_fini_array will
get called by the CRT code. Further work is to ensure functions
registered with atexit can be optionally called during program termination,
and then __crt0_run_fini_array can be registered with atexit during
program initialization.

The mechanisms for supporting the "-minrt" option have also been removed.
"-minrt" enabled a "minimum runtime environment" by removing calls to
functions which run global static initializers and constructors. Since
this behaviour is now dynamic, and these functions are only included
when needed, the minrt versions of the CRT object files are no longer
required.
2020-10-14 10:53:56 -04:00
Ken Brown f5b381ff56 Cygwin: document the last bug fix 2020-10-14 10:53:56 -04:00
Ken Brown 53f657e4a6 Cygwin: fhandler_termios::tcsetpgrp: check that argument is non-negative
Return -1 with EINVAL if pgid < 0.

Previously tcsetpgrp() would blindly go ahead and set the pgid of the
controlling terminal to a negative value, causing later calls to
various functions to fail.

For example, gdb has code like the following:

  tcsetpgrp (0, getpgid (inf->pid));

If getpgid (inf->pid) fails (returns -1), then this code would set the
pgid of fd 0 to -1, so that some later calls to getpgid() would also
return -1.  This caused the problem reported here:

  https://cygwin.com/ml/cygwin/2019-07/msg00166.html.
2020-10-14 10:53:56 -04:00
Corinna Vinschen ea55bbccc5 Regenerate newlib/libc/search/Makefile.in for ndpm port
Signed-off-by: Corinna Vinschen <corinna-cygwin@cygwin.com>
2020-10-14 10:53:56 -04:00
uchan-nos a765977a67 fix compile errors for efgcvt.c 2020-10-14 10:53:56 -04:00
Vaibhav Gupta f9cd363ea4 Port ndbm 2020-10-14 10:53:56 -04:00
Alexander Fedotov 95e86ecd29 Stack Pointer and Stack Limit initialization refactored.
SP initialization changes:
  1. set default value in semihosting case as well
  2. moved existing SP & SL init code for processor modes in separate routine and made it as "hook"
  3. init SP for processor modes in Thumb mode as well

Add new macro FN_RETURN, FN_EH_START and FN_EH_END.
2020-10-14 10:53:56 -04:00
Ken Brown e3e9002520 Cygwin: fix one more check for positive virtual_ftype_t values
Also drop more comments referring to numerical virtual_ftype_t values.
2020-10-14 10:53:56 -04:00
Corinna Vinschen b2671d9e1c Cygwin: change virtual_ftype_t to not rely on negative values
So far negative values were denoting files, positive values
denoting directories.  We should prefer a less error prone
method.  Redefine virtual_ftype_t to contain only positive
values and replace checks for negativ or positive values with
inline functions virt_ftype_isfile() and virt_ftype_isdir().

Drop outdcated comments referring to numerical virtual_ftype_t
values.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:53:56 -04:00
Corinna Vinschen 30b08fcbdb Cygwin: fix /proc/PID/fd return value in error case
commit 2607639992 "Improve error handling in /proc/[pid]/
virtual files." changed the return value of the /proc/PID
formatting functions to return -1 instead of 0 in the error
case to allow a filesize of 0.

The patch neglected to change this behaviour for /proc/PID/fd
content.  This patch fixes that.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:53:56 -04:00
Ken Brown aeb38a24af Cygwin: add release notes for 3.0.8 2020-10-14 10:53:56 -04:00
Ken Brown ceca51fdde Cygwin: socket files are not lnk special files
Change path_conv::is_lnk_special() so that it returns false on socket
files.

is_lnk_special() is called by rename2() in order to deal with special
files (FIFOs and symlinks, for example) whose Win32 names usually have
a ".lnk" suffix.  Socket files do not fall into this category, and
this change prevents ".lnk" from being appended erroneously when such
files are renamed.

Remove a now redundant !pc.issocket() from fhandler_disk_file::link().
2020-10-14 10:53:56 -04:00
Ken Brown 3b23fe5d82 Cygwin: remove path_conv::is_fs_device()
It is used only once.
2020-10-14 10:53:56 -04:00
Ken Brown 0bb03f90e7 Cygwin: remove path_conv::is_auto_device()
It is used only once, and the name is supposed to suggest "device that
is not based on the filesystem".  This intended meaning is clearer if
we just replace is_auto_device() by its definition at the place where
it's used.
2020-10-14 10:53:56 -04:00
Ken Brown eb171bc799 Cygwin: fhandler_*: remove isdevice() and is_auto_device()
isdevice() is used only in the definition of is_auto_device().  And
the latter is used only once, in a context where isdevice() always
returns true.
2020-10-14 10:53:56 -04:00
Ken Brown 103f6a72a3 Cygwin: unbreak the build with GCC 7
The recent port to GCC 8 used the 'nonstring' attribute, which is
unknown to GCC 7.  Define and use an 'ATTRIBUTE_NONSTRING' macro
instead.
2020-10-14 10:53:56 -04:00
Ken Brown 76f3fb3076 Cygwin: fix GCC 8.3 'local external declaration' errors
Move external declarations out of function definition.
2020-10-14 10:53:56 -04:00
Ken Brown a596f6e389 Cygwin: fix GCC 8.3 'asm volatile' errors
Remove the volatile qualifier, which is no longer allowed outside of
the function body.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89585 for discussion.
2020-10-14 10:53:56 -04:00
Ken Brown d6c2cf3b9d Cygwin: suppress GCC 8.3 errors with -Warray-bounds 2020-10-14 10:53:55 -04:00
Ken Brown aa6d3f0250 Cygwin: avoid GCC 8.3 errors with -Werror=stringop-truncation 2020-10-14 10:53:55 -04:00
Ken Brown 603b83eed7 Cygwin: avoid GCC 8.3 errors with -Werror=class-memaccess 2020-10-14 10:53:55 -04:00
Corinna Vinschen 5e3733ac79 Cygwin: sigpending: don't report pending signals for other threads
The sigpending mechanism failed to check if the pending signal was a
process-wide signal, or a signal for the curent thread.  Fix that by
adding a matching conditional to wait_sig's __SIGPENDING code.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:53:55 -04:00
Corinna Vinschen 54eb35e966 Cygwin: return full sigset_t from sig_send
So far sig_send's return type is int.  The problem with this is
that sig_send returns a sigset_t on __SIGPENDING, and sigset_t
is defined as long type.  So the function only returns the lower
32 bit of sigset_t, which is fine on 32 bit, but casts away the
pending RT signals on 64 bit.

Fix this by changing the return type of sig_send to sigset_t, so
as not to narrow down the sigset when returning from handling
__SIGPENDING.  Make sure to cast correctly in all invocations
of sig_send.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:53:55 -04:00
Jeff Johnston ce2bc58399 Set errno in expm1{,f} / log1p{,f}
2019-07-09  Joern Rennecke  <joern.rennecke@riscy-ip.com>

	* libm/common/s_expm1.c ("math_config.h"): Include.
	(expm1): Use __math_oflow to set errno.
	* libm/common/s_log1p.c ("math_config.h"): Include.
	(log1p): Use __math_divzero and __math_invalid to set errno.
	* libm/common/sf_expm1.c ("math_config.h"): Include.
	(expm1f): Use __math_oflow to set errno.
	* libm/common/sf_log1p.c ("math_config.h"): Include.
	(log1pf): Use __math_divzero and __math_invalid to set errno.
2020-10-14 10:53:55 -04:00
Mark Geisert 3988834ee1 Cygwin: Fix return value of sched_getaffinity
Have sched_getaffinity() interface like glibc's, and provide an
undocumented internal interface __sched_getaffinity_sys() like the Linux
kernel's sched_getaffinity() for benefit of taskset(1).
2020-10-14 10:53:55 -04:00
Corinna Vinschen f132e630c4 sched: Move Cygwin cpuset definitions into Cygwin-specific header
This avoids build breakage on RTEMS.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2020-10-14 10:53:55 -04:00
Ken Brown c2b392c600 Cygwin: honor the O_PATH flag when opening a FIFO
Previously fhandler_fifo::open would treat the FIFO as a reader and
would block, waiting for a writer.
2020-10-14 10:53:55 -04:00
Martin Erik Werner d07d375bc4 or1k: Avoid write outside setjmp buf & shrink buf
Update the offsets used to save registers into the stejmp jmp_buf
structure in order to:

* Avoid writing the supervision register outside the buffer and thus
  clobbering something on the stack. Previously the supervision register
  was written at offset 124 while the buffer was of length 124.

* Shrink the jmp_buf down to the size actually needed, by avoiding holes
  at the locations of omitted registers.
2020-10-14 10:53:55 -04:00
Mark Geisert 24590ed7bd Cygwin: Build cygwin-console-helper with correct compiler 2020-10-14 10:53:55 -04:00
Mark Geisert 9afb622c38 Cygwin: Use correct string conversion
Correct the string conversion calls so both argv elements get converted
at full precision.
2020-10-14 10:53:55 -04:00
Martin Erik Werner 775e529689 or1k: Correct longjmp return value
Invert equality check instruction to correct the return value handling
in longjmp.

The return value should be the value of the second argument to longjmp,
unless the argument value was 0 in which case it should be 1.

Previously, longjmp would set return value 1 if the second argument was
non-zero, and 0 if it was 0, which was incorrect.
2020-10-14 10:53:55 -04:00
Ken Brown a83682e167 Cygwin: FIFO: fix a thinko in raw_write
Remove a line that has no effect.
2020-10-14 10:53:55 -04:00
Ken Brown 7faf75c189 Tweak release message 2020-10-14 10:53:55 -04:00
Ken Brown 73e3ff9328 Cygwin: timerfd: avoid a deadlock
Add a function timerfd_tracker::enter_critical_section_cancelable,
which is like enter_critical_section but honors a cancel event.  Call
this when a timer expires while the timerfd thread is in its inner
loop.  This avoids a deadlock if timerfd_tracker::dtor has entered its
critical section and is trying to cancel the thread.  See
https://cygwin.com/ml/cygwin/2019-06/msg00096.html.
2020-10-14 10:53:55 -04:00
Alexander Fedotov b7c9ab1af6 Arm: Use lrdimon-v2m_nano when semihosting v2 and nano selected respectively 2020-10-14 10:53:55 -04:00
Jozef Lawrynowicz 6e0df9496e Support calculation of pointer size for __int20__ type in _intsup.h
GCC r272640 modifies the MSP430 target to use "__int20__" for
PTRDIFF_TYPE (and therefore INTPTR_TYPE) instead of "__int20".

To support the calculation of pointer size in
newlib/libc/include/sys/_intsup.h, definitions for __int20__ need to be
added.
2020-10-14 10:53:55 -04:00
Mark Geisert 860ed4a2bf Cygwin: Implement sched_[gs]etaffinity()
This patch set implements the Linux syscalls sched_getaffinity,
sched_setaffinity, pthread_getaffinity_np, and pthread_setaffinity_np.
Linux has a straightforward view of the cpu sets used in affinity masks.
They are simply long (1024-bit) bit masks.  This code emulates that view
while internally dealing with Windows' distribution of available CPUs among
processor groups.
2020-10-14 10:53:55 -04:00
Ken Brown e5a7dc08c1 Cygwin: FIFO: minor cleanup
Don't use a label with the same name as a variable.

Also fix indentation in fhandler.h.
2020-10-14 10:53:54 -04:00
Ken Brown 4763dcc080 Cygwin: FIFO: slightly change the use of write_ready
Make it a manual reset event.  It's only used once to allow a reader
to open, and there's no reason to ever reset it.  Defensively set it
when a client connection is recorded, even though it should be set by
the writer that connected.
2020-10-14 10:53:54 -04:00
Ken Brown 6af347ba41 Cygwin: FIFO: remove fifo_client_handler::connect_evt
It's not needed.  Instead just create and use an event in
fhandler_fifo::listen_client_thread.
2020-10-14 10:53:54 -04:00
Ken Brown 85601de166 Cygwin: FIFO: simplify raw_read
Call NtReadFile directly instead of calling fhandler_base::raw_read.
In addition to being simpler, this gives us access to the return value
from NtReadFile.
2020-10-14 10:53:54 -04:00
Ken Brown 229be09b1b Cygwin: FIFO: improve termination of the listen_client thread
Add a method fifo_client_handler::pipe_state that queries Windows for
the state of a pipe instance.  Use this to help terminate the
listen_client thread cleanly.

If the last client handler is useless, delete it instead of declaring
it invalid.
2020-10-14 10:53:54 -04:00
Ken Brown 027adac187 Cygwin: FIFO: avoid deadlock when closing
fhandler_fifo::close could be called from a signal handler or another
thread at a time when another function is holding the fifo_client
lock.  This could prevent the listen_client thread from acting on the
thread termination event.  Avoid a deadlock by calling
fifo_client_unlock at the beginning of fhandler_fifo::close.
2020-10-14 10:53:54 -04:00
Ken Brown a92e5ecd0d Cygwin: FIFO: clean up locks
Make sure to use the fifo_client lock when (and only when) it is
needed.
2020-10-14 10:53:54 -04:00
Ken Brown d46b3f83c8 Cygwin: FIFO: add some error checking
Change the return type of fhandler_fifo::delete_client_handler from
void to int so that we can report errors.
2020-10-14 10:53:54 -04:00
Ken Brown b23dcaa411 Cygwin: FIFO: fix signal handling in raw_read and raw_write
cygwait wasn't being called correctly.

Also do some minor cleanup in raw_read and raw_write.
2020-10-14 10:53:54 -04:00
Corinna Vinschen 8c187cceaa Rename <xlocale.h> back to <sys/_locale.h>
libX11 provides <X11/Xlocale.h>.  The build of libX11 itself adds
include/X11 to the compiler's include path.  This results in a name
collision with /usr/include/xlocale.h on case-insensitive filesystems.

Commit 90e35b1eb3 renamed sys/_locale.h to xlocale.h in March 2017 under
the assumption that we should provide the locale_t type in the same file
as on Linux, FreeBSD, and Darwin.

A few weeks later (June 2017), glibc removed the xlocale.h file in favor
of bits/types/locale_t.h, which shouldn't be included directly anyway.

For reference and the reasoning, see
https://sourceware.org/git/?p=glibc.git;a=commit;h=f0be25b6336d

Given the above, revert 90e35b1eb3 and
fix additional usage of xlocale.h.
2020-10-14 10:53:54 -04:00
Ken Brown fdae43a20a Revert "Cygwin: fork: Remember child not before success."
This reverts commit f03ea8e1c5.  That
commit leads to fork problems if cygserver is running:

https://cygwin.com/ml/cygwin-patches/2019-q2/msg00155.html
2020-10-14 10:53:54 -04:00
Jeff Johnston 814f8af633 Fix __getreent stack calculations for AMD GCN
From: Andrew Stubbs <ams@codesourcery.com>

Fix a bug in which the high-part of 64-bit values are being corrupted, leading
to erroneous stack overflow errors. The problem was only that the mixed-size
calculations are being treated as signed when they should be unsigned.
2020-10-14 10:53:54 -04:00
Jeff Johnston aaf5704778 Add gfortran support for AMD GCN
From: Kwok Cheung Yeung <kcy@codesourcery.com>

This patch adds enough support for constructors/destructors and OS functions
to be able to link and run gfortran programs on AMD GCN.

There's no actual ability to do I/O operations on this targets, besides
"write" to stdout and stderr, so most of the functions are just stubs.
2020-10-14 10:53:54 -04:00