Add macOS support #34
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...
Some checks are pending
BlockStorage/repertory/pipeline/head Build queued...
This commit is contained in:
@@ -22,7 +22,7 @@
|
|||||||
#ifndef REPERTORY_INCLUDE_COMMON_HPP_
|
#ifndef REPERTORY_INCLUDE_COMMON_HPP_
|
||||||
#define REPERTORY_INCLUDE_COMMON_HPP_
|
#define REPERTORY_INCLUDE_COMMON_HPP_
|
||||||
|
|
||||||
#if defined(__GNUC__)
|
#if defined(__GNUC__) && !defined(PROJECT_IS_DARWIN)
|
||||||
// clang-format off
|
// clang-format off
|
||||||
#define REPERTORY_IGNORE_WARNINGS_ENABLE() \
|
#define REPERTORY_IGNORE_WARNINGS_ENABLE() \
|
||||||
_Pragma("GCC diagnostic push") \
|
_Pragma("GCC diagnostic push") \
|
||||||
|
@@ -98,7 +98,7 @@ private:
|
|||||||
std::condition_variable notify_;
|
std::condition_variable notify_;
|
||||||
std::mutex start_stop_mutex_;
|
std::mutex start_stop_mutex_;
|
||||||
stop_type stop_requested_{false};
|
stop_type stop_requested_{false};
|
||||||
std::vector<std::unique_ptr<std::jthread>> task_threads_;
|
std::vector<std::unique_ptr<std::thread>> task_threads_;
|
||||||
std::deque<scheduled_task> tasks_;
|
std::deque<scheduled_task> tasks_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@@ -86,8 +86,9 @@ void tasks::start(app_config *config) {
|
|||||||
|
|
||||||
for (std::uint32_t idx = 0U; idx < std::thread::hardware_concurrency() * 2U;
|
for (std::uint32_t idx = 0U; idx < std::thread::hardware_concurrency() * 2U;
|
||||||
++idx) {
|
++idx) {
|
||||||
task_threads_.emplace_back(
|
auto thread{std::make_unique<std::thread>([this]() { task_thread(); })};
|
||||||
std::make_unique<std::jthread>([this]() { task_thread(); }));
|
thread->detach();
|
||||||
|
task_threads_.emplace_back(std::move(thread));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,7 +101,7 @@ void tasks::stop() {
|
|||||||
stop_requested_ = true;
|
stop_requested_ = true;
|
||||||
|
|
||||||
unique_mutex_lock lock(mutex_);
|
unique_mutex_lock lock(mutex_);
|
||||||
std::vector<std::unique_ptr<std::jthread>> threads;
|
std::vector<std::unique_ptr<std::thread>> threads;
|
||||||
std::swap(threads, task_threads_);
|
std::swap(threads, task_threads_);
|
||||||
|
|
||||||
std::deque<scheduled_task> task_list;
|
std::deque<scheduled_task> task_list;
|
||||||
|
@@ -118,10 +118,10 @@ auto to_api_error(int err) -> api_error {
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
case EBADMSG:
|
case EBADMSG:
|
||||||
return api_error::download_failed;
|
return api_error::download_failed;
|
||||||
#else
|
#else // !defined(__APPLE__)
|
||||||
case EREMOTEIO:
|
case EREMOTEIO:
|
||||||
return api_error::download_failed;
|
return api_error::download_failed;
|
||||||
#endif
|
#endif // defined(__APPLE__)
|
||||||
case EIO:
|
case EIO:
|
||||||
return api_error::error;
|
return api_error::error;
|
||||||
case EEXIST:
|
case EEXIST:
|
||||||
@@ -130,8 +130,6 @@ auto to_api_error(int err) -> api_error {
|
|||||||
return api_error::file_in_use;
|
return api_error::file_in_use;
|
||||||
case EINVAL:
|
case EINVAL:
|
||||||
return api_error::invalid_operation;
|
return api_error::invalid_operation;
|
||||||
case ENAMETOOLONG:
|
|
||||||
return api_error::name_too_long;
|
|
||||||
case ENOENT:
|
case ENOENT:
|
||||||
return api_error::item_not_found;
|
return api_error::item_not_found;
|
||||||
case ENOMEM:
|
case ENOMEM:
|
||||||
@@ -151,17 +149,19 @@ auto to_api_error(int err) -> api_error {
|
|||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
case ENOATTR:
|
case ENOATTR:
|
||||||
return api_error::xattr_not_found;
|
return api_error::xattr_not_found;
|
||||||
#else
|
#else // !defined(__APPLE__)
|
||||||
case ENODATA:
|
case ENODATA:
|
||||||
return api_error::xattr_not_found;
|
return api_error::xattr_not_found;
|
||||||
#endif
|
#endif // defined(__APPLE__)
|
||||||
#if defined(__APPLE__)
|
#if defined(__APPLE__)
|
||||||
case ENAMETOOLONG:
|
case ENAMETOOLONG:
|
||||||
return api_error::xattr_too_big;
|
return api_error::xattr_too_big;
|
||||||
#else
|
#else // !defined(__APPLE__)
|
||||||
|
case ENAMETOOLONG:
|
||||||
|
return api_error::name_too_long;
|
||||||
case E2BIG:
|
case E2BIG:
|
||||||
return api_error::xattr_too_big;
|
return api_error::xattr_too_big;
|
||||||
#endif
|
#endif // defined(__APPLE__)
|
||||||
default:
|
default:
|
||||||
return api_error::error;
|
return api_error::error;
|
||||||
}
|
}
|
||||||
|
@@ -182,7 +182,11 @@ if [ "${PROJECT_STATIC_LINK}" == "ON" ]; then
|
|||||||
PROJECT_BUILD_SHARED_LIBS=OFF
|
PROJECT_BUILD_SHARED_LIBS=OFF
|
||||||
PROJECT_ENABLE_BACKWARD_CPP=OFF
|
PROJECT_ENABLE_BACKWARD_CPP=OFF
|
||||||
PROJECT_LINK_TYPE=static
|
PROJECT_LINK_TYPE=static
|
||||||
PROJECT_REQUIRE_ALPINE=ON
|
if [ "${PROJECT_IS_DARWIN}" == "0" ]; then
|
||||||
|
PROJECT_REQUIRE_ALPINE=ON
|
||||||
|
else
|
||||||
|
PROJECT_REQUIRE_ALPINE=OFF
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
PROJECT_BUILD_SHARED_LIBS=ON
|
PROJECT_BUILD_SHARED_LIBS=ON
|
||||||
PROJECT_LINK_TYPE=shared
|
PROJECT_LINK_TYPE=shared
|
||||||
|
Reference in New Issue
Block a user