This repository has been archived by the owner on Mar 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial version of mutex support and some drive-by fixes
- Loading branch information
Showing
9 changed files
with
315 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of libcu++, the C++ Standard Library for your entire system, | ||
// under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#include "std/mutex" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCUDACXX___CUDA_MUTEX_H | ||
#define _LIBCUDACXX___CUDA_MUTEX_H | ||
|
||
#ifndef __cuda_std__ | ||
#error "<__cuda/mutex> should only be included in from <cuda/std/mutex>" | ||
#endif // __cuda_std__ | ||
|
||
#include "../__utility/forward.h" | ||
|
||
_LIBCUDACXX_BEGIN_NAMESPACE_CUDA | ||
|
||
template<thread_scope _Sco> | ||
using mutex = _CUDA_VSTD::__mutex_base<_Sco>; | ||
|
||
template<thread_scope _Sco> | ||
using timed_mutex = _CUDA_VSTD::__mutex_base<_Sco>; | ||
|
||
template<thread_scope _Sco> | ||
using once_flag = _CUDA_VSTD::__once_flag_base<_Sco>; | ||
|
||
template<class... _Args> | ||
inline _LIBCUDACXX_INLINE_VISIBILITY | ||
void call_once(_Args&&... __args) | ||
{ | ||
call_once(_CUDA_VSTD::forward<_Args&&>(__args)...); | ||
} | ||
|
||
_LIBCUDACXX_END_NAMESPACE_CUDA | ||
|
||
#endif // _LIBCUDACXX___CUDA_MUTEX_H |
39 changes: 39 additions & 0 deletions
39
include/cuda/std/detail/libcxx/include/__cuda/mutex_prelude.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
// -*- C++ -*- | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
|
||
#ifndef _LIBCUDACXX___CUDA_MUTEX_PRELUDE_H | ||
#define _LIBCUDACXX___CUDA_MUTEX_PRELUDE_H | ||
|
||
#ifndef __cuda_std__ | ||
#error "<__cuda/mutex_prelude> should only be included in from <cuda/std/mutex>" | ||
#endif // __cuda_std__ | ||
|
||
#include "../__utility/unreachable.h" | ||
#include "../semaphore" | ||
|
||
_LIBCUDACXX_BEGIN_NAMESPACE_STD | ||
|
||
#define _LIBCUDACXX_HAS_TRIVIAL_MUTEX_DESTRUCTION | ||
|
||
_LIBCUDACXX_INLINE_VISIBILITY | ||
inline void __throw_system_error(int, const char*) | ||
{ | ||
__libcpp_unreachable(); | ||
} | ||
|
||
template <class _ValueType> | ||
inline _LIBCUDACXX_INLINE_VISIBILITY | ||
_ValueType __libcpp_acquire_load(atomic<_ValueType> const* __value) { | ||
return __value->load(memory_order_acquire); | ||
} | ||
|
||
_LIBCUDACXX_END_NAMESPACE_STD | ||
|
||
#endif // _LIBCUDACXX___CUDA_MUTEX_PRELUDE_H |
Oops, something went wrong.