xref: /llvm-project/libc/src/threads/thrd_detach.cpp (revision 5ff3ff33ff930e4ec49da7910612d8a41eb068cb)
15db41778SSiva Chandra Reddy //===-- Linux implementation of the thrd_detach function ------------------===//
25db41778SSiva Chandra Reddy //
35db41778SSiva Chandra Reddy // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
45db41778SSiva Chandra Reddy // See https://llvm.org/LICENSE.txt for license information.
55db41778SSiva Chandra Reddy // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
65db41778SSiva Chandra Reddy //
75db41778SSiva Chandra Reddy //===----------------------------------------------------------------------===//
85db41778SSiva Chandra Reddy 
95db41778SSiva Chandra Reddy #include "src/threads/thrd_detach.h"
105db41778SSiva Chandra Reddy #include "src/__support/common.h"
11*5ff3ff33SPetr Hosek #include "src/__support/macros/config.h"
125db41778SSiva Chandra Reddy #include "src/__support/threads/thread.h"
135db41778SSiva Chandra Reddy 
145db41778SSiva Chandra Reddy #include <threads.h> // For thrd_* type definitions.
155db41778SSiva Chandra Reddy 
16*5ff3ff33SPetr Hosek namespace LIBC_NAMESPACE_DECL {
175db41778SSiva Chandra Reddy 
18b6bc9d72SGuillaume Chatelet static_assert(sizeof(thrd_t) == sizeof(LIBC_NAMESPACE::Thread),
19f4580c6dSSiva Chandra Reddy               "Mismatch between thrd_t and internal Thread.");
205db41778SSiva Chandra Reddy 
215db41778SSiva Chandra Reddy LLVM_LIBC_FUNCTION(int, thrd_detach, (thrd_t th)) {
22f4580c6dSSiva Chandra Reddy   auto *thread = reinterpret_cast<Thread *>(&th);
235db41778SSiva Chandra Reddy   thread->detach();
245db41778SSiva Chandra Reddy   return 0;
255db41778SSiva Chandra Reddy }
265db41778SSiva Chandra Reddy 
27*5ff3ff33SPetr Hosek } // namespace LIBC_NAMESPACE_DECL
28