Commit graph

2019 commits

Author SHA1 Message Date
Minsoo Choo
94d1731e73 Makefile*: remove powerpcspe
As reported on the freebsd-announce mailing list[1] FreeBSD is
continuing to retire 32-bit support.  Remove powerpcspe from build
infrastructure.

[1] https://lists.freebsd.org/archives/freebsd-announce/2024-February/000117.html

Signed-off-by: Minsoo Choo <minsoochoo0122@proton.me>
Reviewed by:	jhibbits, emaste
Pull request:	https://github.com/freebsd/freebsd-src/pull/1914
2026-01-09 11:28:43 -05:00
Minsoo Choo
f441a225c4 stdbool.h: Update for C23
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
When a compiler with C23 or higher is detected, builtin bool, true,
and false are used to conform the C23 standard.

Reviewed by:	imp
Differential Revision: https://reviews.freebsd.org/D44664
2026-01-06 20:26:59 -05:00
Konstantin Belousov
b8c99e7d91 libc: add glibc-compatible tdestroy(3)
The function clears the whole tree.

Relnotes:	yes
Reviewed by:	alc, emaste
Discussed with:	dougm
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54365
2025-12-29 19:18:55 +02:00
Brooks Davis
80203a27e9 Add sys/_align.h replacing machine/_align.h
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
Define _ALIGNBYTES using sizeof(void *) (no functional change on any
existing architecture) which will allow it to work with CHERI were we
must align things up to capability alignment.

In _ALIGN, replace integer manipulation which does not preserve pointer
provenance with a type and provenance preserving builtin.  This requires
modest changes in code which assumes _ALIGN returns an integer, but
those are relatively rare.

Reviewed by:	kib, markj
Effort:		CHERI upstreaming
Sponsored by:	Innovate UK
Differential Revision:	https://reviews.freebsd.org/D53947
2025-12-10 10:57:50 +00:00
Konstantin Belousov
a98e5d7850 libc/string: add strdupa(3) and strndupa(3)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54066
2025-12-09 00:34:57 +02:00
Robert Clausecker
fc88be257e Revert "stddef.h: add unreachable() for C23 compliance"
Some checks are pending
Cross-build Kernel / amd64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-22.04 (clang-15) (push) Waiting to run
Cross-build Kernel / amd64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 ubuntu-24.04 (clang-18) (push) Waiting to run
Cross-build Kernel / amd64 macos-latest (clang-18) (push) Waiting to run
Cross-build Kernel / aarch64 macos-latest (clang-18) (push) Waiting to run
Seems like a number of ports are *really* unhappy with this new
macro.  These ports will have to be fixed and the patch reworked
to perhaps not affect C++ (see D54041).  A general discussion on
how we expose new language features may also need to take place.

Reported by:	many people
Approved by:	markj (mentor)

This reverts commit b381d09802.
2025-12-05 00:25:10 +01:00
Robert Clausecker
6296500a85 libc: implement C23 <stdbit.h> functions
This new header complies with ISO/IEC 9899:2024 (C23).

Contrary to glibc, we do not provide inline definitions in
<stdbit.h> as we expect our system compiler to soon recognise
these as builtins anyway.

Relnotes:	yes
MFC after:	1 month
Reviewed by:	adrian
Approved by:	markj (mentor)
Differential Revision:	https://reviews.freebsd.org/D53657
2025-11-30 20:21:52 +01:00
Robert Clausecker
b381d09802 stddef.h: add unreachable() for C23 compliance
unreachable() is a hint to the compiler that it is unreachable.
Add a new man page unreachable(3) to document this macro.

Reviewed by:	imp
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D53967
2025-11-28 16:56:49 +01:00
Robert Clausecker
f0e541118c uchar.h: add char8_t
A type similar to char16 and char32_t, for compliance with C23.
The related type atomic_char8_t is added to stdatomic.h.
As char8_t is always unsigned char, I've skipped adding __char8_t.
This can be added, too, if desired.

