Skip to content

Commit

Permalink
P3370R1 Add new library headers from C23
Browse files Browse the repository at this point in the history
  • Loading branch information
jensmaurer committed Nov 28, 2024
1 parent d017ce4 commit 2d0b3e1
Show file tree
Hide file tree
Showing 4 changed files with 187 additions and 3 deletions.
11 changes: 9 additions & 2 deletions source/lib-intro.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1455,12 +1455,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 @@ -16034,3 +16034,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}
6 changes: 5 additions & 1 deletion source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6217,7 +6217,9 @@
\libheader{stdalign.h} \\
\libheaderdef{stdarg.h} \\
\libheader{stdatomic.h} \\
\libheader{stdbit.h} \\
\libheader{stdbool.h} \\
\libheader{stdckdint.h} \\
\libheaderdef{stddef.h} \\
\columnbreak
\libheaderdef{stdint.h} \\
Expand Down Expand Up @@ -6330,7 +6332,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
\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 @@ -15474,3 +15474,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}

\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}

0 comments on commit 2d0b3e1

Please sign in to comment.