Commit Graph

2982 Commits

Author SHA1 Message Date
Memallox b27b8de827 Add _console_read() implementation which is called by the read syscall (does not work yet!) 2018-10-13 13:26:48 +02:00
Memallox 044e1e61aa Pseudo-implement syscalls: lseek, close, fstat, isatty, raise, read 2018-10-13 13:26:48 +02:00
Memallox b3a1029f71 Remove legacy syscall definitions and changed syscall signatures 2018-10-13 13:26:48 +02:00
Memallox 0ff0769612 Add errno information to some not implemented syscalls. See https://sourceware.org/newlib/libc.html#Syscalls 2018-10-13 13:26:48 +02:00
Memallox e69da8b4e2 Enable newlib_io_c99_format to provide support for the %zu format specifier 2018-10-13 13:26:48 +02:00
Memallox ce937c71e5 Disable some newlib features by default to safe space 2018-10-13 13:26:48 +02:00
Memallox 13d72bd601 Implement a console which is fed by the _write() syscall (and thus e.g. stdout) and redirect locate() to the console 2018-10-13 13:26:48 +02:00
Memallox c1c7c8d46b Add stdlib Casio syscall definitions 2018-10-13 13:26:48 +02:00
Memallox c62afb7008 Add basic Casio syscalls (non-stdlib functionality) which are included into stdio.h 2018-10-13 13:26:38 +02:00
Memallox 00a813c879 Add the targets sh3eb, sh4eb to newlib/configure.host 2018-10-13 13:22:47 +02:00
Memallox adc05ff66f Add floating point definitions for sh3eb, sh4eb in ieeefp.c 2018-10-13 13:22:47 +02:00
Memallox 33212d2dd0 Add the targets sh3eb, sh4eb to the configure.in files and run autoconf 2018-10-13 13:22:47 +02:00
Memallox d5619f065a Copy code from target sh to sh3eb 2018-10-13 13:19:59 +02:00
Christophe Lyon 4f7a6c326a newlib/libc/ctype/jp2uc.c: Declare "cs" variable as "const char *"
Instead of "char *" to avoid compiler warnings.
This is OK because "cs" is only used as input of strcmp.
2018-10-11 16:32:14 +02:00
Sebastian Huber 103b055035 Add generic implementation of fdopendir()
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:17 +02:00
Sebastian Huber ab4fdab5d5 Add generic implementation of dirfd()
Use existing HAVE_OPENDIR define to determine if a generic
implementation should be provided.  Cygwin for example has its own
implementation of opendir() and dirfd().

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Sebastian Huber 738fdc6a42 RTEMS: Add struct dirent::d_type member
This is used by the file system support of libstdc++ for example.  Use
content from latest FreeBSD <sys/dirent.h>

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Sebastian Huber da418955f5 Move common <sys/dirent.h> content to <dirent.h>
Move common content of the various <sys/dirent.h> and the latest FreeBSD
<dirent.h> to <dirent.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Sebastian Huber 61fc64ed97 Open a directory with the usual flags
Use O_RDONLY since you are not supposed to write to a directory.

Use O_DIRECTORY as mandated by POSIX (The Open Group Base Specifications
Issue 7, 2018 edition IEEE Std 1003.1-2017):

"If the type DIR is implemented using a file descriptor, the descriptor
shall be obtained as if the O_DIRECTORY flag was passed to open()."

Use O_CLOEXEC as mandated by POSIX:

"When a file descriptor is used to implement the directory stream, it
behaves as if the FD_CLOEXEC had been set for the file descriptor."

Drop the fcntl() call in favour of O_CLOEXEC.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Sebastian Huber d3d838cc26 Make some standard open() flags visible
Make the POSIX O_CLOEXEC, O_NOFOLLOW, O_DIRECTORY, O_EXEC, and O_SEARCH
open() flags available also to non-Cygwin systems.

Make the BSD/glibc O_DIRECT open() flag  available also to non-Cygwin
systems.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-11 08:29:16 +02:00
Corinna Vinschen 256f1171ac newlib: Build internal strtold code only if HAVE_LONG_DOUBLE defined
Commit fbace81684
("Import correctly working strtold from David M. Gay.")
introduced two new files, strtorx.c and strtodg.c.  The functions
are only called from strtold.c.  However, while strtold.c is only
built if HAVE_LONG_DOUBLE is defined, the patch erroneously added
the two new files to GENERAL_SOURCES unconditionally.

Fix this by building both files only if HAVE_LONG_DOUBLE has been
defined.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10 18:01:22 +02:00
Corinna Vinschen 35555851d7 newlib: strtold: use __builtin_nanl to avoid libm dependency
Commit 6c212a8b78
("Fix strtod ("nan") and strtold ("nan") returns wrong negative NaN")
introduced an unconditional dependency to nanl and, in turn, to libm.

