diff options
author | Jonathan Wakely <jwakely@redhat.com> | 2022-11-11 12:48:29 +0000 |
---|---|---|
committer | Jonathan Wakely <jwakely@redhat.com> | 2022-11-19 11:10:22 +0000 |
commit | 0a62889c7a155f8ed971860d68870dc9c46bb004 (patch) | |
tree | 6f9cdbfaa40430d129e13cb35bbfe39a8e4481d4 /gcc/system.h | |
parent | 8c05d8cd4300f74bf2698f0a6b96464b5be571be (diff) | |
download | gcc-0a62889c7a155f8ed971860d68870dc9c46bb004.zip gcc-0a62889c7a155f8ed971860d68870dc9c46bb004.tar.gz gcc-0a62889c7a155f8ed971860d68870dc9c46bb004.tar.bz2 |
jit: Use std::mutex instead of pthread_mutex_t
This allows JIT to be built with a different thread model from posix
where pthread isn't available
By renaming the acquire_mutex () and release_mutex () member functions
to lock() and unlock() we make the playback::context type meet the C++
Lockable requirements. This allows it to be used with a scoped lock
(i.e. RAII) type as std::lock_guard. This automatically releases the
mutex when leaving the scope.
Co-authored-by: LIU Hao <lh_mouse@126.com>
gcc/jit/ChangeLog:
* jit-playback.cc (playback::context::scoped_lock): Define RAII
lock type.
(playback::context::compile): Use scoped_lock to acquire mutex
for the active playback context.
(jit_mutex): Change to std::mutex.
(playback::context::acquire_mutex): Rename to ...
(playback::context::lock): ... this.
(playback::context::release_mutex): Rename to ...
(playback::context::unlock): ... this.
* jit-playback.h (playback::context): Rename members and declare
scoped_lock.
* jit-recording.cc (INCLUDE_PTHREAD_H): Remove unused define.
* libgccjit.cc (version_mutex): Change to std::mutex.
(struct jit_version_info): Use std::lock_guard to acquire and
release mutex.
gcc/ChangeLog:
* system.h [INCLUDE_MUTEX]: Include header for std::mutex.
Diffstat (limited to 'gcc/system.h')
-rw-r--r-- | gcc/system.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/system.h b/gcc/system.h index de9c5c0..4f9256e 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -747,6 +747,10 @@ extern int vsnprintf (char *, size_t, const char *, va_list); # include <memory> #endif +#ifdef INCLUDE_MUTEX +# include <mutex> +#endif + #ifdef INCLUDE_MALLOC_H #if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2) #include <malloc.h> |