[NFC][Py Reformat] Added more commits to .git-blame-ignore-revs
[llvm-project.git] / libc / src / pthread / pthread_create.cpp
blob706412559aadcfb420be6737f3388dcd6597566a
1 //===-- Linux implementation of the pthread_create function ---------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "pthread_create.h"
11 #include "src/__support/common.h"
12 #include "src/__support/threads/thread.h"
14 #include <errno.h>
15 #include <pthread.h> // For pthread_* type definitions.
17 namespace __llvm_libc {
19 static_assert(sizeof(pthread_t) == sizeof(__llvm_libc::Thread),
20 "Mismatch between pthread_t and internal Thread.");
22 LLVM_LIBC_FUNCTION(int, pthread_create,
23 (pthread_t *__restrict th, const pthread_attr_t *__restrict,
24 __pthread_start_t func, void *arg)) {
25 auto *thread = reinterpret_cast<__llvm_libc::Thread *>(th);
26 // TODO: Use the attributes parameter to set up thread properties.
27 int result = thread->run(func, arg, nullptr, 0);
28 if (result != 0 && result != EPERM)
29 return EAGAIN;
30 return result;
33 } // namespace __llvm_libc