Rather than including nanl in libc as well, just call __builtin_nanl
from here.  Requires GCC 3.3 or later.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10 17:53:55 +02:00
Corinna Vinschen 682c4a9f1e Implement nanl in newlib only
Drop Cygwin-specific nanl in favor of a generic implementation
in newlib.  Requires GCC 3.3 or later.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10 17:49:53 +02:00
Corinna Vinschen 9479563e48 newlib: Drop incorrect const qualifier from __loadlocale parameter
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10 11:18:20 +02:00
Sebastian Huber 201bbec6e4 Add attributes to malloc-like functions
These attributes help static analysis tools to produce less false
positives, e.g. double free warnings.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-10 07:40:06 +02:00
Christophe Lyon 8a7536e91d [ARM] Make _kill() a noreturn function.
AngelSWI_Reason_ReportException does not return accoring to the ARM
documentation, so it is valid to mark _kill() as noreturn.  This way,
the compiler does not warn about _exit() returning a value despite
being noreturn.

2018-10-01  Christophe Lyon  <christophe.lyon@linaro.org>

	* libgloss/arm/_exit.c (_exit): Declare _kill() as noreturn.
	* libgloss/arm/_exit.c (_kill): Likewise. Remove the return
	statements.
	* newlib/libc/sys/arm/syscalls.c (_kill): Likewise..
2018-10-08 14:35:43 +01:00
Christophe Lyon f53ce01125 Define _COMPILING_NEWLIB on aarch64 to define function prototypes from unistd.h.
2018-10-01  Christophe Lyon  <christophe.lyon@linaro.org>

    	* newlib/configure.host: Define _COMPILING_NEWLIB for aarch64.
2018-10-05 13:27:34 +01:00
Christophe Lyon 3878d82a2b [ARM] Cast string pointers to int to avoid compiler warnings.
2018-10-01  Christophe Lyon  <christophe.lyon@linaro.org>

    	* newlib/libc/sys/arm/syscalls.c (_unlink): Cast 'path' to int.
    	(_system): Cast 's' to int.
    	(_rename): Cast 'newpath' and 'oldpath' to int.
2018-10-05 12:00:44 +01:00
Wilco Dijkstra 71e187bc07 Update Arm copyright notices in new math files
While working on the strstr patch I noticed several copyright headers
of the new math functions are missing closing quotes after ``AS IS.
I've added these.  Also update spellings of Arm Ltd in a few places
(but still use ARM LTD in upper case portion).  Finally add SPDX
identifiers to make everything consistent.
2018-09-28 11:03:55 +01:00
Szabolcs Nagy 877a386d76 Fix the documentation comment of checkint
checkint in pow is not supposed to be used with 0, inf or nan inputs.
2018-09-18 14:12:18 -04:00
Hans-Peter Nilsson e3ddbeb84c Committed, CRIS port: fix fallout from time_t defaulting to 64 bits, part 2
It's been a while...  I see the CRIS port broke with the
time_t-default-to-64-bit change, observable by a few test-cases in the gcc
fortran(!) tests failing, regressing when trying a recent newlib.

This is a two-part belt-and-suspenders change: adjust the CRIS port
gettimeofday syscall (the only one in newlib/CRIS passing a time_t or
struct timeval) to handle a userspace 64-bit time_t and secondly default
time_t to 32-bit long anyway.  I considered making the local
"kernel_timeval" copy in _gettimeofday conditional on (userspace) time_t
being 64 bits, but thought it not worth bothering with the few move insns.
The effect of a 64-bit time_t is however observable as longer simulation
time when running the gcc testsuite and as bigger binaries without any
actual upside from the larger time_t size, so I thought better make the
default for this port go back to being a "long" again.

Tested by running the gcc testsuite over the three combinations of two
parts of the patch and observing the expected changes.  Committed.

newlib:
	* configure.host (cris, crisv32): Default to "long" time_t.

Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
2018-09-13 17:58:01 +02:00
Jon Beniston bd993df0e6 search: Fix Berkeley DB hash code for 16-bit targets.
hash.h: Use 32-bit type for data stored on disk, so code
works for 16 and 64-bit targets. Reduce maximum bucket size on 16-bit
targets, so it fits in available memory.
hash.c: Check bucket size isn't too big for target.
hash_buf.c: Fix overflow warning on 16-bit targets.
2018-09-06 17:29:49 +02:00
Keith Packard 77f8a6dfab Use !__HAVE_LOCALE_INFO__ define to use _ctype_ directly [v2]
When __HAVE_LOCALE_INFO__ is not selected, directly access the
existing _ctype_ variable from __locale_ctype_ptr() and
__locale_ctype_ptr_l(), eliminating the need for any locale or reent
structure

Signed-off-by: Keith Packard <keithp@keithp.com>

v2:
	locale: fix conflict with __locale_ctype_ptr macro

	If we are building without __HAVE_LOCALE_INFO__, there is a
	macro providing __locale_ctype_ptr which in turn fouls up this
	declaration.

	Signed-off-by: Michael Lyle <mlyle@lyle.org>
