Commit Graph

18539 Commits

Author SHA1 Message Date
Giacomo Tesio 85e6cabc69 Merge branch 'master' of https://bitbucket.org/tesio/newlib-cygwin 2018-11-26 22:08:58 +01:00
Giacomo Tesio 266d2c4d34 jehanne: ansification + upstream update 2018-11-26 03:04:32 +01:00
Giacomo Tesio a000564873 jehanne: merge upstream changes 2018-11-26 16:27:49 +01:00
Matthew Malcomson 2d6b71ee6d Builtin enable return code with SYS_EXIT_EXTENDED
A previous commit introduced the ability to use the semi-hosting
SYS_EXIT_EXTENDED operation to libgloss, this commit adds the same
ability to the sys/arm/ backend so that building newlib only will
provide the same capabilities.
2018-11-26 10:07:55 -05:00
Giacomo Tesio 98675f1ea0 jehanne: fix broken code 2018-11-21 22:45:26 +01:00
Giacomo Tesio 699179a669 jehanne: completed termios and drafted (f)pathconf
I/O baudrate hard coded at 38400 (set functions fail with EINVAL).

fpathconf and pathconf fail with EINVAL
2018-11-20 11:57:38 +01:00
Jim Wilson 7e72be1c39 Add libgloss install-pdf and install-html targets.
The toplevel makefile used by binutils/gcc/newlib/etc has install-pdf and
install-html targets, but they fail because libgloss doesn't support them.
Tested with an arm-eabi combined tree build and install, and verifying that
the install-pdf and install-html targets now work, and that the pdf and html
doc files are now in the install tree.

	libgloss/
	* Makefile.in (install-html, install-pdf): New.
	* doc/Makefile.in (htmldir, pdfdir): New.
	(porting.ps): Delete white space on blank line.
	(install-pdf, install-html): New.
2018-11-20 11:13:34 +01:00
Matthew Malcomson 6dbd190111 Enable return code with semi-hosting SYS_EXIT_EXTENDED
The _exit function currently passes -1 as a "sig" to the _kill function as an
invalid signal number so that _kill can distinguish between an abort and a
standard exit.

For boards using the SYS_EXIT_EXTENDED semi-hosting operation to return a
status code, this means that the "status" paramter to _exit is ignored and the
return code is always -1.
https://developer.arm.com/docs/100863/latest/semihosting-operations/sys_exit_extended-0x20

This patch puts shared code between _kill and _exit into a new function
_kill_shared that takes the semi-hosting "reason" to use (if semi-hosting is
available) as an argument.

For semi-hosting _kill_shared provides that "reason".

Without the "sig" argument being used to distinguish between a normal and
abnormal exit, the _exit function can provide the return code to be used if the
SYS_EXIT_EXTENDED operation is available.

Hence the exit code can be returned.
2018-11-19 13:46:19 +01:00
Wilco Dijkstra df7824d1a4 Fix issue with dst bias in memset
This patch fixes an issue in the previous memset loop change. If the
zva size is >= 256 and there are more than 64 bytes left in the
tail, we could enter the loop and thus need to rebias dst by 32 as
well.

Since no known CPUs use this size this can't be tested natively, so I've
tested it on a simulator initialized with a large zva size.

--
2018-11-08 16:45:19 +00:00
Corinna Vinschen bba82041b2 Cygwin: Bump DLL version to 2.11.3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-11-08 15:31:25 +01:00
Sebastian Huber 2ab57ad59b Fix v850 target for RTEMS
Do not define __ATTRIBUTE_IMPURE_PTR__ for RTMES on the v850 target.
The previous definition lead to the following linker error in
combination with -fdata-sections:

