Skip to content

Commit

Permalink
build(thirdparty): bump fmtlib to 10.1.1 (apache#1605)
Browse files Browse the repository at this point in the history
apache#1604

- Add ecplicit formatters for user defined types. Because since fmtlib 8.0:
  > Format string compilation now requires `format` functions of `formatter` specializations for user-defined types to be `const`.

  See https://github.com/fmtlib/fmt/releases/tag/8.0.0
  • Loading branch information
acelyc111 authored Sep 12, 2023
1 parent 26b99e1 commit 5489b43
Show file tree
Hide file tree
Showing 76 changed files with 210 additions and 72 deletions.
8 changes: 3 additions & 5 deletions cmake_modules/BaseFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -388,11 +388,9 @@ function(dsn_common_setup)

set(BUILD_SHARED_LIBS OFF)

include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++1y" COMPILER_SUPPORTS_CXX1Y)
if(NOT ${COMPILER_SUPPORTS_CXX1Y})
message(FATAL_ERROR "You need a compiler with C++1y support.")
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

dsn_setup_system_libs()
dsn_setup_compiler_flags()
Expand Down
9 changes: 9 additions & 0 deletions src/base/idl_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <string>

#include "rrdb/rrdb_types.h"
#include "utils/fmt_utils.h"

namespace pegasus {

Expand All @@ -40,3 +41,11 @@ inline bool cas_is_check_operand_needed(dsn::apps::cas_check_type::type type)
}

} // namespace pegasus

namespace dsn {
namespace apps {
USER_DEFINED_ENUM_FORMATTER(cas_check_type::type)
USER_DEFINED_ENUM_FORMATTER(filter_type::type)
USER_DEFINED_ENUM_FORMATTER(mutate_operation::type)
} // namespace apps
} // namespace dsn
3 changes: 3 additions & 0 deletions src/base/value_field.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

#pragma once

#include "utils/fmt_utils.h"

namespace pegasus {

enum value_field_type
Expand All @@ -28,6 +30,7 @@ enum value_field_type
USER_DATA,
FIELD_COUNT,
};
USER_DEFINED_ENUM_FORMATTER(value_field_type)

struct value_field
{
Expand Down
2 changes: 1 addition & 1 deletion src/client/replication_ddl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include "common/replication.codes.h"
#include "common/replication_common.h"
#include "common/replication_enums.h"
#include "fmt/ostream.h"
#include "fmt/core.h"
#include "meta/meta_rpc_types.h"
#include "runtime/api_layer1.h"
#include "runtime/rpc/group_address.h"
Expand Down
3 changes: 1 addition & 2 deletions src/client/test/ddl_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
// specific language governing permissions and limitations
// under the License.

#include <fmt/ostream.h>
#include <fmt/core.h>
// IWYU pragma: no_include <gtest/gtest-message.h>
// IWYU pragma: no_include <gtest/gtest-test-part.h>
#include <gtest/gtest.h>
#include <stdint.h>
#include <algorithm>
#include <deque>
#include <iosfwd>
#include <memory>
#include <vector>

Expand Down
1 change: 1 addition & 0 deletions src/client_lib/pegasus_client_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
* under the License.
*/

#include <fmt/core.h>
#include <pegasus/error.h>
#include <algorithm>
#include <chrono>
Expand Down
3 changes: 3 additions & 0 deletions src/common/duplication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "runtime/rpc/rpc_holder.h"
#include "utils/errors.h"
#include "utils/flags.h"
#include "utils/fmt_utils.h"

namespace dsn {
namespace replication {
Expand Down Expand Up @@ -87,5 +88,7 @@ struct duplication_constants
const static std::string kDuplicationEnvMasterMetasKey;
};

USER_DEFINED_ENUM_FORMATTER(duplication_fail_mode::type)
USER_DEFINED_ENUM_FORMATTER(duplication_status::type)
} // namespace replication
} // namespace dsn
4 changes: 2 additions & 2 deletions src/common/fs_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <iosfwd>
#include <utility>

#include <fmt/std.h> // IWYU pragma: keep

#include "common/gpid.h"
#include "common/replication_enums.h"
#include "fmt/core.h"
#include "fmt/ostream.h"
#include "perf_counter/perf_counter.h"
#include "replica_admin_types.h"
#include "runtime/api_layer1.h"
Expand Down
4 changes: 4 additions & 0 deletions src/common/gpid.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#include <ostream>
#include <thrift/protocol/TProtocol.h>

#include "utils/fmt_utils.h"

namespace dsn {

// Group-Partition-ID.
Expand Down Expand Up @@ -91,6 +93,8 @@ class gpid

} // namespace dsn

USER_DEFINED_STRUCTURE_FORMATTER(::dsn::gpid);