2018-09-06 14:19:53 +02:00
Keith Packard 3b6994ec5f stdlib: Use __get_numeric_locale instead of __localeconv_l for decimal_point
The string/float conversion functions need to get the locale decimal
point. Instead of calling __localeconv_l (which copies locale data
into lconv form from __get_numeric_locale), use __get_numeric_locale
directly.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-09-06 14:14:05 +02:00
Keith Packard 28ecec475f Include sys/syslimits.h in limits.h
This makes sure any system-defined limits are specified before the
defaults are checked. Without this, ARG_MAX and PATH_MAX end up
getting the default definitions from limits.h rather than the defines
from syslimits.h. This could potentially cause problems when
different files used different values for the same name.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-09-06 14:11:45 +02:00
Keith Packard 81e0841dbc xdr_private.h needs sys/types.h for u_char
u_char is defined in sys/types.h, which doesn't appear to get
included, at least in my environments.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-09-06 14:10:42 +02:00
Szabolcs Nagy f92a4c5d2d Document the log table generation method
Add comments with enough detail so the log lookup tables can be recreated.
2018-09-06 13:34:13 +02:00
Jon Beniston 7283d2513c stdlib/arc4random.c: Fix reseed count for 16-bit targets. 2018-09-06 13:26:25 +02:00
Wilco Dijkstra 6dbb20dfc7 Improve strstr performance of short needles
Improve strstr performance for the common case of short needles.  For a single
character strchr is best, for 2-4 characters a small loop is fastest.  For these
the speedup over the Two-Way algorithm is ~10 times on large strings.

Newlib builds, the new code passes GLIBC testsuite. OK for commit?
2018-09-05 10:09:31 +02:00
Jon Beniston 86c31ae47b math_config.h: Fix signed overflow warning for 16-bit targets 2018-09-03 09:41:26 +02:00
Jon Beniston fcc1e7039f e_scalb.c: Call scalbln instead of scalbn on 16-bit targets to ensure constant fits in an int. 2018-09-03 09:41:23 +02:00
Andy Koppe 3017f23f1c Avoid ARM SWI Seek when querying file position
Issuing an ARM semi-hosting Seek command when just querying file
position with SEEK_CUR and offset zero is unnecessary, because unlike
the lseek() Unix system call the Seek command does not actually return
the file position. For that reason, syscalls.c for ARM keeps track of
file position in the 'poslog', so we can just return that.

Moreover, since the Seek command only accepts an absolute file position,
SEEK_CUR operations are implemented by adding the relative offset to the
position in the poslog. If the host implements non-binary files with
implicit carriage return characters but doesn't discount those implicit
CRs when implementing Seek (by just mapping straight to Windows file
operations), this actually ended up wrongly changing file position when
using SEEK_CUR with offset zero or functions like ftell() or fgetpos()
that are based on that.

Also, use off_t rather than int for the poslog.
2018-09-03 09:40:39 +02:00
Jon Beniston a9cfb33b6c Add --disable-newlib-fno-builtin to allow compilation without -fno-builtin for smaller and faster code. 2018-08-31 15:40:42 -04:00
Andy Koppe d8ccbcdacc Drop non-reserved parameter names from sys/signal.h
Standard headers shouldn't use non-reserved identifiers as parameter
names in function declarations, because programs could in theory
define macros with such names before including a header.
2018-08-29 17:46:27 +02:00
Keith Packard 82dfae9ab0 Use __inhibit_loop_to_libcall in all memset/memcpy implementations
This macro selects a compiler option that disables recognition of
common memset/memcpy patterns and converting those to direct
memset/memcpy calls.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-08-29 16:05:37 +02:00
Keith Packard 088a45cdf6 Remove unused variable 'one' from sf_cos.c
Defined, never mentioned.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-08-29 15:57:27 +02:00
Keith Packard 2c245028af Use nanf("") instead of nanf(NULL)
Newer GCC versions require a non-NULL argument to this function for
some reason.

Signed-off-by: Keith Packard <keithp@keithp.com>
2018-08-29 15:57:27 +02:00
Sebastian Huber d13c84eb07 RTEMS: Add kvaddr_t and ksize_t
These types were introduced by FreeBSD commit:

"Make struct xinpcb and friends word-size independent.

Replace size_t members with ksize_t (uint64_t) and pointer members
(never used as pointers in userspace, but instead as unique
idenitifiers) with kvaddr_t (uint64_t). This makes the structs
identical between 32-bit and 64-bit ABIs.

On 64-bit bit systems, the ABI is maintained. On 32-bit systems,
this is an ABI breaking change. The ABI of most of these structs
was previously broken in r315662.  This also imposes a small API
change on userspace consumers who must handle kernel pointers
becoming virtual addresses.

PR:		228301 (exp-run by antoine)
Reviewed by:	jtl, kib, rwatson (various versions)
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D15386"

In RTEMS, there is no user/kernel space separation.  So, use the types
size_t and uintptr_t.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-08-24 15:07:29 +02:00
Sebastian Huber d35971f392 RTEMS: Introduce <machine/_kernel_mman.h>
This helps to avoid Newlib updates due to FreeBSD kernel space changes.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-08-24 15:04:43 +02:00
Sebastian Huber a2a8600f7d RTEMS: Introduce <machine/_kernel_socket.h>
This helps to avoid Newlib updates due to FreeBSD kernel space changes.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-08-24 15:04:43 +02:00