Files
freebsd/lib
Faraz Vahedi d08296c7ab libc: Implement qualifier-preserving standard library functions
Several standard library functions are specified to return an unqualified
pointer while accepting a pointer to a potentially const-qualified object.
N3020 addresses this behaviour, discarding qualifiers due to incompatible
pointer types, by introducing qualifier-preserving macros for the affected
set of standard library functions.

Add `__qualsel()` helper to `<sys/cdefs.h>`, implemented using the generic
selection, and define qualifier-preserving macros for that set of functions
in `<string.h>`, `<wchar.h>`, and `<stdlib.h>`.

Macros are gated on `_STDC_VERSION__ >= 202311L && !__cplusplus`, therefore
there is no behavioural change for earlier C modes or C++ translation units.
The kernel is likewise unaffected, as it does not include userland headers.

As function-like macros, they are transparent except at a call site where
the address-of operator is applied, the macro is suppressed via `#undef`,
or the identifier appears in parenthesised form; all of which cause the
underlying function designator to be used instead.

Reviewed by:	fuz
Approved by:	fuz (mentor)
MFC after:	1 month
Pull Request:	https://github.com/freebsd/freebsd-src/pull/2288
2026-08-13 20:08:49 +03:30
..
2026-01-13 10:19:04 -05:00
2024-10-14 10:26:17 -07:00
2025-01-01 15:11:06 -06:00
2026-01-03 21:37:18 +01:00
2024-10-14 10:26:17 -07:00
2026-01-06 12:56:50 -05:00
2026-03-31 18:45:14 -07:00
2026-06-02 21:54:25 -07:00
2025-10-03 19:46:55 +02:00
2026-03-15 00:41:29 -03:00
2025-11-24 10:47:10 -05:00
2025-08-08 13:27:26 -05:00
2024-10-08 16:13:39 -03:00
2024-10-14 10:26:17 -07:00
2024-11-12 12:11:51 -05:00
2026-08-04 18:27:21 +00:00
2025-09-30 09:14:05 +01:00
2026-01-06 04:26:53 +00:00
2026-03-13 23:49:53 +00:00
2026-04-08 14:22:45 -07:00
2026-08-02 13:17:45 +02:00
2026-01-15 07:28:28 +01:00
2025-12-03 14:21:07 +00:00
2026-07-07 08:47:36 +02:00