Commit Graph

3149 Commits

Author SHA1 Message Date
Giacomo Tesio b674052101 Merge of upstream-master 2019-08-12 01:41:02 +02:00
Alexander Fedotov bf56973edc Align libgloss/arm and libc/sys/arm sources: miscellaneous fixes
1. Trim trailing spaces
2. Align comments, function declarations and definitions
2019-08-05 13:00:53 +01:00
Alexander Fedotov bd5596f4fd Align libgloss/arm and libc/sys/arm sources: Lite exit support
Applied changes from commit 2404223:

	* arm/crt0.S (_mainCRTStartup): Weak reference to atexit and _fini
		when lite exit is enabled.
2019-08-05 13:00:53 +01:00
Alexander Fedotov dfffe68303 Align libgloss/arm and libc/sys/arm sources: HeapInfo and __heap_limit
Applied changes from commit 8d98f95:

	* arm/crt0.S: Initialise __heap_limit when ARM_RDI_MONITOR is defined.
	* arm/syscalls.c: define __heap_limit global symbol.
	* arm/syscalls.c (_sbrk): Honour __heap_limit.

Applied changes from commit 8d98f95:
	Fixed semihosting for ARM when heapinfo not provided by debugger
2019-08-05 13:00:53 +01:00
Alexander Fedotov 37e80fbb1c Align libgloss/arm and libc/sys/arm sources: Fix GetCmdLine semihosting directives
Applied changes from the commit 9b11672:

	When simulating arm code, the target program startup code (crt0) uses
	semihosting invocations to get the command line from the simulator. The
	simulator returns the command line and its size into the area passed in
	parameter. (ARM 32-bit specifications :
	http://infocenter.arm.com/help/topic/com.arm.doc.dui0058d/DUI0058.pdf
	chapter "5.4.19 SYS_GET_CMDLINE").

	The memory area pointed by the semihosting register argument is located
	in .text section (usually not writtable (RX)).

	If we run this code on a simulator that respects this rights properties
	(qemu user-mode for instance), the command line will not be written to
	the .text program memory, in particular the length of the string. The
	program runs with an empty command line. This problem hasn't been seen
	earlier probably because qemu user-mode is not so much used, but this can
	happen with another simulator that refuse to write in a read-only segment.

	With this modification, the command line can be correctly passed to the
	target program.

	Changes:
	- newlib/libc/sys/arm/crt0.S : Arguments passed to the
	AngelSWI_Reason_GetCmdLine semihosting invocation are placed into .data
	section instead of .text
2019-08-05 13:00:53 +01:00
Kito Cheng 654398db84 RISC-V: Fix header guard for sys/fenv.h 2019-08-02 09:34:39 +02:00
Joel Sherrill 3e5302714f common/math_errf.c: Enable compilation of __math_oflowf
This resolved linking errors when using methods such as
	expm1().
2019-07-26 14:54:29 -05:00
Ken Brown dea3d8c73e hash.c: #include <reent.h>
This is needed for the prototypes of _stat64 and _fstat64 on Cygwin.

Fixes: commit 279805b2 "hash functions: use reentrant stat functions".
2019-07-26 13:06:12 -04:00
Richard Earnshaw 65416cca7e [arm] remove libc/sys/arm/sys/param.h
The Arm sys/param.h does not define anything differently to the
generic sys/param.h, but fails to define some things that that file
provides.  There does not appear to be any reason to keep this version
and we should revert to using the common version.
2019-07-26 16:13:30 +01:00
Vaibhav Gupta b39cd00f07 Port ndbm - Remove Declaration of dbm_forder 2019-07-25 15:28:32 +02:00
Corinna Vinschen 279805b20b hash functions: use reentrant stat functions
_stat64 and _fstat64 are not exported from Cygwin.  Use the
reentrant analogues, like everywhere else.

