Commit graph

2017 commits

Author SHA1 Message Date
Konstantin Belousov
522dbeb9f2 sys: add renameat2(2) syscall
(cherry picked from commit 28599a1e5f1b90676a818e0a4818cddd0839ad25)
2026-03-10 13:41:31 +02:00
Konstantin Belousov
6a263d7c1f libc: improve include usage for exterror sources
(cherry picked from commit 1443a455a96e587a7b49608def79495e9d74513f)
2026-02-21 11:48:57 +02:00
Konstantin Belousov
f68ddd04ae libc: add posix_spawnattr_{get,set}procdescp_np
(cherry picked from commit 080d8ed7dd29ba537ce4cca286ed3369aca61ef5)
2026-02-01 23:38:50 +02:00
Konstantin Belousov
6b9e7e922d libc: add posix_spawnattr_{get,set}execfd_np(3)
(cherry picked from commit 3f0aea09689f6c10740de78011469355208a19a5)
2026-02-01 23:38:49 +02:00
Konstantin Belousov
a8891c29d6 libthr: add pthread_tryjoin_np()
(cherry picked from commit afa70a8496e90fa751418be8d1b55e3d559a281a)
2026-01-25 02:23:35 +02:00
Minsoo Choo
5656d0f745 stdbool.h: Update for C23
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

(cherry picked from commit f441a225c4eb56deff1edc2402fe85a0ae263ebd)
2026-01-13 09:01:56 -05:00
Konstantin Belousov
6197518ee9 libc: add glibc-compatible tdestroy(3)
(cherry picked from commit b8c99e7d912f0dad84cec80f8c4331646b87a3ec)
2026-01-05 02:44:21 +02:00
Robert Clausecker
275c11b7cc 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

(cherry picked from commit 6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64)
2026-01-01 21:51:52 +01:00
Robert Clausecker
72609bb2bb 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

(cherry picked from commit f0e541118c374869a8226eaa1320bb6eda248a20)
2026-01-01 21:47:33 +01:00
Robert Clausecker
35787967e8 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

(cherry picked from commit 5da388c633f8da8fbb35b8407ca848373e3ea977)
2026-01-01 21:47:33 +01:00
Konstantin Belousov
b2e649a0b9 libc/string: add strdupa(3) and strndupa(3)
(cherry picked from commit a98e5d78500193dc7aa352e1f60ac2c6529e2c38)
2025-12-16 06:57:01 +02:00
Robert Clausecker
24ea81047d 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

(cherry picked from commit 6c57e368eb1777f6097158eeca2fcc175d068dba)
2025-12-12 11:32:58 +01:00
Robert Clausecker
e72536a11f 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

(cherry picked from commit 42664610795bc0a728851ba6223fcf9b93801167)
2025-12-12 11:32:37 +01:00
Robert Clausecker
a8b8b7065c 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

(cherry picked from commit d518f64cef6db1d301377e78742b94ca96a881e3)
2025-10-31 14:03:13 +01:00
Konstantin Belousov
e54e24bcc7 include/stdckdint.h: make the header compatible with C++
PR:	290299

(cherry picked from commit 3c052bec12fcf09f81ba0760ebecec38e196d332)
2025-10-24 10:47:12 +03:00
Dag-Erling Smørgrav
b28b044287 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

(cherry picked from commit 155290b23f0b503b9db675d6a45f85b189ee1926)
2025-10-02 08:19:23 +00:00
Lexi Winter
9655d4f5e1 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

(cherry picked from commit a053f948ade60e8a63ebdaa676bf95c5ce38af07)
2025-10-01 11:36:37 +01: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
Stephen Hurd
9d0eea9422 Make newly POSIX functions visible
Some of the POSIX 202405L functions are already in the system, make
them visible when appropriate.

Reviewed by:	imp
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D47859
2025-03-19 19:45:06 -04:00
Gleb Smirnoff
c62ae124cc rpc: limited multithread support for svc_nl
The rpc(3) itself was not designed with multithreading in mind, but we can
actually achieve some parallelism without modifying the library and the
framework.  This transport will allow to process RPCs in threads, with
some hacks on the application side (documented in code).  We make
reentrable only one method - SVC_REPLY().  Reading and parsing of incoming
calls is still done synchronously.  But the actual processing of the calls
can be offloaded to a thread, and once finished the thread can safely
execute svc_sendreply() and the reply would be sent with the correct xid.

Differential Revision:	https://reviews.freebsd.org/D48569
2025-02-01 01:00:28 -08:00