summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-05-03 21:39:36 +0200
committerMaria Matejka <mq@ucw.cz>2023-05-06 10:50:31 +0200
commitfac64056696680a21f1121d15620969876407ef7 (patch)
treee9180bb322f3f4c03b52ba0d9617f09d262007a1
parentfa973c2c153eaaa1abcef8d0f52a0b1fd68c37d8 (diff)
Page allocator: indentation of messy ifdef blocks
-rw-r--r--sysdep/unix/alloc.c120
1 files changed, 60 insertions, 60 deletions
diff --git a/sysdep/unix/alloc.c b/sysdep/unix/alloc.c
index 1b951da2..22b9a88c 100644
--- a/sysdep/unix/alloc.c
+++ b/sysdep/unix/alloc.c
@@ -17,79 +17,79 @@
#include <unistd.h>
#ifdef HAVE_MMAP
-#include <sys/mman.h>
+# include <sys/mman.h>
#endif
#ifdef CONFIG_DISABLE_THP
-#include <sys/prctl.h>
-#ifndef PR_SET_THP_DISABLE
-#define PR_SET_THP_DISABLE 41
-#endif
+# include <sys/prctl.h>
+# ifndef PR_SET_THP_DISABLE
+# define PR_SET_THP_DISABLE 41
+# endif
#endif
long page_size = 0;
#ifdef HAVE_MMAP
-#define KEEP_PAGES_MAX 512
-#define KEEP_PAGES_MIN 32
-#define KEEP_PAGES_MAX_LOCAL 16
-#define ALLOC_PAGES_AT_ONCE 8
-
-STATIC_ASSERT(KEEP_PAGES_MIN * 4 < KEEP_PAGES_MAX);
-STATIC_ASSERT(ALLOC_PAGES_AT_ONCE < KEEP_PAGES_MAX_LOCAL);
-
-static _Bool use_fake = 0;
-static _Bool initialized = 0;
-
-#if DEBUGGING
-struct free_page {
- node unused[42];
- struct free_page * _Atomic next;
-};
-#else
-struct free_page {
- struct free_page * _Atomic next;
-};
-#endif
-
-#define EP_POS_MAX ((page_size - OFFSETOF(struct empty_pages, pages)) / sizeof (void *))
-
-struct empty_pages {
- struct empty_pages *next;
- uint pos;
- void *pages[0];
-};
-
-DEFINE_DOMAIN(resource);
-static DOMAIN(resource) empty_pages_domain;
-static struct empty_pages *empty_pages = NULL;
-
-static struct free_page * _Atomic page_stack = NULL;
-static _Thread_local struct free_page * local_page_stack = NULL;
-
-static void page_cleanup(void *);
-static event page_cleanup_event = { .hook = page_cleanup, };
-#define SCHEDULE_CLEANUP do if (initialized && !shutting_down) ev_send(&global_event_list, &page_cleanup_event); while (0)
-
-_Atomic int pages_kept = 0;
-_Atomic int pages_kept_locally = 0;
-static _Thread_local int pages_kept_here = 0;
-
-static void *
-alloc_sys_page(void)
-{
- void *ptr = mmap(NULL, page_size * ALLOC_PAGES_AT_ONCE, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+# define KEEP_PAGES_MAX 512
+# define KEEP_PAGES_MIN 32
+# define KEEP_PAGES_MAX_LOCAL 16
+# define ALLOC_PAGES_AT_ONCE 8
+
+ STATIC_ASSERT(KEEP_PAGES_MIN * 4 < KEEP_PAGES_MAX);
+ STATIC_ASSERT(ALLOC_PAGES_AT_ONCE < KEEP_PAGES_MAX_LOCAL);
+
+ static _Bool use_fake = 0;
+ static _Bool initialized = 0;
+
+# if DEBUGGING
+ struct free_page {
+ node unused[42];
+ struct free_page * _Atomic next;
+ };
+# else
+ struct free_page {
+ struct free_page * _Atomic next;
+ };
+# endif
+
+# define EP_POS_MAX ((page_size - OFFSETOF(struct empty_pages, pages)) / sizeof (void *))
+
+ struct empty_pages {
+ struct empty_pages *next;
+ uint pos;
+ void *pages[0];
+ };
+
+ DEFINE_DOMAIN(resource);
+ static DOMAIN(resource) empty_pages_domain;
+ static struct empty_pages *empty_pages = NULL;
+
+ static struct free_page * _Atomic page_stack = NULL;
+ static _Thread_local struct free_page * local_page_stack = NULL;
+
+ static void page_cleanup(void *);
+ static event page_cleanup_event = { .hook = page_cleanup, };
+# define SCHEDULE_CLEANUP do if (initialized && !shutting_down) ev_send(&global_event_list, &page_cleanup_event); while (0)
+
+ _Atomic int pages_kept = 0;
+ _Atomic int pages_kept_locally = 0;
+ static _Thread_local int pages_kept_here = 0;
+
+ static void *
+ alloc_sys_page(void)
+ {
+ void *ptr = mmap(NULL, page_size * ALLOC_PAGES_AT_ONCE, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- if (ptr == MAP_FAILED)
- die("mmap(%ld) failed: %m", (s64) page_size);
+ if (ptr == MAP_FAILED)
+ die("mmap(%ld) failed: %m", (s64) page_size);
- return ptr;
-}
+ return ptr;
+ }
-extern int shutting_down; /* Shutdown requested. */
+ extern int shutting_down; /* Shutdown requested. */
#else // ! HAVE_MMAP
-#define use_fake 1
+# define use_fake 1
#endif
void *