clang-format set column width to 100 chars

This commit is contained in:
2025-12-22 19:38:32 +01:00
parent 7b33d0757a
commit 69feceaaae
17 changed files with 77 additions and 120 deletions

View File

@@ -94,8 +94,7 @@ static inline int getexp (unsigned int size) {
}
#ifdef DEBUG
printf ("getexp returns %i (%i bytes) for %i size\n", shift - 1,
(1 << (shift - 1)), size);
printf ("getexp returns %i (%i bytes) for %i size\n", shift - 1, (1 << (shift - 1)), size);
#endif
return shift - 1;
@@ -223,12 +222,10 @@ static inline struct boundary_tag* absorb_right (struct boundary_tag* tag) {
}
static inline struct boundary_tag* split_tag (struct boundary_tag* tag) {
unsigned int remainder =
tag->real_size - sizeof (struct boundary_tag) - tag->size;
unsigned int remainder = tag->real_size - sizeof (struct boundary_tag) - tag->size;
struct boundary_tag* new_tag =
(struct boundary_tag*)((uintptr_t)tag + sizeof (struct boundary_tag) +
tag->size);
(struct boundary_tag*)((uintptr_t)tag + sizeof (struct boundary_tag) + tag->size);
new_tag->magic = LIBALLOC_MAGIC;
new_tag->real_size = remainder;
@@ -285,8 +282,8 @@ static struct boundary_tag* allocate_new_tag (unsigned int size) {
tag->split_right = NULL;
#ifdef DEBUG
printf ("Resource allocated %x of %i pages (%i bytes) for %i size.\n", tag,
pages, pages * l_pageSize, size);
printf ("Resource allocated %x of %i pages (%i bytes) for %i size.\n", tag, pages,
pages * l_pageSize, size);
l_allocated += pages * l_pageSize;
@@ -322,11 +319,9 @@ void* malloc (size_t size) {
tag = l_freePages[index]; // Start at the front of the list.
while (tag != NULL) {
// If there's enough space in this tag.
if ((tag->real_size - sizeof (struct boundary_tag)) >=
(size + sizeof (struct boundary_tag))) {
if ((tag->real_size - sizeof (struct boundary_tag)) >= (size + sizeof (struct boundary_tag))) {
#ifdef DEBUG
printf ("Tag search found %i >= %i\n",
(tag->real_size - sizeof (struct boundary_tag)),
printf ("Tag search found %i >= %i\n", (tag->real_size - sizeof (struct boundary_tag)),
(size + sizeof (struct boundary_tag)));
#endif
break;
@@ -363,17 +358,16 @@ void* malloc (size_t size) {
tag->real_size - size - sizeof (struct boundary_tag), index, 1 << index);
#endif
unsigned int remainder = tag->real_size - size -
sizeof (struct boundary_tag) * 2; // Support a new tag + remainder
unsigned int remainder =
tag->real_size - size - sizeof (struct boundary_tag) * 2; // Support a new tag + remainder
if (((int)(remainder) >
0) /*&& ( (tag->real_size - remainder) >= (1<<MINEXP))*/) {
if (((int)(remainder) > 0) /*&& ( (tag->real_size - remainder) >= (1<<MINEXP))*/) {
int childIndex = getexp (remainder);
if (childIndex >= 0) {
#ifdef DEBUG
printf ("Seems to be splittable: %i >= 2^%i .. %i\n", remainder,
childIndex, (1 << childIndex));
printf ("Seems to be splittable: %i >= 2^%i .. %i\n", remainder, childIndex,
(1 << childIndex));
#endif
struct boundary_tag* new_tag = split_tag (tag);
@@ -381,8 +375,8 @@ void* malloc (size_t size) {
(void)new_tag;
#ifdef DEBUG
printf ("Old tag has become %i bytes, new tag is now %i bytes (%i exp)\n",
tag->real_size, new_tag->real_size, new_tag->index);
printf ("Old tag has become %i bytes, new tag is now %i bytes (%i exp)\n", tag->real_size,
new_tag->real_size, new_tag->index);
#endif
}
}
@@ -391,8 +385,7 @@ void* malloc (size_t size) {
#ifdef DEBUG
l_inuse += size;
printf ("malloc: %x, %i, %i\n", ptr, (int)l_inuse / 1024,
(int)l_allocated / 1024);
printf ("malloc: %x, %i, %i\n", ptr, (int)l_inuse / 1024, (int)l_allocated / 1024);
dump_array ();
#endif
@@ -418,17 +411,15 @@ void free (void* ptr) {
#ifdef DEBUG
l_inuse -= tag->size;
printf ("free: %x, %i, %i\n", ptr, (int)l_inuse / 1024,
(int)l_allocated / 1024);
printf ("free: %x, %i, %i\n", ptr, (int)l_inuse / 1024, (int)l_allocated / 1024);
#endif
// MELT LEFT...
while ((tag->split_left != NULL) && (tag->split_left->index >= 0)) {
#ifdef DEBUG
printf (
"Melting tag left into available memory. Left was %i, becomes %i (%i)\n",
tag->split_left->real_size, tag->split_left->real_size + tag->real_size,
tag->split_left->real_size);
printf ("Melting tag left into available memory. Left was %i, becomes %i (%i)\n",
tag->split_left->real_size, tag->split_left->real_size + tag->real_size,
tag->split_left->real_size);
#endif
tag = melt_left (tag);
remove_tag (tag);
@@ -437,10 +428,9 @@ void free (void* ptr) {
// MELT RIGHT...
while ((tag->split_right != NULL) && (tag->split_right->index >= 0)) {
#ifdef DEBUG
printf (
"Melting tag right into available memory. This was was %i, becomes %i (%i)\n",
tag->real_size, tag->split_right->real_size + tag->real_size,
tag->split_right->real_size);
printf ("Melting tag right into available memory. This was was %i, becomes %i (%i)\n",
tag->real_size, tag->split_right->real_size + tag->real_size,
tag->split_right->real_size);
#endif
tag = absorb_right (tag);
}
@@ -481,9 +471,8 @@ void free (void* ptr) {
insert_tag (tag, index);
#ifdef DEBUG
printf (
"Returning tag with %i bytes (requested %i bytes), which has exponent: %i\n",
tag->real_size, tag->size, index);
printf ("Returning tag with %i bytes (requested %i bytes), which has exponent: %i\n",
tag->real_size, tag->size, index);
dump_array ();
#endif

View File

@@ -31,8 +31,8 @@ void pmm_init (void) {
"framebuffer",
"acpi tables"};
DEBUG ("memmap entry: %-25s %p (%zu bytes)\n", entry_strings[entry->type],
entry->base, entry->length);
DEBUG ("memmap entry: %-25s %p (%zu bytes)\n", entry_strings[entry->type], entry->base,
entry->length);
if (entry->type == LIMINE_MEMMAP_USABLE && region < PMM_REGIONS_MAX) {
struct pmm_region* pmm_region = &pmm.regions[region];
@@ -87,8 +87,7 @@ void pmm_init (void) {
* Find free space for a block range. For every bit of the bitmap, we test nblks bits forward.
* bm_test_region helps us out, because it automatically does range checks. See comments there.
*/
static size_t pmm_find_free_space (struct pmm_region* pmm_region,
size_t nblks) {
static size_t pmm_find_free_space (struct pmm_region* pmm_region, size_t nblks) {
for (size_t bit = 0; bit < pmm_region->bm.nbits; bit++) {
if (bm_test_region (&pmm_region->bm, bit, nblks)) {
continue;
@@ -140,8 +139,7 @@ void pmm_free (physaddr_t p_addr, size_t nblks) {
continue;
/* If aligned_p_addr is within the range if this region, it belongs to it. */
if (aligned_p_addr >= pmm_region->membase &&
aligned_p_addr < pmm_region->size) {
if (aligned_p_addr >= pmm_region->membase && aligned_p_addr < pmm_region->size) {
physaddr_t addr = aligned_p_addr - pmm_region->membase;
size_t bit = div_align_up (addr, PAGE_SIZE);