Signed-off-by: Corinna Vinschen <corinna-cygwin@cygwin.com>
2019-07-24 22:32:48 +02:00
Corinna Vinschen 280b21d373 Regenerate newlib/libc/search/Makefile.in for ndpm port
Signed-off-by: Corinna Vinschen <corinna-cygwin@cygwin.com>
2019-07-24 18:49:11 +02:00
uchan-nos 9cde02051e fix compile errors for efgcvt.c 2019-07-24 11:58:21 +02:00
Vaibhav Gupta e50ad9fbdc Port ndbm 2019-07-24 09:19:40 +02:00
Alexander Fedotov 942f60d714 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.
2019-07-23 10:00:06 +02:00
Jeff Johnston 0d24a86822 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.
2019-07-09 13:06:59 -04:00
Corinna Vinschen 383e19ca55 sched: Move Cygwin cpuset definitions into Cygwin-specific header
This avoids build breakage on RTEMS.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-06-27 20:19:31 +02:00
Martin Erik Werner 739e89cbe6 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.
2019-06-27 12:51:54 +02:00
Martin Erik Werner 8b080534ca 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.
2019-06-27 09:09:37 +02:00
Jozef Lawrynowicz 301facfb60 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.
2019-06-25 13:37:16 -04:00
Mark Geisert 641ecb0753 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.
2019-06-24 09:18:14 +02:00
Corinna Vinschen ad101bcb0f 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.
2019-06-14 10:02:08 +02:00
Jeff Johnston eb429ad509 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.
2019-06-07 13:57:45 -04:00
Jeff Johnston 007bc1923c 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.
2019-06-07 13:55:43 -04:00
trasz 4feb21d705 Mark inline functions with __unused;
prevents compiler warning when they end up being unused.

Reviewed by:	kib
Obtained from:	OpenBSD
MFC after:	2 weeks
Sponsored by:	Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D20185
2019-06-07 09:13:13 +02:00
pfg 160f9f0bf2 sys/sys: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.
2019-06-07 09:11:15 +02:00
Lucio Andrés Illanes Albornoz d5daede26c 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>

--
2019-06-03 10:38:40 +02:00
Sebastian Huber f5a5a23ea8 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>
2019-06-03 10:20:15 +02:00
Sebastian Huber 86809750bb 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>
2019-06-03 10:20:15 +02:00
Sebastian Huber 66e75b6961 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>
2019-06-03 10:20:15 +02:00
Jim Wilson 5c86f0da5f 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.
2019-05-22 17:36:57 -07:00
Jozef Lawrynowicz 1e6c561d48 Implement reduced code size "tiny" printf and puts
"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
2019-04-15 14:22:33 +02:00
Jozef Lawrynowicz 2af6ad9f05 Copy prerequisite file for "tiny" printf implementation
Use newlib/libc/stdio/nano-vfprintf.c as baseline for tiny-printf.c
2019-04-15 14:22:30 +02:00
Alexander Fedotov a0b0a4a018 Align comments and spaces in libgloss/arm/crt0.S and newlib/libc/sys/arm/crt0.S to ease further code alignment. 2019-04-12 14:34:47 +01:00
Christophe Lyon cc430406ac Include code in trap.S for APCS only.
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__.
2019-04-11 14:20:21 +00:00
Christophe Lyon 630808d2a2 Make more macro checks ARMv8-M baseline proof.
Commit 69f4c40291 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__.
2019-04-11 14:20:21 +00:00
Andrew Stubbs e8b23909e4 Add missing includes.
These missing includes were causing build warnings, but also a real bug in
which the "size" parameter to "write" was being passed in 32-bit, whereas it
ought to be 64-bit.  This led to intermittent bad behaviour.
2019-03-25 16:44:10 +01:00
Andrew Stubbs 62c66a39bd AMD GCN: Implement circular buffering.
The GCN port outputs stdout and stderr via a shared-memory interface.
Previously the buffer was limited to 1000 write operations, which was enough
for testing purposes, but easy to exhaust.

This patch implements a new circular buffering system allowing a greater
amount of output.  The interface must allow hundreds of hardware threads to
output simultaneously.  The new limit is UINT32_MAX write operations.

