Skip to content

Commit f9d964c

Browse files
authored
Switch to pragma once for all header files (#39)
* Move from explicit define calls to pragma once * Same for kclib * Add 'On cross-compilers' section to readme
1 parent 14749d0 commit f9d964c

25 files changed

Lines changed: 29 additions & 100 deletions

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ In order from `critical` to `meh`:
2626
- [optional] `doxygen` for documentation (`sudo apt install doxygen` or similar)
2727
- [optional] `qemu-system-x86` if you want to use `qemu.sh` to run COS (`sudo apt install qemu-system-x86` or similar)
2828

29+
#### On cross-compilers
30+
31+
COS has been written keeping in mind the capabilities and conventions of GNU C23. It is strongly recommended to compile a GCC for compiling COS, and this requirement has been enforced in build.sh. Use other compilers at your own risk.
32+
2933
### Actually building (and running) COS
3034

3135
You can run the following code to download and build COS:

kernel/include/kclib/ctype.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef CTYPE_H
2-
#define CTYPE_H
1+
#pragma once
32

43
int isalnum (int c);
54
int isalpha (int c);
@@ -16,5 +15,3 @@ int ispunct (int c);
1615

1716
int tolower (int c);
1817
int toupper (int c);
19-
20-
#endif

kernel/include/kclib/stdio.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef STDIO_H
2-
#define STDIO_H
1+
#pragma once
32

43
#include <kernel/console.h>
54
#include <stdarg.h>
@@ -11,5 +10,3 @@ void ksprintf (char* buf, const char* fmt, ...);
1110
void kprintf (const char*, ...);
1211

1312
void kserial_printf (const char* fmt, ...);
14-
15-
#endif

kernel/include/kclib/string.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef STRING_H
2-
#define STRING_H
1+
#pragma once
32

43
#include <stddef.h>
54
#include <stdint.h>
@@ -44,5 +43,3 @@ char* kstrtok_r (char* restrict s1, const char* restrict s2, char** restrict sav
4443

4544
void kitos (int32_t i, char* buf, uint32_t b);
4645
void kulitos (uint64_t i, char* buf, uint32_t b);
47-
48-
#endif

kernel/include/kernel/console.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef CONSOLE_H
2-
#define CONSOLE_H
1+
#pragma once
32

43
#include <stdbool.h>
54
#include <stddef.h>
@@ -18,5 +17,3 @@ void update (void);
1817

1918
void putchar (unsigned char);
2019
void putstr (const char*, size_t);
21-
22-
#endif

kernel/include/kernel/elf.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef ELF_H
2-
#define ELF_H
1+
#pragma once
32

43
#include <kernel/process.h>
54
#include <stdbool.h>
@@ -56,5 +55,3 @@ typedef struct __attribute__ ((packed)) {
5655

5756
bool verify_elf_loadable (elf64_header_t* elf);
5857
int load_elf (const char* filepath, process* target_process, uintptr_t* entry_point_r);
59-
60-
#endif

kernel/include/kernel/error.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef ERROR_H
2-
#define ERROR_H
1+
#pragma once
32

43
// Invalid argument
54
#define EINVARG 100
@@ -28,5 +27,3 @@
2827

2928
// Cannot execute
3029
#define ENOEXEC 701
31-
32-
#endif

kernel/include/kernel/fs/chardev.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
#ifndef CHAR_DEV_H
2-
#define CHAR_DEV_H
1+
#pragma once
32

43
#include <kernel/fs/vfs.h>
54

65
void init_tty1 (inode* absolute_root);
7-
8-
#endif

kernel/include/kernel/fs/cpio.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef CPIO_H
2-
#define CPIO_H
1+
#pragma once
32

43
#include <kernel/fs/vfs.h>
54
#include <stddef.h>
@@ -23,5 +22,3 @@ typedef struct {
2322
} cpio_newc_header_t;
2423

2524
int load_cpio_from_memory (void* pos, const char* out_path);
26-
27-
#endif

kernel/include/kernel/fs/ramfs.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
#ifndef RAMFS_H
2-
#define RAMFS_H
1+
#pragma once
32

43
#include <kernel/fs/vfs.h>
54

@@ -27,5 +26,3 @@ typedef struct {
2726
} fs_info_t;
2827

2928
inode* init_ramfs_root (void);
30-
31-
#endif

0 commit comments

Comments
 (0)