Skip to content

Commit 2d0b3e1

Browse files
committed
P3370R1 Add new library headers from C23
1 parent d017ce4 commit 2d0b3e1

File tree

4 files changed

+187
-3
lines changed

4 files changed

+187
-3
lines changed

source/lib-intro.tex

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1455,12 +1455,19 @@
14551455
\pnum
14561456
The named module \tcode{std.compat} exports the same declarations as
14571457
the named module \tcode{std}, and
1458-
additionally exports declarations in the global namespace
1458+
additionally exports
1459+
\begin{itemize}
1460+
\item
1461+
declarations in the global namespace
14591462
corresponding to the declarations in namespace \tcode{std}
14601463
that are provided by
14611464
the \Cpp{} headers for C library facilities~(\tref{headers.cpp.c}),
14621465
except the explicitly excluded declarations
1463-
described in \ref{support.c.headers.other}.
1466+
described in \ref{support.c.headers.other} and
1467+
\item
1468+
declarations provided by
1469+
the headers \libheaderref{stdbit.h} and \libheaderref{stdckdint.h}.
1470+
\end{itemize}
14641471

14651472
\pnum
14661473
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
@@ -16034,3 +16034,48 @@
1603416034
A, t, d, B, divides<void>{});
1603516035
\end{codeblock}
1603616036
\end{itemdescr}
16037+
16038+
\rSec1[numerics.c]{C compatibility}
16039+
16040+
\rSec2[stdckdint.h.syn]{Header \tcode{<stdckdint.h>} synopsis}
16041+
16042+
\begin{codeblock}
16043+
#define @\libglobal{__STDC_VERSION_STDCKDINT_H__}@ 202311L
16044+
16045+
template<class type1, class type2, class type3>
16046+
bool ckd_add(type1* result, type2 a, type3 b);
16047+
template<class type1, class type2, class type3>
16048+
bool ckd_sub(type1* result, type2 a, type3 b);
16049+
template<class type1, class type2, class type3>
16050+
bool ckd_mul(type1* result, type2 a, type3 b);
16051+
\end{codeblock}
16052+
16053+
\pnum
16054+
\xref{\IsoCUndated{}:2024, 7.20} %% TODO: change to \xrefc{7.20}
16055+
16056+
\rSec2[numerics.c.ckdint]{Checked integer operations}
16057+
16058+
\indexlibraryglobal{ckd_add}%
16059+
\indexlibraryglobal{ckd_sub}%
16060+
\indexlibraryglobal{ckd_mul}%
16061+
\begin{itemdecl}
16062+
template<class type1, class type2, class type3>
16063+
bool ckd_add(type1* result, type2 a, type3 b);
16064+
template<class type1, class type2, class type3>
16065+
bool ckd_sub(type1* result, type2 a, type3 b);
16066+
template<class type1, class type2, class type3>
16067+
bool ckd_mul(type1* result, type2 a, type3 b);
16068+
\end{itemdecl}
16069+
16070+
\begin{itemdescr}
16071+
\pnum
16072+
\mandates
16073+
Each of the types \tcode{type1}, \tcode{type2}, and \tcode{type3} is a
16074+
cv-unqualified signed or unsigned integer type.
16075+
16076+
\pnum
16077+
\remarks
16078+
Each function template has the same semantics as
16079+
the corresponding type-generic macro with the same name
16080+
specified in \IsoCUndated{}:2024, 7.20.
16081+
\end{itemdescr}

source/support.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6217,7 +6217,9 @@
62176217
\libheader{stdalign.h} \\
62186218
\libheaderdef{stdarg.h} \\
62196219
\libheader{stdatomic.h} \\
6220+
\libheader{stdbit.h} \\
62206221
\libheader{stdbool.h} \\
6222+
\libheader{stdckdint.h} \\
62216223
\libheaderdef{stddef.h} \\
62226224
\columnbreak
62236225
\libheaderdef{stdint.h} \\
@@ -6330,7 +6332,9 @@
63306332
\libheaderref{iso646.h},
63316333
\libheaderref{stdalign.h},\newline
63326334
\libheaderref{stdatomic.h},
6333-
\libheaderref{stdbool.h}, and
6335+
\libheaderref{stdbit.h}
6336+
\libheaderref{stdbool.h},
6337+
\libheaderref{stdckdint.h}, and
63346338
\libheaderref{tgmath.h},
63356339
each of
63366340
which has a name of the form

source/utilities.tex

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

0 commit comments

Comments
 (0)