Unfortunately, there's no way to tell if the host side has also been updated.
This code will misbehave unless the gcn-run from GCC is also updated (although
it's fine the other way around), but that patch has already been committed.

OK?

Andrew Stubbs
Mentor Graphics / CodeSourcery
2019-03-18 17:38:25 +01:00
Corinna Vinschen 5fcbbf7ead stdio: drop unused O_TEXT handling on non-Cygwin
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-02-22 21:58:51 +01:00
Yaakov Selkowitz 850705f92e Cygwin: add secure_getenv
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2019-02-19 13:01:50 -06:00
Sebastian Huber 1d35a003fd Define u_register_t if __BSD_VISIBLE
Add u_register_t definition for FreeBSD compatibility.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2019-02-19 09:06:22 +01:00
Sebastian Huber 688e584efe Change register_t definition
On 64-bit targets, the register_t type must be a 64-bit integer.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2019-02-19 09:06:22 +01:00
Sebastian Huber 6246ef7949 Fix comment in <sys/types.h>
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2019-02-19 09:06:22 +01:00
Sebastian Huber 9d4a6534fb Move RTEMS and XMK specific type definitions
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2019-02-19 09:06:22 +01:00
Sebastian Huber 3e24fbf6f0 scandir: Add support for struct dirent::d_type
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2019-02-01 10:37:00 +01:00
ache 67613cbbd8 a) Use strcoll() in opendir() and alphasort()
as POSIX 2008 requires. It also matches now how our 'ls' works for years.

b) Remove comment expressed 2 fears:
 1) One just simple describe how strcoll() works in _any_ context,
 not for directories only. Are we plan to remove strcoll() from everything
 just because it is little more complex than strcmp()? I doubt, and
 directories give nothing different here. Moreover, strcoll() used
 in 'ls' for years and nobody complaints yet.

 2) Plain wrong statement about undefined strcoll() behaviour. strcoll()
 always gives predictable results, falling back to strcmp() on any
 trouble, see strcoll(3).

No objections from -current list discussion.
2019-02-01 10:37:00 +01:00
das 2d3c2f4697 scandir(3) previously used st_size
to obtain an initial estimate of the array length needed to store all
the directory entries. Although BSD has historically guaranteed that
st_size is the size of the directory file, POSIX does not, and more to
the point, some recent filesystems such as ZFS use st_size to mean
something else.

The fix is to not stat the directory at all, set the initial
array size to 32 entries, and realloc it in powers of 2 if that
proves insufficient.

PR:	113668
2019-02-01 10:36:40 +01:00
obrien d785551a46 Remove __P and convert to ANSI prototypes.
* Fix SCM ID's.
2019-02-01 10:33:14 +01:00
jhb 0e7db0c356 Clean up the vcs ID strings
in libc's gen/ directory.

- Move CSRG IDs into __SCCSID().
- When a file has been copied, consistently use 'From: <tag>' for strings
  referencing the version of the source file copied from in the license
  block comment.
- Some of the 'From:' tags were using $FreeBSD$ that was being expanded on
  each checkout.  Fix those to hardcode the FreeBSD tag from the file that
  was copied at the time of the copy.
- When multiple strings are present list them in "chronological" order,
  so CSRG (__SCCSID) before FreeBSD (__FBSDID).  If a file came from
  OtherBSD and contains a CSRG ID from the OtherBSD file, use the order
  CSRG -> OtherBSD -> FreeBSD.

Reviewed by:	imp
Differential Revision:	https://reviews.freebsd.org/D15831
2019-02-01 10:32:24 +01:00
imp b46ef7699f Renumber copyright clause 4
Renumber cluase 4 to 3, per what everybody else did when BSD granted
them permission to remove clause 3. My insistance on keeping the same
numbering for legal reasons is too pedantic, so give up on that point.

Submitted by:	Jan Schaumann <jschauma@stevens.edu>
Pull Request:	https://github.com/freebsd/freebsd/pull/96
2019-02-01 10:32:24 +01:00