namespace std {
template <>
struct hash<::dsn::gpid>
Expand Down
15 changes: 15 additions & 0 deletions src/common/replication_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "consensus_types.h"
#include "meta_admin_types.h"
#include "replica_admin_types.h"
#include "utils/fmt_utils.h"

namespace dsn {
ENUM_BEGIN2(app_status::type, app_status, app_status::AS_INVALID)
Expand Down Expand Up @@ -163,4 +164,18 @@ ENUM_REG(replication::manual_compaction_status::QUEUING)
ENUM_REG(replication::manual_compaction_status::RUNNING)
ENUM_REG(replication::manual_compaction_status::FINISHED)
ENUM_END2(replication::manual_compaction_status::type, manual_compaction_status)

USER_DEFINED_ENUM_FORMATTER(app_status::type)
namespace replication {
USER_DEFINED_ENUM_FORMATTER(bulk_load_status::type)
USER_DEFINED_ENUM_FORMATTER(config_type::type)
USER_DEFINED_ENUM_FORMATTER(detect_action::type)
USER_DEFINED_ENUM_FORMATTER(disk_migration_status::type)
USER_DEFINED_ENUM_FORMATTER(disk_status::type)
USER_DEFINED_ENUM_FORMATTER(learner_status::type)
USER_DEFINED_ENUM_FORMATTER(learn_type::type)
USER_DEFINED_ENUM_FORMATTER(manual_compaction_status::type)
USER_DEFINED_ENUM_FORMATTER(meta_function_level::type)
USER_DEFINED_ENUM_FORMATTER(partition_status::type)
} // namespace replication
} // namespace dsn
4 changes: 3 additions & 1 deletion src/http/http_message_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ http_message_parser::http_message_parser()
header->hdr_type = http_method::HTTP_METHOD_POST;
header->context.u.is_request = 1;
} else {
LOG_ERROR("invalid http type {} and method {}", parser->type, parser->method);
// Bit fields don't work with "perfect" forwarding, see
// https://github.com/fmtlib/fmt/issues/1284
LOG_ERROR("invalid http type {} and method {}", +parser->type, +parser->method);
return 1;
}
return 0;
Expand Down
1 change: 0 additions & 1 deletion src/http/http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "http_server.h"

#include <fmt/ostream.h>
#include <stdint.h>
#include <string.h>
#include <memory>
Expand Down
4 changes: 4 additions & 0 deletions src/include/pegasus/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
#include <functional>
#include <memory>

#include "utils/fmt_utils.h"

namespace pegasus {

class rrdb_client;
Expand Down Expand Up @@ -1216,4 +1218,6 @@ class pegasus_client_factory
static pegasus_client *get_client(const char *cluster_name, const char *app_name);
};

USER_DEFINED_ENUM_FORMATTER(pegasus_client::filter_type)
USER_DEFINED_ENUM_FORMATTER(pegasus_client::cas_check_type)
} // namespace pegasus
2 changes: 0 additions & 2 deletions src/meta/duplication/meta_duplication_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@
// under the License.

#include <fmt/core.h>
#include <fmt/ostream.h>
#include <algorithm>
#include <cstdint>
#include <iosfwd>
#include <queue>
#include <type_traits>

Expand Down
4 changes: 4 additions & 0 deletions src/meta/meta_backup_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@
#include "runtime/task/task_tracker.h"
#include "utils/api_utilities.h"
#include "utils/error_code.h"
#include "utils/fmt_utils.h"
#include "utils/zlocks.h"

namespace dsn {
class message_ex;
class rpc_address;

namespace dist {
namespace block_service {
class block_filesystem;
Expand Down Expand Up @@ -420,3 +422,5 @@ class backup_service
};
} // namespace replication
} // namespace dsn

USER_DEFINED_STRUCTURE_FORMATTER(::dsn::replication::backup_start_time);
1 change: 1 addition & 0 deletions src/meta/meta_options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <map>
#include <utility>

#include "common/replication_enums.h" // IWYU pragma: keep
#include "utils/flags.h"
#include "utils/fmt_logging.h"
#include "utils/strings.h"
Expand Down
3 changes: 1 addition & 2 deletions src/meta/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

// IWYU pragma: no_include <boost/detail/basic_pointerbuf.hpp>
#include <boost/lexical_cast.hpp>
// IWYU pragma: no_include <ext/alloc_traits.h>
#include <fmt/ostream.h>
#include <ext/alloc_traits.h>
#include <algorithm> // for std::remove_if
#include <chrono>
#include <functional>
Expand Down
9 changes: 5 additions & 4 deletions src/meta/meta_state_service_utils_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

#pragma once

#include "common/replication.codes.h"
#include "meta/meta_state_service.h"
#include "meta_state_service_utils.h"
#include "runtime/pipeline.h"
#include "utils/fmt_logging.h"

