diff options
author | Tim Northover <t.p.northover@gmail.com> | 2021-07-09 09:51:57 +0100 |
---|---|---|
committer | Tim Northover <t.p.northover@gmail.com> | 2021-07-09 10:39:52 +0100 |
commit | 0c39f82f0b3e9268f7699e62f59f960a1bff89fa (patch) | |
tree | 1af3ce9b3ca80072939f787c098645f1acb61b3b /llvm/lib/Support/Unix/Threading.inc | |
parent | 375694a07bcba3be66864c42a5932be1a22831e2 (diff) | |
download | llvm-0c39f82f0b3e9268f7699e62f59f960a1bff89fa.zip llvm-0c39f82f0b3e9268f7699e62f59f960a1bff89fa.tar.gz llvm-0c39f82f0b3e9268f7699e62f59f960a1bff89fa.tar.bz2 |
[Support] reorder Threading includes to avoid conflict with FreeBSD headers
FreeBSD's condvar.h (included by user.h in Threading.inc) uses a "struct
thread" that conflicts with llvm::thread if both are visible when it's
included.
So this moves our #include after the FreeBSD code.
Diffstat (limited to 'llvm/lib/Support/Unix/Threading.inc')
-rw-r--r-- | llvm/lib/Support/Unix/Threading.inc | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Support/Unix/Threading.inc b/llvm/lib/Support/Unix/Threading.inc index 2131def..5de1cf0 100644 --- a/llvm/lib/Support/Unix/Threading.inc +++ b/llvm/lib/Support/Unix/Threading.inc @@ -48,9 +48,10 @@ #include <unistd.h> // For syscall() #endif +namespace llvm { pthread_t -llvm::llvm_execute_on_thread_impl(void *(*ThreadFunc)(void *), void *Arg, - llvm::Optional<unsigned> StackSizeInBytes) { +llvm_execute_on_thread_impl(void *(*ThreadFunc)(void *), void *Arg, + llvm::Optional<unsigned> StackSizeInBytes) { int errnum; // Construct the attributes object. @@ -80,7 +81,7 @@ llvm::llvm_execute_on_thread_impl(void *(*ThreadFunc)(void *), void *Arg, return Thread; } -void llvm::llvm_thread_detach_impl(pthread_t Thread) { +void llvm_thread_detach_impl(pthread_t Thread) { int errnum; if ((errnum = ::pthread_detach(Thread)) != 0) { @@ -88,7 +89,7 @@ void llvm::llvm_thread_detach_impl(pthread_t Thread) { } } -void llvm::llvm_thread_join_impl(pthread_t Thread) { +void llvm_thread_join_impl(pthread_t Thread) { int errnum; if ((errnum = ::pthread_join(Thread, nullptr)) != 0) { @@ -96,14 +97,16 @@ void llvm::llvm_thread_join_impl(pthread_t Thread) { } } -pthread_t llvm::llvm_thread_get_id_impl(pthread_t Thread) { +pthread_t llvm_thread_get_id_impl(pthread_t Thread) { return Thread; } -pthread_t llvm::llvm_thread_get_current_id_impl() { +pthread_t llvm_thread_get_current_id_impl() { return ::pthread_self(); } +} // namespace llvm + uint64_t llvm::get_threadid() { #if defined(__APPLE__) // Calling "mach_thread_self()" bumps the reference count on the thread |