Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake: set cpp17 standard #8922

Merged
merged 4 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ enable_language(C ASM)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down Expand Up @@ -999,6 +999,9 @@ else()

if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=default -DGTEST_HAS_TR1_TUPLE=0")
if(ARM)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-aligned-allocation")
selsta marked this conversation as resolved.
Show resolved Hide resolved
endif()
endif()

set(DEBUG_FLAGS "-g3")
Expand Down Expand Up @@ -1077,6 +1080,7 @@ if (WIN32)
endif()
find_package(Boost 1.58 QUIET REQUIRED COMPONENTS ${BOOST_COMPONENTS})
add_definitions(-DBOOST_ASIO_ENABLE_SEQUENTIAL_STRAND_ALLOCATION)
add_definitions(-DBOOST_NO_AUTO_PTR)

set(CMAKE_FIND_LIBRARY_SUFFIXES ${OLD_LIB_SUFFIXES})
if(NOT Boost_FOUND)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ library archives (`.a`).

| Dep | Min. version | Vendored | Debian/Ubuntu pkg | Arch pkg | Void pkg | Fedora pkg | Optional | Purpose |
| ------------ | ------------- | -------- | -------------------- | ------------ | ------------------ | ------------------- | -------- | --------------- |
| GCC | 5 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | |
| GCC | 7 | NO | `build-essential` | `base-devel` | `base-devel` | `gcc` | NO | |
| CMake | 3.5 | NO | `cmake` | `cmake` | `cmake` | `cmake` | NO | |
| pkg-config | any | NO | `pkg-config` | `base-devel` | `base-devel` | `pkgconf` | NO | |
| Boost | 1.58 | NO | `libboost-all-dev` | `boost` | `boost-devel` | `boost-devel` | NO | C++ libraries |
Expand Down
2 changes: 1 addition & 1 deletion contrib/depends/toolchain.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
SET(PORT OFF)
SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")
SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
SET(CMAKE_CXX_STANDARD 14)
SET(CMAKE_CXX_STANDARD 17)
SET(LLVM_ENABLE_PIC OFF)
SET(LLVM_ENABLE_PIE OFF)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
Expand Down
9 changes: 3 additions & 6 deletions src/device/device_ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@
#include "cryptonote_basic/subaddress_index.h"
#include "cryptonote_core/cryptonote_tx_utils.h"

#include <boost/thread/locks.hpp>
#include <boost/thread/lock_guard.hpp>

namespace hw {

namespace ledger {
Expand Down Expand Up @@ -322,10 +319,10 @@ namespace hw {
//automatic lock one more level on device ensuring the current thread is allowed to use it
#define AUTO_LOCK_CMD() \
/* lock both mutexes without deadlock*/ \
boost::lock(device_locker, command_locker); \
std::lock(device_locker, command_locker); \
/* make sure both already-locked mutexes are unlocked at the end of scope */ \
boost::lock_guard<boost::recursive_mutex> lock1(device_locker, boost::adopt_lock); \
boost::lock_guard<boost::mutex> lock2(command_locker, boost::adopt_lock)
std::lock_guard<std::recursive_mutex> lock1(device_locker, std::adopt_lock); \
std::lock_guard<std::mutex> lock2(command_locker, std::adopt_lock)

//lock the device for a long sequence
void device_ledger::lock(void) {
Expand Down
7 changes: 3 additions & 4 deletions src/device/device_ledger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
#include "device.hpp"
#include "log.hpp"
#include "device_io_hid.hpp"
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include <mutex>

namespace hw {

Expand Down Expand Up @@ -140,8 +139,8 @@ namespace hw {
class device_ledger : public hw::device {
private:
// Locker for concurrent access
mutable boost::recursive_mutex device_locker;
mutable boost::mutex command_locker;
mutable std::recursive_mutex device_locker;
mutable std::mutex command_locker;

//IO
hw::io::device_io_hid hw_device;
Expand Down
15 changes: 7 additions & 8 deletions src/device_trezor/device_trezor_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,12 @@


#include <cstddef>
#include <mutex>
#include <string>
#include "device/device.hpp"
#include "device/device_default.hpp"
#include "device/device_cold.hpp"
#include <boost/scope_exit.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/recursive_mutex.hpp>
#include "cryptonote_config.h"
#include "trezor.hpp"

Expand All @@ -49,12 +48,12 @@
//automatic lock one more level on device ensuring the current thread is allowed to use it
#define TREZOR_AUTO_LOCK_CMD() \
/* lock both mutexes without deadlock*/ \
boost::lock(device_locker, command_locker); \
std::lock(device_locker, command_locker); \
/* make sure both already-locked mutexes are unlocked at the end of scope */ \
boost::lock_guard<boost::recursive_mutex> lock1(device_locker, boost::adopt_lock); \
boost::lock_guard<boost::mutex> lock2(command_locker, boost::adopt_lock)
std::lock_guard<std::recursive_mutex> lock1(device_locker, std::adopt_lock); \
std::lock_guard<std::mutex> lock2(command_locker, std::adopt_lock)

#define TREZOR_AUTO_LOCK_DEVICE() boost::lock_guard<boost::recursive_mutex> lock1_device(device_locker)
#define TREZOR_AUTO_LOCK_DEVICE() std::lock_guard<std::recursive_mutex> lock1_device(device_locker)

namespace hw {
namespace trezor {
Expand Down Expand Up @@ -86,8 +85,8 @@ namespace trezor {
protected:

// Locker for concurrent access
mutable boost::recursive_mutex device_locker;
mutable boost::mutex command_locker;
mutable std::recursive_mutex device_locker;
mutable std::mutex command_locker;

std::shared_ptr<Transport> m_transport;
i_device_callback * m_callback;
Expand Down
Loading