relocation truncated to fit: R_V810_GPWLO_1 against symbol
`_global_impure_ptr' defined in .rodata._global_impure_ptr section in
libc.a(lib_a-impure.o)

relocation truncated to fit: R_V810_GPWLO_1 against symbol `_impure_ptr'
defined in .data._impure_ptr section in libc.a(lib_a-impure.o)

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-11-08 09:38:13 +01:00
Sebastian Huber 1471e7cd74 RTEMS: Avoid <machine/param.h> in <sys/_cpuset.h>
The <machine/param.h> header file exposes some unrelated stuff not
covered by C or POSIX.  Avoid its use in <sys/_cpuset.h> since it is
included in <rtems.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-11-08 09:38:12 +01:00
Wilco Dijkstra d80db60066 Adjust writeback in non-zero memset
This fixes an ineffiency in the non-zero memset.  Delaying the writeback
until the end of the loop is slightly faster on some cores - this shows
~5% performance gain on Cortex-A53 when doing large non-zero memsets.

Tested against the GLIBC testsuite.
2018-11-06 14:59:51 +00:00
Corinna Vinschen 535903696c Cygwin: honor SOCK_NONBLOCK/SOCK_CLOEXEC in socket(2)/socketpair(2)
fhandler_socket_wsock::set_socket_handle calls set_flags after
setting the O_NONBLOCK/O_CLOEXEC flags, thus overwriting them.

It also turns out that fhandler_socket_wsock::init_events is called
too late.  The inheritence flags are changed before creating the
socket event handling objects.  Thus, inheritence flags for
those objects are wrong with SOCK_CLOEXEC.

Fix this by reordering the calls and setting the file flags through
fhandler_base::set_flags.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-11-05 21:02:22 +01:00
Stafford Horne 8ac94ca7bb newlib/configure.host: Set have_init_fini to no for OpenRISC
The new GCC port for OpenRISC will use the init_fini_array only and not
provide the init() and fini() functions.  Disable the function usage by
default as its no longer needed.

Signed-off-by: Stafford Horne <shorne@gmail.com>
2018-11-05 10:02:20 +01:00
Tamar Christina 9a7f131e0e Initialize SVE system registers.
This patch initializes the SVE system registers if available
and initializes the vector length to the maximum supported.

This is done according to the SVE specification [1].

[1] https://developer.arm.com/docs/ddi0584/latest/arm-architecture-reference-manual-supplement-the-scalable-vector-extension-sve-for-armv8-a
2018-10-31 11:14:57 +00:00
Corinna Vinschen 2bbe8697d8 Cygwin: fix memory corruption/SEGV if certain socket functions fail
Regression introduced with 2.11.0:

The failure paths in socket, socketpair and accept4 functions and
methods accidentally release *unused* cygheap_fdmanip objects.  The
subsequently called dtable::release method was designed to be called for
*used* cygheap_fdmanip objects only.  Using them on unused objects leads
to NULL pointer member dereferencing.

Worse, the inet/local accept4 methods only release the cygheap_fdmanip
object but neglect to delete the just created fhandler_socket_* object.

Fix this by removing the erroneous release calls in the aforementioned
failure paths and delete the fhandler_socket_* object in accept4 instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-29 16:32:48 +01:00
David McFarland af85fdd73f Cygwin: Fix cygheap corruption caused by cloned atomic buffer
The fhandler_base_overlapped::copyto clears atomic_write_buf on the
clone, but none of the derived classes were doing this.  This allowed
the destructor to double-free the buffer and corrupt cygheap.
Clear atomic_write_buf in copyto of all derived classes.
2018-10-29 10:08:53 +01:00
Sebastian Huber 08eab6396f Fix posix_memalign() attributes
The malloc, alloc_size and alloc_aligned attributes must be only used in
case the function returns the pointer to the allocated memory.

See also:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87683

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-22 11:26:39 +02:00
Sebastian Huber 5835688440 RTEMS: Use function and data sections
Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-10-22 11:26:39 +02:00
Joel Sherrill 037428fae3 newlib/libc/sys/rtems/include/machine/param.h: Add _KERNEL to stop method leakage
The following FreeBSD kernel methods are not in any standard and
prototypes/definitions were leaking into application space:

  + round_page()
  + trunc_page()
  + atop()
  + ptoa()
  + pgtok()
2018-10-18 17:19:50 -05:00
Wilco Dijkstra 473f1a3a5d Improve performance of strstr
v3: Add support for read ahead using strnlen, giving an additional 25% speedup
on large inputs (both short and long needles).

