aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/include/sys
AgeCommit message (Collapse)AuthorFilesLines
11 daysmips: Implement MIPS HAL and UHIJovan Dmitrović2-2/+16
Implement abstract interface for MIPS, including unified hosting interface (UHI). Signed-off-by: Jovan Dmitrović <jovan.dmitrovic@htecgroup.com>
2025-06-18add value for _h_errno in _REENT_INIT(var) for struct, _reentJohannes Rosa1-1/+2
The define '_REENT_INIT' for the case '!_REENT_SMALL' was missing an initializing value for 'int _h_errno'. If code uses the _REENT_INIT() macro to preset a variable of type struct _reent, this led to an issue when compiling with -Wmissing-field-initializers.
2025-04-11newlib: sys/unistd.h: Change inline to __inlineTakashi Yano1-1/+1
Addresses: https://sourceware.org/pipermail/cygwin-patches/2025q2/013644.html Fixes: 3e8a7eb1a868 ("sys/unistd.h: fix definition of setproctitle_init") Reported-by: Brian Inglis <Brian.Inglis@SystematicSW.ab.ca> Co-authored-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-03-24getlocalename_l: allow LC_ALL categoryCorinna Vinschen1-2/+9
Following the changes from Austin Group bug https://www.austingroupbugs.net/view.php?id=1741, getlocalename_l() now allows to specify LC_ALL and returns a setlocale-conmpatible LC_ALL locale string. Consequentially we have to raise the size of _reent::_getlocalename_l_buf so there's enough space for the LC_ALL locale string. Guard all different definitions and usages of _getlocalename_l_buf in reent.h with _MB_CAPABLE. Link: https://www.austingroupbugs.net/view.php?id=1741 Fixes: 71511d4ac868 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-03-05sys/unistd.h: fix definition of setproctitle_initCorinna Vinschen1-1/+1
setproctitle_init is defined in c2x manner, omitting names for the unused parameters. This can result in warnings or errors on certain compiler versions: clang 8: error: parameter name omitted clang 15: warning: omitting the parameter name in a function definition is a C2x extension [-Wc2x-extensions] gcc -Wsystem-headers -pedantic -std=c17: warning: ISO C does not support omitting parameter names in function definitions before C2X [-Wpedantic] Add parameters to avoid above warning and errors. Fixes: 2e7f7b96e5f1 ("Cygwin: implement setproctitle") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-02-14unistd.h: enable SEEK_DATA and SEEK_HOLE also for POSIX-1.2024Christian Franke1-1/+1
https://pubs.opengroup.org/onlinepubs/9799919799/functions/lseek.html Signed-off-by: Christian Franke <christian.franke@t-online.de>
2025-01-28unistd.h: declare posix_closeCorinna Vinschen1-0/+10
Declare posix_close, a new function defined by POSIX-1.2024, per https://pubs.opengroup.org/onlinepubs/9799919799/functions/posix_close.html Define POSIX_CLOSE_RESTART. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-12-12Cygwin: sched_setscheduler: accept SCHED_RESET_ON_FORK flagChristian Franke1-0/+3
Add SCHED_RESET_ON_FORK to <sys/sched.h>. If this flag is set, SCHED_FIFO and SCHED_RR are reset to SCHED_OTHER and negative nice values are reset to zero in each child process created with fork(2). Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-12Cygwin: sched_setscheduler: accept SCHED_BATCHChristian Franke1-0/+1
Add SCHED_BATCH to <sys/sched.h>. SCHED_BATCH is similar to SCHED_OTHER, except that the nice value is mapped to a one step lower Windows priority. Rework the mapping functions to ease the addition of this functionality. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-12-04Cygwin: sched_setscheduler: accept SCHED_IDLEChristian Franke1-0/+4
Add SCHED_IDLE to <sys/sched.h>. If SCHED_IDLE is selected, preserve the nice value and set the Windows priority to IDLE_PRIORITY_CLASS. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-11-04sys/features.h: Use _ISOC23_SOURCE instead of _ISOC23_SOURCE and remap ↵Lenard Mollenkopf1-7/+14
_ISOC2x_SOURCE to _ISOC23_SOURCE Signed-off-by: Lenard Mollenkopf <newlib@lenardmollenkopf.de>
2024-10-28sys/features.h: Spelling _ISOC2x_SOURCE is not C11Lenard Mollenkopf1-1/+1
2024-08-19newlib/libc/include/sys/tree.h: Add deprecation warningJoel Sherrill1-0/+4
2024-08-19libc/include/sys/tree.h: Re-add sys/tree.hJoel Sherrill1-0/+864
Reverts 1339af44679aee0895fe311cfad89d38cfc2b919
2024-08-15features.h: support POSIX.1-2024Corinna Vinschen1-3/+15
TBD: Align _GNU_SOURCE, too? Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-08-15features.h: fix whitespaceCorinna Vinschen1-44/+44
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-07-09sys/tree.h: RemovedJoel Sherrill1-864/+0
This file was from a specific older FreeBSD version. There have been multiple changes to this file with FreeBSD 14 including breaking changes to the file. Including this file as part of newlib results in not always having the correct version of sys/tree.h for any specific software. RTEMS will manage its use of this file outside of newlib.
2024-07-09libc/include/sys/resource.h: Add RUSAGE_THREADJoel Sherrill1-0/+3
2024-07-03libc/include/sys/_default_fcntl.h: O_RSYNC and O_DSYNC are POSIXJoel Sherrill1-2/+3
These should not be in a Cygewin conditional.
2024-03-13libc/include/sys/select.h: Use elif not elifdefJoel Sherrill1-1/+1
The cpp directive "elifdef" is only available in very recent GCC versions. This should be able to compile on older toolchains in C99 mode.`
2024-03-13RTEMS: Increase FS_SETSIZE to 256 bitsChris Johns1-0/+2
2024-02-28Cygwin: add compile warning if ENOSHARE or ECASECLASH is usedChristian Franke1-3/+3
These errno values are no longer used by Cygwin. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-02-05getlocalename_l: fix _reent for _REENT_SMALL targetsCorinna Vinschen1-1/+6
The new _MB_CAPABALE-only _misc_reent member getlocalename_l_buf was incorrectly initialized in the _REENT_INIT_MISC macro, so the build failed for _REENT_SMALL targets, independet of the _MB_CAPABALE setting. Fixes: 71511d4ac868 ("getlocalename_l: implement per SUS Base Specifications Issue 8 draft") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31Cygwin: implement setproctitletopic/3.6Corinna Vinschen1-0/+8
Make sure to create commandline according to setting of setproctitle. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31sys/stat.h: drop __INSIDE_CYGWIN__ guardsCorinna Vinschen1-2/+2
These were only necessary until we dropped 32 bit Cygwin. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-31getlocalename_l: implement per SUS Base Specifications Issue 8 draftCorinna Vinschen1-0/+12
#include <locale.h> const char *getlocalename_l(int category, locale_t locobj); Most notably, we need a per-thread space to store the string returned if locobj is LC_GLOBAL_LOCALE. No errors are defined for getlocalename_l. So we can't use buffer allocation which might lead to an ENOMEM error. We have to use a "static" buffer in the per-thread state. Note that the feature test macro in locale.h is not quite correct. This needs to be fixed as soon as the Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2024-01-29ssp: add support for _FORTIFY_SOURCE=3Christian Franke1-3/+9
If specified, use __builtin_dynamic_object_size() instead of __builtin_object_size() if supported (GCC 12.0 or later). This enables buffer overflow checks if the buffer size is non-const but known during runtime. Use new macro __ssp_bos_known() instead of the (bos(p) != (size_t)-1) checks. The latter is no longer a compile time constant in all cases. This avoids the generation of unused code. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2024-01-15Cygwin: introduce close_range(2)Christian Franke1-0/+6
This function closes or sets the close-on-exec flag for a specified range of file descriptors. It is available on FreeBSD and Linux. Signed-off-by: Christian Franke <christian.franke@t-online.de>
2023-09-25newlib: Add missing prototype for _getentropyTorbjörn SVENSSON1-0/+1
2023-09-11Reentrancy, attempt to always provide _Thread_local in <sys/reent.h>Pekka Seppänen1-0/+1
Attempt to always provide _Thread_local in <sys/reent.h> by including <sys/cdefs.h>. The C specific keyword _Thread_local is not available unless targetting a suitable C version.
2023-08-15struct _reent: add state for unicode functionsCorinna Vinschen1-0/+16
C23 requires that the unicode functions c16rtomb, c8rtomb, mbrtoc16, mbrtoc32 and mbrtoc8 use their own internal state object. c32rtomb only needs an internal state if the lib supports encoding with shift states, but that's the case for newlib and Cygwin. Only Cygwin implements these functions so add the states objects only for Cygwin for now. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-09sys/unistd.h: define GNU extensions SEEK_DATA and SEEK_HOLECorinna Vinschen1-0/+4
SEEK_DATA and SEEK_HOLE are GNU nonstandard extensions also present in Solaris, FreeBSD, and DragonFly BSD; they are proposed for inclusion in the next POSIX revision (Issue 8). Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-07sys/cdefs.h: introduce __restrict_arr, as in glibcCorinna Vinschen1-0/+13
C99 allows to define arrays as non-overlappiung using the restrict keyword. This is supported by GCC 3.1 and later, but it's not allowed in C++. This is in preparation of fixing a Cygwin build problem introduce by commit 3c75fac130b5. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-08-07sys/cdefs.h: fix for use __restrict in C++Sebastian Huber1-9/+7
Newlib shares large parts of <sys/cdefs.h> with FreeBSD and received this bug report: https://sourceware.org/pipermail/newlib/2023/020400.html As an extension, GCC and clang offer C99-style restricted pointers in C++ mode: https://gcc.gnu.org/onlinedocs/gcc/Restricted-Pointers.html We notice that this extension is broken when including newlib headers: restricted pointers are treated as ordinary pointers. We traced this to the following section of newlib/libc/include/sys/cdefs.h: /* * GCC 2.95 provides `__restrict' as an extension to C90 to support the * C99-specific `restrict' type qualifier. We happen to use `__restrict' as * a way to define the `restrict' type qualifier without disturbing older * software that is unaware of C99 keywords. */ #if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) #if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 #define __restrict #else #define __restrict restrict #endif #endif While the GCC __restrict extension was indeed introduced in GCC 2.95, it is not limited to this version; the extension is also not limited to C90: https://gcc.gnu.org/gcc-2.95/c++features.html Rewrite the logic in the header so that __restrict is kept alone when available. PR: 272723 MFC after: 1 week
2023-08-07<sys/cdefs.h>: Decay expression passed to fallbackJohn Baldwin1-1/+4
version of __generic() This ensures that __generic() more closely matches _Generic() when using the fallback version when _Generic() is not available (such as GCC). Co-authored by: jrtc27 Reviewed by: jrtc27 Differential Revision: https://reviews.freebsd.org/D38215
2023-08-02sys/features.h: Define _ISOC2X_SOURCE and __ISO_C_VISIBLECorinna Vinschen1-1/+14
Add feature test for C2X code. Add matching definitions _ISOC2X_SOURCE for requesting sources and __ISO_C_VISIBLE to be used in headers. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-07-26Define _AT_NULL_PATHNAME_ALLOWEDCorinna Vinschen1-5/+6
Cygwin needs an internal flag to allow specifying an empty pathname in utimesat (GLIBC extension). We define it in _default_fcntl.h to make sure we never introduce a value collision accidentally. While at it, define the values as 16 bit hex values. Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2023-06-21Make SIG2STR_MAX usable in #ifMingye Wang1-2/+2
The text accepted for POSIX issue 8 requires that SIG2STR_MAX be usable in #if, which we currently break with sizeof. Use static values instead.
2023-05-16newlib: Add FreeBSD files for non LDBL_EQ_DBL supportJennifer Averett1-0/+207
FreeBSD files to add long double support for i386, aarch64 and x86_64.
2023-04-26Fix _REENT_EMERGENCY() if TLS is enabledSebastian Huber1-1/+1
If the thread-local storage (TLS) support was enabled, the _REENT_EMERGENCY() object had the wrong size. It must be a buffer of length _REENT_EMERGENCY_SIZE and not just a single character.
2022-12-08Cygwin: define FILE as struct __sFILE64, not as __sFILECorinna Vinschen1-1/+17
Until Cygwin 3.3.6, we define __LARGE64_FILES unconditionally, so we were using the type __sFILE64 even for 64 bit. That was lazy and wrong. so commit 2902b3a09e0a ("Cygwin: drop requirement to build newlib's stdio64") tried to fix that. Unfortunately this patch forgot to take the exposure of the typename __sFILE64 in userspace into account. This leads to trouble in C++ due to name mangling. Commit 0f376ae22036 tried to fix this by just renaming __sFILE to __sFILE64 by using a macro. While __sFILE and __sFILE64 are the same size, they are not exactly congruent. To avoid backward compatibility problems, make sure to define FILE as the real __sFILE64, and make sure that __sFILE is not defined at all on Cygwin. Fixes: 0f376ae22036 ("Cygwin: rename __sFILE to __sFILE64 for backward compatibility") Fixes: 2902b3a09e0a ("Cygwin: drop requirement to build newlib's stdio64") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2022-09-26Fix missing extern C statementMarkus B. Moessner1-0/+7
2022-07-13Add --enable-newlib-reent-thread-local optionMatt Joyce3-0/+104
By default, Newlib uses a huge object of type struct _reent to store thread-specific data. This object is returned by __getreent() if the __DYNAMIC_REENT__ Newlib configuration option is defined. The reentrancy structure contains for example errno and the standard input, output, and error file streams. This means that if an application only uses errno it has a dependency on the file stream support even if it does not use it. This is an issue for lower end targets and applications which need to qualify the software according to safety standards (for example ECSS-E-ST-40C, ECSS-Q-ST-80C, IEC 61508, ISO 26262, DO-178, DO-330, DO-333). If the new _REENT_THREAD_LOCAL configuration option is enabled, then struct _reent is replaced by dedicated thread-local objects for each struct _reent member. The thread-local objects are defined in translation units which use the corresponding object.
2022-07-13Add _REENT_IS_NULL()Matt Joyce1-0/+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_SIG_FUNC(ptr)Matt Joyce1-0/+1
Add a _REENT_SIG_FUNC() macro to encapsulate access to the _sig_func 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-13Add _REENT_CVTBUF(ptr)Matt Joyce1-0/+1
Add a _REENT_CVTBUF() macro to encapsulate access to the _cvtbuf 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-13Add _REENT_CVTLEN(ptr)Matt Joyce1-0/+1
Add a _REENT_CVTLEN() macro to encapsulate access to the _cvtlen 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-13Add _REENT_CLEANUP(ptr)Matt Joyce1-0/+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-13Add _REENT_LOCALE(ptr)Matt Joyce1-0/+1
Add a _REENT_LOCALE() macro to encapsulate access to the _locale 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-13Add _REENT_INC(ptr)Matt Joyce1-0/+1
Add a _REENT_INC() macro to encapsulate access to the _inc member of struct reent. This will help to replace the struct member with a thread-local storage object in a follow up patch.