mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] [C23 const 0/2] some interfaces become type-generic
@ 2023-05-25 14:44 Jens Gustedt
  2023-05-25 14:44 ` [musl] [C23 const 1/2] C23: change bsearch to a macro that respects the const contract Jens Gustedt
  2023-05-25 14:45 ` [musl] [C23 const 2/2] C23: change string.h and wchar.h interfaces to macros " Jens Gustedt
  0 siblings, 2 replies; 9+ messages in thread
From: Jens Gustedt @ 2023-05-25 14:44 UTC (permalink / raw)
  To: musl

In C23, some interfaces become type-generic with the aim that they
respect the const-contract for their pointer parameters.

With the functions alone, non-qualified pointers of buffers that are
`const`-qualified can escape. The type-generic functions/macros at an
additional security here, that compilers may then check.

This code needs `_Generic`, so it only works for compilers with at
least C11. Other compilers should still see the function interfaces as
before.

Jens Gustedt (2):
  C23: change bsearch to a macro that respects the const contract
  C23: change string.h and wchar.h interfaces to macros that respects
    the const contract

 include/stdlib.h     | 12 +++++++++-
 include/string.h     | 54 ++++++++++++++++++++++++++++++++++++++-----
 include/wchar.h      | 55 +++++++++++++++++++++++++++++++++++++++-----
 src/include/stdlib.h |  2 ++
 src/include/string.h |  6 +++++
 src/include/wchar.h  |  6 +++++
 src/stdlib/bsearch.c |  2 +-
 src/string/memchr.c  |  2 +-
 src/string/strchr.c  |  2 +-
 src/string/strpbrk.c |  2 +-
 src/string/strrchr.c |  2 +-
 src/string/strstr.c  |  2 +-
 src/string/wcschr.c  |  2 +-
 src/string/wcspbrk.c |  2 +-
 src/string/wcsrchr.c |  2 +-
 src/string/wcsstr.c  |  2 +-
 src/string/wmemchr.c |  2 +-
 17 files changed, 133 insertions(+), 24 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 9+ messages in thread
[parent not found: <cover.1685541439.git.Jens.Gustedt@inria.fr>]

end of thread, other threads:[~2023-05-31 14:01 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-25 14:44 [musl] [C23 const 0/2] some interfaces become type-generic Jens Gustedt
2023-05-25 14:44 ` [musl] [C23 const 1/2] C23: change bsearch to a macro that respects the const contract Jens Gustedt
2023-05-26 11:29   ` Nat!
2023-05-26 17:20     ` NRK
2023-05-26 19:29       ` Jₑₙₛ Gustedt
2023-05-26 20:09         ` Rich Felker
2023-05-27  7:51           ` Jₑₙₛ Gustedt
2023-05-25 14:45 ` [musl] [C23 const 2/2] C23: change string.h and wchar.h interfaces to macros " Jens Gustedt
     [not found] <cover.1685541439.git.Jens.Gustedt@inria.fr>
2023-05-31 14:00 ` Jens Gustedt

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).