Commit Graph

533 Commits

Author SHA1 Message Date
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
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
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
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
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
Jeff Johnston 1787e9d033 AMD GCN Port contributed by Andrew Stubbs <ams@codesourcery.com>
Add support for the AMD GCN GPU architecture.  This is primarily intended for
use with OpenMP and OpenACC offloading.  It can also be used for stand-alone
programs, but this is intended mostly for testing the compiler and is not
expected to be useful in general.

The GPU architecture is highly parallel, and therefore Newlib must be
configured to use dynamic re-entrancy, and thread-safe malloc.

The only I/O available is a via a shared-memory interface provided by libgomp
and the gcn-run tool included with GCC.  At this time this is limited to
stdout, argc/argv, and the return code.
2019-01-15 10:48:08 -05:00
Corinna Vinschen fe8f406cc6 fcntl.h: expose AT_EMPTY_PATH with _GNU_SOURCE only
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-07 20:09:20 +01:00
Corinna Vinschen 9443efe099 Cygwin: linkat: support Linux-specific AT_EMPTY_PATH flag
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-07 19:36:37 +01:00
Corinna Vinschen b93022a82d Cygwin: open: support Linux-specific O_PATH flag
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-07 19:35:00 +01:00
Sebastian Huber 55db4a8e3a sys/time.h: Remove KASSERT
The KASSERT is only used by the FreeBSD kernel.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-12-04 07:39:20 +01:00
imp be517bd298 Ensure that all values of ns, us and ms work
for {n,u,m}stosbt

Integer overflows and wrong constants limited the accuracy of these
functions and created situatiosn where sbttoXs(Xstosbt(Y)) != Y. This
was especailly true in the ns case where we had millions of values
that were wrong.

Instead, used fixed constants because there's no way to say ceil(X)
for integer math. Document what these crazy constants are.

Also, use a shift one fewer left to avoid integer overflow causing
incorrect results, and adjust the equasion accordingly. Document this.

Allow times >= 1s to be well defined for these conversion functions
(at least the Xstosbt). There's too many users in the tree that they
work for >= 1s.

This fixes a failure on boot to program firmware on the mlx4
NIC. There was a msleep(1000) in the code. Prior to my recent rounding
changes, msleep(1000) worked, but msleep(1001) did not because the old
code rounded to just below 2^64 and the new code rounds to just above
it (overflowing, causing the msleep(1000) to really sleep 1ms).

A test program to test all cases will be committed shortly. The test
exaustively tries every value (thanks to bde for the test).

Sponsored by: Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D18051
2018-12-04 07:39:15 +01:00
imp 7bf8fc0987 When converting ns,us,ms to sbt, return the ceil()
of the result rather than the floor(). Returning the floor means that
sbttoX(Xtosbt(y)) != y for almost all values of y. In practice, this
results in a difference of at most 1 in the lsb of the sbintime_t. This
difference is meaningless for all current users of these functions, but
is important for the newly introduced sysctl conversion routines which
implicitly rely on the transformation being idempotent.

Sponsored by: Netflix, Inc
2018-12-04 07:30:18 +01:00
ian 68b1d72e1d Correct a misplaced closing paren.
Does not affect the result, but does clarify (at least for me) that the
multiplication happens before the shift.
2018-12-04 07:30:09 +01:00
pfg 3266b2dd5e sys: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

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.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2018-12-04 07:30:05 +01:00
ian 3c3c17500c Add inline functions to convert between sbintime_t
and decimal time units. Use them in some existing code that is
vulnerable to roundoff errors.

The existing constant SBT_1NS is a honeypot, luring unsuspecting folks into
writing code such as long_timeout_ns*SBT_1NS to generate the argument for a
sleep call.  The actual value of 1ns in sbt units is ~4.3, leading to a
large roundoff error giving a shorter sleep than expected when multiplying
by the trucated value of 4 in SBT_1NS.  (The evil honeypot aspect becomes
clear after you waste a whole day figuring out why your sleeps return early.)
2018-12-04 07:29:51 +01:00
imp 8f4149ea93 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
2018-12-04 07:29:50 +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 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
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
rrs 215e33310b This commit brings in a new refactored TCP stack called Rack.
Rack includes the following features: - A different SACK processing
scheme (the old sack structures are not used). - RACK (Recent
acknowledgment) where counting dup-acks is no longer done instead time
is used to knwo when to retransmit. (see the I-D) - TLP (Tail Loss
Probe) where we will probe for tail-losses to attempt to try not to take
a retransmit time-out. (see the I-D) - Burst mitigation using TCPHTPS -
PRR (partial rate reduction) see the RFC.

