diff --git a/.clang-format b/.clang-format index 56335676..73bb0409 100644 --- a/.clang-format +++ b/.clang-format @@ -7,3 +7,23 @@ AllowShortFunctionsOnASingleLine: false AlignConsecutiveMacros: true IndentCaseLabels: true ColumnLimit: 100 +IncludeBlocks: Regroup + +# Include block order goes like this +# - config.h style files, including ../config.h +# - system headers (<>) +# - All m1n1 headers, starting with the "this file" header, rest sorted +# - 3rd party code headers +# - build artifact headers (stuff outside of src/) +IncludeCategories: + - Regex: '^"(\.\./)*config\.h"$' + Priority: -2 + - Regex: '^<' + Priority: -1 + - Regex: '^"\.\./' + Priority: 3 + - Regex: '/' + Priority: 2 + - Regex: '.*' + Priority: 0 + SortPriority: 1 diff --git a/src/adt.h b/src/adt.h index 6497a2f0..78934e1e 100644 --- a/src/adt.h +++ b/src/adt.h @@ -3,10 +3,11 @@ #ifndef XDT_H #define XDT_H -#include "types.h" #include #include +#include "types.h" + #define ADT_ERR_NOTFOUND 1 #define ADT_ERR_BADOFFSET 4 #define ADT_ERR_BADPATH 5 diff --git a/src/kboot.c b/src/kboot.c index 030ba7f4..ff381eb0 100644 --- a/src/kboot.c +++ b/src/kboot.c @@ -5,7 +5,6 @@ #include "adt.h" #include "exception.h" #include "kboot.h" -#include "libfdt/libfdt.h" #include "malloc.h" #include "memory.h" #include "smp.h" @@ -13,6 +12,8 @@ #include "utils.h" #include "xnuboot.h" +#include "libfdt/libfdt.h" + static void *dt = NULL; static int dt_bufsize = 0; static char *bootargs = NULL; diff --git a/src/proxy.c b/src/proxy.c index 7cb699a7..c2bc7dca 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -4,14 +4,15 @@ #include "kboot.h" #include "malloc.h" #include "memory.h" -#include "minilzlib/minlzma.h" #include "smp.h" -#include "tinf/tinf.h" #include "types.h" #include "uart.h" #include "utils.h" #include "xnuboot.h" +#include "minilzlib/minlzma.h" +#include "tinf/tinf.h" + int proxy_process(ProxyRequest *request, ProxyReply *reply) { enum exc_guard_t guard_save = exc_guard; diff --git a/src/utils.c b/src/utils.c index 5cf85179..00270d77 100644 --- a/src/utils.c +++ b/src/utils.c @@ -1,12 +1,12 @@ /* SPDX-License-Identifier: MIT */ +#include + #include "utils.h" #include "types.h" #include "uart.h" #include "vsprintf.h" -#include - static char ascii(char s) { if (s < 0x20) diff --git a/src/vsprintf.c b/src/vsprintf.c index 47c36ea1..1f2b1827 100644 --- a/src/vsprintf.c +++ b/src/vsprintf.c @@ -93,9 +93,10 @@ * 2.5 printf(3S) man page. */ -#include "types.h" #include +#include "types.h" + #define VA_START(ap, last) va_start(ap, last) #define VA_SHIFT(ap, value, type) /* No-op for ANSI C. */