Commit Graph

1103 Commits

Author SHA1 Message Date
Keith Packard 9042d0ce65 Use remove-advertising-clause script to edit BSD licenses
This edits licenses held by Berkeley and NetBSD, both of which
have removed the advertising requirement from their licenses.

Signed-off-by: Keith Packard <keithp@keithp.com>
2020-01-29 19:03:31 +01:00
Anthony Green b481c11e5a Optimize setjmp/longjmp for moxie.
We don't need to save/restore every register -- just those
we don't expect to be trashed by function calls.
2019-12-20 09:00:26 -05:00
Keith Packard ed2a469cdd Set __IEEE_LITTLE_ENDIAN for _XTENSA_EL__ (ESP32)
Signed-off-by: Keith Packard <keithp@keithp.com>
2019-12-17 10:09:36 +01:00
Anthony Green 31227ba53d Fix setjmp/longjmp for the moxie port.
These functions needs to save and restore the stack frame, because
that's where the return address is stored.
2019-12-13 13:08:06 -05:00
Brian Inglis c63c29e76e newlib/libc/include/sys/features.h: update __STDC_ISO_10646__
newlib wide char conversion functions were updated to
Unicode 11 on 2019-01-12
update standard symbol __STDC_ISO_10646__ to
Unicode 11 release date 2018-06-05 for Cygwin
2019-11-26 18:34:39 +01:00
Sebastian Huber 4082e91b59 Move timeval macros to <sys/time.h>
In FreeBSD, NetBSD, and OpenBSD these macros are defined in
<sys/time.h>.
2019-11-04 07:03:15 +01:00
Sebastian Huber aae831b083 Synchronize <sys/time.h> with FreeBSD
This change is based on the FreeBSD commit:

Author: asomers <asomers@FreeBSD.org>
Date:   Mon Jul 30 15:46:40 2018 +0000

    Make timespecadd(3) and friends public

    The timespecadd(3) family of macros were imported from NetBSD back in
    r35029. However, they were initially guarded by #ifdef _KERNEL. In the
    meantime, we have grown at least 28 syscalls that use timespecs in some
    way, leading many programs both inside and outside of the base system to
    redefine those macros. It's better just to make the definitions public.

    Our kernel currently defines two-argument versions of timespecadd and
    timespecsub.  NetBSD, OpenBSD, and FreeDesktop.org's libbsd, however, define
    three-argument versions.  Solaris also defines a three-argument version, but
    only in its kernel.  This revision changes our definition to match the
    common three-argument version.

    Bump _FreeBSD_version due to the breaking KPI change.

    Discussed with: cem, jilles, ian, bde
    Differential Revision:  https://reviews.freebsd.org/D14725
2019-11-04 07:03:15 +01:00
Sebastian Huber 4b3f69e4ac Synchronize <sys/_timespec.h> with FreeBSD 2019-11-04 07:03:15 +01:00
imp 7346e14d44 Fix sbttons for values > 2s
Add test against negative times. Add code to cope with larger values
properly.

Discussed with: bde@ (quite some time ago, for an earlier version)
2019-11-04 07:03:15 +01:00
Dimitar Dimitrov 0c7734673a Initial PRU port for libgloss and newlib
Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2019-10-31 14:47:19 -04:00
Jeff Johnston e06f2fbde7 Allow verifying _REENT_CHECK macros memory allocation
- change sys/reent.h to replace _REENT_CHECK_DEBUG with
  _REENT_CHECK_VERIFY which when set asserts that any memory
  allocated is non-NULL and calls __assert_func directly
- add new --enable-newlib-reent-check-verify configure option
- add support for configure.host to specify default for
  newlib_reent_check_verify
- add _REENT_CHECK_VERIFY macro support to acconfig.h and newlib.hin
2019-10-07 15:36:03 -04:00
Joel Sherrill 9786b05595 libc/include/devctl.h: Add SOCKCLOSE per FACE Technical Standard, Edition 3.0
The FACE Technical Standard, Edition 3.0 and later require the
	definition of the subcommand SOCKCLOSE in <devctl.h>.
	Reference: https://www.opengroup.org/face
2019-09-10 10:49:11 -05:00
Jeff Johnston b99887c428 Revert previous change to sys/stat.h and fix cris libgloss
- revert previous fix which altered sys/stat.h
- fix libgloss/cris/gensyscalls to undef st_atime, st_mtime,
  and st_ctime macros which cannot be used with new_stat structure
2019-08-19 18:01:45 -04:00
Jeff Johnston f75aa67851 Fix regression in cris-elf caused by sys/stat.h change 2019-08-19 17:46:51 -04:00
Corinna Vinschen 72ff9acad2 stat.h: use POSIX-required timefields throughout
...except in certain SysV R4 cases for backward compat.
This is probably not required anymore, but it doesn't hurt
to keep it in.
2019-08-16 10:52:43 +02:00
Corinna Vinschen 8ef2461000 sched.h: Declare affinity functions only on targets supporting them 2019-08-12 17:30:20 +02:00
Joel Sherrill eae68bfc87 Add default implementation of fenv.h and all methods
The default implementation of the fenv.h methods return
	-EOPNOTSUP. Some of these have implementations appropriate
        for soft-float.

	The intention of the new fenv.h is that it be portable
	and that architectures provide their own implementation
	of sys/fenv.h.
2019-08-09 17:49:16 +02:00
Vaibhav Gupta b39cd00f07 Port ndbm - Remove Declaration of dbm_forder 2019-07-25 15:28:32 +02:00
Vaibhav Gupta e50ad9fbdc Port ndbm 2019-07-24 09:19:40 +02: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
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
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
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
Jozef Lawrynowicz b14a879d85 Remove matherr, and SVID and X/Open math library configurations
Default math library configuration is now IEEE
2019-01-23 10:46:24 +01:00
Corinna Vinschen 13ea67a3c6 time.h: Add CLOCK_REALTIME_ALARM/CLOCK_BOOTTIME_ALARM
Slightly reshuffle and add comment

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-01-22 15:39:39 +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
Corinna Vinschen 09870c6e95 stdio.h: Expose cuserid with __GNU_VISIBLE
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-11-29 11:22:42 +01:00
Corinna Vinschen f4d6ef2d41 time.h: Introduce Linux-specific CLOCK id values
- Add CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_RAW,
  CLOCK_MONOTONIC_COARSE and CLOCK_BOOTTIME

- Guard new values with __GNU_VISIBLE

- Add CLOCK_REALTIME_COARSE as (clockid_t) 0 for simplicity
  (It allows to have all values < 8 and so be used as array
   index into an array of clocks)

- Fix macro bracketing

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2018-11-29 10:01:57 +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