Make lib work as a c or c++ library
This commit is contained in:
@@ -594,7 +594,7 @@ bool checkInvariants(Node *node) {
|
||||
|
||||
} // namespace
|
||||
|
||||
struct ConflictSet::Impl {
|
||||
struct __attribute__((__visibility__("hidden"))) ConflictSet::Impl {
|
||||
Node *root;
|
||||
int64_t oldestVersion;
|
||||
explicit Impl(int64_t oldestVersion) noexcept
|
||||
@@ -772,8 +772,10 @@ ConflictSet::ConflictSet(int64_t oldestVersion)
|
||||
: impl(new(malloc(sizeof(Impl))) Impl{oldestVersion}) {}
|
||||
|
||||
ConflictSet::~ConflictSet() {
|
||||
impl->~Impl();
|
||||
free(impl);
|
||||
if (impl) {
|
||||
impl->~Impl();
|
||||
free(impl);
|
||||
}
|
||||
}
|
||||
|
||||
ConflictSet::ConflictSet(ConflictSet &&other) noexcept
|
||||
@@ -784,6 +786,38 @@ ConflictSet &ConflictSet::operator=(ConflictSet &&other) noexcept {
|
||||
return *this;
|
||||
}
|
||||
|
||||
using ConflictSet_Result = ConflictSet::Result;
|
||||
using ConflictSet_Key = ConflictSet::Key;
|
||||
using ConflictSet_ReadRange = ConflictSet::ReadRange;
|
||||
using ConflictSet_WriteRange = ConflictSet::WriteRange;
|
||||
|
||||
extern "C" {
|
||||
__attribute__((__visibility__("default"))) void
|
||||
ConflictSet_check(void *cs, const ConflictSet_ReadRange *reads,
|
||||
ConflictSet_Result *results, int count) {
|
||||
((ConflictSet::Impl *)cs)->check(reads, results, count);
|
||||
}
|
||||
__attribute__((__visibility__("default"))) void
|
||||
ConflictSet_addWrites(void *cs, const ConflictSet_WriteRange *writes,
|
||||
int count) {
|
||||
((ConflictSet::Impl *)cs)->addWrites(writes, count);
|
||||
}
|
||||
__attribute__((__visibility__("default"))) void
|
||||
ConflictSet_setOldestVersion(void *cs, int64_t oldestVersion) {
|
||||
((ConflictSet::Impl *)cs)->setOldestVersion(oldestVersion);
|
||||
}
|
||||
__attribute__((__visibility__("default"))) void *
|
||||
ConflictSet_create(int64_t oldestVersion) {
|
||||
return new (malloc(sizeof(ConflictSet::Impl)))
|
||||
ConflictSet::Impl{oldestVersion};
|
||||
}
|
||||
__attribute__((__visibility__("default"))) void ConflictSet_destroy(void *cs) {
|
||||
using Impl = ConflictSet::Impl;
|
||||
((Impl *)cs)->~Impl();
|
||||
free(cs);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_TESTS
|
||||
int main(void) {
|
||||
int64_t writeVersion = 0;
|
||||
|
Reference in New Issue
Block a user