This patch significantly improves performance of strstr by using Sunday's
Quick-Search algorithm.  Due to its simplicity it has the best average
performance of string matching algorithms on almost all inputs.  It uses a
bad-character shift table to skip past mismatches.

The needle length is limited to 254 - this reduces the shift table memory
4 to 8 times, lowering preprocessing overhead and minimizing cache effects.
The limit also implies its worst-case performance is linear.

Larger needles are processed by the Two-Way algorithm.  The macro AVAILABLE
has been improved to use strnlen to read the input in chunks.  This results
in a 2.5 times speedup for large needles, reducing the performance drop when
the Quick-Search algorithm can't be used.

The code for 1-4 byte needles has been simplified and now uses unsigned
char.  Since the optimized code relies on 8-bit chars, we defer to the
size-optimized implementation if CHAR_BIT > 8.

The performance gain of finding a set of randomly chosen words of size 8 in
256 bytes of English text is 14 times on AArch64. For longer haystacks the
gain is well over 20 times.

The size-optimized strstr has also been rewritten from scratch to improve
performance.  On the same test the performance gain is 69%.

Tested against GLIBC testsuite, randomized tests and the GNULIB strstr test
(https://git.savannah.gnu.org/cgit/gnulib.git/tree/tests/test-strstr.c).

--
2018-10-18 19:51:39 +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 323b48b975 Cygwin: lseek: return ESPIPE rather than EINVAL when called on a fifo
Thanks to Henri for tracking this down:
https://cygwin.com/ml/cygwin/2018-10/msg00062.html

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-10-10 13:20:45 +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 b6ba19e355 [Aarch64] Syscalls: fix prototypes
This patch is similar the arm one committed recently.

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

	* libgloss/aarch64/syscalls.c (_sbrk): Fix prototype.
	(_getpid, _write, _swiwrite, _lseek, _swilseek, _read, _wriread):
	Likewise.
2018-10-08 14:39:16 +01: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 9edf0810db [Aarch64] Fix warning in _sbrk
2018-10-01  Christophe Lyon  <christophe.lyon@linaro.org>

    	* libgloss/aarch64/syscalls.c (_sbrk): Cast "__heap_limit" to
    	"char *".
2018-10-05 13:21:54 +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
Jeff Johnston 9feedf23db Update Arm entry in COPYING.NEWLIB.
- per Wilco Dijkstra's patch
- update Arm copyright notice to not exclude AArch64 and the various generic
  contributions made (like the new math functions).  Also update the date and
  change spelling to Arm Ltd.
2018-09-25 15:10:46 -04: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
Hans-Peter Nilsson a6837ca34f Committed, CRIS port: fix fallout from time_t defaulting to 64 bits, part 1
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.

libgloss:
	Adjust for syscall and userspace having different time_t or timeval.
	* cris/linunistd.h (kernel_time_t, kernel_suseconds_t, kernel_timeval):
	New types.
	(gettimeofday): Change the type of the first argument to be a
	pointer to a struct kernel_timeval.
	* cris/gensyscalls (_gettimeofday): Use an intermediate struct
	kernel_timeval for the syscall and initialize the result from
	that.

Signed-off-by: Hans-Peter Nilsson <hp@axis.com>
2018-09-13 17:57:11 +02:00
Corinna Vinschen d83404e418 Cygwin: console: make sure EnumFontFamiliesExW loop isn't infinite
The current loop condition is borderline.  Make sure it ends and
choose a replacement char in the unlikely case the current console
font isn't recognized at all.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-09-07 13:49:54 +02:00
Corinna Vinschen 7a720bfe08 Cygwin: console: store replacement char directly
Rather than relying on an index variable, store the current
replacement char and use that directly in WriteConsoleW.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-09-07 13:48:35 +02:00
Corinna Vinschen 60471176fd Cygwin: console: don't hang in check_font with raster fonts
EnumFontFamiliesExW fails if the font is "Terminal" (aka "Raster Fonts")
and lfCharSet requests ANSI_CHARSET.  Using DEFAULT_CHARSET fixes this.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-09-07 13:44:44 +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