aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
AgeCommit message (Collapse)AuthorFilesLines
2022-06-22Revert "cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it"Mark Johnston1-2/+0
This reverts commit 9068f6ea697b1b28ad1326a4c7a9ba86f08b985e. The underlying macro needs to be reworked to avoid problems with control flow statements. Reported by: rlibby
2022-06-22cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use itMark Johnston1-0/+2
This implementation is faster and doesn't modify the cpuset, so it lets us avoid some unnecessary copying as well. No functional change intended. Reviewed by: cem, kib, jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32029
2022-06-22bitset(9): Introduce BIT_FOREACH_ISSET and BIT_FOREACH_ISCLRMark Johnston1-0/+10
These allow one to non-destructively iterate over the set or clear bits in a bitset. The motivation is that we have several code fragments which iterate over a CPU set like this: while ((cpu = CPU_FFS(&cpus)) != 0) { cpu--; CPU_CLR(cpu, &cpus); <do something>; } This is slow since CPU_FFS begins the search at the beginning of the bitset each time. On amd64 and arm64, CPU sets have size 256, so there are four limbs in the bitset and we do a lot of unnecessary scanning. A second problem is that this is destructive, so code which needs to preserve the original set has to make a copy. In particular, we have quite a few functions which take a cpuset_t parameter by value, meaning that each call has to copy the 32 byte cpuset_t. The new macros address both problems. Reviewed by: cem, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32028
2022-06-22iflib: Improve mapping of TX/RX queues to CPUsPatrick Kelsey1-0/+1
iflib now supports mapping each (TX,RX) queue pair to the same CPU (default), to separate CPUs, or to a pair of physical and logical CPUs that share the same L2 cache. The mapping mechanism supports unequal numbers of TX and RX queues, with the excess queues always being mapped to consecutive physical CPUs. When the platform cannot distinguish between physical and logical CPUs, all are treated as physical CPUs. See the comment on get_cpuid_for_queue() for the entire matrix. The following device-specific tunables influence the mapping process: dev.<device>.<unit>.iflib.core_offset (existing) dev.<device>.<unit>.iflib.separate_txrx (existing) dev.<device>.<unit>.iflib.use_logical_cores (new) The following new, read-only sysctls provide visibility of the mapping results: dev.<device>.<unit>.iflib.{t,r}xq<n>.cpu When an iflib driver allocates TX softirqs without providing reference RX IRQs, iflib now binds those TX softirqs to CPUs using the above mapping mechanism (that is, treats them as if they were TX IRQs). Previously, such bindings were left up to the grouptaskqueue code and thus fell outside of the iflib CPU mapping strategy. Reviewed by: kbowling Tested by: olivier, pkelsey MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D24094
2022-06-22bitset: implement BIT_TEST_CLR_ATOMIC & BIT_TEST_SET_ATOMICRyan Libby1-0/+14
That is, provide wrappers around the atomic_testandclear and atomic_testandset primitives. Submitted by: jeff Reviewed by: cem, kib, markj Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22702
2022-06-22bitset: expand bit index type to `long`D Scott Phillips2-5/+4
An upcoming patch to use the bitset macros for tracking vm page dump information could conceivably need more than INT_MAX bits. Expand the bit type to long so that the extra range is available on 64-bit platforms where it would most likely be needed. CPUSET_COUNT and DOMAINSET_COUNT are also modified to remain of type `int`. Reviewed by: kib, markj Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26190
2022-06-22bitset: add BIT_FFS_AT() for finding the first bit set greater than a start bitD Scott Phillips1-4/+15
Reviewed by: kib Approved by: scottl (implicit) MFC after: 1 week Sponsored by: Ampere Computing, Inc. Differential Revision: https://reviews.freebsd.org/D26128
2022-06-22Fix undefined behavior: left-shifting into the sign bit.Konstantin Belousov1-1/+1
Reviewed by: dim, markj Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D22898
2022-06-22bitset: rename confusing macro NAND to ANDNOTRyan Libby2-6/+6
s/BIT_NAND/BIT_ANDNOT/, and for CPU and DOMAINSET too. The actual implementation is "and not" (or "but not"), i.e. A but not B. Fortunately this does appear to be what all existing callers want. Don't supply a NAND (not (A and B)) operation at this time. Discussed with: jeff Reviewed by: cem Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22791
2022-06-22bitset: avoid pessimized code when bitset size is not constantRyan Libby1-2/+9
We have a couple optimizations for when the bitset is known to be just one word. But with dynamically sized bitsets, it was actually more work to determine the size than just to do the necessary computation. Now, only use the optimization when the size is known to be constant. Reviewed by: markj Discussed with: jeff Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D22639
2022-06-22Use a precise bit count for the slab free items in UMA.Jeff Roberson1-2/+3
This significantly shrinks embedded slab structures. Reviewed by: markj, rlibby (prior version) Differential Revision: https://reviews.freebsd.org/D22584
2022-06-22RTEMS: Remove FreeBSD version tagsSebastian Huber4-4/+4
2022-06-10Use global stdio streams for all configurationsSebastian Huber7-213/+12
The _REENT_GLOBAL_STDIO_STREAMS was introduced by commit 668a4c8722090fffd10869dbb15b879651c1370d in 2017. Since then it was enabled by default for RTEMS. Recently, the option was enabled for Cygwin which previously used an alternative implementation to use global stdio streams. In Newlib, the stdio streams are defined to thread-specific pointers _reent::_stdin, _reent::_stdout and _reent::_stderr. If the option is disabled (the default for most systems), then these pointers are initialized to thread-specific FILE objects which use file descriptors 0, 1, and 2, respectively. There are at least three problems with this: (1) The thread-specific FILE objects are closed by _reclaim_reent(). This leads to problems with language run-time libraries that provide wrappers to the C/POSIX stdio streams (for example C++ and Ada), since they use the thread-specific FILE objects of the initialization thread. In case the initialization thread is deleted, then they use freed memory. (2) Since thread-specific FILE objects are used with a common output device via file descriptors 0, 1 and 2, the locking at FILE object level cannot ensure atomicity of the output, e.g. a call to printf(). (3) There are resource managment issues, see: https://sourceware.org/pipermail/newlib/2022/019558.html https://bugs.linaro.org/show_bug.cgi?id=5841 This patch enables the _REENT_GLOBAL_STDIO_STREAMS behaviour for all Newlib configurations and removes the option. This removes a couple of #ifdef blocks.
2022-06-10Fix __fp_lock_all() and __fp_unlock_all()Sebastian Huber1-0/+4
For _REENT_GLOBAL_STDIO_STREAMS, lock/unlock all FILE objects. In the repository, this function is only used by Cygwin during process forks. Since Cygwin enabled _REENT_GLOBAL_STDIO_STREAMS recently, without this fix no FILE object at all was locked.
2022-06-08Clarify struct _reent commentSebastian Huber1-2/+3
2022-06-07Fix __sglue inititializationSebastian Huber1-4/+0
Do not initialize __sglue with the FILE objects of _GLOBAL_REENT to avoid a double use in the !_REENT_SMALL and !_REENT_GLOBAL_STDIO_STREAMS configurations which didn't use a thread-specific reentrancy structure.
2022-05-29Cygwin: simplify some function namesKen Brown4-28/+3
Remove "32" or "64" from each of the following names: acl32, aclcheck32, aclfrommode32, aclfrompbits32, aclfromtext32, aclsort32, acltomode32, acltopbits32, acltotext32, facl32, fchown32, fcntl64, fstat64, _fstat64, _fstat64_r, ftruncate64, getgid32, getgrent32, getgrgid32, getgrnam32, getgroups32, getpwuid32, getpwuid_r32, getuid32, getuid32, initgroups32, lseek64, lstat64, mknod32, mmap64, setegid32, seteuid32, setgid32, setgroups32, setregid32, setreuid32, setuid32, stat64, _stat64_r, truncate64. Remove prototypes and macro definitions of these names. Remove "#ifndef __INSIDE_CYGWIN__" from some headers so that the new names will be available when compiling Cygwin. Remove aliases that are no longer needed. Include <unistd.h> in fhandler_clipboard.cc for the declarations of geteuid and getegid.
2022-05-27Modify tzset_r.c to handle errorsJeff Johnston1-20/+48
- change __tzset_r so errors end up setting the timezone to unnamed UTC
2022-05-19Use weak reference for _REENT_SMALLSebastian Huber1-0/+4
Avoid a strong reference to __sfp[] for _impure_data. The __sfp[] is linked in if __sinit() is used for example.
2022-05-19Fix __sFILE::_lock initializationSebastian Huber1-8/+0
The __sFILE::_lock member is present if __SINGLE_THREAD__ is not defined. In this case, it is initialized in __sfp(). It is a bug to do it sometimes also in std().
2022-05-18newlib: libc: reent.h: remove unnecessary parenthesesJia-Wei Chen1-1/+1
The compiler warns the double parentheses are unnecessary in some target, and cause fail cases when doing some testcases in regression. gcc/testsuite/g++.dg/warn/Wstringop-overflow-6.C Remove the unnecessary parentheses will fix it. See more details in https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85775 Same like in commit 05425831290c9869bc7987b5df3ce84aa4f19a6c, Author: Maxim Blinov <maxim.blinov@embecosm.com> Date: Thu Jul 22 22:41:42 2021 +0100 Remove unneccesary parenthesis around declarator Thanks for Sebastian Huber's remind!
2022-05-18Use global atexit data for all configurationsSebastian Huber5-61/+23
For the exit processing only members of _GLOBAL_REENT were used by default. If the _REENT_GLOBAL_ATEXIT option was enabled, then the data structures were provided through dedicated global objects. Make this option the default. Remove the option. Rename struct _reent members _atexit and _atexit0 to _reserved_6 and _reserved_7, respectively. Provide them only if _REENT_BACKWARD_BINARY_COMPAT is defined.
2022-05-18Optional struct _reent::_new::_unusedSebastian Huber1-7/+5
Rename struct _reent::_new::_unused members _nextf and _nmalloc to _reserved_3 and _reserved_4, respectively. Rename struct _reent::_new member _unused to _reserved_5. Provide them only if _REENT_BACKWARD_BINARY_COMPAT is defined. Remove unused _N_LISTS define.
2022-05-18Optional struct _reent::_new::_reent::_unused_randSebastian Huber1-2/+6
Rename struct _reent member _unused_rand to _reserved_2. Provide it only if _REENT_BACKWARD_BINARY_COMPAT is defined.
2022-05-18Optional struct _reent::_unspecified_locale_infoSebastian Huber1-7/+9
Rename struct _reent member _unspecified_locale_info to _reserved_1. Provide it only if _REENT_BACKWARD_BINARY_COMPAT is defined.
2022-05-18Optional struct _reent::__unused_sdidinitSebastian Huber1-9/+15
Rename struct _reent member __unused_sdidinit to _reserved_0. Provide it only if _REENT_BACKWARD_BINARY_COMPAT is defined.
2022-05-18Add --enable-newlib-reent-binary-compatSebastian Huber1-0/+6
Add the --enable-newlib-reent-binary-compat configure option. This option is disabled by default. If enabled, then unused members in struct _reent are preserved to maintain the structure layout.
2022-05-18Use right lock release in __register_exitproc()Sebastian Huber1-1/+1
2022-05-17Fix stdio exit handlingSebastian Huber1-12/+17
Make sure that the stdio exit handler is set in all stdio initialization paths. The bug was introduced by commit 26747c47bc0a1137e02e0377306d721cc3478855.
2022-05-13Make cleanup_glue() staticSebastian Huber1-1/+1
Remove cleanup_glue from the list of symbols exported by Cygwin.
2022-05-13Remove __sglue member for one configurationMatt Joyce4-5/+21
Remove __sglue member of struct reent when _REENT_GLOBAL_STDIO_STREAMS is defined.
2022-05-13Add global __sglue object for all configurationsMatt Joyce5-9/+14
Added a new global __sglue object for all configurations. Decouples the global file object list from the _GLOBAL_REENT structure by using this new object instead of the __sglue member of _GLOBAL_REENT in __sfp() and _fwalk_sglue().
2022-05-13stdio: Replace _fwalk_reent() with _fwalk_sglue()Sebastian Huber7-17/+25
Replaced _fwalk_reent() with _fwalk_sglue(). The change adds an extra __sglue object as a parameter, which will allow the passing of a global __sglue object separate from the __sglue member of struct _reent. The global __sglue object will be added in a follow-on patch.
2022-05-13Add stdio_exit_handler()Matt Joyce3-3/+15
Add a dedicated stdio exit handler to avoid using _GLOBAL_REENT in exit().
2022-05-13Add CLEANUP_FILE defineMatt Joyce1-19/+19
Define the configuration-dependent constant CLEANUP_FILE for use in cleanup_stdio(). This will reduce duplicate code during the addition of a dedicated stdio atexit handler in a follow-on patch.
2022-05-13Move __sglue initializations to __sfp()Matt Joyce1-3/+7
Moved last remaining __sglue initializations from __sinit() to __sfp(). The move better encapsulates access to __sglue and facilitates its decoupling from struct _reent in a follow-on patch.
2022-05-13Remove __sinit_locks / __sinit_recursive_mutexMatt Joyce3-22/+3
Remove __sinit_lock_acquire() and __sinit_lock_release(). Replace these with __sfp_lock_acquire() and __sfp_lock_release(), respectively. This eliminates a potential deadlock issue between __sinit() and __sfp(). Remove now unused __sinit_recursive_mutex and __lock___sinit_recursive_mutex.
2022-05-13Add two __sglue initialization macrosMatt Joyce2-7/+9
Added _REENT_INIT_SGLUE and _REENT_INIT_SGLUE_ZEROED macros to initialize __sglue member of struct _reent. This allows further simplification of __sinit() and facilitates the removal of __sglue as a member of struct _reent for certain configurations in a follow-on patch.
2022-05-13Declare global __sf[] only onceSebastian Huber1-2/+4
Reduced number of global __sf[] declarations from two to one, simplifying initializations in sys/reent.h.
2022-05-13Remove duplicate sglue initializationsMatt Joyce1-3/+0
Removed duplicate sglue initializations from __sinit(). These are already initialized in the _REENT_INIT macro in sys/reent.h. This simplification enables the reduction of _GLOBAL_REENT dependency in a follow-on patch.
2022-05-13Remove duplicate stdio initializationsMatt Joyce1-4/+0
Removed duplicate stdio initializations from __sinit(). These are already initialized in the _REENT_INIT macro in sys/reent.h. This simplification enables the reduction of _GLOBAL_REENT dependency in a follow-on patch.
2022-05-04Generate manpages for functions in chapter sys.texJon Turney1-1/+3
Also generate manpages for functions in chapter sys.tex, omitted in error.
2022-05-04Silence xsltproc when writing manpagesJon Turney1-1/+1
Unless make is invoked with V=1, have xmlto pass the parameter 'man.output.quietly=1' to xsltproc to suppress "Note: Writing foo.N" output from the manpages stylesheet. (This doesn't quite do what it says: The output is not silenced if V has any value, including 0. You could consider that either a bug or a feature.)
2022-05-04Add build avoidance for 'make man'Jon Turney1-4/+5
This will generate multiple manpage files as an output, but we don't know what they will be called, so use a timestamp for build avoidance.
2022-05-04Simplify rules for creating man pagesJon Turney1-5/+3
Simplify rules for creating docbook XML used to create manpages: Updating the output using move-if-change and then unconditionally touching the .stamp file doesn't make much sense.
2022-05-04Fix ndbm.c build breakDimitar Dimitrov1-0/+1
The ndbm.c build broke with: Commit 357d7fcc6 In <stdio.h> provide only necessary types The above commit exposed a latent missing-header bug: newlib/newlib/libc/include/ndbm.h:83:38: error: unknown type name ‘mode_t’ Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2022-05-04Fix nano-malloc buildDimitar Dimitrov1-0/+1
The nano malloc build broke with: Commit 357d7fcc6 In <stdio.h> provide only necessary types The above commit exposed a latent missing-header bug: newlib/libc/stdlib/nano-mallocr.c:220:33: error: ‘uintptr_t’ undeclared (first use in this function) Fix by including <stdint.h>. Signed-off-by: Dimitar Dimitrov <dimitar@dinux.eu>
2022-05-04Remove _global_impure_ptr indirectionSebastian Huber5-31/+11
Remove the pointer indirection through the read-only _global_impure_ptr and directly use a externally visible _impure_data object of type struct _reent. This enables the static initialization of global data structures in a follow up patch. In addition, we get rid of a machine-specific file.
2022-05-04In <stdio.h> provide only necessary typesSebastian Huber1-1/+11
2022-05-04Revert "sys/types.h: Don't include sys/_stdint.h"Corinna Vinschen4-73/+72
This reverts commit 4232d171a620662aaed650879936eac60aefd9e0.