Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

P3370R1 Add new library headers from C23 #7461

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions source/lib-intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1486,12 +1486,19 @@
\pnum
The named module \tcode{std.compat} exports the same declarations as
the named module \tcode{std}, and
additionally exports declarations in the global namespace
additionally exports
\begin{itemize}
\item
declarations in the global namespace
corresponding to the declarations in namespace \tcode{std}
that are provided by
the \Cpp{} headers for C library facilities~(\tref{headers.cpp.c}),
except the explicitly excluded declarations
described in \ref{support.c.headers.other}.
described in \ref{support.c.headers.other} and
\item
declarations provided by
the headers \libheaderref{stdbit.h} and \libheaderref{stdckdint.h}.
\end{itemize}

\pnum
It is unspecified to which module a declaration in the standard library
Expand Down
45 changes: 45 additions & 0 deletions source/numerics.tex
Original file line number Diff line number Diff line change
Expand Up @@ -16076,3 +16076,48 @@
A, t, d, B, divides<void>{});
\end{codeblock}
\end{itemdescr}

\rSec1[numerics.c]{C compatibility}

\rSec2[stdckdint.h.syn]{Header \tcode{<stdckdint.h>} synopsis}

\begin{codeblock}
#define @\libglobal{__STDC_VERSION_STDCKDINT_H__}@ 202311L

template<class type1, class type2, class type3>
bool ckd_add(type1* result, type2 a, type3 b);
template<class type1, class type2, class type3>
bool ckd_sub(type1* result, type2 a, type3 b);
template<class type1, class type2, class type3>
bool ckd_mul(type1* result, type2 a, type3 b);
\end{codeblock}

\pnum
\xref{\IsoCUndated{}:2024, 7.20} %% TODO: change to \xrefc{7.20}

\rSec2[numerics.c.ckdint]{Checked integer operations}

\indexlibraryglobal{ckd_add}%
\indexlibraryglobal{ckd_sub}%
\indexlibraryglobal{ckd_mul}%
\begin{itemdecl}
template<class type1, class type2, class type3>
bool ckd_add(type1* result, type2 a, type3 b);
template<class type1, class type2, class type3>
bool ckd_sub(type1* result, type2 a, type3 b);
template<class type1, class type2, class type3>
bool ckd_mul(type1* result, type2 a, type3 b);
\end{itemdecl}

\begin{itemdescr}
\pnum
\mandates
Each of the types \tcode{type1}, \tcode{type2}, and \tcode{type3} is a
cv-unqualified signed or unsigned integer type.

\pnum
\remarks
Each function template has the same semantics as
the corresponding type-generic macro with the same name
specified in \IsoCUndated{}:2024, 7.20.
\end{itemdescr}
10 changes: 7 additions & 3 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6228,16 +6228,18 @@
\libheader{stdalign.h} \\
\libheaderdef{stdarg.h} \\
\libheader{stdatomic.h} \\
\libheader{stdbit.h} \\
\libheader{stdbool.h} \\
\libheaderdef{stddef.h} \\
\columnbreak
\libheader{stdckdint.h} \\
\libheaderdef{stddef.h} \\
\libheaderdef{stdint.h} \\
\libheaderdef{stdio.h} \\
\libheaderdef{stdlib.h} \\
\libheaderdef{string.h} \\
\columnbreak
\libheader{tgmath.h} \\
\libheaderdef{time.h} \\
\columnbreak
\libheaderdef{uchar.h} \\
\libheaderdef{wchar.h} \\
\libheaderdef{wctype.h} \\
Expand Down Expand Up @@ -6341,7 +6343,9 @@
\libheaderref{iso646.h},
\libheaderref{stdalign.h},\newline
\libheaderref{stdatomic.h},
\libheaderref{stdbool.h}, and
\libheaderref{stdbit.h},
\libheaderref{stdbool.h},
\libheaderref{stdckdint.h}, and\newline
\libheaderref{tgmath.h},
each of
which has a name of the form
Expand Down
128 changes: 128 additions & 0 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -15480,3 +15480,131 @@
Otherwise, \tcode{endian::native} is not equal
to either \tcode{endian::big} or \tcode{endian::little}.
\end{itemdescr}

\rSec1[stdbit.h.syn]{Header \tcode{<stdbit.h>} synopsis}
tkoeppe marked this conversation as resolved.
Show resolved Hide resolved

\begin{codeblock}
#define @\libglobal{__STDC_VERSION_STDBIT_H__}@ 202311L

#define @\libglobal{__STDC_ENDIAN_BIG__}@ @\seebelow@
#define @\libglobal{__STDC_ENDIAN_LITTLE__}@ @\seebelow@
#define @\libglobal{__STDC_ENDIAN_NATIVE__}@ @\seebelow@

unsigned int @\libglobal{stdc_leading_zeros_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_leading_zeros_us}@(unsigned short value);
unsigned int @\libglobal{stdc_leading_zeros_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_leading_zeros_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_leading_zeros_ull}@(unsigned long long int value);
template<class T> @\seebelow@ @\libglobal{stdc_leading_zeros}@(T value);

unsigned int @\libglobal{stdc_leading_ones_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_leading_ones_us}@(unsigned short value);
unsigned int @\libglobal{stdc_leading_ones_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_leading_ones_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_leading_ones_ull}@(unsigned long long int value);
template<class T> @\seebelow@ @\libglobal{stdc_leading_ones}@(T value);

