diff options
-rw-r--r-- | src/kernel/arch/amd64/sysenter.c | 2 | ||||
-rw-r--r-- | src/kernel/arch/amd64/tty/tty.c | 2 | ||||
-rw-r--r-- | src/kernel/vfs/path.c | 2 | ||||
-rw-r--r-- | src/user/app/init/driver/ansiterm.c | 2 | ||||
-rw-r--r-- | src/user/app/init/driver/ps2.c | 2 | ||||
-rw-r--r-- | src/user/app/init/driver/termcook.c | 2 | ||||
-rw-r--r-- | src/user/app/init/driver/tmpfs.c | 2 | ||||
-rw-r--r-- | src/user/app/init/main.c | 6 | ||||
-rw-r--r-- | src/user/app/init/shell.c | 2 | ||||
-rw-r--r-- | src/user/app/init/tests/main.c | 2 | ||||
-rw-r--r-- | src/user/app/init/tests/pipe.c | 4 | ||||
-rw-r--r-- | src/user/app/init/tests/semaphore.c | 6 | ||||
-rw-r--r-- | src/user/app/init/tests/stress.c | 4 | ||||
-rw-r--r-- | src/user/lib/esemaphore.c | 4 | ||||
-rw-r--r-- | src/user/lib/fs/misc.c | 4 | ||||
-rw-r--r-- | src/user/lib/fs/misc.h | 2 | ||||
-rw-r--r-- | src/user/lib/malloc.c | 2 | ||||
-rw-r--r-- | src/user/lib/stdlib.c | 2 | ||||
-rwxr-xr-x | tools/sort_includes.rb | 42 |
19 files changed, 68 insertions, 26 deletions
diff --git a/src/kernel/arch/amd64/sysenter.c b/src/kernel/arch/amd64/sysenter.c index 7591d83..536ada9 100644 --- a/src/kernel/arch/amd64/sysenter.c +++ b/src/kernel/arch/amd64/sysenter.c @@ -1,5 +1,5 @@ -#include <kernel/arch/generic.h> #include <kernel/arch/amd64/sysenter.h> +#include <kernel/arch/generic.h> #include <kernel/proc.h> #include <shared/syscalls.h> diff --git a/src/kernel/arch/amd64/tty/tty.c b/src/kernel/arch/amd64/tty/tty.c index 6593ef6..fcd4675 100644 --- a/src/kernel/arch/amd64/tty/tty.c +++ b/src/kernel/arch/amd64/tty/tty.c @@ -1,6 +1,6 @@ -#include <kernel/arch/generic.h> #include <kernel/arch/amd64/driver/serial.h> #include <kernel/arch/amd64/tty/tty.h> +#include <kernel/arch/generic.h> #include <shared/printf.h> void tty_init(void) { diff --git a/src/kernel/vfs/path.c b/src/kernel/vfs/path.c index df5f00f..e8ce49c 100644 --- a/src/kernel/vfs/path.c +++ b/src/kernel/vfs/path.c @@ -1,5 +1,5 @@ -#include <kernel/vfs/path.h> #include <kernel/panic.h> +#include <kernel/vfs/path.h> #include <shared/mem.h> int path_simplify(const char *in, char *out, size_t len) { diff --git a/src/user/app/init/driver/ansiterm.c b/src/user/app/init/driver/ansiterm.c index df7fb23..8206e85 100644 --- a/src/user/app/init/driver/ansiterm.c +++ b/src/user/app/init/driver/ansiterm.c @@ -1,6 +1,6 @@ -#include <user/app/init/driver/driver.h> #include <shared/syscalls.h> #include <stdbool.h> +#include <user/app/init/driver/driver.h> struct vga_cell { unsigned char c; diff --git a/src/user/app/init/driver/ps2.c b/src/user/app/init/driver/ps2.c index bc7f4f0..9bbab8e 100644 --- a/src/user/app/init/driver/ps2.c +++ b/src/user/app/init/driver/ps2.c @@ -1,7 +1,7 @@ -#include <user/app/init/driver/driver.h> #include <shared/container/ring.h> #include <shared/syscalls.h> #include <stdbool.h> +#include <user/app/init/driver/driver.h> static const char keymap_lower[] = { diff --git a/src/user/app/init/driver/termcook.c b/src/user/app/init/driver/termcook.c index 4142322..2ddd3f9 100644 --- a/src/user/app/init/driver/termcook.c +++ b/src/user/app/init/driver/termcook.c @@ -1,6 +1,6 @@ #include <shared/syscalls.h> -#include <user/lib/stdlib.h> #include <user/app/init/driver/driver.h> +#include <user/lib/stdlib.h> static void w_output(handle_t output, const char *buf, size_t len) { size_t pos = 0; diff --git a/src/user/app/init/driver/tmpfs.c b/src/user/app/init/driver/tmpfs.c index 6e5b45e..c6cc0f3 100644 --- a/src/user/app/init/driver/tmpfs.c +++ b/src/user/app/init/driver/tmpfs.c @@ -1,7 +1,7 @@ -#include <user/lib/malloc.h> #include <shared/mem.h> #include <shared/syscalls.h> #include <stddef.h> +#include <user/lib/malloc.h> struct node { const char *name; diff --git a/src/user/app/init/main.c b/src/user/app/init/main.c index fe06fab..4c4bf4e 100644 --- a/src/user/app/init/main.c +++ b/src/user/app/init/main.c @@ -1,12 +1,12 @@ #include <shared/flags.h> #include <shared/syscalls.h> #include <stdint.h> -#include <user/app/init/shell.h> #include <user/app/init/driver/driver.h> -#include <user/lib/fs/misc.h> +#include <user/app/init/shell.h> +#include <user/app/init/tests/main.h> #include <user/lib/elfload.h> +#include <user/lib/fs/misc.h> #include <user/lib/stdlib.h> -#include <user/app/init/tests/main.h> __attribute__((visibility("hidden"))) extern char _image_base[]; diff --git a/src/user/app/init/shell.c b/src/user/app/init/shell.c index cda8a65..f420208 100644 --- a/src/user/app/init/shell.c +++ b/src/user/app/init/shell.c @@ -1,9 +1,9 @@ #include <shared/syscalls.h> #include <stdbool.h> #include <user/app/init/shell.h> +#include <user/app/init/tests/main.h> #include <user/lib/elfload.h> #include <user/lib/stdlib.h> -#include <user/app/init/tests/main.h> static bool isspace(char c) { return c == ' ' || c == '\t' || c == '\n'; diff --git a/src/user/app/init/tests/main.c b/src/user/app/init/tests/main.c index 5db6324..015a3be 100644 --- a/src/user/app/init/tests/main.c +++ b/src/user/app/init/tests/main.c @@ -3,8 +3,8 @@ #include <shared/execbuf.h> #include <shared/flags.h> #include <shared/syscalls.h> -#include <user/lib/stdlib.h> #include <user/app/init/tests/main.h> +#include <user/lib/stdlib.h> static void run_forked(void (*fn)()) { if (!fork()) { diff --git a/src/user/app/init/tests/pipe.c b/src/user/app/init/tests/pipe.c index e7724e9..54025d0 100644 --- a/src/user/app/init/tests/pipe.c +++ b/src/user/app/init/tests/pipe.c @@ -1,8 +1,8 @@ #define TEST_MACROS -#include <user/lib/stdlib.h> -#include <user/app/init/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> +#include <user/app/init/tests/main.h> +#include <user/lib/stdlib.h> static const char *pipe_msgs[2] = {"hello", "world"}; diff --git a/src/user/app/init/tests/semaphore.c b/src/user/app/init/tests/semaphore.c index 0bfa979..66ea4ba 100644 --- a/src/user/app/init/tests/semaphore.c +++ b/src/user/app/init/tests/semaphore.c @@ -1,9 +1,9 @@ #define TEST_MACROS -#include <user/lib/esemaphore.h> -#include <user/lib/stdlib.h> -#include <user/app/init/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> +#include <user/app/init/tests/main.h> +#include <user/lib/esemaphore.h> +#include <user/lib/stdlib.h> static void odd(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) { _syscall_write(out, "1", 1, -1); diff --git a/src/user/app/init/tests/stress.c b/src/user/app/init/tests/stress.c index 9223d01..9af1706 100644 --- a/src/user/app/init/tests/stress.c +++ b/src/user/app/init/tests/stress.c @@ -1,8 +1,8 @@ #define TEST_MACROS -#include <user/lib/stdlib.h> -#include <user/app/init/tests/main.h> #include <shared/flags.h> #include <shared/syscalls.h> +#include <user/app/init/tests/main.h> +#include <user/lib/stdlib.h> static void run_forked(void (*fn)()) { if (!fork()) { diff --git a/src/user/lib/esemaphore.c b/src/user/lib/esemaphore.c index 2fdd659..1230274 100644 --- a/src/user/lib/esemaphore.c +++ b/src/user/lib/esemaphore.c @@ -1,7 +1,7 @@ -#include <user/lib/esemaphore.h> -#include <user/lib/stdlib.h> #include <shared/flags.h> #include <shared/syscalls.h> +#include <user/lib/esemaphore.h> +#include <user/lib/stdlib.h> void esem_signal(struct evil_sem *sem) { _syscall_write(sem->signal, NULL, 0, 0); diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c index 9522cfa..3631e35 100644 --- a/src/user/lib/fs/misc.c +++ b/src/user/lib/fs/misc.c @@ -1,9 +1,9 @@ -#include <user/lib/fs/misc.h> -#include <user/lib/stdlib.h> #include <shared/flags.h> #include <shared/mem.h> #include <shared/syscalls.h> #include <stdbool.h> +#include <user/lib/fs/misc.h> +#include <user/lib/stdlib.h> bool fork2_n_mount(const char *path) { handle_t h; diff --git a/src/user/lib/fs/misc.h b/src/user/lib/fs/misc.h index 3a8b071..1e41956 100644 --- a/src/user/lib/fs/misc.h +++ b/src/user/lib/fs/misc.h @@ -1,6 +1,6 @@ #pragma once -#include <user/lib/stdlib.h> #include <stdbool.h> +#include <user/lib/stdlib.h> bool fork2_n_mount(const char *path); diff --git a/src/user/lib/malloc.c b/src/user/lib/malloc.c index 5157e91..40ae917 100644 --- a/src/user/lib/malloc.c +++ b/src/user/lib/malloc.c @@ -1,7 +1,7 @@ -#include <user/lib/malloc.h> #include <shared/flags.h> #include <shared/syscalls.h> #include <stdbool.h> +#include <user/lib/malloc.h> #include <user/lib/stdlib.h> diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index 56b8bb4..e947486 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -1,6 +1,6 @@ -#include <user/lib/stdlib.h> #include <shared/printf.h> #include <shared/syscalls.h> +#include <user/lib/stdlib.h> // TODO oh god this garbage - malloc, actually open, [...] static libc_file _stdin_null = { .fd = 0 }; diff --git a/tools/sort_includes.rb b/tools/sort_includes.rb new file mode 100755 index 0000000..c9f7076 --- /dev/null +++ b/tools/sort_includes.rb @@ -0,0 +1,42 @@ +#!/usr/bin/env ruby + +def is_include str + str.start_with? '#include' +end + +files = ARGV +if files.empty? + default = "src/**/*.[ch]" + puts "no arguments passed, defaulting to #{default}" + files = Dir[default] +end + +files.each { |path| + File.open(path, "r+") do |file| + lines = file.readlines + + last = nil + grouped = [] + lines.each do |line| + if is_include(line) != last + grouped << [line] + last = is_include(line) + else + grouped[-1] << line + end + end + + grouped.map do |group| + group.sort! if is_include group[0] + end + grouped = grouped.flatten + + next if grouped == lines + + puts path + file.truncate(0) + file.seek(0) + file.write grouped.join + end +} + |