Reviewed by:	imp
Approved by:	markj (mentor)
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D53952
2025-11-28 16:19:53 +01:00
Robert Clausecker
5da388c633 time.h: add timegm() to the C23 namespace
This function is part of ISO/IEC 9899:2024 (C23) and was forgotten in D47856.

Reviewed by:	imp
Approved by:	markj (mentor)
See also:	D47856
Fixes:		59677aecb6
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D53951
2025-11-28 16:19:40 +01:00
John Baldwin
e928afc531 Use ZFSTOP more broadly
Reviewed by:	brooks
Obtained from:	CheriBSD
Differential Revision:	https://reviews.freebsd.org/D53791
2025-11-24 10:47:10 -05:00
Robert Clausecker
6c57e368eb lib/libc: implement C23 memalignment()
This new function computes the alignment of a pointer.
It is part of ISO/IEC 9899:2024, the new C standard.
If the pointer is a null pointer, null is returned.
I have tried to write an implementation that can cope
with traditional address-based architectures, even if
size_t and uintptr_t are of different length.  Adjustments
may be needed for CHERI though.

A man page is provided, too.  No unit test for now.

Reviewed by:	kib, imp, ziaee (manpages), pauamma@gundo.com
Approved by:	markj (mentor)
MFC after:	1 month
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D53673
2025-11-12 13:23:09 +01:00
Konstantin Belousov
3c052bec12 include/stdckdint.h: make the header compatible with C++
by removing the cast to _Bool.  The _Bool type is not defined for C++,
and the specification from the gcc info doc states that the return
type of the  __builtin_{add,sub,mul}_overflow() is bool already.

This is done instead of including stdbool.h to avoid namespace
pollution, since defining bool from stdckdint.h simingly is not
sanctioned by ISO/IEC 9899:2024.

PR:	290299
Reviewed by:	des
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D53149
2025-10-18 00:48:30 +03:00
Robert Clausecker
d518f64cef libc/resolv: get rid of MD5
MD5 is used by libc/resolv to generate a random sequence id from a
current time stamp.  Replace this convoluted mechanism with a call
to arc4random().  This permits us to entirely drop MD5 from libc,
simplifying the MD5 rework proposed in D45670.

Approved by:	markj
Reviewed by:	kevans, markj
See also:	D45670
Event:		EuroBSDcon 2025
Differential Revision:	https://reviews.freebsd.org/D52784
2025-10-04 10:50:02 +02:00
Robert Clausecker
4266461079 lib/libc: add recallocarray()
This function from OpenBSD is a hybrid of reallocarray() and calloc().
It reallocates an array, clearing any newly allocated items.
reallocarray() ultimately originates from OpenBSD.

The source is taken from lib/libopenbsd, which now no longer has the
function unless when bootstrapping (needed for mandoc).

Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D52863
2025-10-03 19:46:55 +02:00
Lexi Winter
a053f948ad libbsm: Rename package to audit-lib
This is part of audit, so use the new LIB_PACKAGE feature to name the
package audit-lib, rather than libbsm.

MFC after:	1 day
Reviewed by:	bapt
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D52789
2025-09-30 09:14:58 +01:00
Dag-Erling Smørgrav
155290b23f tzcode: Expose and document offtime() and offtime_r()
Includes diff reduction to upstream version of this patch.

MFC after:	3 days
Sponsored by:	Klara, Inc.
Reviewed by:	philip
Differential Revision:	https://reviews.freebsd.org/D39715
2025-09-23 21:38:49 +02:00
Dag-Erling Smørgrav
d20c825072 Revert "libc: Remove readdir_r(3)"
This reverts commit d549de7690.
2025-09-11 17:12:22 +02:00
Dag-Erling Smørgrav
d549de7690 libc: Remove readdir_r(3)
This function was never safe to use.  We marked it deprecated in the
manual page in 2016, and it is marked obsolete in POSIX 2024.  We
previously added a linker warning and annotated the prototype; now that
stable/15 has been branched, we can remove it from main.

