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

Update to metall 0.28 #10

Merged
merged 13 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from 10 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 CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.22)
project(metall-ffi VERSION 0.2.2)
project(metall-ffi VERSION 0.2.4)

include(cmake/boilerplate_init.cmake)
boilerplate_init()
Expand Down
16 changes: 11 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,22 @@ class Recipe(ConanFile):

# Binary configuration
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False], "with_test_deps": [True, False]}
default_options = {"shared": False, "fPIC": True, "with_test_deps": False}
options = {
"shared": [True, False],
"fPIC": [True, False],
"with_test_deps": [True, False],
}
default_options = {
"shared": False,
"fPIC": True,
"with_test_deps": False,
}
exports = "LICENSE",
exports_sources = "src/*", "CMakeLists.txt", "cmake/*"
generators = "CMakeDeps", "CMakeToolchain"

def requirements(self):
self.requires("metall/0.23.1", transitive_headers=True)
self.requires("boost/1.83.0", transitive_headers=True, force=True)
self.requires("metall/0.28", transitive_headers=True)

if self.options.with_test_deps:
self.requires("doctest/2.4.11")
Expand Down Expand Up @@ -64,5 +71,4 @@ def package_info(self):
self.cpp_info.set_property("cmake_target_name", f"{self.name}::{self.name}")
self.cpp_info.requires = [
"metall::metall",
"boost::headers",
]
4 changes: 4 additions & 0 deletions src/dice/ffi/metall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ metall_manager *metall_create(char const *path) {
return reinterpret_cast<metall_manager *>(manager);
}

bool metall_is_read_only(metall_manager const *manager) {
return reinterpret_cast<metall_manager_t const *>(manager)->read_only();
}

bool metall_snapshot(metall_manager *manager, char const *dst_path) {
return reinterpret_cast<metall_manager_t *>(manager)->snapshot(dst_path);
}
Expand Down
9 changes: 9 additions & 0 deletions src/dice/ffi/metall.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <stdbool.h>
#include <stddef.h>

#include <metall/logger_interface.h>

#ifdef __cplusplus
extern "C" {
#endif
Expand Down Expand Up @@ -35,6 +37,13 @@ metall_manager *metall_open_read_only(char const *path);
*/
metall_manager *metall_create(char const *path);

/**
* @brief Returns true if the metall manager was opened as read-only
* @param manager manager to check
* @return true if the given manager was openened as read-only
*/
bool metall_is_read_only(metall_manager const *manager);

/**
* @brief Creates a snapshot of the metall datastore of manager and places it at dst_path
* @param manager manager to perform snapshot
Expand Down
3 changes: 2 additions & 1 deletion src/dice/ffi/metall_internal.hpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#ifndef DICE_METALLFFI_METALLINTERNAL_HPP
#define DICE_METALLFFI_METALLINTERNAL_HPP

#define METALL_LOGGER_EXTERN_C 1
#include <metall/metall.hpp>

namespace dice::metall_ffi::internal {
/**
* @brief The metall manager type used internally.
* This object type is whats actually behind the opaque ::metall_manager * in the interface
*/
using metall_manager = metall::basic_manager<uint32_t, 1ULL << 28>;
using metall_manager = metall::basic_manager<metall::kernel::storage, metall::kernel::segment_storage, uint32_t, 1ULL << 28>;
} // namespace

#endif//DICE_METALLFFI_METALLINTERNAL_HPP
4 changes: 4 additions & 0 deletions test_package/example.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include <dice/ffi/metall.h>

extern "C" void metall_log(metall_log_level, char const *, size_t, char const *) {
// noop
}

int main() {
metall_open("/tmp/test");
}
6 changes: 5 additions & 1 deletion tests/tests_Sanity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <string>
#include <random>

extern "C" void metall_log(metall_log_level lvl, char const *file, size_t line, char const *msg) {
std::cerr << lvl << " " << file << ":" << line << ": " << msg << std::endl;
}

TEST_SUITE("metall-ffi") {
TEST_CASE("sanity check") {
char const *obj_name = "obj";
Expand All @@ -19,7 +23,7 @@ TEST_SUITE("metall-ffi") {
}

{
auto *ptr = static_cast<size_t *>(metall_malloc(manager, obj_name, sizeof(size_t)));
liss-h marked this conversation as resolved.
Show resolved Hide resolved
auto *ptr = static_cast<size_t *>(metall_malloc(manager, obj_name, sizeof(size_t) * 2));
CHECK_NE(ptr, nullptr);
CHECK_EQ(reinterpret_cast<uintptr_t>(ptr) % alignof(size_t), 0);

Expand Down
Loading