Namespaces

Records

Functions

  • int thrd_create_with_name (thrd_t * thread, thrd_start_t func, void * arg, const char * name)

    Defined at line 12 of file ../../sdk/lib/c/threads/thrd_create_with_name.cc

  • void abort ()

    Defined at line 13 of file ../../sdk/lib/c/stdlib/abort.cc

  • void exit (int status)

    Defined at line 15 of file ../../sdk/lib/c/stdlib/exit.cc

  • int pthread_attr_init (pthread_attr_t * attr)

    Defined at line 12 of file ../../sdk/lib/c/pthread/pthread_attr_init.cc

  • int pthread_detach (pthread_t thread)

    Defined at line 12 of file ../../sdk/lib/c/pthread/pthread_detach.cc

  • void pthread_exit (void * retval)

    Defined at line 12 of file ../../sdk/lib/c/pthread/pthread_exit.cc

  • int pthread_join (pthread_t thread, void ** retval)

    Defined at line 14 of file ../../sdk/lib/c/pthread/pthread_join.cc

  • int pthread_setname_np (pthread_t , const char * name)

    Defined at line 16 of file ../../sdk/lib/c/pthread/pthread_setname_np.cc

  • int thrd_create (thrd_t * thread, thrd_start_t func, void * arg)

    Defined at line 12 of file ../../sdk/lib/c/threads/thrd_create.cc

  • int thrd_detach (thrd_t thread)

    Defined at line 12 of file ../../sdk/lib/c/threads/thrd_detach.cc

  • void thrd_exit (int retval)

    Defined at line 12 of file ../../sdk/lib/c/threads/thrd_exit.cc

  • pthread_attr_t ToPthreadAttr (ThreadAttributes attr)

    Defined at line 12 of file ../../sdk/lib/c/pthread/attr.h

  • int thrd_join (thrd_t thread, int * retval)

    Defined at line 12 of file ../../sdk/lib/c/threads/thrd_join.cc

  • int pthread_create (pthread_t *__restrict thread, const pthread_attr_t *__restrict attr, __pthread_start_t func, void * arg)

    Defined at line 13 of file ../../sdk/lib/c/pthread/pthread_create.cc

  • int dl_iterate_phdr (__dl_iterate_phdr_callback_t , void * )

    Defined at line 18 of file ../../sdk/lib/c/link/dl_iterate_phdr.cc

  • int pthread_getname_np (pthread_t , char * , size_t )

    Defined at line 16 of file ../../sdk/lib/c/pthread/pthread_getname_np.cc

  • void ThreadExit (intptr_t value)

    This does the final "normal" work on the exiting thread: running

    destructors, etc. This is reached either directly from a call to

    thrd_exit() or pthread_exit(), or from a thread function returning.

    Defined at line 17 of file ../../sdk/lib/c/threads/thread-exit.cc

  • template <default_initializable T>
    void ExpectSafeZeroConstruction ()

    Verify that default construction is the same as no construction (when the

    initial storage bytes are already zero). Even if it's not technically

    trivial, if all zero bytes is what it produces, then it's fine.

    Defined at line 19 of file ../../sdk/lib/c/threads/../test/safe-zero-construction.h

  • zx::result<intptr_t> ThreadJoin (Thread & thread)

    This underlies thrd_join() and pthread_join(). It yields the value passed

    to ThreadExit().

    Defined at line 19 of file ../../sdk/lib/c/threads/thread-join.cc

  • zx::result<> ThreadDetach (Thread & thread)

    This underlies thrd_detach() and pthread_detach(). As soon as it returns

    success, the Thread reference is no longer safe to use in any way because

    the thread can exit and free the storage itself at any time.

    Defined at line 17 of file ../../sdk/lib/c/threads/thread-detach.cc

  • ThreadAttributes FromPthreadAttr (const pthread_attr_t * attr)

    Defined at line 20 of file ../../sdk/lib/c/pthread/attr.h

  • zx::unowned_vmar AllocationVmar ()

    This is the VMAR to be used for general data allocations and mappings.

    **Note:** It should not be presumed to permit executable mappings.

    Defined at line 24 of file ../../sdk/lib/c/zircon/vmar.h

  • void _Exit (int status)

    Standard C specifies _Exit and C++ declares it noexcept.

    POSIX specifies _exit and in C++ it's not declared noexcept.

    They're actually the same thing, but a strict C++ compiler

    won't let us make them [[gnu::alias]] aliases directly here

    because the noexcept constitutes a type difference. So both

    are separately defined identically and will be ICF'd together

    for the same effect as the alias, but we can't use the alias

    (unless we resort to assembly, but this seems cleaner).

    Defined at line 34 of file ../../sdk/lib/c/stdlib/_Exit.cc

  • void _exit (int status)

    Defined at line 36 of file ../../sdk/lib/c/stdlib/_Exit.cc

  • void __thread_allocation_inhibit ()

    dlopen calls this under another lock. Only one dlopen call can be modifying

    state at a time. It excludes all ThreadStorage::Allocate() calls until the

    corresponding Thread goes on the gAllThreads list (thread-list.h).

    Defined at line 49 of file ../../sdk/lib/c/threads/thread-create.cc

  • void __thread_allocation_release ()

    Defined at line 53 of file ../../sdk/lib/c/threads/thread-create.cc

  • template <auto&& f>
    void OnStack (NoStack , auto && f)

    Defined at line 55 of file ../../sdk/lib/c/threads/stack-abi.h

  • template <auto&& stack, auto&& f>
    void OnStack (auto && stack, auto && f)

    Defined at line 56 of file ../../sdk/lib/c/threads/stack-abi.h

  • zx::result<CreatedThread> ThreadCreate (ThreadAttributes attrs)

    Create a new Thread. This does all the allocation and creates the kernel

    thread. The new Thread object is initialized, owns that zx::thread handle,

    and is attached to the global thread list. The thread is not running yet and

    will be destroyed when the CreatedThread object dies before ThreadStart.

    Kernel operations can now be done via the thread handle to affect the thread

    (set scheduling parameters, etc.) before it starts running.

    Defined at line 57 of file ../../sdk/lib/c/threads/thread-create.cc

  • ThreadFunction * ToThreadFunction (int (*)(void *) func)

    Defined at line 58 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • template <auto value>
    auto StackOr (NoStack , auto value)

    Defined at line 60 of file ../../sdk/lib/c/threads/stack-abi.h

  • ThreadFunction * ToThreadFunction (void *(*)(void *) func)

    Defined at line 61 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • template <auto stack, auto value>
    auto StackOr (auto stack, std::convertible_to<decltype(stack)> auto value)

    Defined at line 61 of file ../../sdk/lib/c/threads/stack-abi.h

  • thrd_t ToC11Thread (Thread & thread)

    The C11

    <threads

    .h> thrd_t is actually just the Thread*.

    Defined at line 66 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • Thread * FromC11Thread (thrd_t thread)

    Defined at line 67 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • void ShadowCallStackSet (uint64_t * scsp)

    Defined at line 68 of file ../../sdk/lib/c/threads/stack-abi.h

  • pthread_t ToPthread (Thread & thread)

    The POSIX

    <pthread

    .h> pthread_t is the same thing too.

    Defined at line 70 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • Thread * FromPthread (pthread_t thread)

    Defined at line 71 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • void ShadowCallStackPrologue (void * caller)

    This must be called first thing in the first function that runs with the

    full compiler ABI available. In builds of libc without shadow-call-stack

    support enabled on machines where the ABI includes it, this mimics what the

    compiler's (non-leaf) function prologue would usually do. This ensures that

    however libc is built, the shadow-call-stack backtraces are consistent with

    the frame-pointer backtraces for the initial frames, yielding a predictable

    backtrace of _start -> __libc_start_main -> main via CFI, frame-pointer, and

    shadow-call-stack techniques. If main and the code it calls (outside libc)

    do use shadow-call-stack and expect good backtraces taken purely from the

    shadow call stack, then the outermost frames will match expectations.

    Defined at line 90 of file ../../sdk/lib/c/threads/stack-abi.h

  • ld::DlPhdrInfoCounts _dlfcn_phdr_info_counts ()

    These are defined here so calling into LIBC_NAMESPACE::dl_iterate_phdr will

    exercise the defined-symbols case rather than the weak-undefined case that's

    exercised in the dl_iterate_phdr_test.cc tests in the main libc-unittests.

    The assertions in SetUpTestSuite ensure there wasn't some other definition

    linked into this test binary (such as libdl's).

    Defined at line 101 of file ../../sdk/lib/c/link/dl_iterate_phdr-dlfcn-abi-tests.cc

  • int _dlfcn_iterate_phdr (__dl_iterate_phdr_callback_t , void * )

    This has the exact signature and semantics of dl_iterate_phdr, except that

    it's only called after all the startup modules have been reported to the

    user's callback. If the user's callback bailed out with a nonzero return

    value, this will never be called. If this is called at all, then it's

    paired with the preceding _dlfcn_phdr_info_counts() call on the same thread.

    This is tail-called by libc's dl_iterate_phdr after reporting the startup

    modules. If it's undefined, dl_iterate_phdr just returns zero instead.

    Defined at line 103 of file ../../sdk/lib/c/link/dl_iterate_phdr-dlfcn-abi-tests.cc

  • template <std::invocable<Thread&> auto NewThread, std::invocable<zx_status_t> auto Status>
    decltype(Status(std::declval<zx_status_t>())) ThreadCreateAndStart (decltype(NewThread(std::declval<Thread &>())) * new_thread, ThreadAttributes attrs, ThreadFunction * func, void * arg)

    Combines ThreadCreate and ThreadStart. This is templatized with converter

    functions for the public thread and error types (ToC11Thread / ToPthread,

    C11ThreadError / PthreadError) rather than just being a non-template

    function returning zx::result

    <Thread

    *> because thrd_create is required to

    write its result parameter before the new thread might read it back out of

    that same memory; the caller unpacking the result would be too late.

    Defined at line 104 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • ThreadList AllThreadsLocked ()

    Defined at line 119 of file ../../sdk/lib/c/threads/thread-list.h

  • int C11ThreadError (zx_status_t status)

    Convert Zircon error to C11

    <threads

    .h> return value.

    Defined at line 158 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • void NotDefined ()
  • void NotDefinedWithArgs (int , const char * , double )
  • void InitStartupRandom ()

    This fills all LIBC_STARTUP_RANDOM_VAR objects with random bits. This is

    called very early, before the compiler ABI is set up. In fact, it's also

    what initializes the main thread's ZX_TLS_STACK_GUARD_OFFSET slot with

    random bits. Therefore it's built with an hermetic partial link, and so

    needs LIBC_ASM_LINKAGE.

  • PageRoundedSize InitialStackSize ()

    Get the stack size indicated by the executable's PT_GNU_STACK, or default.

    This must use only the basic machine ABI because it's called in phase one

    from StartCompilerAbi (startup-trampoline.h).

  • int PthreadError (zx_status_t status)

    Convert Zircon error to POSIX errno.

    Defined at line 172 of file ../../sdk/lib/c/pthread/../threads/thread.h

  • void _dlfcn_lock ()

    The libdl entrypoints do their own locking for the most part. But in some

    places libc needs to exclude libdl (dlopen) changes while doing other things

    before or after it calls into a _dlfcn_* hook to have libdl do something.

  • void _dlfcn_unlock ()
  • void SetStartHandles (zx::process process_self, zx::vmar allocation_vmar, zx::thread thread_self)

    This is called by StartCompilerAbi with the full Fuchsia Compiler ABI but

    still on the original stack: so technically still phase one, but closer to

    phase two and outside phase one's basic-ABI hermetic partial links so it

    must use asm linkage to be called across that hermetic boundary. It takes

    ownership of these handles by storing them in libc global state that can't

    be accessed directly from hermetic (phase one proper) code.

  • void __libc_start_main (void * hook, zx_handle_t svc_server_end, MainFunction * main)

    This is called by startup-trampoline.S (the public __libc_start_main) after

    switching to the stack returned by StartCompilerAbi. It constitutes phase

    two: it already has the full Fuchsia Compiler ABI in place. It calls the

    second two

    <zircon

    /startup.h> API functions that complete the work done in

    phase one to start handling the process bootstrap protocol and yield `hook`,

    which is propagated to the phase-two

    <zircon

    /startup.h> functions.

  • void StartupSanitizerModuleLoaded ()

    This calls the

    <zircon

    /sanitizer.h> __sanitizer_module_loaded hook for every

    module dl_iterate_phdr would report. This is called in phase two before

    calling the __sanitizer_startup_hook.

  • void __libc_start_main (zx_handle_t bootstrap_client_end, const void * vdso, zx_handle_t svc_server_end, MainFunction * )

    This is the ABI between the _start (Scrt1.o) code linked into each

    executable and libc, whether libc is linked in statically or dynamically.

    This is implemented in assembly (startup-trampoline.S) and is wholly

    independent of the bootstrap protocol details. It is entered using the

    basic machine ABI and calls StartCompilerAbi (below), but then acts as a

    tail call to the namespaced __libc_start_main (declared in start-main.h).

    Both functions have the same name in the source and thus as rendered in

    backtraces with debugging symbols so that, at least by plain function name,

    every point in startup should show _start -> __libc_start_main -> ... in a

    backtrace whether in the initial phase or when -> ... is -> main -> ...

    NOLINTNEXTLINE(bugprone-reserved-identifier)

  • void StartupCtors ()

    This calls all the static constructors and such encoded via ELF. This is

    the end of phase two, the point at which the full normal standard C runtime

    environment is entirely place: it comes after all sanitizer hooks; the

    libc-internal (and fdio) setup and preinit hooks; and very shortly before

    calling the user's `main` (final argument to __libc_start_main)

  • StartupTrampoline StartCompilerAbi (zx_handle_t bootstrap_client_end, const void * vdso)

    This is called by startup-trampoline.S using the basic machine ABI. It

    takes exactly the arguments of the actual `zx_process_start` entry point

    (the first two that `_start` and then `__libc_start_main` saw and then

    propagated), but returns a value (in two registers).

    It's responsible for allocating the stacks and initializing the thread

    pointer. It uses [`_zx_startup_get_handles`](../include/zircon/startup.h).

    That must decode the bootstrap protocol at least enough to acquire essential

    handles like the VMAR to use for allocation. This does all the allocation

    and initializes the thread pointer and shadow call stack register as fully

    as required by the Fuchsia Compiler ABI. When it returns to the assembly

    code, [phase two](start-main.h) is entered.

  • zx::result<Thread *> ThreadStart (CreatedThread thread, ThreadFunction * func, void * arg)

    After a new Thread has been fully created, this actually starts it running.

    The new thread will call ThreadExit(func(arg)). Once the thread is running,

    it owns its own storage and kernel handle, so the CreatedThread is released.

    But unless the thread is detached, the caller now owns it via the Thread*

    until that is passed to ThreadJoin (or detached).

    Defined at line 289 of file ../../sdk/lib/c/threads/thread-start.cc

  • void ThreadExitFinish (Thread & self)

    The last phase of exit is compiled using only the basic machine ABI so it

    can do some stack-switching and then free all the main thread stacks.

    Defined at line 166 of file ../../sdk/lib/c/threads/thread-exit-finish.cc

  • void OnTlsSegments (Thread & threadsanitizer_memory_snapshot_callback_t * callbackvoid * callback_arg)

    Make the callback on the thread's TLS segments.

Concepts

template <typename IncrementFunctiontypename ValueType> Incrementer std::regular_invocable<IncrementFunction, ValueType> && std::convertible_to<std::invoke_result_t<IncrementFunction, ValueType>, ValueType>

Defined at line 60 of file ../../sdk/lib/c/threads/thread-list.h

Variables

Mutex gAllThreadsLock

Defined at line 9 of file ../../sdk/lib/c/threads/thread-list.cc

Thread * gAllThreads

Defined at line 10 of file ../../sdk/lib/c/threads/thread-list.cc

std::array<uint64_t, (4 + 0)> gJmpBufManglers

Defined at line 17 of file ../../sdk/lib/c/setjmp/fuchsia/manglers.cc

decltype(ld::abi::_ld_abi) & _ld_abi

Defined at line 30 of file ../../sdk/lib/c/link/../ld/ld-abi.h

Log gLog
const bool kShadowCallStackAbi

Defined at line 36 of file ../../sdk/lib/c/threads/stack-abi.h

const WeakLock<_dlfcn_lock, _dlfcn_unlock> kDlfcnLock

Defined at line 37 of file ../../sdk/lib/c/threads/../dlfcn/dlfcn-abi.h

const bool kSafeStackAbi

Defined at line 45 of file ../../sdk/lib/c/threads/stack-abi.h

const WeakLock<__thread_allocation_inhibit, __thread_allocation_release> kStaticTlsLock

Defined at line 56 of file ../../sdk/lib/c/threads/thread-list.h