A tool for deriving PKG packet encryption keys for ps4 written in c++
| 1 | // SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | |
| 4 | #pragma once |
| 5 | |
| 6 | #ifdef __linux__ |
| 7 | #include <pthread.h> |
| 8 | #endif |
| 9 | |
| 10 | namespace Common { |
| 11 | |
| 12 | #ifdef PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
| 13 | class AdaptiveMutex { |
| 14 | public: |
| 15 | void lock() { |
| 16 | pthread_mutex_lock(&mutex); |
| 17 | } |
| 18 | void unlock() { |
| 19 | pthread_mutex_unlock(&mutex); |
| 20 | } |
| 21 | |
| 22 | private: |
| 23 | pthread_mutex_t mutex = PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP; |
| 24 | }; |
| 25 | #endif // PTHREAD_ADAPTIVE_MUTEX_INITIALIZER_NP |
| 26 | |
| 27 | } // namespace Common |
| 28 |