-
- Downloads
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.
Showing
- gcc/jit/jit-playback.cc 23 additions, 17 deletionsgcc/jit/jit-playback.cc
- gcc/jit/jit-playback.h 3 additions, 2 deletionsgcc/jit/jit-playback.h
- gcc/jit/jit-recording.cc 0 additions, 1 deletiongcc/jit/jit-recording.cc
- gcc/jit/libgccjit.cc 3 additions, 4 deletionsgcc/jit/libgccjit.cc
- gcc/system.h 4 additions, 0 deletionsgcc/system.h
Loading
Please register or sign in to comment