#include "meta_state_service_utils.h"
#include "meta/meta_state_service.h"
#include "common/replication.codes.h"
#include "utils/fmt_utils.h"

namespace dsn {
namespace replication {
Expand Down Expand Up @@ -61,6 +61,7 @@ struct op_type
return op_type_to_string_map[v - 1];
}
};
USER_DEFINED_ENUM_FORMATTER(op_type::type)

/// Base class for all operations.
struct operation : pipeline::environment
Expand Down
5 changes: 3 additions & 2 deletions src/meta/meta_state_service_zookeeper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,8 +390,9 @@ void meta_state_service_zookeeper::visit_zookeeper_internal(ref_this,
{
zookeeper_session::zoo_opcontext *op =
reinterpret_cast<zookeeper_session::zoo_opcontext *>(result);
LOG_DEBUG(
"visit zookeeper internal: ans({}), call type({})", zerror(op->_output.error), op->_optype);
LOG_DEBUG("visit zookeeper internal: ans({}), call type({})",
zerror(op->_output.error),
static_cast<int>(op->_optype));

switch (op->_optype) {
case zookeeper_session::ZOO_OPERATION::ZOO_CREATE:
Expand Down
3 changes: 1 addition & 2 deletions src/meta/test/meta_service_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
// specific language governing permissions and limitations
// under the License.

#include <fmt/ostream.h>
#include <fmt/core.h>
// IWYU pragma: no_include <gtest/gtest-message.h>
// IWYU pragma: no_include <gtest/gtest-test-part.h>
#include <gtest/gtest.h>
#include <iosfwd>
#include <memory>
#include <vector>

Expand Down
2 changes: 2 additions & 0 deletions src/perf_counter/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <vector>

#include "utils/autoref_ptr.h"
#include "utils/fmt_utils.h"

typedef enum dsn_perf_counter_type_t {
COUNTER_TYPE_NUMBER,
Expand All @@ -42,6 +43,7 @@ typedef enum dsn_perf_counter_type_t {
COUNTER_TYPE_COUNT,
COUNTER_TYPE_INVALID
} dsn_perf_counter_type_t;
USER_DEFINED_ENUM_FORMATTER(dsn_perf_counter_type_t)

typedef enum dsn_perf_counter_percentile_type_t {
COUNTER_PERCENTILE_50,
Expand Down
2 changes: 1 addition & 1 deletion src/replica/backup/cold_backup_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ void cold_backup_context::on_upload_file_complete(const std::string &local_filen
} else {
CHECK_GT(total, 0.0);
update_progress(static_cast<int>(complete_size / total * 1000));
LOG_INFO("{}: the progress of upload checkpoint is {}", name, _progress);
LOG_INFO("{}: the progress of upload checkpoint is {}", name, _progress.load());
}
if (is_ready_for_upload()) {
std::vector<std::string> upload_files;
Expand Down
2 changes: 0 additions & 2 deletions src/replica/duplication/mutation_batch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
// under the License.

#include <fmt/core.h>
#include <fmt/ostream.h>
#include <functional>
#include <iosfwd>
#include <string>
#include <tuple>
#include <utility>
Expand Down
2 changes: 2 additions & 0 deletions src/replica/prepare_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "replica/mutation.h"
#include "replica/replica_base.h"
#include "utils/error_code.h"
#include "utils/fmt_utils.h"

namespace dsn {
namespace replication {
Expand All @@ -45,6 +46,7 @@ enum commit_type
COMMIT_ALL_READY // commit (last_committed, ...<all is_commit_ready mutations> ...]
// - only valid when partition_status::PS_SECONDARY or partition_status::PS_PRIMARY
};
USER_DEFINED_ENUM_FORMATTER(commit_type)

// prepare_list origins from the concept of `prepared list` in PacificA.
// It stores an continuous and ordered list of mutations.
Expand Down
2 changes: 0 additions & 2 deletions src/replica/replica.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@
#include "replica.h"

#include <fmt/core.h>
#include <fmt/ostream.h>
#include <rocksdb/status.h>
#include <algorithm>
#include <functional>
#include <iosfwd>
#include <set>

#include "backup/replica_backup_manager.h"
Expand Down
2 changes: 2 additions & 0 deletions src/replica/replica_learn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
#include <utility>
#include <vector>

#include <fmt/std.h> // IWYU pragma: keep

#include "aio/aio_task.h"
#include "common/fs_manager.h"
#include "common/gpid.h"
Expand Down
1 change: 0 additions & 1 deletion src/replica/replica_stub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include <boost/algorithm/string/replace.hpp>
// IWYU pragma: no_include <ext/alloc_traits.h>
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
Loading

0 comments on commit 5489b43

Please sign in to comment.