Commit Graph

1018 Commits

Author SHA1 Message Date
Yaakov Selkowitz 70ee6b17df ansification: remove _EXFUN, _EXFUN_NOTHROW
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:29 -06:00
Yaakov Selkowitz 77f16db546 ansification: remove _EXFNPTR, _EXPARM
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:27 -06:00
Yaakov Selkowitz 9087163804 ansification: remove _DEFUN
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:26 -06:00
Yaakov Selkowitz 44276afe2a ansification: remove _VOLATILE, _SIGNED
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:21 -06:00
Yaakov Selkowitz 67ee0cac4c ansification: remove _VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:20 -06:00
Yaakov Selkowitz fff27f8429 ansification: remove _DEFUN_VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:19 -06:00
Yaakov Selkowitz 670b01da7f ansification: remove _CAST_VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:17 -06:00
Yaakov Selkowitz e6321aa6a6 ansification: remove _PTR
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:16 -06:00
Yaakov Selkowitz eea249da3b ansification: remove _PARAMS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:13 -06:00
Yaakov Selkowitz e13e191b60 ansification: remove _NOARGS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:11 -06:00
Yaakov Selkowitz 2310096fbc ansification: remove _DOTS
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:10 -06:00
Yaakov Selkowitz 0bda30e1ff ansification: remove _CONST
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:08 -06:00
Yaakov Selkowitz 6783860a2e ansification: remove _AND
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:05 -06:00
Yaakov Selkowitz 82339fcd71 Make __always_inline macro compatible with glibc
For example, this is used when cross-compiling the Linux kernel on Cygwin.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-16 13:24:42 -06:00
Yaakov Selkowitz 2cb24159fb cygwin: add LFS_CFLAGS etc. to confstr/getconf
These are used, for instance, when cross-compiling the Linux kernel.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-16 12:12:45 -06:00
Martin Aberg 1251555311 newlib: Availability of _kill() in sys/signal.h
Make prototype of _kill() always visible when _COMPILING_NEWLIB is
defined. This makes <sys/signal.h> consistent with the use of
_COMPILING_NEWLIB in <sys/unistd.h>, <sys/times.h>, etc.
2017-12-18 19:58:05 +01:00
Yaakov Selkowitz 8f7c712bb8 ssp: add Object Size Checking for wchar.h, part 1
The following functions are also guarded in glibc:
fwprintf, swprintf, wprintf, vfwprintf, vswprintf, vwprintf.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-12-04 04:09:46 -06:00
Yaakov Selkowitz 8ba0bbb913 ssp: add Object Size Checking for unistd.h, part 2
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-12-01 03:41:49 -06:00
Yaakov Selkowitz b9a662bb4c Feature test macros overhaul: unistd.h, part 3
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-30 12:09:05 -06:00
Yaakov Selkowitz 1e43e181c2 ssp: add Object Size Checking for stdlib.h
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-30 12:09:03 -06:00
Yaakov Selkowitz 8a94bca694 string: add wmempcpy
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-30 04:06:49 -06:00
Yaakov Selkowitz 6b02865d80 ssp: add Object Size Checking for unistd.h, part 1
The implementation is from NetBSD, with the addition of feature test macros
for readlink.  glibc also wraps the following functions:
confstr, getdomainname, getgroups, gethostname, getlogin_r, getwd, pread,
readlinkat, ttyname_r.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29 11:25:44 -06:00
Yaakov Selkowitz 576093d46b ssp: add Object Size Checking for stdio.h, part 1
The implementation is mostly from NetBSD, except for switching fgets to
pure inline, and the addition of fgets_unlocked, fread, and fread_unlocked
for parity with glibc.  The following functions are also guarded in glibc:
asprintf, dprintf, fprintf, printf, vasprintf, vdprintf, vfprintf, vprintf.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29 11:25:42 -06:00
Yaakov Selkowitz a997f98b2a ssp: add Object Size Checking for strings.h
The implementation is from NetBSD, with the addition of explicit_bzero
for parity with glibc.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29 11:25:41 -06:00
Yaakov Selkowitz e4fc4d7bc4 ssp: add Object Size Checking for string.h
The implementation is from NetBSD, with the addition of mempcpy (a GNU
extension) for parity with glibc and libssp.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29 11:25:40 -06:00
Yaakov Selkowitz 3e8fc7d9f2 ssp: add Object Size Checking common code
The Object Size Checking (-D_FORTIFY_SOURCE=*) functionality provides
wrappers around functions suspectible to buffer overflows.  While
independent from Stack Smashing Protection (-fstack-protector*), they
are often used and implemented together.

