Skip to content
Merged
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
116 changes: 34 additions & 82 deletions source/support.tex
Original file line number Diff line number Diff line change
Expand Up @@ -102,67 +102,19 @@
\rSec2[cstdlib.syn]{Header \tcode{<cstdlib>} synopsis}

\indexheader{cstdlib}%
\indexlibraryglobal{EXIT_FAILURE}%
\indexlibraryglobal{EXIT_SUCCESS}%
\indexlibraryglobal{MB_CUR_MAX}%
\indexlibraryglobal{NULL}%
\indexlibraryglobal{RAND_MAX}%
\indexlibraryglobal{_Exit}%
\indexlibraryglobal{abort}%
\indexlibraryglobal{abs}%
\indexlibraryglobal{aligned_alloc}%
\indexlibraryglobal{at_quick_exit}%
\indexlibraryglobal{atexit}%
\indexlibraryglobal{atof}%
\indexlibraryglobal{atoi}%
\indexlibraryglobal{atol}%
\indexlibraryglobal{atoll}%
\indexlibraryglobal{bsearch}%
\indexlibraryglobal{calloc}%
\indexlibraryglobal{div}%
\indexlibraryglobal{div_t}%
\indexlibraryglobal{exit}%
\indexlibraryglobal{free}%
\indexlibraryglobal{getenv}%
\indexlibraryglobal{labs}%
\indexlibraryglobal{ldiv}%
\indexlibraryglobal{ldiv_t}%
\indexlibraryglobal{llabs}%
\indexlibraryglobal{lldiv}%
\indexlibraryglobal{lldiv_t}%
\indexlibraryglobal{malloc}%
\indexlibraryglobal{mblen}%
\indexlibraryglobal{mbstowcs}%
\indexlibraryglobal{mbtowc}%
\indexlibraryglobal{qsort}%
\indexlibraryglobal{quick_exit}%

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We removed this here, but didn't add \libglobal below, it seems.

@eisenwave eisenwave Sep 4, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is intentional for all of the comments that you've left. All of the functions that have not received \libglobal formatting are defined in some other place, such as https://eel.is/c++draft/c.mb.wcs#lib:mbstowcs

We don't usually add an index entry for forward declarations, and https://eel.is/c++draft/cstdlib.syn#1 explicitly exempts the functions defined in those other subclauses from receiving the "this does the same thing as in C" treatment.

I think indexing mbstowcs in this place would be outright misleading because it would incorrectly imply that the function is defined in [cstdlib.syn] with "this does the C thing" treatment.

\indexlibraryglobal{rand}%
\indexlibraryglobal{realloc}%
\indexlibraryglobal{size_t}%
\indexlibraryglobal{srand}%
\indexlibraryglobal{strtod}%
\indexlibraryglobal{strtof}%
\indexlibraryglobal{strtol}%
\indexlibraryglobal{strtold}%
\indexlibraryglobal{strtoll}%
\indexlibraryglobal{strtoul}%
\indexlibraryglobal{strtoull}%
\indexlibraryglobal{system}%
\indexlibraryglobal{wcstombs}%
\indexlibraryglobal{wctomb}%
\begin{codeblock}
namespace std {
using size_t = @\seebelow@; // freestanding
using div_t = @\seebelow@; // freestanding
using ldiv_t = @\seebelow@; // freestanding
using lldiv_t = @\seebelow@; // freestanding
using @\libglobal{size_t}@ = @\seebelow@; // freestanding
using @\libglobal{div_t}@ = @\seebelow@; // freestanding
using @\libglobal{ldiv_t}@ = @\seebelow@; // freestanding
using @\libglobal{lldiv_t}@ = @\seebelow@; // freestanding
}

#define NULL @\seebelow@ // freestanding
#define EXIT_FAILURE @\seebelow@ // freestanding
#define EXIT_SUCCESS @\seebelow@ // freestanding
#define RAND_MAX @\seebelow@
#define MB_CUR_MAX @\seebelow@
#define @\libmacro{NULL}@ @\seebelow@ // freestanding
#define @\libmacro{EXIT_FAILURE}@ @\seebelow@ // freestanding
#define @\libmacro{EXIT_SUCCESS}@ @\seebelow@ // freestanding
#define @\libmacro{RAND_MAX}@ @\seebelow@
#define @\libmacro{MB_CUR_MAX}@ @\seebelow@

