aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/sys
AgeCommit message (Collapse)AuthorFilesLines
2025-03-03H8/300: Silence -Wold-style-definition warningsJan Dubiec2-6/+3
2025-03-02 Jan Dubiec <jdx@o2.pl> newlib/ChangeLog: * libc/sys/h8300hms/sbrk.c: Replace the K&R definition with the standard one. * libc/sys/h8300hms/syscalls.c (_isatty): Ditto. (_unlink): Ditto. newlib/libc/sys/h8300hms/sbrk.c | 3 +-- newlib/libc/sys/h8300hms/syscalls.c | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-)
2025-02-21Use .p2align 2 instead of .align 0Volodymyr Turanskyy2-2/+2
This is to improve compatibility with LLVM clang: .align 0 is a special case for GCC that is not handled by clang. Change-Id: I855939a32294c74813ecce7275a362265dbc3b1a
2024-12-16or1k: Fix compiler warningsStafford Horne1-0/+3
In my build the below are treated as error now and causing failures. I have described the fixes of each warning below. In newlib/libc/sys/or1k/mlock.c: CC libc/sys/or1k/libc_a-mlock.o newlib/libc/sys/or1k/mlock.c: In function ‘__malloc_lock’: newlib/libc/sys/or1k/mlock.c:56:19: warning: implicit declaration of function ‘or1k_critical_begin’ [-Wimplicit-function-declaration] 56 | restore = or1k_critical_begin(); | ^~~~~~~~~~~~~~~~~~~ newlib/libc/sys/or1k/mlock.c: In function ‘__malloc_unlock’: newlib/libc/sys/or1k/mlock.c:93:17: warning: implicit declaration of function ‘or1k_critical_end’ [-Wimplicit-function-declaration] 93 | or1k_critical_end(restore); | ^~~~~~~~~~~~~~~~~ This patch adds prototypes for functions or1k_critical_begin and or1k_critical_end to suppress the warning, inline with what we do for or1k_sync_cas. In libgloss/or1k/or1k_uart.c: libgloss/or1k/or1k_uart.c: In function ‘or1k_uart_set_read_cb’: libgloss/or1k/or1k_uart.c:163:25: warning: passing argument 2 of ‘or1k_interrupt_handler_add’ from incompatible pointer type [-Wincompatible-pointer-types] 163 | _or1k_uart_interrupt_handler, 0); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | void (*)(uint32_t) {aka void (*)(long unsigned int)} In file included from libgloss/or1k/or1k_uart.c:19: libgloss/or1k/include/or1k-support.h:97:45: note: expected ‘or1k_interrupt_handler_fptr’ {aka ‘void (*)(void *)’} but argument is of type ‘void (*)(uint32_t)’ {aka ‘void (*)(long unsigned int)’} 97 | or1k_interrupt_handler_fptr handler, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ The public API is ‘void (*)(void *)' for our interrupt handlers. The function _or1k_uart_interrupt_hander is the internal default implementation of the uart IRQ handler and it doesn't use the data argument. This patch updates the _or1k_uart_interrupt_handler argument type from uint32_t to void* allowing the function prototype to match the required prototype. If we did have a 64-bit implementation it would be an ABI issue. But, there never has been one, or1k is only 32-bit. In libgloss/or1k/interrupts.c: libgloss/or1k/interrupts.c: In function ‘or1k_interrupt_handler_add’: libgloss/or1k/interrupts.c:41:52: warning: assignment to ‘void *’ from ‘long unsigned int’ makes pointer from integer without a cast [-Wint-conversion] 41 | _or1k_interrupt_handler_data_ptr_table[id] = (uint32_t) data_ptr; | ^ The table _or1k_interrupt_handler_data_ptr_table is an array of void* and data_ptr is void*. There is no need for the cast so remove it. In libgloss/or1k/sbrk.c: libgloss/or1k/sbrk.c:23:29: warning: initialization of ‘uint32_t’ {aka ‘long unsigned int’} from ‘uint32_t *’ {aka ‘long unsigned int *’} makes integer from pointer without a cast [-Wint-conversion] 23 | uint32_t _or1k_heap_start = &end; | This patch adds a cast, which is safe in or1k as the architecture in 32-bit only. But this code would not be 64-compatible. Signed-off-by: Stafford Horne <shorne@gmail.com>
2024-09-02newlib: esp: add dirent.h header fileAlexey Lapshin1-0/+49
Support dirent in *-esp-* toolchains
2024-09-02newlib: xtensa: remove sys/xtensa. use machine/xtensaAlexey Lapshin10-338/+0
Remove sys/xtensa that is actually duplicate newlib's code. Move used code to machine/xtensa or to libgloss
2024-06-28libc: sh: add missing prototypes and change functions from K&R to ANSIPietro Monteiro4-18/+33
The SuperH target doesn't build on GCC 14.1 because of missing function prototypes or because some function declarations use the deprecated K&R style. This patch adds missing prototypes on the files the functions are used and convert K&R declarations to ANSI-style. Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
2024-06-26arm: emit .type %function directive in FUNC_START macroChristophe Lyon1-0/+2
The linker needs to know whether a symbol is STT_FUNCTION when deciding which farcall stub to emit (if needed), this patch adds this to the FUNC_START macro which is used in crt0.
2024-04-04amdgcn: Implement proper locks: Fix ↵Thomas Schwinge1-0/+4
'newlib/libc/sys/amdgcn/include/sys/lock.h' for C++ As of commit 7dd4eb1db9e1b1b9f14ef5b743705156e5f370e1 "amdgcn: Implement proper locks", we get, by the thousands, for C++ code: In file included from [...]/newlib/libc/include/stdio.h:60, from [...]: [...]/newlib/libc/include/sys/reent.h:911:1: error: expected declaration before '}' token
2024-03-25amdgcn: Implement proper locksAndrew Stubbs3-1/+228
This should prevent printf output from multiple threads getting garbled. I don't know why IO ever worked properly -- probably it was always a bit broken -- but the GFX11 devices have a different cache architecture and trying to print from many threads at once corrupted the FILE buffers.
2024-02-24RTEMS: Define ssize_t for <dirent.h>Sebastian Huber1-0/+5
This fixes the following build issue: newlib/libc/include/dirent.h:84:1: error: unknown type name 'ssize_t'; did you mean '_ssize_t'? 84 | ssize_t posix_getdents(int, void *, size_t, int); | ^~~~~~~ | _ssize_t
2023-12-31Minor improvement to H8 startup codeJeff Law1-18/+12
Basically the startup code needs to clear memory from _edata to _end. In the past it's been done with a fairly naive copy loop. This changes the code to just call memset and let memset figure out a sensible way to handle the operation given the size and alignment requirements. I don't have performance data on this. I cobbled it together some time ago in response to seeing some of the GCC tests with larger .bss sections taking an insane amount of time to just get from _start to main. With the fixes to the H8 decoder in the simulator it may not matter nearly as much anymore. This has been in my tester for months. Naturally it does not cause any regressions in the H8 port.
2023-12-29newlib MMIX: Fix compilation warnings that recent gcc treats as errorsHans-Peter Nilsson10-21/+30
Without this, when building with recent gcc, we'll see errors when compiling for --target mmix the first being: CC libc/sys/mmixware/libc_a-chmod.o In file included from /x/newlib/libc/sys/mmixware/chmod.c:17: /x/newlib/libc/sys/mmixware/chmod.c: In function 'chmod': /x/newlib/libc/sys/mmixware/sys/syscall.h:139:6: error: implicit declaration \ of function 'sprintf' [-Wimplicit-function-declaration] 139 | sprintf (buf, "UNIMPLEMENTED %s in %s\n", __FUNCTION__, __FILE__); \ Other warnings also quelled. * libc/sys/mmixware/sys/syscall.h: Include stdio.h, string.h and unistd.h. * libc/sys/mmixware/_exit.c: Call __unreachable after simulator exit. * libc/sys/mmixware/chown.c (chown): Match declaration in unistd.h. * libc/sys/mmixware/getpid.c (_getpid): Ditto. * libc/sys/mmixware/kill.c (_kill): Ditto. * libc/sys/mmixware/link.c (_link): Ditto. * libc/sys/mmixware/read.c (_read): Ditto. * libc/sys/mmixware/sbrk.c (_sbrk): Ditto. * libc/sys/mmixware/unlink.c (_unlink): Ditto. * libc/sys/mmixware/write.c (_write): Ditto.
2023-12-22Fix newlib H8/300 bits for C99/gcc-14Jeff Law1-0/+2
Similar to other patches. This adds a missing prototype and #include to some H8/300 specific code in newlib. Pushed to the trunk given Jeff J's pre-approval for these kinds of changes.
2023-12-19Fix various v850 problemsJeff Law6-7/+10
These fixes fall into a few different buckets. First c99 doesn't allow a parameter without a type. So in cases where the type had previously been an implicit int, make it an explicit int. Second, for return values, don't allow them to be implicit ints either, make them explicit. In a few cases change c89 function definitions to c99 function definitions. Lastly include <stdlib.h> in sbrk.c to get the prototype for abort () which we call when we detect a heap/stack collision.
2023-08-17newlib: add Xtensa portAlexey Lapshin10-0/+338
2023-04-24RTEMS: Add __m68k_read_tp() to crt0.cSebastian Huber1-0/+4
This is required to build libgomp.
2023-03-03arm: Restrict processor mode change when in hypervisor modeSrinath Parvathaneni1-7/+7
If a CPU implements EL2 as its highest exception level then programs using newlib may start in hypervisor mode. In that state it is not trivial to switch into the various EL1 modes to configure the individual exception stacks, so do not try.
2023-03-03arm: Fix the SP used in setting stack limit for standalone application.Srinath Parvathaneni1-2/+1
Move the instruction that saves SP before the mode check so that applications that start in USER mode correctly set the stack limit.
2023-01-11libgloss: arm: break newlib dependencyMike Frysinger1-1/+1
The libgloss port has been reaching back into newlib internals for a single header whose contents have been frozen for almost a decade. To break this backwards libgloss->newlib dependency, move the acle header to the srcroot include/ so everyone can use the same copy.
2022-12-21remove +x bit on source filesMike Frysinger9-0/+0
These should never be marked executable as they have no shebang and are pure source files.
2022-11-21amdgcn: Replace asm("s8") by __builtin_gcn_kernarg_ptr if existingTobias Burnus1-0/+4
Check whether __builtin_gcn_kernarg_ptr is available and, if it is, call it instead using the hard-coded 'asm("s8")' in: * newlib/libc/machine/amdgcn/exit-value.h (exit_with_int) * newlib/libc/machine/amdgcn/mlock.c (sbrk) * newlib/libc/sys/amdgcn/write.c (write) newlib/libc/machine/amdgcn/exit-value.h | 6 ++++++ newlib/libc/machine/amdgcn/mlock.c | 10 +++++++--- newlib/libc/sys/amdgcn/write.c | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-)
2022-09-19Implement sysconf for ArmJeff Johnston2-1/+35
- add support for using sysconf to get page size in _mallocr.c via HAVE_SYSCONF_PAGESIZE flag set in configure.host - set flag in configure.host for arm and add a default sysconf implementation in libc/sys/arm that returns the page size - the default implementation can be overridden outside newlib to allow a different page size to improve malloc on devices with a small footprint without needing to rebuild newlib - this patch is based on a contribution from Torbjorn Svensson and Niklas Dahlquist (https://ecos.sourceware.org/ml/newlib/current/017616.html)
2022-08-15SH: Do not build syscalls if option providedYilin Sun via Newlib1-0/+2
This patch makes syscalls for SH architecture respecting the global option "--disable-newlib-supplied-syscalls". This is useful when a bare-metal toolchain is needed. Signed-off-by: Yilin Sun <imi415@imi.moe>
2022-07-13Add _REENT_IS_NULL()Matt Joyce1-1/+2
In a follow up patch, struct _reent is optionally replaced by dedicated thread-local objects. In this case,_REENT is optionally defined to NULL. Add the _REENT_IS_NULL() macro to disable this check on demand.
2022-07-13Add _REENT_CLEANUP(ptr)Matt Joyce1-1/+1
Add a _REENT_CLEANUP() macro to encapsulate access to the __cleanup member of struct reent. This will help to replace the struct member with a thread-local storage object in a follow up patch.
2022-07-11RTEMS: Add READMESebastian Huber1-0/+79
2022-07-11libc/syslog: fully deprecate and don't try to open "/dev/log"Gleb Smirnoff1-1/+0
The "/dev/log" socket existed in pre-FreeBSD times. Later it was substituted to a compatibility symlink. The symlink creation was deprecated in FreeBSD 10.2 and 9-STABLE. Reviewed by: markj Differential revision: https://reviews.freebsd.org/D35304
2022-07-11arp: Implement sticky ARP mode for interfaces.Konrad Sewiłło-Jopek1-0/+1
Provide sticky ARP flag for network interface which marks it as the "sticky" one similarly to what we have for bridges. Once interface is marked sticky, any address resolved using the ARP will be saved as a static one in the ARP table. Such functionality may be used to prevent ARP spoofing or to decrease latencies in Ethernet networks. The drawbacks include potential limitations in usage of ARP-based load-balancers and high-availability solutions such as carp(4). The implemented option is disabled by default, therefore should not impact the default behaviour of the networking stack. Sponsored by: Conclusive Engineering sp. z o.o. Reviewed By: melifaro, pauamma_gundo.com Differential Revision: https://reviews.freebsd.org/D35314 MFC after: 2 weeks
2022-07-11Correctly measure system load averages > 1024Alan Somers1-4/+4
The old fixed-point arithmetic used for calculating load averages had an overflow at 1024. So on systems with extremely high load, the observed load average would actually fall back to 0 and shoot up again, creating a kind of sawtooth graph. Fix this by using 64-bit math internally, while still reporting the load average to userspace as a 32-bit number. Sponsored by: Axcient Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D35134
2022-07-11Add ifcap2 names for RXTLS4 and RXTLS6 interface capabilitiesKonstantin Belousov1-0/+6
and corresponding nvlist capabilities name strings. Reviewed by: hselasky, jhb, kp (previous version) Sponsored by: NVIDIA Networking MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D32551
2022-07-11Kernel-side infrastructure to implement nvlist-based set/get ifcapsKonstantin Belousov2-2/+49
Reviewed by: hselasky, jhb, kp (previous version) Sponsored by: NVIDIA Networking MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D32551
2022-07-11tcp: LRO code to deal with all 12 TCP header flagsRichard Scheffenegger1-2/+2
TCP per RFC793 has 4 reserved flag bits for future use. One of those bits may be used for Accurate ECN. This patch is to include these bits in the LRO code to ease the extensibility if/when these bits are used. Reviewed By: hselasky, rrs, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D34127
2022-07-11kernel: deprecate Internet Class A/B/CMike Karels1-5/+17
Hide historical Class A/B/C macros unless IN_HISTORICAL_NETS is defined; define it for user level. Define IN_MULTICAST separately from IN_CLASSD, and use it in pf instead of IN_CLASSD. Stop using class for setting default masks when not specified; instead, define new default mask (24 bits). Warn when an Internet address is set without a mask. MFC after: 1 month Reviewed by: cy Differential Revision: https://reviews.freebsd.org/D32708
2022-07-11tcp: socket option to get stack alias namePeter Lei1-0/+1
TCP stack sysctl nodes are currently inserted using the stack name alias. Allow the user to get the current stack's alias to allow for programatic sysctl access. Obtained from: Netflix
2022-07-11tcp: Add hystart-plus to cc_newreno and rack.Randall Stewart1-1/+1
TCP Hystart draft version -03: https://datatracker.ietf.org/doc/html/draft-ietf-tcpm-hystartplusplus Is a new version of hystart that allows one to carefully exit slow start if the RTT spikes too much. The newer version has a slower-slow-start so to speak that then kicks in for five round trips. To see if you exited too early, if not into congestion avoidance. This commit will add that feature to our newreno CC and add the needed bits in rack to be able to enable it. Reviewed by: tuexen Sponsored by: Netflix Inc. Differential Revision: https://reviews.freebsd.org/D32373
2022-07-11tcp: Add support for DSACK based reordering window to rack.Randall Stewart1-0/+1
The rack stack, with respect to the rack bits in it, was originally built based on an early I-D of rack. In fact at that time the TLP bits were in a separate I-D. The dynamic reordering window based on DSACK events was not present in rack at that time. It is now part of the RFC and we need to update our stack to include these features. However we want to have a way to control the feature so that we can, if the admin decides, make it stay the same way system wide as well as via socket option. The new sysctl and socket option has the following meaning for setting: 00 (0) - Keep the old way, i.e. reordering window is 1 and do not use DSACK bytes to add to reorder window 01 (1) - Change the Reordering window to 1/4 of an RTT but do not use DSACK bytes to add to reorder window 10 (2) - Keep the reordering window as 1, but do use SACK bytes to add additional 1/4 RTT delay to the reorder window 11 (3) - reordering window is 1/4 of an RTT and add additional DSACK bytes to increase the reordering window (RFC behavior) The default currently in the sysctl is 3 so we get standards based behavior. Reviewed by: tuexen Sponsored by: Netflix Inc. Differential Revision: https://reviews.freebsd.org/D31506
2022-07-11tsleep: Add a PNOLOCK flagAndrew Gallatin1-3/+5
Add a PNOLOCK flag so that, in the race circumstance where wakeup races are externally mitigated, tsleep() can be called with a sleep time of 0 without triggering an an assertion. Reviewed by: jhb Sponsored by: Netflix
2022-07-11socket: Implement SO_RERRORRoy Marples1-0/+1
SO_RERROR indicates that receive buffer overflows should be handled as errors. Historically receive buffer overflows have been ignored and programs could not tell if they missed messages or messages had been truncated because of overflows. Since programs historically do not expect to get receive overflow errors, this behavior is not the default. This is really really important for programs that use route(4) to keep in sync with the system. If we loose a message then we need to reload the full system state, otherwise the behaviour from that point is undefined and can lead to chasing bogus bug reports. Reviewed by: philip (network), kbowling (transport), gbe (manpages) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26652
2022-07-11pf: syncookie supportKristof Provost1-0/+2
Import OpenBSD's syncookie support for pf. This feature help pf resist TCP SYN floods by only creating states once the remote host completes the TCP handshake rather than when the initial SYN packet is received. This is accomplished by using the initial sequence numbers to encode a cookie (hence the name) in the SYN+ACK response and verifying this on receipt of the client ACK. Reviewed by: kbowling Obtained from: OpenBSD MFC after: 1 week Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D31138
2022-07-11tcp: Add a socket option to rackRandall Stewart1-0/+1
so we can test various changes to the slop value in timers. Timer_slop, in TCP, has been 200ms for a long time. This value dates back a long time when delayed ack timers were longer and links were slower. A 200ms timer slop allows 1 MSS to be sent over a 60kbps link. Its possible that lowering this value to something more in line with todays delayed ack values (40ms) might improve TCP. This bit of code makes it so rack can, via a socket option, adjust the timer slop. Reviewed by: mtuexen Sponsered by: Netflix Inc Differential Revision: https://reviews.freebsd.org/D30249
2022-07-11tcp: SACK Lost Retransmission Detection (LRD)Richard Scheffenegger1-0/+1
Recover from excessive losses without reverting to a retransmission timeout (RTO). Disabled by default, enable with sysctl net.inet.tcp.do_lrd=1 Reviewed By: #transport, rrs, tuexen, #manpages Sponsored by: Netapp, Inc. Differential Revision: https://reviews.freebsd.org/D28931
2022-07-11This brings into sync FreeBSD with the netflixRandall Stewart1-1/+23
versions of rack and bbr. This fixes several breakages (panics) since the tcp_lro code was committed that have been reported. Quite a few new features are now in rack (prefecting of DGP -- Dynamic Goodput Pacing among the largest). There is also support for ack-war prevention. Documents comming soon on rack.. Sponsored by: Netflix Reviewed by: rscheff, mtuexen Differential Revision: https://reviews.freebsd.org/D30036
2022-07-11Use thunks for compat ioctls using struct ifgroupreq.John Baldwin1-2/+0
Reviewed by: brooks, kib Obtained from: CheriBSD Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D29893
2022-07-11ioccom: define ioctl cmd value that can never be validKonstantin Belousov1-0/+3
Its use is for cases where some filler is needed for cmd, or we need an indication that there were no cmd supplied, and so on. Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29935
2022-07-11poll(2): Add POLLRDHUP.Thomas Munro1-0/+1
Teach poll(2) to support Linux-style POLLRDHUP events for sockets, if requested. Triggered when the remote peer shuts down writing or closes its end. Reviewed by: kib MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D29757
2022-07-11tcp: add support for TCP over UDPMichael Tuexen1-0/+1
Adding support for TCP over UDP allows communication with TCP stacks which can be implemented in userspace without requiring special priviledges or specific support by the OS. This is joint work with rrs. Reviewed by: rrs Sponsored by: Netflix, Inc. MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D29469
2022-07-11termios: add more speedsBjoern A. Zeeb1-0/+8
A lot of small arm64 gadgets are using 1500000 as console speed. While cu can perfectly deal with this some 3rd party software, e.g., comms/conserver-con add speeds based on B<n> being defined. Having it defined here simplifies enhancing other software. Obtained-from: NetBSD sys/sys/termios.h 1.36 MFC-after: 2 weeks Reviewed-by: philip (,okayed by imp) Differential Revision: https://reviews.freebsd.org/D29209
2022-07-11Revert "SO_RERROR indicates that receive buffer overflows"Alexander V. Chernikov1-1/+0
Wrong version of the change was pushed inadvertenly. This reverts commit 4a01b854ca5c2e5124958363b3326708b913af71.
2022-07-11SO_RERROR indicates that receive buffer overflowsAlexander V. Chernikov1-0/+1
should be handled as errors. Historically receive buffer overflows have been ignored and programs could not tell if they missed messages or messages had been truncated because of overflows. Since programs historically do not expect to get receive overflow errors, this behavior is not the default. This is really really important for programs that use route(4) to keep in sync with the system. If we loose a message then we need to reload the full system state, otherwise the behaviour from that point is undefined and can lead to chasing bogus bug reports.
2022-07-11Expose clang's alignment builtins and use them for roundup2/rounddown2Alex Richardson1-2/+2
This makes roundup2/rounddown2 type- and const-preserving and allows using it on pointer types without casting to uintptr_t first. Not performing pointer-to-integer conversions also helps the compiler's optimization passes and can therefore result in better code generation. When using it with integer values there should be no change other than the compiler checking that the alignment value is a valid power-of-two. I originally implemented these builtins for CHERI a few years ago and they have been very useful for CheriBSD. However, they are also useful for non-CHERI code so I was able to upstream them for Clang 10.0. Rationale from the clang documentation: Clang provides builtins to support checking and adjusting alignment of pointers and integers. These builtins can be used to avoid relying on implementation-defined behavior of arithmetic on integers derived from pointers. Additionally, these builtins retain type information and, unlike bitwise arithmetic, they can perform semantic checking on the alignment value. There is also a feature request for GCC, so GCC may also support it in the future: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98641 Reviewed By: brooks, jhb, imp Differential Revision: https://reviews.freebsd.org/D28332