While GCC also provides an implementation in libssp, it is completely
broken (CVE-2016-4973, RHBZ#1324759) and seemingly unfixable, as there
is no reliable way for a preprocessor macro to trigger a link flag.
Therefore, adding this here is necessary to make it work.

Note that this does require building gcc with --disable-libssp and
gcc_cv_libc_provides_ssp=yes.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-29 11:25:39 -06:00
Yaakov Selkowitz 36a0a675b4 Make __nonnull macro compatible with glibc
This form allows for multiple arguments, e.g. __nonnull((1,2)).

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-28 10:26:29 -06:00
Yaakov Selkowitz f2b27ce620 cygwin: define _POSIX_TIMEOUTS
Since commit 8128f5482f, we have all the
non-tracing functions listed in posixoptions(7).  The tracing functions
are gated by their own option, and are obsolecent anyway.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-11-28 10:26:00 -06:00
Jeff Johnston 569d048c89 Add the Aarch64 SVE specific HWCAP_SVE define
Checking in change from Alan Hayward <Alan.Hayward@arm.com>

Signed-off-by: Jeff Johnston <jjohnstn@redhat.com>
2017-11-22 14:10:37 -05:00
Corinna Vinschen baaceb8f37 Cygwin: fcntl.h: Use test macros to guard non-standard open flags
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-14 21:45:31 +01:00
Corinna Vinschen f9d071aaf8 Cygwin: fcntl.h: Define O_NOATIME
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-14 21:45:31 +01:00
Corinna Vinschen 0aa99373c1 Cygwin: fcntl.h: Define O_TMPFILE and implement it
Difference to Linux: We can't create files which don't show up
in the filesystem due to OS restrictions.  As a kludge, make a
(half-hearted) attempt to hide the file in the filesystem.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-11-14 21:45:25 +01:00
Sebastian Huber 1f42dc2bcf Make ffsl() and ffsll() BSD-visible
Since glibc 2.27, they are visible via _DEFAULT_SOURCE (__USE_MISC):

https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/man3/ffs.3?id=247bbcf00c9a425ab0ad6e303ec8718e4ba844a6

In FreeBSD, they are guarded by __BSD_VISIBLE.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-11-03 10:46:07 +01:00
Szabolcs Nagy c156098271 New expf, exp2f, logf, log2f and powf implementations
Based on code from https://github.com/ARM-software/optimized-routines/

This patch adds a highly optimized generic implementation of expf,
exp2f, logf, log2f and powf.  The new functions are not only
faster (6x for powf!), but are also smaller and more accurate.
In order to achieve this, the algorithm uses double precision
arithmetic for accuracy, avoids divisions and uses small table
lookups to minimize the polynomials.  Special cases are handled
inline to avoid the unnecessary overhead of wrapper functions and
set errno to POSIX requirements.

The new functions are added under newlib/libm/common, but the old
implementations are kept (in newlib/libm/math) for non-IEEE or
pre-C99 systems.  Targets can enable the new math code by defining
__OBSOLETE_MATH_DEFAULT to 0 in newlib/libc/include/machine/ieeefp.h,
users can override the default by defining __OBSOLETE_MATH.
Currently the new code is enabled for AArch64 and AArch32 with VFP.
Targets with a single precision FPU may still prefer the old
implementation.

libm.a size changes:
arm: -1692
arm/thumb/v7-a/nofp: -878
arm/thumb/v7-a+fp/hard: -864
arm/thumb/v7-a+fp/softfp: -908
aarch64: -1476
2017-10-13 10:58:00 +02:00
Sebastian Huber 4de8754bac Change time_t to 64-bit by default
In order to avoid the year 2038 problem, define time_t to a signed
integer with at least 64-bits.  The type for time_t can be forced to
long with the --enable-newlib-long-time_t configure option or with the
_USE_LONG_TIME_T system configuration define.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-09-07 15:39:34 +02:00
Corinna Vinschen e18b7ffa48 stdio.h: Don't define unlocked macros using static inline on C++
In C++, the usage of static inline functions for getchar_unlocked and
putchar_unlocked may result in error messages like

  error: ‘_putchar_unlocked’ was not declared in this scope

Fix this by not using the _getchar_unlocked and _putchar_unlocked
macros in C++.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-09-04 10:52:33 +02:00
Yaakov Selkowitz 51d1fb715d include: fix ffs, fls guards
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-08-30 12:29:47 -05:00
Sichen Zhao c206d04422 Port strnstr.c to newlib. 2017-08-25 18:00:46 +02:00
Eric Blake a4961ccd3f Revert "headers: avoid bareword attributes" for clang
This reverts most of commit 979d467ff6.

We cannot avoid some bareword attributes until clang is fixed to
properly support __-decorated attributes; see this bug:
https://bugs.llvm.org/show_bug.cgi?id=34319

The macros in question expand to the empty string under gcc, so
only compilation under clang is affected, and since clang has the
bug, the obvious solution is to roll back the changes, and document
the issue.

Signed-off-by: Eric Blake <eblake@redhat.com>
2017-08-25 09:23:10 -05:00
Sebastian Huber 7b2c362190 Make _CLOCK_T_ system configurable
Let systems optionally provide the _CLOCK_T_ type via
<machine/_types.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-08-25 14:25:42 +02:00
Ken Brown f665b1cef3 cygwin: Implement renameat2
Define the RENAME_NOREPLACE flag in <cygwin/fs.h> as defined on Linux
in <linux/fs.h>.  The other RENAME_* flags defined on Linux are not
supported.
2017-08-19 18:06:49 +02:00
Eric Blake 979d467ff6 headers: avoid bareword attributes
Always use the __-decorated form of an attribute name in public
headers, as the bareword form is in the user's namespace, and we
don't want compilation to break just because the user defines the
bareword to mean something else.

Signed-off-by: Eric Blake <eblake@redhat.com>
2017-08-17 07:10:03 -05:00
Kito Cheng 363dbb9e44 Add RISC-V port for newlib
Contributor list:
    - Andrew Waterman  <andrew@sifive.com>
    - Palmer Dabbelt  <palmer@dabbelt.com>
    - Kito Cheng  <kito.cheng@gmail.com>
    - Scott Beamer  <sbeamer@eecs.berkeley.edu>
2017-08-16 18:00:58 -04:00
Ken Brown d7821c045e Define sigsetjmp/siglongjmp only if __POSIX_VISIBLE 2017-08-07 16:07:46 +02:00
Sebastian Huber b0f271d1db Proper locking for getchar() and putchar()
Add internal inline functions _getchar_unlocked() and
_putchar_unlocked() if __CUSTOM_FILE_IO__ is not defined.  These
functions get _REENT only once.  Use them for getchar_unlocked() and
putchar_unlocked().  Define getchar() and putchar() to these unlocked
internal functions if __SINGLE_THREAD__ is defined, otherwise use the
external functions to use proper locking of the FILE object.

Assumes that __SINGLE_THREAD__ is not defined if __CYGWIN__ is defined.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2017-08-07 07:54:58 +02:00
Aditya Upadhyay a1c2491f70 Importing wcstoumax inttypes method from FreeBSD. 2017-08-02 13:02:26 +02:00
Aditya Upadhyay 88abc0958b Importing wcstoimax inttypes method from FreeBSD. 2017-08-02 13:02:26 +02:00
Aditya Upadhyay fd1981a7df Importing strtoumax inttypes method from FreeBSD. 2017-08-02 13:02:26 +02:00
Aditya Upadhyay 910cc30c10 Importing strtoimax inttypes method from FreeBSD. 2017-08-02 13:02:26 +02:00
Yaakov Selkowitz 4aaec3cb88 Add elf.h to newlib
This is copied from musl (MIT license).  This is newer and more thorough
than that of FreeBSD currently shipped only on Cygwin.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2017-08-02 01:18:55 -05:00