namespace std {
// Exposition-only function type aliases
Expand All @@ -181,33 +133,33 @@
[[noreturn]] void _Exit(int status) noexcept; // freestanding
[[noreturn]] void quick_exit(int status) noexcept; // freestanding

char* getenv(const char* name);
int system(const char* string);
char* @\libglobal{getenv}@(const char* name);
int @\libglobal{system}@(const char* string);

// \ref{c.malloc}, C library memory allocation
void* aligned_alloc(size_t alignment, size_t size);
void* calloc(size_t nmemb, size_t size);
Comment on lines 140 to 141

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about these? No index entries?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

void free(void* ptr);
void free_sized(void* ptr, size_t size);
void free_aligned_sized(void* ptr, size_t alignment, size_t size);
void @\libglobal{free_sized}@(void* ptr, size_t size);
void @\libglobal{free_aligned_sized}@(void* ptr, size_t alignment, size_t size);
void* malloc(size_t size);
void* realloc(void* ptr, size_t size);
Comment on lines 145 to 146

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here? No index entries?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t memalignment(const void* p); // freestanding

double atof(const char* nptr);
int atoi(const char* nptr);
long int atol(const char* nptr);
long long int atoll(const char* nptr);
double strtod(const char* nptr, char** endptr);
int strfromd(char* s, size_t n, const char* format, double fp);
int strfromf(char* s, size_t n, const char* format, float fp);
int strfroml(char* s, size_t n, const char* format, long double fp);
float strtof(const char* nptr, char** endptr);
long double strtold(const char* nptr, char** endptr);
long int strtol(const char* nptr, char** endptr, int base);
long long int strtoll(const char* nptr, char** endptr, int base);
unsigned long int strtoul(const char* nptr, char** endptr, int base);
unsigned long long int strtoull(const char* nptr, char** endptr, int base);
size_t @\libglobal{memalignment}@(const void* p); // freestanding

double @\libglobal{atof}@(const char* nptr);
int @\libglobal{atoi}@(const char* nptr);
long int @\libglobal{atol}@(const char* nptr);
long long int @\libglobal{atoll}@(const char* nptr);
double @\libglobal{strtod}@(const char* nptr, char** endptr);
int @\libglobal{strfromd}@(char* s, size_t n, const char* format, double fp);
int @\libglobal{strfromf}@(char* s, size_t n, const char* format, float fp);
int @\libglobal{strfroml}@(char* s, size_t n, const char* format, long double fp);
float @\libglobal{strtof}@(const char* nptr, char** endptr);
long double @\libglobal{strtold}@(const char* nptr, char** endptr);
long int @\libglobal{strtol}@(const char* nptr, char** endptr, int base);
long long int @\libglobal{strtoll}@(const char* nptr, char** endptr, int base);
unsigned long int @\libglobal{strtoul}@(const char* nptr, char** endptr, int base);
unsigned long long int @\libglobal{strtoull}@(const char* nptr, char** endptr, int base);

// \ref{c.mb.wcs}, multibyte / wide string and character conversion functions
int mblen(const char* s, size_t n);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of these: no index entries?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expand Down Expand Up @@ -238,14 +190,14 @@
constexpr long long int abs(long long int j); // freestanding
constexpr @\placeholder{floating-point-type}@ abs(@\placeholder{floating-point-type}@ j); // freestanding-deleted

constexpr long int labs(long int j); // freestanding
constexpr long long int llabs(long long int j); // freestanding
constexpr long int @\libglobal{labs}@(long int j); // freestanding
constexpr long long int @\libglobal{llabs}@(long long int j); // freestanding

constexpr div_t div(int numer, int denom); // freestanding
constexpr div_t @\libglobal{div}@(int numer, int denom); // freestanding
constexpr ldiv_t div(long int numer, long int denom); // freestanding; see \ref{library.c}
constexpr lldiv_t div(long long int numer, long long int denom); // freestanding; see \ref{library.c}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we normally put libglobal on every member of an overload set. I think that would generate multiple quasi-identical index entries.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Index entries pointing to the same page are automatically merged by the indexing machinery.

constexpr ldiv_t ldiv(long int numer, long int denom); // freestanding
constexpr lldiv_t lldiv(long long int numer, long long int denom); // freestanding
constexpr ldiv_t @\libglobal{ldiv}@(long int numer, long int denom); // freestanding
constexpr lldiv_t @\libglobal{lldiv}@(long long int numer, long long int denom); // freestanding
}
\end{codeblock}

Expand Down
Loading