Skip to content

Commit

Permalink
Minor update to clangformat file. (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjp41 authored Nov 22, 2024
1 parent 45dbdb0 commit 69e280c
Show file tree
Hide file tree
Showing 33 changed files with 60 additions and 0 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
ReflowComments: true
SeparateDefinitionBlocks: Always
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/aal/aal_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#endif

#include <cstddef>

namespace snmalloc
{
/**
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/backend_helpers/buddy.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace snmalloc

public:
constexpr Buddy() = default;

/**
* Add a block to the buddy allocator.
*
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/backend_helpers/commonconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,5 @@ namespace snmalloc
}
}
} // namespace snmalloc

#include "../mem/remotecache.h"
1 change: 1 addition & 0 deletions src/snmalloc/backend_helpers/smallbuddyrange.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace snmalloc
static constexpr Contents root = nullptr;

static constexpr address_t MASK = 1;

static void set(Handle ptr, Contents r)
{
SNMALLOC_ASSERT((address_cast(r) & MASK) == 0);
Expand Down
2 changes: 2 additions & 0 deletions src/snmalloc/ds/flaglock.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ namespace snmalloc
{}

void set_owner() {}

void clear_owner() {}

void assert_not_owned_by_current_thread() {}
};

Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/ds_core/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ namespace snmalloc
*/
template<typename Fn>
struct function_ref;

template<typename R, typename... Args>
struct function_ref<R(Args...)>
{
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/ds_core/redblacktree.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ namespace snmalloc
{
return ptr != t.ptr;
}

///@}

bool is_null()
Expand Down
2 changes: 2 additions & 0 deletions src/snmalloc/global/memcpy.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ namespace snmalloc
{
char data[Size];
};

auto* d = static_cast<Block*>(dst);
auto* s = static_cast<const Block*>(src);
*d = *s;
Expand Down Expand Up @@ -254,6 +255,7 @@ namespace snmalloc
{
void* p[2];
};

if (sizeof(Ptr2) <= len)
{
auto dp = static_cast<Ptr2*>(dst);
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/mem/backend_concept.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# include "sizeclasstable.h"

# include <cstddef>

namespace snmalloc
{
/**
Expand Down
2 changes: 2 additions & 0 deletions src/snmalloc/mem/corealloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace snmalloc
*/
using BackendSlabMetadata = typename Config::Backend::SlabMetadata;
using PagemapEntry = typename Config::PagemapEntry;

/// }@

/**
Expand Down Expand Up @@ -197,6 +198,7 @@ namespace snmalloc
{
capptr::AllocFull<PreAllocObject> next;
};

// The following code implements Sattolo's algorithm for generating
// random cyclic permutations. This implementation is in the opposite
// direction, so that the original space does not need initialising.
Expand Down
3 changes: 3 additions & 0 deletions src/snmalloc/mem/external_alloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace snmalloc::external_alloc
}
# elif defined(__APPLE__)
# include <malloc/malloc.h>

namespace snmalloc::external_alloc
{
inline size_t malloc_usable_size(void* ptr)
Expand All @@ -30,6 +31,7 @@ namespace snmalloc::external_alloc
}
# elif defined(__linux__) || defined(__HAIKU__)
# include <malloc.h>

namespace snmalloc::external_alloc
{
using ::malloc_usable_size;
Expand All @@ -41,6 +43,7 @@ namespace snmalloc::external_alloc
}
# elif defined(__FreeBSD__)
# include <malloc_np.h>

namespace snmalloc::external_alloc
{
using ::malloc_usable_size;
Expand Down
4 changes: 4 additions & 0 deletions src/snmalloc/mem/freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,7 @@ namespace snmalloc

protected:
constexpr Prev(address_t prev) : prev(prev) {}

constexpr Prev() = default;

address_t replace(address_t next)
Expand Down Expand Up @@ -570,10 +571,12 @@ namespace snmalloc
struct KeyTweak
{
address_t key_tweak = 0;

SNMALLOC_FAST_PATH address_t get()
{
return key_tweak;
}

void set(address_t kt)
{
key_tweak = kt;
Expand All @@ -588,6 +591,7 @@ namespace snmalloc
{
return 0;
}

void set(address_t) {}
};

Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/mem/localalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <string.h>
#include <utility>

namespace snmalloc
{
enum Boundary
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/mem/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ namespace snmalloc
{
return meta &= ~META_BOUNDARY_BIT;
}

///@}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/snmalloc/override/jemalloc_compat.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include <string.h>

using namespace snmalloc;

namespace
{
/**
Expand Down Expand Up @@ -88,7 +89,9 @@ extern "C"
// statistics on fork if built with statistics.

SNMALLOC_EXPORT SNMALLOC_USED_FUNCTION inline void _malloc_prefork(void) {}

SNMALLOC_EXPORT SNMALLOC_USED_FUNCTION inline void _malloc_postfork(void) {}

SNMALLOC_EXPORT SNMALLOC_USED_FUNCTION inline void _malloc_first_thread(void)
{}

Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/override/malloc-extensions.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#pragma once

/**
* Malloc extensions
*
Expand Down
2 changes: 2 additions & 0 deletions src/snmalloc/pal/pal_freebsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
*/
extern "C" ssize_t __sys_writev(int fd, const struct iovec* iov, int iovcnt);
extern "C" int __sys_fsync(int fd);

/// @}

namespace snmalloc
Expand Down Expand Up @@ -57,6 +58,7 @@ namespace snmalloc
static constexpr size_t address_bits = (Aal::bits == 32) ?
Aal::address_bits :
(Aal::aal_name == RISCV ? 38 : Aal::address_bits);

// TODO, if we ever backport to MIPS, this should yield 39 there.

/**
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/pal/pal_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ namespace snmalloc
uint64_t result;
char buffer[sizeof(uint64_t)];
};

ssize_t ret;

// give a try to SYS_getrandom
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/pal/pal_netbsd.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
extern "C" ssize_t _sys_writev(int fd, const struct iovec* iov, int iovcnt);
extern "C" int _sys_fsync(int fd);

/// @}

namespace snmalloc
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/pal/pal_open_enclave.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace snmalloc
UNUSED(str);
oe_abort();
}

static constexpr size_t address_bits = Aal::address_bits;
static constexpr size_t page_size = Aal::smallest_page_size;
};
Expand Down
1 change: 1 addition & 0 deletions src/snmalloc/pal/pal_posix.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,7 @@ namespace snmalloc
uint64_t result;
char buffer[sizeof(uint64_t)];
};

ssize_t ret;
int flags = O_RDONLY;
#if defined(O_CLOEXEC)
Expand Down
3 changes: 3 additions & 0 deletions src/snmalloc/pal/pal_windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ namespace snmalloc

# ifdef PLATFORM_HAS_WAITONADDRESS
using WaitingWord = char;

template<class T>
static void wait_on_address(std::atomic<T>& addr, T expected)
{
Expand All @@ -247,11 +248,13 @@ namespace snmalloc
break;
}
}

template<class T>
static void notify_one_on_address(std::atomic<T>& addr)
{
::WakeByAddressSingle(&addr);
}

template<class T>
static void notify_all_on_address(std::atomic<T>& addr)
{
Expand Down
1 change: 1 addition & 0 deletions src/test/func/client_meta/client_meta.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ namespace snmalloc
using Alloc = snmalloc::LocalAllocator<snmalloc::StandardConfigClientMeta<
ArrayClientMetaDataProvider<std::atomic<size_t>>>>;
}

#define SNMALLOC_PROVIDE_OWN_CONFIG
#include <snmalloc/snmalloc.h>

Expand Down
1 change: 1 addition & 0 deletions src/test/func/domestication/domestication.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ int main()

// Specify type of allocator
# define SNMALLOC_PROVIDE_OWN_CONFIG

namespace snmalloc
{
class CustomConfig : public CommonConfig
Expand Down
1 change: 1 addition & 0 deletions src/test/func/miracle_ptr/miracle_ptr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ namespace snmalloc
using Alloc = snmalloc::LocalAllocator<snmalloc::StandardConfigClientMeta<
ArrayClientMetaDataProvider<std::atomic<size_t>>>>;
}

# define SNMALLOC_PROVIDE_OWN_CONFIG
# include <snmalloc/snmalloc.h>

Expand Down
3 changes: 3 additions & 0 deletions src/test/func/pagemap/pagemap.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@

using namespace snmalloc;
static constexpr size_t GRANULARITY_BITS = 20;

struct T
{
size_t v = 99;

T(size_t v) : v(v) {}

T() {}
};

Expand Down
8 changes: 8 additions & 0 deletions src/test/func/redblack/redblack.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,36 @@ struct NodeRef
static constexpr size_t offset = 10000;

size_t* ptr;

constexpr NodeRef(size_t* p) : ptr(p) {}

constexpr NodeRef() : ptr(nullptr) {}

constexpr NodeRef(const NodeRef& other) : ptr(other.ptr) {}

constexpr NodeRef(NodeRef&& other) : ptr(other.ptr) {}

bool operator!=(const NodeRef& other) const
{
return ptr != other.ptr;
}

NodeRef& operator=(const NodeRef& other)
{
ptr = other.ptr;
return *this;
}

void set(uint16_t val)
{
*ptr = ((size_t(val) + offset) << 1) + (*ptr & 1);
}

explicit operator uint16_t()
{
return uint16_t((*ptr >> 1) - offset);
}

explicit operator size_t*()
{
return ptr;
Expand Down
1 change: 1 addition & 0 deletions src/test/func/sandbox/sandbox.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace
{
SNMALLOC_CHECK(0 && "Should never be called!");
}

/**
* Sandbox class. Allocates a memory region and an allocator that can
* allocate into this from the outside.
Expand Down
1 change: 1 addition & 0 deletions src/test/func/two_alloc_types/alloc1.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

// Specify type of allocator
#define SNMALLOC_PROVIDE_OWN_CONFIG

namespace snmalloc
{
using CustomGlobals = FixedRangeConfig<PALNoAlloc<DefaultPal>>;
Expand Down
1 change: 1 addition & 0 deletions src/test/func/two_alloc_types/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ extern "C" void* enclave_malloc(size_t);
extern "C" void enclave_free(void*);

using namespace snmalloc;

int main()
{
setup();
Expand Down
5 changes: 5 additions & 0 deletions src/test/perf/msgpass/msgpass.cc
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ void chatty(const char* p, ...)
struct MyAlloc
{
MyAlloc() {}

void* alloc(size_t sz)
{
return malloc(sz);
}

void dealloc(void* p)
{
free(p);
Expand All @@ -59,11 +61,14 @@ struct MyAlloc
struct MyAlloc
{
snmalloc::Alloc& a;

MyAlloc() : a(ThreadAlloc::get()) {}

void* alloc(size_t sz)
{
return a.alloc(sz);
}

void dealloc(void* p)
{
a.dealloc(p);
Expand Down
Loading

0 comments on commit 69e280c

Please sign in to comment.