Skip to content

Commit

Permalink
Move to clang-format 15
Browse files Browse the repository at this point in the history
The current version requires clang-format-9.  This now getting hard to get.
This commit moves it to the clang-format-15, which is the latest in 22.04.
  • Loading branch information
mjp41 committed Jul 17, 2023
1 parent dc12688 commit 731fd8a
Show file tree
Hide file tree
Showing 16 changed files with 274 additions and 341 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ function(clangformat_targets)
# tool. It does not work with older versions as AfterCaseLabel is not supported
# in earlier versions.
find_program(CLANG_FORMAT NAMES
clang-format90 clang-format-9)
clang-format150 clang-format-15)

# If we've found a clang-format tool, generate a target for it, otherwise emit
# a warning.
Expand Down
120 changes: 56 additions & 64 deletions src/snmalloc/aal/aal_concept.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,87 +14,79 @@ namespace snmalloc
* machine word size, and an upper bound on the address space size
*/
template<typename AAL>
concept IsAAL_static_members = requires()
{
typename std::integral_constant<uint64_t, AAL::aal_features>;
typename std::integral_constant<int, AAL::aal_name>;
typename std::integral_constant<std::size_t, AAL::bits>;
typename std::integral_constant<std::size_t, AAL::address_bits>;
};
concept IsAAL_static_members =
requires() {
typename std::integral_constant<uint64_t, AAL::aal_features>;
typename std::integral_constant<int, AAL::aal_name>;
typename std::integral_constant<std::size_t, AAL::bits>;
typename std::integral_constant<std::size_t, AAL::address_bits>;
};

/**
* AALs provide a prefetch operation.
*/
template<typename AAL>
concept IsAAL_prefetch = requires(void* ptr)
{
{
AAL::prefetch(ptr)
}
noexcept->ConceptSame<void>;
};
concept IsAAL_prefetch = requires(void* ptr) {
{
AAL::prefetch(ptr)
} noexcept -> ConceptSame<void>;
};

/**
* AALs provide a notion of high-precision timing.
*/
template<typename AAL>
concept IsAAL_tick = requires()
{
{
AAL::tick()
}
noexcept->ConceptSame<uint64_t>;
};
concept IsAAL_tick = requires() {
{
AAL::tick()
} noexcept -> ConceptSame<uint64_t>;
};

template<typename AAL>
concept IsAAL_capptr_methods =
requires(capptr::Chunk<void> auth, capptr::AllocFull<void> ret, size_t sz)
{
/**
* Produce a pointer with reduced authority from a more privilged pointer.
* The resulting pointer will have base at auth's address and length of
* exactly sz. auth+sz must not exceed auth's limit.
*/
{
AAL::template capptr_bound<void, capptr::bounds::Chunk>(auth, sz)
}
noexcept->ConceptSame<capptr::Chunk<void>>;
requires(capptr::Chunk<void> auth, capptr::AllocFull<void> ret, size_t sz) {
/**
* Produce a pointer with reduced authority from a more privilged pointer.
* The resulting pointer will have base at auth's address and length of
* exactly sz. auth+sz must not exceed auth's limit.
*/
{
AAL::template capptr_bound<void, capptr::bounds::Chunk>(auth, sz)
} noexcept -> ConceptSame<capptr::Chunk<void>>;

/**
* "Amplify" by copying the address of one pointer into one of higher
* privilege. The resulting pointer differs from auth only in address.
*/
{
AAL::capptr_rebound(auth, ret)
}
noexcept->ConceptSame<capptr::Chunk<void>>;
/**
* "Amplify" by copying the address of one pointer into one of higher
* privilege. The resulting pointer differs from auth only in address.
*/
{
AAL::capptr_rebound(auth, ret)
} noexcept -> ConceptSame<capptr::Chunk<void>>;

/**
* Round up an allocation size to a size this architecture can represent.
* While there may also, in general, be alignment requirements for
* representability, in snmalloc so far we have not had reason to consider
* these explicitly: when we use our...
*
* - sizeclass machinery (for user-facing data), we assume that all
* sizeclasses describe architecturally representable aligned-and-sized
* regions
*
* - Range machinery (for internal meta-data), we always choose NAPOT
* regions big enough for the requested size (returning space above the
* allocation within such regions for use as smaller NAPOT regions).
*
* That is, capptr_size_round is not needed on the user-facing fast paths,
* merely internally for bootstrap and metadata management.
*/
{
AAL::capptr_size_round(sz)
}
noexcept->ConceptSame<size_t>;
};
/**
* Round up an allocation size to a size this architecture can represent.
* While there may also, in general, be alignment requirements for
* representability, in snmalloc so far we have not had reason to consider
* these explicitly: when we use our...
*
* - sizeclass machinery (for user-facing data), we assume that all
* sizeclasses describe architecturally representable aligned-and-sized
* regions
*
* - Range machinery (for internal meta-data), we always choose NAPOT
* regions big enough for the requested size (returning space above the
* allocation within such regions for use as smaller NAPOT regions).
*
* That is, capptr_size_round is not needed on the user-facing fast paths,
* merely internally for bootstrap and metadata management.
*/
{
AAL::capptr_size_round(sz)
} noexcept -> ConceptSame<size_t>;
};

