aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2022-07-11Expose clang's alignment builtins and use them for roundup2/rounddown2Alex Richardson1-0/+19
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
2022-07-11cdefs.h: remove intel_compiler supportWarner Losh1-22/+12
The age of the intel compiler support is so old as to be uninteresting. No recent recports of intel compiler support have been received. Remove all the special case workarounds for the Intel compiler. Should there be interest in supporting the compiler, contact me and I'll work with people to make it happen, though I suspect these instances are more likely to be in the way than to be helpful. Reviewed by: cem, emaste, vangyzen, dim Differential Revision: https://reviews.freebsd.org/D26817
2022-07-09Cygwin: console: Fix an issue which causes when realloc() fails.Takashi Yano1-5/+13
2022-07-08Reduce namespace pollution from <sys/_types.h>Sebastian Huber3-6/+8
Provide only __daddr_t through <sys/_types.h>.
2022-07-08RTEMS: Declare ioctl() also if _KERNEL is definedSebastian Huber1-6/+1
This fixes the following warning in libbsd: rtems/blkdev.h:200:10: warning: implicit declaration of function 'ioctl'; did you mean 'ifioctl'? [-Wimplicit-function-declaration] Remove unnecessary includes.
2022-07-07Cygwin: redefine some macros for Linux compatibilityKen Brown5-5/+21
Define FD_SETSIZE (<sys/select.h>) to be 1024 by default, and define NOFILE (<sys/param.h>) to be OPEN_MAX (== 3200) by default. Remove the comment in <sys/select.h> that FD_SETSIZE should be >= NOFILE. Bump API minor. Addresses: https://cygwin.com/pipermail/cygwin/2022-July/251839.html
2022-07-07winsup/doc/faq-setup.xml: align help text with setup 2.919Christian Franke1-7/+11
2022-07-05Cygwin: spawn: Treat empty path as the current directory.Takashi Yano2-2/+23
- With this patch, the empty path (empty element in PATH or PATH is absent) is treated as the current directory as Linux does. This feature is added for Linux compatibility, but it is deprecated. POSIX notes that a conforming application shall use an explicit pathname to specify the current working directory. Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251730.html
2022-07-05Cygwin: console: Fix issue of pasting very long text input again.Takashi Yano1-22/+65
- The recent commit "Cygwin: console: Allow pasting very long text input." did not fix the issue enough. This patch adds fixes for that.
2022-07-04Cygwin: implement getfacl(1) for socket filesKen Brown3-0/+82
Do this by defining the acl_get method for the fhandler_socket_local and fhandler_socket_unix classes. Also define acl_set for these classes. Partially addresses: https://cygwin.com/pipermail/cygwin/2022-July/251768.html
2022-07-04Cygwin: stdio: don't try again to read after EOFKen Brown3-8/+8
This reverts commit 1f8f7e2d54, "* libc/stdio/refill.c (__srefill): Try again after EOF on Cygwin." If EOF is set on a file, the stdio input functions will now immediately return EOF rather than trying again to read. This aligns Cygwin's behavior to that of Linux. Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251672.html
2022-07-03Cygwin: console: Fix new bugs in cons_master_thread().Takashi Yano1-8/+9
- The previous commit for console introduced new bugs in error handling in cons_master_thread(). This patch fixes that.
2022-07-02Cygwin: console: Allow pasting very long text input.Takashi Yano5-27/+113
- Currently, if the text longer than 1024 byte is pasted in console, some of the text is discarded. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251764.html
2022-07-01RTEMS: _KERNEL tweak for <sys/cpuset.h>Sebastian Huber1-0/+2
If _KERNEL is defined, then do not delcare CPU_ALLOC() and CPU_FREE() since __cpuset_alloc() and __cpuset_free() are not declared as well.
2022-06-27Cygwin: poll: Fix a bug on inquiring same fd with different events.Takashi Yano2-3/+10
- poll() has a bug that it returns event which is not inquired if events are inquired in multiple pollfd entries on the same fd at the same time. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251732.html
2022-06-22newlib/libc/sys/rtems/include/sys/cpuset.hStefan Eßer1-1/+1
Fix typo in source file. Reported by: pluknet at gmail.com (Sergey Kandaurov)
2022-06-22Make CPU_SET macros compliant with other implementationsStefan Eßer4-10/+15
The introduction of <sched.h> improved compatibility with some 3rd party software, but caused the configure scripts of some ports to assume that they were run in a GLIBC compatible environment. Parts of sched.h were made conditional on -D_WITH_CPU_SET_T being added to ports, but there still were compatibility issues due to invalid assumptions made in autoconfigure scripts. The differences between the FreeBSD version of macros like CPU_AND, CPU_OR, etc. and the GLIBC versions was in the number of arguments: FreeBSD used a 2-address scheme (one source argument is also used as the destination of the operation), while GLIBC uses a 3-adderess scheme (2 source operands and a separately passed destination). The GLIBC scheme provides a super-set of the functionality of the FreeBSD macros, since it does not prevent passing the same variable as source and destination arguments. In code that wanted to preserve both source arguments, the FreeBSD macros required a temporary copy of one of the source arguments. This patch set allows to unconditionally provide functions and macros expected by 3rd party software written for GLIBC based systems, but breaks builds of externally maintained sources that use any of the following macros: CPU_AND, CPU_ANDNOT, CPU_OR, CPU_XOR. One contributed driver (contrib/ofed/libmlx5) has been patched to support both the old and the new CPU_OR signatures. If this commit is merged to -STABLE, the version test will have to be extended to cover more ranges. Ports that have added -D_WITH_CPU_SET_T to build on -CURRENT do no longer require that option. The FreeBSD version has been bumped to 1400046 to reflect this incompatible change. Reviewed by: kib MFC after: 2 weeks Relnotes: yes Differential Revision: https://reviews.freebsd.org/D33451
2022-06-22sys/_bitset.h: Fix fall-out from commit 5e04571cf3cStefan Eßer1-3/+4
The changes to the bitset macros allowed sched.h to be included into userland programs without name space pollution due to BIT_* and BITSET_* macros. The definition of a "struct bitset" had been overlooked. This name space pollution caused the build of port print/miktex to fail. This commit makes the definition of struct bitset depend on the same condition as the visibility of the BIT_* and BITSET_* macros, i.e. needs _KERNEL or _WANT_FREEBSD_BITSET to be defined before including sys/_bitset.h. It has been tested with "make universe" since a prior attempt to fix the issue broke the PowerPC64 kernel build. This commit shall be MFCed together with commit 5e04571cf3c. Reported by: arrowd MFC after: 1 month
2022-06-22sys/_bitset.h: revert commit 74e014dbfabStefan Eßer1-3/+1
It caused kernel build for PowerPC64 to fail. A different patch is being tested with make universe to make sure it works on all architectures. MFC after: 1 month<N [day[s]|week[s]|month[s]]. Request a reminder email>
2022-06-22sys/_bitset.h: Fix fall-out from commit 5e04571cf3cStefan Eßer1-2/+2
There is a reference to malloc() in #define __BITSET_ALLOC. Even though this macro is only defined but not used, it causes the lang/gcc ports to fail. The gcc ports "poison" a number of functions including malloc() and prevent their use (including in macro definitions). This commit moved the declaration of __BITSET_ALLOC into the conditional block that depends on _KERNEL or _WANT_FREEBSD_BITSET being defined. There is no use of __BITSET_ALLOC in the FreeBSD sources, and userland programs that want to use BITSEC_ALLOC will define _WANT_FREEBSD_BITSET anyway. This patch has been tested by building lang/gcc11 and a successful make buildworld. This commit shall be MFCed together with commit 5e04571cf3c. MFC after: 1 month
2022-06-22sys/_bitset.h: Fix fall-out from commit 5e04571cf3cKonstantin Belousov1-1/+3
The changes to the bitset macros allowed sched.h to be included into userland programs without name space pollution due to BIT_* and BITSET_* macros. The definition of a global variable "bitset" had been overlooked. This name space pollution caused a compile failure in print/miktex. This commit renames the bitset variable to __bitset with the same mapping back to the bitset if _KERNEL or _WANT_FREEBSD_BITSET is defined. This fix has been suggested by kib. It has been tested to let the build of the print/miktex port succeed and to not break buildworld. This commit shall be MFCed together with commit 5e04571cf3c. Reported by: arrowd MFC after: 1 month
2022-06-22sys/bitset.h: reduce visibility of BIT_* macrosStefan Eßer4-78/+127
Add two underscore characters "__" to names of BIT_* and BITSET_* macros to move them to the implementation name space and to prevent a name space pollution due to BIT_* macros in 3rd party programs with conflicting parameter signatures. These prefixed macro names are used in kernel header files to define macros in e.g. sched.h, sys/cpuset.h and sys/domainset.h. If C programs are built with either -D_KERNEL (automatically passed when building a kernel or kernel modules) or -D_WANT_FREENBSD_BITSET (or this macros is defined in the source code before including the bitset macros), then all macros are made visible with their previous names, too. E.g., both __BIT_SET() and BIT_SET() are visible with either of _KERNEL or _WANT_FREEBSD_BITSET defined. The main reason for this change is that some 3rd party sources including sched.h have been found to contain conflicting BIT_* macros. As a work-around, parts of shed.h have been made conditional and depend on _WITH_CPU_SET_T being set when sched.h is included. Ports that expect the full functionality provided by sched.h need to be built with -D_WITH_CPU_SET_T. But this leads to conflicts if BIT_* macros are defined in that program, too. This patch set makes all of sched.h visible again without this parameter being passed and without any name space pollution due to BIT_* macros becoming visible when sched.h is included. This patch set will be backported to the STABLE branches, but ports will need to use -D_WITH_CPU_SET_T as long as there are supported releases that do not contain these patches. Reviewed by: kib, markj MFC after: 1 month Relnotes: yes Differential Revision: https://reviews.freebsd.org/D33235
2022-06-22sched.h: add CPU_EQUAL() for better compatibility with LinuxKonstantin Belousov1-1/+1
Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32901
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. This is a re-application of commit 9068f6ea697b1b28ad1326a4c7a9ba86f08b985e. Reviewed by: cem, kib, jhb MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32029
2022-06-22bitset: Reimplement BIT_FOREACH_IS(SET|CLR)Mark Johnston1-6/+25
Eliminate the nested loops and re-implement following a suggestion from rlibby. Add some simple regression tests. Reviewed by: rlibby, kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D32472
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-21Regenerate configure and newlib.hinSebastian Huber2-13/+1
In commit b0cb9f85ca3626e0e68fd451c3090d253ceb4300 the regeneration of the configure and newlib.hin files was missing.
2022-06-19Cygwin: console: Handle setting very long window title correctly.Takashi Yano2-24/+69
- Previously, the console code could not handle escape sequence setting window title longer than 256 byte correctly. This patch fixes the issue. Addresses: https://cygwin.com/pipermail/cygwin/2022-June/251662.html
2022-06-14Cygwin: console: Retain ENABLE_VIRTUAL_TERMIANL_PROCESSING flag.Takashi Yano2-0/+5
- Currently, ENABLE_VIRTUAL_TERMINAL_PROCESSING flag is disabled unconditionally when exiting from cygwin. This causes ANSI escape sequence disabled in Windows Terminal where it is enables by default. This patch retains that flag if it is originally enabled.
2022-06-11Cygwin: restore one more '#ifdef __x86_64__'Ken Brown1-0/+4
2022-06-10Cygwin: restore '#ifdef __x86_64__' for CPU-specific codeKen Brown6-0/+47
Commit e1ce752a1d, "Cygwin: remove miscellaneous 32-bit code", removed most occurrences of '#ifdef __x86_64__'. Restore those occurrences that guarded code specific to the AMD64 processor, and #error out if the processor is different. This will make it easier to find AMD64-specific code if we ever want to add support for a different 64-bit processor (e.g., ARM64).
2022-06-10Use global stdio streams for all configurationsSebastian Huber10-228/+14
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-10Cygwin: Have gmondump support ssp-generated gmon.outMark Geisert1-13/+22
Cygwin tool ssp generates gmon.out files with different address resolution than other tools do. Two address bytes per bucket rather than the usual four address bytes. Gprof can deal with the difference but gmondump can't because the latter's gmon.out header validation fails. - Remove the offending portion of the header validation code. - Make sure all code can handle differing address resolutions. - Display address resolution in verbose data dumps. - Change "rawarc" to "struct rawarc" in certain sizeof expressions to avoid buffer overrun faults. - When "-v" (verbose) is specified, note when there is missing bucket data or rawarc data.
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-06-07Cygwin: restore two instances of __stdcallKen Brown2-2/+2
In the previous commit, __stdcall was removed from _dll_crt0 in winsup.h and dcrt0.cc but not in lib/cygwin_crt0.c. For consistency, restore the first two occurrences of __stdcall. We could instead remove it from the declaration in lib/cygwin_crt0.c, but this might appear to affect binary compatibility, even though it really doesn't.
2022-06-06Cygwin: remove most occurrences of __stdcall and __cdeclKen Brown49-147/+147
These have no effect on x86_64. Retain a few occurrences of __cdecl in files imported from other sources. Also retain all occurrences of WINAPI, even though the latter is simply a macro that expands to __stdcall. Most of these occurrences are associated with Windows API functions, and removing them might make the code confusing instead of simpler.
2022-06-06Cygwin: remove ntsecapi.hKen Brown1-26/+0
This was a wrapper for w32api/ntsecapi.h. It was introduced to fix a bug that only affected 32-bit Cygwin, so it is no longer needed.