Relnotes:	yes
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D52474
2025-09-10 18:58:06 +02:00
Lexi Winter
dc5ba6b8b4 Remove MK_GSSAPI
For MIT Kerberos, MK_GSSAPI has no meaning: GSSAPI is a required part of
Kerberos and is always built if MK_KERBEROS is enabled.  Backport this
behaviour to Heimdal so it works the same way.

While here, change Heimdal's libcom_err and compile_et to be selected by
MK_KERBEROS, not MK_KERBEROS_SUPPORT, since these are part of Kerberos
and third-party users might need it even if Kerberos support is disabled
in the base system.  This means MK_KERBEROS_SUPPORT installs the same
files with both MIT and Heimdal.

Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D51859
2025-08-20 19:42:20 +01:00
Lexi Winter
837b13af68 Revert "Remove Secure RPC DES authentication"
This reverts commit 7ac276298b.

Requested by:	kib
2025-08-15 17:59:18 +01:00
Lexi Winter
7ac276298b Remove Secure RPC DES authentication
Following the earlier removal of keyserv, none of this functionality
works since it requires keyserv.

Remove the relevant symbols from libc's Symbol.map.  Leave compatibility
symbols for existing applications, but since the functions don't work
without keyserv, stub them out to return an error.

Remove some private symbols that were only used by keyserv; these don't
get compatibility symbols.

Remove the documentation for the old functions.

Remove rpc.ypupdated since it requires DES authentication.

Reviewed by:		manu, des, emaste
Differential Revision:	https://reviews.freebsd.org/D50442
2025-08-10 16:36:40 +01:00
Cy Schubert
e26259f48a gssapi,krb5: Replace libgssapi with the MIT version
lib/libgssapi is based on Heimdal. As on Linux systems, the MIT
libgssapi_krb5 replaces it. With both gssapi libraries and header files
installed results in broken buildworld (gssd) and ports that will not
build without modifications to support the MIT gssapi in an alternate
location.

73ed0c7992 removed the MIT GSSAPI headers from /usr/include. Apps using
MIT KRB5 gssapi functions and structures will fail to build without this
patch.

This patch includes a temporary patch to usr.sbin/gssd to allow it
to build with this patch. rmacklem@ has a patch for this and for
kgssapi that uses this patch to resolve kgssapi issues for NFS with
Kerberos.

This patch is an updated version of D51661 to allow it to build following
additional patchs to the tree.

This should have been implmented with 7e35117eb0.

Fixes:			7e35117eb0, 73ed0c7992
Differential Revision:	https://reviews.freebsd.org/D51661
2025-08-07 10:17:00 -07:00
Dag-Erling Smørgrav
2bd157bc73 libc: Deprecate readdir_r()
This function was never safe to use.  We marked it deprecated in the
manual page in 2016, and it is marked obsolete in POSIX 2024.  Add a
linker warning and annotate the prototype.

Sponsored by:	Klara, Inc.
Reviewed by:	imp, markj
Differential Revision:	https://reviews.freebsd.org/D51681
2025-08-02 01:11:56 +02:00
Ed Maste
c143ffbaf7 rpc.h: Remove reference to unimplemented DES ioctls
We won't be adding support for hardware DES.  Remove the #ifdef notdef
block.

Sponsored by:	The FreeBSD Foundation
2025-07-23 16:53:30 -04:00
Dag-Erling Smørgrav
0a5b763d98 libc: Rename fscandir{,_b}() to fdscandir{,_b}().
This seems to fit the pattern better (e.g. fdopendir()).

I've added weak references to ease the transition, but since it's only
been a few days, we can remove them (and the ObsoleteFiles entries for
the manual pages) before we branch stable/15.

Fixes:		deeebfdeca
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D50980
2025-06-23 15:03:10 +02:00
Dag-Erling Smørgrav
deeebfdeca libc: Add fscandir(), fscandir_b(), scandirat_b().
While here, clean up scandir() a bit and improve the documentation.

