Files
cppdraft_translate/cppdraft/support/runtime.md
2025-10-25 03:02:53 +03:00

9.3 KiB
Raw Blame History

[support.runtime]

17 Language support library [support]

17.14 Other runtime support [support.runtime]

17.14.1 General [support.runtime.general]

1

#

Headers (nonlocal jumps), (signal handling), (variable arguments), and (runtime environment getenv, system), provide further compatibility with C code.

2

#

Calls to the functiongetenv ([cstdlib.syn]) shall not introduce a data race ([res.on.data.races]) provided that nothing modifies the environment.

[Note 1:

Calls to the POSIX functionssetenv andputenv modify the environment.

— end note]

3

#

A call to the setlocale function may introduce a data race with other calls to the setlocale function or with calls to functions that are affected by the current C locale.

The implementation shall behave as if no library function other than locale::global calls the setlocale function.

17.14.2 Header synopsis [cstdarg.syn]

🔗

// all freestanding#define STDC_VERSION_STDARG_H 202311Lnamespace std {using va_list = see below;}#define va_arg(V, P) see below#define va_copy(VDST, VSRC) see below#define va_end(V) see below#define va_start(V, ...) see below

1

#

The contents of the header are the same as the C standard library header <stdarg.h>, with the following changes:

  • (1.1)

    In lieu of the default argument promotions specified in ISO/IEC 9899:2024 6.5.2.2, the definition in [expr.call] applies.

  • (1.2)

    The preprocessing tokens comprising the second and subsequent arguments to va_start (if any) are discarded. [Note 1: va_start accepts a second argument for compatibility with prior revisions of C++. — end note]

See also: ISO/IEC 9899:2024, 7.16

17.14.3 Header synopsis [csetjmp.syn]

🔗

#define STDC_VERSION_SETJMP_H 202311Lnamespace std {using jmp_buf = see below; noreturn void longjmp(jmp_buf env, int val);}#define setjmp(env) see below

1

#

The contents of the header are the same as the C standard library header <setjmp.h>.

2

#

The function signaturelongjmp(jmp_buf jbuf, int val) has more restricted behavior in this document.

A setjmp/longjmp call pair has undefined behavior if replacing the setjmp and longjmp by catch and throw would invoke any non-trivial destructors for any objects with automatic storage duration.

A call to setjmp or longjmp has undefined behavior if invoked in a suspension context of a coroutine ([expr.await]).

See also: ISO/IEC 9899:2024, 7.13

17.14.4 Header synopsis [csignal.syn]

🔗

namespace std {using sig_atomic_t = see below; // [support.signal], signal handlersextern "C" using signal-handler = void(int); // exposition onlysignal-handler signal(int sig, signal-handler func); int raise(int sig);}#define SIG_DFL see below#define SIG_ERR see below#define SIG_IGN see below#define SIGABRT see below#define SIGFPE see below#define SIGILL see below#define SIGINT see below#define SIGSEGV see below#define SIGTERM see below

1

#

The contents of the header are the same as the C standard library header <signal.h>.

17.14.5 Signal handlers [support.signal]

1

#

A call to the function signal synchronizes with any resulting invocation of the signal handler so installed.

2

#

A plain lock-free atomic operation is an invocation of a function f from [atomics], such that:

f is the function atomic_is_lock_free(), or

f is the member function is_lock_free(), or

f is a non-static member function of class atomic_flag, or

f is a non-member function, and the first parameter of f has type cv atomic_flag*, or

f is a non-static member function invoked on an object A, such that A.is_lock_free() yields true, or

f is a non-member function, and for every pointer-to-atomic argument A passed to f,atomic_is_lock_free(A) yields true.

3

#

An evaluation is signal-safe unless it includes one of the following:

a call to any standard library function, except for plain lock-free atomic operations and functions explicitly identified as signal-safe; [Note 1: This implicitly excludes the use of new and delete expressions that rely on a library-provided memory allocator. — end note]

an access to an object with thread storage duration;

a dynamic_cast expression;

throwing of an exception;

control entering a try-block or function-try-block;

initialization of a variable with static storage duration requiring dynamic initialization ([basic.start.dynamic], [stmt.dcl])191 ; or

waiting for the completion of the initialization of a variable with static storage duration ([stmt.dcl]).

A signal handler invocation has undefined behavior if it includes an evaluation that is not signal-safe.

4

#

The function signal is signal-safe if it is invoked with the first argument equal to the signal number corresponding to the signal that caused the invocation of the handler.

See also: ISO/IEC 9899:2024, 7.14

191)191)

Such initialization can occur because it is the first odr-use ([basic.def.odr]) of that variable.