Skip to content

Commit 8e2cc1d

Browse files
jensmaurertkoeppe
authored andcommitted
P3370R1 Add new library headers from C23
1 parent e887fd8 commit 8e2cc1d

File tree

4 files changed

+189
-5
lines changed

4 files changed

+189
-5
lines changed

source/lib-intro.tex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,12 +1486,19 @@
14861486
\pnum
14871487
The named module \tcode{std.compat} exports the same declarations as
14881488
the named module \tcode{std}, and
1489-
additionally exports declarations in the global namespace
1489+
additionally exports
1490+
\begin{itemize}
1491+
\item
1492+
declarations in the global namespace
14901493
corresponding to the declarations in namespace \tcode{std}
14911494
that are provided by
14921495
the \Cpp{} headers for C library facilities~(\tref{headers.cpp.c}),
14931496
except the explicitly excluded declarations
1494-
described in \ref{support.c.headers.other}.
1497+
described in \ref{support.c.headers.other} and
1498+
\item
1499+
declarations provided by
1500+
the headers \libheaderref{stdbit.h} and \libheaderref{stdckdint.h}.
1501+
\end{itemize}
14951502

14961503
\pnum
14971504
It is unspecified to which module a declaration in the standard library

source/numerics.tex

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16076,3 +16076,48 @@
1607616076
A, t, d, B, divides<void>{});
1607716077
\end{codeblock}
1607816078
\end{itemdescr}
16079+
16080+
\rSec1[numerics.c]{C compatibility}
16081+
16082+
\rSec2[stdckdint.h.syn]{Header \tcode{<stdckdint.h>} synopsis}
16083+
16084+
\begin{codeblock}
16085+
#define @\libglobal{__STDC_VERSION_STDCKDINT_H__}@ 202311L
16086+
16087+
template<class type1, class type2, class type3>
16088+
bool ckd_add(type1* result, type2 a, type3 b);
16089+
template<class type1, class type2, class type3>
16090+
bool ckd_sub(type1* result, type2 a, type3 b);
16091+
template<class type1, class type2, class type3>
16092+
bool ckd_mul(type1* result, type2 a, type3 b);
16093+
\end{codeblock}
16094+
16095+
\pnum
16096+
\xref{\IsoCUndated{}:2024, 7.20} %% TODO: change to \xrefc{7.20}
16097+
16098+
\rSec2[numerics.c.ckdint]{Checked integer operations}
16099+
16100+
\indexlibraryglobal{ckd_add}%
16101+
\indexlibraryglobal{ckd_sub}%
16102+
\indexlibraryglobal{ckd_mul}%
16103+
\begin{itemdecl}
16104+
template<class type1, class type2, class type3>
16105+
bool ckd_add(type1* result, type2 a, type3 b);
16106+
template<class type1, class type2, class type3>
16107+
bool ckd_sub(type1* result, type2 a, type3 b);
16108+
template<class type1, class type2, class type3>
16109+
bool ckd_mul(type1* result, type2 a, type3 b);
16110+
\end{itemdecl}
16111+
16112+
\begin{itemdescr}
16113+
\pnum
16114+
\mandates
16115+
Each of the types \tcode{type1}, \tcode{type2}, and \tcode{type3} is a
16116+
cv-unqualified signed or unsigned integer type.
16117+
16118+
\pnum
16119+
\remarks
16120+
Each function template has the same semantics as
16121+
the corresponding type-generic macro with the same name
16122+
specified in \IsoCUndated{}:2024, 7.20.
16123+
\end{itemdescr}

source/support.tex

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6228,16 +6228,18 @@
62286228
\libheader{stdalign.h} \\
62296229
\libheaderdef{stdarg.h} \\
62306230
\libheader{stdatomic.h} \\
6231+
\libheader{stdbit.h} \\
62316232
\libheader{stdbool.h} \\
6232-
\libheaderdef{stddef.h} \\
62336233
\columnbreak
6234+
\libheader{stdckdint.h} \\
6235+
\libheaderdef{stddef.h} \\
62346236
\libheaderdef{stdint.h} \\
62356237
\libheaderdef{stdio.h} \\
62366238
\libheaderdef{stdlib.h} \\
62376239
\libheaderdef{string.h} \\
6240+
\columnbreak
62386241
\libheader{tgmath.h} \\
62396242
\libheaderdef{time.h} \\
6240-
\columnbreak
62416243
\libheaderdef{uchar.h} \\
62426244
\libheaderdef{wchar.h} \\
62436245
\libheaderdef{wctype.h} \\
@@ -6341,7 +6343,9 @@
63416343
\libheaderref{iso646.h},
63426344
\libheaderref{stdalign.h},\newline
63436345
\libheaderref{stdatomic.h},
6344-
\libheaderref{stdbool.h}, and
6346+
\libheaderref{stdbit.h},
6347+
\libheaderref{stdbool.h},
6348+
\libheaderref{stdckdint.h}, and\newline
63456349
\libheaderref{tgmath.h},
63466350
each of
63476351
which has a name of the form

