1 //===--- A platform independent indirection for a thread class --*- C++ -*-===// 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 //===----------------------------------------------------------------------===// 8 9 #ifndef LLVM_LIBC_SRC_SUPPORT_THREADS_THREAD_H 10 #define LLVM_LIBC_SRC_SUPPORT_THREADS_THREAD_H 11 12 #include <stddef.h> 13 14 // The platform specific implemnetations are pulled via the following include. 15 // The idea is for the platform implementation to implement a class named Thread 16 // in the namespace __llvm_libc with the following properties: 17 // 18 // 1. Has a defaulted default constructor (not a default constructor). 19 // 20 // 2. Has a "run" method with the following signature: 21 // 22 // int run(ThreadRunner *f, void *arg, void *stack, size_t size); 23 // 24 // Returns: 25 // 0 on success and an error value on failure. 26 // Args: 27 // arg - The argument to be passed to the thread runner after the thread 28 // is created. 29 // stack - The stack to use for the thread. 30 // size - The stack size. 31 // 32 // If callers pass a non-null |stack| value, then it will assumed that 33 // 1. The clean up the stack memory is their responsibility 34 // 2. The guard area is setup appropriately by the caller. 35 // 36 // 3. Has a "join" method with the following signature: 37 // ErrorOr<ReturnType> join(); 38 // The "join" method should return 0 on success and set retcode to the 39 // threads return value. On failure, an appropriate errno value should be 40 // returned. 41 // 42 // 4. Has an operator== for comparison between two threads. 43 #ifdef __unix__ 44 #include "linux/thread.h" 45 #endif // __unix__ 46 47 #endif // LLVM_LIBC_SRC_SUPPORT_THREADS_THREAD_H 48