Once built into your kernel, you can select this stack by either
socket option with the name of the stack is "rack" or by setting
the global sysctl so the default is rack.

Note that any connection that does not support SACK will be kicked
back to the "default" base  FreeBSD stack (currently known as "default").

To build this into your kernel you will need to enable in your
kernel:
   makeoptions WITH_EXTRA_TCP_STACKS=1
   options TCPHPTS

Sponsored by:	Netflix Inc.
Differential Revision:		https://reviews.freebsd.org/D15525
2018-08-24 15:00:04 +02:00
Sebastian Huber 5d29023c11 Add __nl_item to <sys/_types.h> and use it
Add __nl_item to <sys/_types.h> for FreeBSD compatibility.  Use it in
<langinfo.h> and the Cygwin <nl_types.h>.  Make the enum __nl_item in
<langinfo.h> anonymous.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-08-24 15:00:01 +02:00
Sebastian Huber a31a7bad6a FreeBSD compat. __alloc_size(), __alloc_align()
Restore FreeBSD compatibility for __alloc_size() and __alloc_align().

This is a follow-up to commit e494b56035.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-07-30 10:47:57 +02:00
pfg 271e856a49 Define a new __alloc_size2 attribute to complement the exiting support.
At least on GCC7 calling __alloc_size(x) twice is not equivalent to
calling using the attribute once with two arguments. The later is the
documented use in GCC documentation so add a new alloc_size(n, x)
alternative to cover for the few places where it is used: basically:
calloc(3), reallocarray(3) and  mallocarray(9).

Submitted by:	Mark Millard
MFC after:	3 days
Reference:
http://docs.freebsd.org/cgi/mid.cgi?F227842D-6BE2-4680-82E7-07906AF61CD7
2018-07-30 10:47:57 +02:00
kib 1736bd3003 Remove lint support from system headers and MD x86 headers.
Reviewed by:	dim, jhb
Discussed with:	imp
Sponsored by:	The FreeBSD Foundation
Differential revision:	https://reviews.freebsd.org/D13156
2018-07-30 10:47:57 +02:00
pfg 00a7ef9163 sys: further adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 3-Clause license.

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.

Special thanks to Wind River for providing access to "The Duke of
Highlander" tool: an older (2014) run over FreeBSD tree was useful as a
starting point.
2018-07-30 10:47:57 +02:00
ed@FreeBSD.org 84e294dc69 Make _Static_assert() work with GCC in older C++ standards.
GCC only activates C11 keywords in C mode, not C++ mode. This means
that when targeting an older C++ standard, we cannot fall back to using
_Static_assert(). In this case, do define _Static_assert() as a macro
that uses a typedef'ed array.

Discussed in:	r322875 commit thread
Reported by:	Mark MIllard
MFC after:	1 month
2018-07-30 10:47:57 +02:00
Yaakov Selkowitz f6417be2aa Cygwin: define _POSIX_ASYNCHRONOUS_IO
This feature is now available as of the recent AIO commits.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-07-25 10:48:55 -05:00
Yaakov Selkowitz e494b56035 Fix alloc_align and alloc_size macros for multiple arguments
https://sourceware.org/ml/newlib/2018/msg00263.html

This is a follow-up to commit 4564b30f33.

Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-03-14 10:17:51 -05:00
Sebastian Huber a9c8434527 Make _CLOCKID_T_ system configurable
Let systems optionally provide the _CLOCKID_T_ type via
<machine/_types.h>.

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
2018-03-06 11:40:16 +01:00
Our Air Quality b7520b14d5 Add global stdio streams support for reent small. 2018-03-01 18:05:31 -05:00
Corinna Vinschen 4c73ad6b20 newlib: drop Cygwin license from sys/select.h
This license was accidentally retained when moving the file from Cygwin to newlib.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-02-02 11:27:58 +01:00
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 67ee0cac4c ansification: remove _VOID
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:20 -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 0bda30e1ff ansification: remove _CONST
Signed-off-by: Yaakov Selkowitz <yselkowi@redhat.com>
2018-01-17 11:47:08 -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 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 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 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