template<typename AAL>
concept IsAAL = IsAAL_static_members<AAL>&& IsAAL_prefetch<AAL>&&
IsAAL_tick<AAL>&& IsAAL_capptr_methods<AAL>;
concept IsAAL = IsAAL_static_members<AAL> && IsAAL_prefetch<AAL> &&
IsAAL_tick<AAL> && IsAAL_capptr_methods<AAL>;

} // namespace snmalloc
#endif
6 changes: 2 additions & 4 deletions src/snmalloc/backend/fixedglobalconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,11 @@ namespace snmalloc
* C++, and not just its initializer fragment, to initialize a non-prefix
* subset of the flags (in any order, at that).
*/
static constexpr Flags Options = []() constexpr
{
static constexpr Flags Options = []() constexpr {
Flags opts = {};
opts.HasDomesticate = true;
return opts;
}
();
}();

// This needs to be a forward reference as the
// thread local state will need to know about this.
Expand Down
7 changes: 4 additions & 3 deletions src/snmalloc/ds/aba.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,10 @@ namespace snmalloc
error("Only one inflight ABA operation at a time is allowed.");
operation_in_flight = true;
# endif
return Cmp{{independent.ptr.load(std::memory_order_relaxed),
independent.aba.load(std::memory_order_relaxed)},
this};
return Cmp{
{independent.ptr.load(std::memory_order_relaxed),
independent.aba.load(std::memory_order_relaxed)},
this};
}

struct Cmp
Expand Down
8 changes: 4 additions & 4 deletions src/snmalloc/ds_core/mitigations.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ namespace snmalloc
*/
full_checks + cheri_checks + clear_meta - freelist_forward_edge -
pal_enforce_access :
/**
* clear_meta is important on CHERI to avoid leaking capabilities.
*/
sanity_checks + cheri_checks + clear_meta;
/**
* clear_meta is important on CHERI to avoid leaking capabilities.
*/
sanity_checks + cheri_checks + clear_meta;
#else
CHECK_CLIENT ? full_checks : no_checks;
#endif
Expand Down
79 changes: 31 additions & 48 deletions src/snmalloc/ds_core/redblacktree.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ namespace snmalloc
* ID.
*/
template<typename Rep>
concept RBRepTypes = requires()
{
typename Rep::Handle;
typename Rep::Contents;
};
concept RBRepTypes = requires() {
typename Rep::Handle;
typename Rep::Contents;
};

/**
* The representation must define operations on the holder and contents
Expand All @@ -41,50 +40,36 @@ namespace snmalloc
*/
template<typename Rep>
concept RBRepMethods =
requires(typename Rep::Handle hp, typename Rep::Contents k, bool b)
{
{
Rep::get(hp)
}
->ConceptSame<typename Rep::Contents>;
{
Rep::set(hp, k)
}
->ConceptSame<void>;
{
Rep::is_red(k)
}
->ConceptSame<bool>;
{
Rep::set_red(k, b)
}
->ConceptSame<void>;
{
Rep::ref(b, k)
}
->ConceptSame<typename Rep::Handle>;
{
Rep::null
}
->ConceptSameModRef<const typename Rep::Contents>;
{
typename Rep::Handle
requires(typename Rep::Handle hp, typename Rep::Contents k, bool b) {
{
Rep::get(hp)
} -> ConceptSame<typename Rep::Contents>;
{
Rep::set(hp, k)
} -> ConceptSame<void>;
{
Rep::is_red(k)
} -> ConceptSame<bool>;
{
const_cast<
Rep::set_red(k, b)
} -> ConceptSame<void>;
{
Rep::ref(b, k)
} -> ConceptSame<typename Rep::Handle>;
{
Rep::null
} -> ConceptSameModRef<const typename Rep::Contents>;
{
typename Rep::Handle{const_cast<
std::remove_const_t<std::remove_reference_t<decltype(Rep::root)>>*>(
&Rep::root)
}
}
->ConceptSame<typename Rep::Handle>;
};
&Rep::root)}
} -> ConceptSame<typename Rep::Handle>;
};

template<typename Rep>
concept RBRep = //
RBRepTypes<Rep> //
&& RBRepMethods<Rep> //
&& ConceptSame<
decltype(Rep::null),
std::add_const_t<typename Rep::Contents>>;
RBRepTypes<Rep> && RBRepMethods<Rep> &&
ConceptSame<decltype(Rep::null), std::add_const_t<typename Rep::Contents>>;
#endif

/**
Expand Down Expand Up @@ -490,8 +475,7 @@ namespace snmalloc
*/
path.move(true);
while (path.move(false))
{
}
{}

K curr = path.curr();

Expand Down Expand Up @@ -742,8 +726,7 @@ namespace snmalloc

auto path = get_root_path();
while (path.move(true))
{
}
{}

K result = path.curr();

Expand Down
Loading

0 comments on commit 731fd8a

Please sign in to comment.