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

[k2] switch to c++23 #1231

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion cmake/init-compilation-flags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
endif()

if(COMPILE_RUNTIME_LIGHT)
set(REQUIRED_CMAKE_CXX_STANDARD 20)
set(REQUIRED_CMAKE_CXX_STANDARD 23)
else()
set(REQUIRED_CMAKE_CXX_STANDARD 17)
endif()
Expand Down
2 changes: 2 additions & 0 deletions compiler/compiler-settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ void CompilerSettings::init() {
ss << " -std=c++17";
#elif __cplusplus <= 202002L
ss << " -std=c++20";
#elif __cplusplus <= 202302L
ss << " -std=c++23";
#else
#error unsupported __cplusplus value
#endif
Expand Down
2 changes: 1 addition & 1 deletion compiler/make/make.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ static std::string get_light_runtime_compiler_options() {
s << option << " ";
}
}
s << "-std=c++20 ";
s << "-std=c++23 ";
s << "-iquote " << G->settings().runtime_and_common_src.get() << " ";
#endif

Expand Down
1 change: 1 addition & 0 deletions runtime-light/coroutine/task.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <cassert>
#include <concepts>
#include <coroutine>
#include <exception>
#include <optional>
#include <type_traits>
#include <utility>
Expand Down
18 changes: 8 additions & 10 deletions runtime-light/tl/tl-types.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
#include <cstdint>
#include <optional>
#include <string_view>
#include <type_traits>
#include <utility>
#include <variant>

#include "common/tl/constants/common.h"
#include "runtime-light/allocator/allocator.h"
#include "runtime-common/core/allocator/script-allocator.h"
#include "runtime-common/core/std/containers.h"
#include "runtime-light/tl/tl-core.h"

Expand Down Expand Up @@ -387,26 +387,24 @@ struct HttpVersion final {
}

bool fetch(TLBuffer &tlb) noexcept {
using version_utype = std::underlying_type_t<Version>;

switch (tlb.fetch_trivial<uint32_t>().value_or(TL_ZERO)) {
case static_cast<version_utype>(Version::V09): {
case std::to_underlying(Version::V09): {
version = Version::V09;
break;
}
case static_cast<version_utype>(Version::V10): {
case std::to_underlying(Version::V10): {
version = Version::V10;
break;
}
case static_cast<version_utype>(Version::V11): {
case std::to_underlying(Version::V11): {
version = Version::V11;
break;
}
case static_cast<version_utype>(Version::V2): {
case std::to_underlying(Version::V2): {
version = Version::V2;
break;
}
case static_cast<version_utype>(Version::V3): {
case std::to_underlying(Version::V3): {
version = Version::V3;
break;
}
Expand All @@ -420,7 +418,7 @@ struct HttpVersion final {
}

void store(TLBuffer &tlb) const noexcept {
tlb.store_trivial<uint32_t>(static_cast<std::underlying_type_t<Version>>(version));
tlb.store_trivial<uint32_t>(std::to_underlying(version));
}
};

Expand Down
4 changes: 2 additions & 2 deletions runtime-light/utils/panic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Distributed under the GPL v3 License, see LICENSE.notice.txt

#include <string_view>
#include <type_traits>
#include <utility>

#include "runtime-common/core/utils/kphp-assert-core.h"
#include "runtime-light/k2-platform/k2-api.h"
Expand All @@ -12,7 +12,7 @@

void critical_error_handler() {
constexpr std::string_view message = "script panic";
k2::log(static_cast<std::underlying_type_t<LogLevel>>(LogLevel::Debug), message.size(), message.data());
k2::log(std::to_underlying(LogLevel::Debug), message.size(), message.data());

if (k2::instance_state() != nullptr) {
InstanceState::get().poll_status = k2::PollStatus::PollFinishedError;
Expand Down
11 changes: 6 additions & 5 deletions runtime-light/utils/php_assert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <execinfo.h>
#include <sys/wait.h>
#include <unistd.h>
#include <utility>

#include "runtime-common/core/utils/kphp-assert-core.h"
#include "runtime-light/k2-platform/k2-api.h"
Expand All @@ -24,36 +25,36 @@ static void php_warning_impl(bool out_of_memory, int error_type, char const *mes

int size = vsnprintf(buf, BUF_SIZE, message, args);
k2::log(error_type, size, buf);
if (error_type == static_cast<std::underlying_type_t<LogLevel>>(LogLevel::Error)) {
if (error_type == std::to_underlying(LogLevel::Error)) {
critical_error_handler();
}
}

void php_debug(char const *message, ...) {
va_list args;
va_start(args, message);
php_warning_impl(false, static_cast<std::underlying_type_t<LogLevel>>(LogLevel::Debug), message, args);
php_warning_impl(false, std::to_underlying(LogLevel::Debug), message, args);
va_end(args);
}

void php_notice(char const *message, ...) {
va_list args;
va_start(args, message);
php_warning_impl(false, static_cast<std::underlying_type_t<LogLevel>>(LogLevel::Info), message, args);
php_warning_impl(false, std::to_underlying(LogLevel::Info), message, args);
va_end(args);
}

void php_warning(char const *message, ...) {
va_list args;
va_start(args, message);
php_warning_impl(false, static_cast<std::underlying_type_t<LogLevel>>(LogLevel::Warn), message, args);
php_warning_impl(false, std::to_underlying(LogLevel::Warn), message, args);
va_end(args);
}

void php_error(char const *message, ...) {
va_list args;
va_start(args, message);
php_warning_impl(false, static_cast<std::underlying_type_t<LogLevel>>(LogLevel::Error), message, args);
php_warning_impl(false, std::to_underlying(LogLevel::Error), message, args);
va_end(args);
}

Expand Down
Loading