MFC after:	never
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D50935
2025-06-20 13:10:23 +02:00
Olivier Certner
63c9b01806
arm64: lib32: Don't try to install removed <machine/runq.h>
Reported by:    Herbert J. Skuhra (herbert gojira.at)
Fixes:          79d8a99ee583 ("runq: Deduce most parameters, remove machine headers")
MFC after:      1 month
Event:          Kitchener-Waterloo Hackathon 202506
Sponsored by:   The FreeBSD Foundation
2025-06-18 12:00:08 -04:00
Warner Losh
d8b51259ca ssp: Protect sig2str with proper visibility markers
We only define SIG2STR_MAX with careful visibility, but define the
fortified version unconditionally. It needs to have the same visibility
both places.

Fixes:		3d12567133
Reviewed by:	jrtc27, kevans
Sponsored by:	Netflix
2025-06-11 21:19:05 -06:00
Ricardo Branco
b0334450aa include: ssp: fortify <signal.h>
sig2str(3)

Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
Closes: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco
3d12567133 Add the POSIX sig2str(3) & str2sig(3) calls
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Reviewed by: imp, kib, des, jilles
Pull Request: https://github.com/freebsd/freebsd-src/pull/1696
2025-06-11 17:16:22 -06:00
Ricardo Branco
86f06e612b Add POSIX NSIG_MAX & _SC_NSIG
Signed-off-by: Ricardo Branco <rbranco@suse.de>
Reviewed by: imp, kib
Pull Request: https://github.com/freebsd/freebsd-src/pull/1710
Closes: https://github.com/freebsd/freebsd-src/pull/1710
2025-06-11 17:16:20 -06:00
Brooks Davis
2d92a5abef Add sys/stdarg.h
While the type of va_list and implementation of va_*() psuedo functions
varies (sometimes greatly) by architecture, they will always be defined
by the compiler in a consistant way that does not require machine
dependent handling.

MFC after:	1 week

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:02 +01:00
Brooks Davis
c190cd94b7 sys/_stdarg.h: drop cdefs.h and _types.h polution
Rely in sys/_visible for visibility macros and use __buitin_va_list
instead of __va_list everywere we declare va_list.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:02 +01:00
Brooks Davis
2e783ea70a stddef.h: don't include sys/cdefs.h
Switch to sys/_visible.h for visibility macros.

Prefer __builtin_offsetof over __offset.  sys/cdefs.h always defines
__offsetof to __builtin_offsetof so just use the latter to remove a
dependency on sys/cdefs.h.  Realistically, we're never going to care
about a compiler that doesn't supply this builtin.

Add a somewhat questionable guard around the offsetof() definition
because the compiler no longer thinks it the same as a number of other
redundent definitions scattered around (e.g., in the openzfs codebase).
It is actually the same and those defintions likely shouldn't exist at
all, but it's easy to add a guard for now.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:02 +01:00
Brooks Davis
b01e971fd3 Don't rely on sys/_types.h including sys/cdefs.h
These headers relied in __BEGIN_DECS/__END_DECLS being defined when
sys/_types.h was included, but there's not a requirement that this be
the case.

Reviewed by:	imp
Exp-run by:	antoine (PR 286274)
Pull Request:	https://github.com/freebsd/freebsd-src/pull/1595
2025-06-11 17:39:01 +01:00
Bojan Novković
8bc0b97e19 glob.h: Limit glob_b prototype visibility
Hide glob_b behind __BSD_VISIBLE as it is not a POSIX function.

Reported by:	kib
Reviewed by:	kib
Fixes:	1e0743f54d ("glob: Add blocks support")
Differential Revision:	https://reviews.freebsd.org/D50670
2025-06-03 22:59:28 +02:00
Bojan Novković
1e0743f54d glob: Add blocks support
This change introduces the `glob_b` function which takes a block instead
of a function pointer.