source/utilities.tex

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15480,3 +15480,131 @@
1548015480
Otherwise, \tcode{endian::native} is not equal
1548115481
to either \tcode{endian::big} or \tcode{endian::little}.
1548215482
\end{itemdescr}
15483+
15484+
\rSec1[stdbit.h.syn]{Header \tcode{<stdbit.h>} synopsis}
15485+
15486+
\begin{codeblock}
15487+
#define @\libglobal{__STDC_VERSION_STDBIT_H__}@ 202311L
15488+
15489+
#define @\libglobal{__STDC_ENDIAN_BIG__}@ @\seebelow@
15490+
#define @\libglobal{__STDC_ENDIAN_LITTLE__}@ @\seebelow@
15491+
#define @\libglobal{__STDC_ENDIAN_NATIVE__}@ @\seebelow@
15492+
15493+
unsigned int @\libglobal{stdc_leading_zeros_uc}@(unsigned char value);
15494+
unsigned int @\libglobal{stdc_leading_zeros_us}@(unsigned short value);
15495+
unsigned int @\libglobal{stdc_leading_zeros_ui}@(unsigned int value);
15496+
unsigned int @\libglobal{stdc_leading_zeros_ul}@(unsigned long int value);
15497+
unsigned int @\libglobal{stdc_leading_zeros_ull}@(unsigned long long int value);
15498+
template<class T> @\seebelow@ @\libglobal{stdc_leading_zeros}@(T value);
15499+
15500+
unsigned int @\libglobal{stdc_leading_ones_uc}@(unsigned char value);
15501+
unsigned int @\libglobal{stdc_leading_ones_us}@(unsigned short value);
15502+
unsigned int @\libglobal{stdc_leading_ones_ui}@(unsigned int value);
15503+
unsigned int @\libglobal{stdc_leading_ones_ul}@(unsigned long int value);
15504+
unsigned int @\libglobal{stdc_leading_ones_ull}@(unsigned long long int value);
15505+
template<class T> @\seebelow@ @\libglobal{stdc_leading_ones}@(T value);
15506+
15507+
unsigned int @\libglobal{stdc_trailing_zeros_uc}@(unsigned char value);
15508+
unsigned int @\libglobal{stdc_trailing_zeros_us}@(unsigned short value);
15509+
unsigned int @\libglobal{stdc_trailing_zeros_ui}@(unsigned int value);
15510+
unsigned int @\libglobal{stdc_trailing_zeros_ul}@(unsigned long int value);
15511+
unsigned int @\libglobal{stdc_trailing_zeros_ull}@(unsigned long long int value);
15512+
template<class T> @\seebelow@ @\libglobal{stdc_trailing_zeros}@(T value);
15513+
15514+
unsigned int @\libglobal{stdc_trailing_ones_uc}@(unsigned char value);
15515+
unsigned int @\libglobal{stdc_trailing_ones_us}@(unsigned short value);
15516+
unsigned int @\libglobal{stdc_trailing_ones_ui}@(unsigned int value);
15517+
unsigned int @\libglobal{stdc_trailing_ones_ul}@(unsigned long int value);
15518+
unsigned int @\libglobal{stdc_trailing_ones_ull}@(unsigned long long int value);
15519+
template<class T> @\seebelow@ @\libglobal{stdc_trailing_ones}@(T value);
15520+
15521+
unsigned int @\libglobal{stdc_first_leading_zero_uc}@(unsigned char value);
15522+
unsigned int @\libglobal{stdc_first_leading_zero_us}@(unsigned short value);
15523+
unsigned int @\libglobal{stdc_first_leading_zero_ui}@(unsigned int value);
15524+
unsigned int @\libglobal{stdc_first_leading_zero_ul}@(unsigned long int value);
15525+
unsigned int @\libglobal{stdc_first_leading_zero_ull}@(unsigned long long int value);
15526+
template<class T> @\seebelow@ @\libglobal{stdc_first_leading_zero}@(T value);
15527+
15528+
unsigned int @\libglobal{stdc_first_leading_one_uc}@(unsigned char value);
15529+
unsigned int @\libglobal{stdc_first_leading_one_us}@(unsigned short value);
15530+
unsigned int @\libglobal{stdc_first_leading_one_ui}@(unsigned int value);
15531+
unsigned int @\libglobal{stdc_first_leading_one_ul}@(unsigned long int value);
15532+
unsigned int @\libglobal{stdc_first_leading_one_ull}@(unsigned long long int value);
15533+
template<class T> @\seebelow@ stdc_first_leading_one(T value);
15534+
15535+
unsigned int @\libglobal{stdc_first_trailing_zero_uc}@(unsigned char value);
15536+
unsigned int @\libglobal{stdc_first_trailing_zero_us}@(unsigned short value);
15537+
unsigned int @\libglobal{stdc_first_trailing_zero_ui}@(unsigned int value);
15538+
unsigned int @\libglobal{stdc_first_trailing_zero_ul}@(unsigned long int value);
15539+
unsigned int @\libglobal{stdc_first_trailing_zero_ull}@(unsigned long long int value);
15540+
template<class T> @\seebelow@ stdc_first_trailing_zero(T value);
15541+
15542+
unsigned int @\libglobal{stdc_first_trailing_one_uc}@(unsigned char value);
15543+
unsigned int @\libglobal{stdc_first_trailing_one_us}@(unsigned short value);
15544+
unsigned int @\libglobal{stdc_first_trailing_one_ui}@(unsigned int value);
15545+
unsigned int @\libglobal{stdc_first_trailing_one_ul}@(unsigned long int value);
15546+
unsigned int @\libglobal{stdc_first_trailing_one_ull}@(unsigned long long int value);
15547+
template<class T> @\seebelow@ stdc_first_trailing_one(T value);
15548+
15549+
unsigned int @\libglobal{stdc_count_zeros_uc}@(unsigned char value);
15550+
unsigned int @\libglobal{stdc_count_zeros_us}@(unsigned short value);
15551+
unsigned int @\libglobal{stdc_count_zeros_ui}@(unsigned int value);
15552+
unsigned int @\libglobal{stdc_count_zeros_ul}@(unsigned long int value);
15553+
unsigned int @\libglobal{stdc_count_zeros_ull}@(unsigned long long int value);
15554+
template<class T> @\seebelow@ @\libglobal{stdc_count_zeros}@(T value);
15555+
15556+
unsigned int @\libglobal{stdc_count_ones_uc}@(unsigned char value);
15557+
unsigned int @\libglobal{stdc_count_ones_us}@(unsigned short value);
15558+
unsigned int @\libglobal{stdc_count_ones_ui}@(unsigned int value);
15559+
unsigned int @\libglobal{stdc_count_ones_ul}@(unsigned long int value);
15560+
unsigned int @\libglobal{stdc_count_ones_ull}@(unsigned long long int value);
15561+
template<class T> @\seebelow@ stdc_count_ones(T value);
15562+
15563+
bool @\libglobal{stdc_has_single_bit_uc}@(unsigned char value);
15564+
bool @\libglobal{stdc_has_single_bit_us}@(unsigned short value);
15565+
bool @\libglobal{stdc_has_single_bit_ui}@(unsigned int value);
15566+
bool @\libglobal{stdc_has_single_bit_ul}@(unsigned long int value);
15567+
bool @\libglobal{stdc_has_single_bit_ull}@(unsigned long long int value);
15568+
template<class T> bool @\libglobal{stdc_has_single_bit}@(T value);
15569+
15570+
unsigned int @\libglobal{stdc_bit_width_uc}@(unsigned char value);
15571+
unsigned int @\libglobal{stdc_bit_width_us}@(unsigned short value);
15572+
unsigned int @\libglobal{stdc_bit_width_ui}@(unsigned int value);
15573+
unsigned int @\libglobal{stdc_bit_width_ul}@(unsigned long int value);
15574+
unsigned int @\libglobal{stdc_bit_width_ull}@(unsigned long long int value);
15575+
template<class T> @\seebelow@ @\libglobal{stdc_bit_width}@(T value);
15576+
15577+
unsigned char @\libglobal{stdc_bit_floor_uc}@(unsigned char value);
15578+
unsigned short @\libglobal{stdc_bit_floor_us}@(unsigned short value);
15579+
unsigned int @\libglobal{stdc_bit_floor_ui}@(unsigned int value);
15580+
unsigned long int @\libglobal{stdc_bit_floor_ul}@(unsigned long int value);
15581+
unsigned long long int @\libglobal{stdc_bit_floor_ull}@(unsigned long long int value);
15582+
template<class T> T @\libglobal{stdc_bit_floor}@(T value);
15583+
15584+
unsigned char @\libglobal{stdc_bit_ceil_uc}@(unsigned char value);
15585+
unsigned short @\libglobal{stdc_bit_ceil_us}@(unsigned short value);
15586+
unsigned int @\libglobal{stdc_bit_ceil_ui}@(unsigned int value);
15587+
unsigned long int @\libglobal{stdc_bit_ceil_ul}@(unsigned long int value);
15588+
unsigned long long int @\libglobal{stdc_bit_ceil_ull}@(unsigned long long int value);
15589+
template<class T> T @\libglobal{stdc_bit_ceil}@(T value);
15590+
\end{codeblock}
15591+
15592+
\pnum
15593+
For a function template whose return type is not specified above,
15594+
the return type is
15595+
an \impldef{return types for \tcode{<stdbit.h>} functions} unsigned integer type
15596+
large enough to represent all possible result values.
15597+
Each function template has the same semantics
15598+
as the corresponding type-generic function with the same name
15599+
specified in \IsoCUndated{}:2024, 7.18. %% change to \xrefc{7.18}
15600+
15601+
\pnum
15602+
\mandates
15603+
\tcode{T} is an unsigned integer type.
15604+
15605+
\pnum
15606+
Otherwise,
15607+
the contents and meaning of the header \libheader{stdbit.h} are the same as
15608+
the C standard library header \tcode{<stdbit.h>}.
15609+
15610+
\xref{\IsoCUndated{}:2024, 7.18} %% TODO: change to \xrefc{7.18}

0 commit comments

Comments
 (0)