unsigned int @\libglobal{stdc_trailing_zeros_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_trailing_zeros_us}@(unsigned short value);
unsigned int @\libglobal{stdc_trailing_zeros_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_trailing_zeros_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_trailing_zeros_ull}@(unsigned long long int value);
template<class T> @\seebelow@ @\libglobal{stdc_trailing_zeros}@(T value);

unsigned int @\libglobal{stdc_trailing_ones_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_trailing_ones_us}@(unsigned short value);
unsigned int @\libglobal{stdc_trailing_ones_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_trailing_ones_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_trailing_ones_ull}@(unsigned long long int value);
template<class T> @\seebelow@ @\libglobal{stdc_trailing_ones}@(T value);

unsigned int @\libglobal{stdc_first_leading_zero_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_first_leading_zero_us}@(unsigned short value);
unsigned int @\libglobal{stdc_first_leading_zero_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_first_leading_zero_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_first_leading_zero_ull}@(unsigned long long int value);
template<class T> @\seebelow@ @\libglobal{stdc_first_leading_zero}@(T value);

unsigned int @\libglobal{stdc_first_leading_one_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_first_leading_one_us}@(unsigned short value);
unsigned int @\libglobal{stdc_first_leading_one_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_first_leading_one_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_first_leading_one_ull}@(unsigned long long int value);
template<class T> @\seebelow@ stdc_first_leading_one(T value);

unsigned int @\libglobal{stdc_first_trailing_zero_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_first_trailing_zero_us}@(unsigned short value);
unsigned int @\libglobal{stdc_first_trailing_zero_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_first_trailing_zero_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_first_trailing_zero_ull}@(unsigned long long int value);
template<class T> @\seebelow@ stdc_first_trailing_zero(T value);

unsigned int @\libglobal{stdc_first_trailing_one_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_first_trailing_one_us}@(unsigned short value);
unsigned int @\libglobal{stdc_first_trailing_one_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_first_trailing_one_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_first_trailing_one_ull}@(unsigned long long int value);
template<class T> @\seebelow@ stdc_first_trailing_one(T value);

unsigned int @\libglobal{stdc_count_zeros_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_count_zeros_us}@(unsigned short value);
unsigned int @\libglobal{stdc_count_zeros_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_count_zeros_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_count_zeros_ull}@(unsigned long long int value);
template<class T> @\seebelow@ @\libglobal{stdc_count_zeros}@(T value);

unsigned int @\libglobal{stdc_count_ones_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_count_ones_us}@(unsigned short value);
unsigned int @\libglobal{stdc_count_ones_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_count_ones_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_count_ones_ull}@(unsigned long long int value);
template<class T> @\seebelow@ stdc_count_ones(T value);

bool @\libglobal{stdc_has_single_bit_uc}@(unsigned char value);
bool @\libglobal{stdc_has_single_bit_us}@(unsigned short value);
bool @\libglobal{stdc_has_single_bit_ui}@(unsigned int value);
bool @\libglobal{stdc_has_single_bit_ul}@(unsigned long int value);
bool @\libglobal{stdc_has_single_bit_ull}@(unsigned long long int value);
template<class T> bool @\libglobal{stdc_has_single_bit}@(T value);

unsigned int @\libglobal{stdc_bit_width_uc}@(unsigned char value);
unsigned int @\libglobal{stdc_bit_width_us}@(unsigned short value);
unsigned int @\libglobal{stdc_bit_width_ui}@(unsigned int value);
unsigned int @\libglobal{stdc_bit_width_ul}@(unsigned long int value);
unsigned int @\libglobal{stdc_bit_width_ull}@(unsigned long long int value);
template<class T> @\seebelow@ @\libglobal{stdc_bit_width}@(T value);

unsigned char @\libglobal{stdc_bit_floor_uc}@(unsigned char value);
unsigned short @\libglobal{stdc_bit_floor_us}@(unsigned short value);
unsigned int @\libglobal{stdc_bit_floor_ui}@(unsigned int value);
unsigned long int @\libglobal{stdc_bit_floor_ul}@(unsigned long int value);
unsigned long long int @\libglobal{stdc_bit_floor_ull}@(unsigned long long int value);
template<class T> T @\libglobal{stdc_bit_floor}@(T value);

unsigned char @\libglobal{stdc_bit_ceil_uc}@(unsigned char value);
unsigned short @\libglobal{stdc_bit_ceil_us}@(unsigned short value);
unsigned int @\libglobal{stdc_bit_ceil_ui}@(unsigned int value);
unsigned long int @\libglobal{stdc_bit_ceil_ul}@(unsigned long int value);
unsigned long long int @\libglobal{stdc_bit_ceil_ull}@(unsigned long long int value);
template<class T> T @\libglobal{stdc_bit_ceil}@(T value);
\end{codeblock}

\pnum
For a function template whose return type is not specified above,
the return type is
an \impldef{return types for \tcode{<stdbit.h>} functions} unsigned integer type
large enough to represent all possible result values.
Each function template has the same semantics
as the corresponding type-generic function with the same name
specified in \IsoCUndated{}:2024, 7.18. %% change to \xrefc{7.18}

\pnum
\mandates
\tcode{T} is an unsigned integer type.

\pnum
Otherwise,
the contents and meaning of the header \libheader{stdbit.h} are the same as
the C standard library header \tcode{<stdbit.h>}.

\xref{\IsoCUndated{}:2024, 7.18} %% TODO: change to \xrefc{7.18}
Loading