Relnotes:	yes
Sponsored by:   Klara, Inc.
Inspired by:  https://github.com/apple-oss-distributions/Libc
Differential Revision:	https://reviews.freebsd.org/D50485
2025-06-02 11:32:50 +02:00
Konstantin Belousov
a56fe703c2 Provide user interface to retrieve reported extended errors
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D50483
2025-05-31 22:52:42 +03:00
Konstantin Belousov
98af94cae7 sysconf(3): add _SC_UEXTERR_LEN, the max length of the extended error string
Reviewed by:	brooks
Sponsored by:	The FreeBSD Foundation
MFC after:	2 weeks
Differential revision:	https://reviews.freebsd.org/D50483
2025-05-31 22:52:42 +03:00
Konstantin Belousov
31760ee65a libthr: add stable user interface for sigfastblock(2)
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50377
2025-05-19 09:07:43 +03:00
Konstantin Belousov
c0fdd2bf94 pthread_switch_add_np(3): remove
The interface is not functional with libthr and returns not supported
error always.  There is no point in providing it to userspace or document.

The symbols are kept for ABI compatibility, of course.

Reviewed by:	emaste, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50376
2025-05-19 09:07:43 +03:00
Dag-Erling Smørgrav
da2025a0e8 fts: Add FTS_COMFOLLOWDIR and FTS_NOSTAT_TYPE.
MFC after:	never
Relnotes:	yes
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, imp
Differential Revision:	https://reviews.freebsd.org/D50233
2025-05-08 16:29:15 +02:00
Konstantin Belousov
5ab906195b include/paths.h: add _PATH_NOSHUTDOWN
Reviewed by:	bapt, kevans, olce
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D50166
2025-05-05 19:04:22 +03:00
Dag-Erling Smørgrav
873420ca1e libc: Add getenv_r() function.
This is a calque of the NetBSD function of the same name.

MFC after:	never
Relontes:	yes
Sponsored by:	Klara, Inc.
Reviewed by:	kevans
Differential Revision:	https://reviews.freebsd.org/D49979
2025-04-27 08:29:32 +02:00
Dag-Erling Smørgrav
f0ac5e919f fts: Add blocks support.
This adds an `fts_open_b()` variant of `fts_open()` which takes a block
instead of a function pointer.

This was inspired by, and is intended to be compatible with, Apple's
implementation; however, although our FTS and theirs share a common
ancestor, they have diverged significantly.  That and the fact that
we still target compilers which don't support blocks means Apple's
implementation was not directly reusable.

This is the second use case for blocks in FreeBSD (the first being
`qsort_b()`, which we use here).  This suggest we might want to add
a `COMPILER_FEATURE` for blocks to avoid hardcoding any further
`COMPILER_TYPE` checks.

MFC after:	never
Relnotes:	yes
Sponsored by:	Klara, Inc.
Reviewed by:	kevans, theraven, imp
Differential Revision:	https://reviews.freebsd.org/D49877
2025-04-22 19:25:56 +02:00
Ricardo Branco
3b2f0bfc35 Add POSIX psiginfo(3) call
Signed-off-by: Ricardo Branco <rbranco@suse.de>
PR:	286133
MFC after:	 1 week
Github PR:	 https://github.com/freebsd/freebsd-src/pull/1666
2025-04-17 18:19:44 +03:00
Dag-Erling Smørgrav
80e06d621a fts: Move private flags away from public ones.
Renumber the private flags so there is a sizeable gap between them and
the public flags, making it easier to add public flags in the future.
These private flags are only ever set or read by FTS itself, so there
is no compatibility issue.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D49711
2025-04-10 13:35:46 +02:00
Stephen Hurd
415a0ce02c Revert Make newly POSIX functions visible
Summary:
This reverts commit d7efac1be1.
This reverts commit 9d0eea9422.

Some ports (specifically Python) define __BSD_VISIBLE themselves, so
the change from __BSD_VISIBLE to __POSIX_VISIBLE >= 202405 makes them
fail.

Reported by:	jrtc27, cperciva
2025-03-20 03:41:27 -04:00
Stephen Hurd
d7efac1be1 Add missing ||
Fixes:	9d0eea9422
2025-03-19 20:55:13 -04:00