Skip to content

Commit

Permalink
On libc side:
Browse files Browse the repository at this point in the history
- Replaced _syscallN macros with explicit function implementations, ensuring clear naming and direct use of __inline_syscall_N.
- Standardized function styles with consistent __syscall_return handling.
- Updated syscall wrappers across unistd, sys, and other libc modules for easier maintenance and extensibility.
- Fixed formatting issues and streamlined error handling for a cleaner implementation.
- Disable `mmap` and  `munmap`.

On `kernel` side:

- Improved parameter descriptions and return value docs for better clarity across files.
- Simplified and standardized debug logging by removing redundant function names.
- Added a fget utility in process.c for easier file descriptor retrieval.
- Enhanced sys_mmap in paging.c to validate file sizes and fetch stats before mapping.
- Refactored syscall_handler for streamlined argument handling, removing unused 6-argument support.
- Tweaked VFS and pipe operations with better naming and structural improvements, da pipes are flowin’ proppa now.
  • Loading branch information
Galfurian committed Nov 20, 2024
1 parent 75be783 commit 6c1f84b
Show file tree
Hide file tree
Showing 71 changed files with 790 additions and 461 deletions.
147 changes: 77 additions & 70 deletions doc/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,15 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/mentos/inc/klib/mutex.h
${CMAKE_SOURCE_DIR}/mentos/inc/klib/compiler.h
${CMAKE_SOURCE_DIR}/mentos/inc/klib/rbtree.h
${CMAKE_SOURCE_DIR}/mentos/inc/klib/hashmap.h
${CMAKE_SOURCE_DIR}/mentos/inc/klib/list.h
${CMAKE_SOURCE_DIR}/mentos/inc/boot.h
${CMAKE_SOURCE_DIR}/mentos/inc/sys/types.h
${CMAKE_SOURCE_DIR}/mentos/inc/sys/reboot.h
${CMAKE_SOURCE_DIR}/mentos/inc/sys/module.h
${CMAKE_SOURCE_DIR}/mentos/inc/sys/utsname.h
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga_font.h
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga.h
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga_palette.h
${CMAKE_SOURCE_DIR}/mentos/inc/io/vga/vga_mode.h
${CMAKE_SOURCE_DIR}/mentos/inc/io/proc_modules.h
${CMAKE_SOURCE_DIR}/mentos/inc/io/video.h
${CMAKE_SOURCE_DIR}/mentos/inc/io/debug.h
${CMAKE_SOURCE_DIR}/mentos/inc/devices/pci.h
${CMAKE_SOURCE_DIR}/mentos/inc/devices/fpu.h
${CMAKE_SOURCE_DIR}/mentos/inc/system/printk.h
Expand All @@ -99,65 +95,12 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/mentos/inc/system/signal.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/vfs.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/ext2.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/pipe.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/namei.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/attr.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/procfs.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/vfs_types.h
${CMAKE_SOURCE_DIR}/mentos/inc/fs/ioctl.h
${CMAKE_SOURCE_DIR}/libc/inc/limits.h
${CMAKE_SOURCE_DIR}/libc/inc/stdbool.h
${CMAKE_SOURCE_DIR}/libc/inc/stdint.h
${CMAKE_SOURCE_DIR}/libc/inc/time.h
${CMAKE_SOURCE_DIR}/libc/inc/bits/termios-struct.h
${CMAKE_SOURCE_DIR}/libc/inc/bits/ioctls.h
${CMAKE_SOURCE_DIR}/libc/inc/bits/stat.h
${CMAKE_SOURCE_DIR}/libc/inc/shadow.h
${CMAKE_SOURCE_DIR}/libc/inc/fcvt.h
${CMAKE_SOURCE_DIR}/libc/inc/string.h
${CMAKE_SOURCE_DIR}/libc/inc/pwd.h
${CMAKE_SOURCE_DIR}/libc/inc/readline.h
${CMAKE_SOURCE_DIR}/libc/inc/crypt/sha256.h
${CMAKE_SOURCE_DIR}/libc/inc/termios.h
${CMAKE_SOURCE_DIR}/libc/inc/stdlib.h
${CMAKE_SOURCE_DIR}/libc/inc/fcntl.h
${CMAKE_SOURCE_DIR}/libc/inc/stdio.h
${CMAKE_SOURCE_DIR}/libc/inc/ring_buffer.h
${CMAKE_SOURCE_DIR}/libc/inc/err.h
${CMAKE_SOURCE_DIR}/libc/inc/stdarg.h
${CMAKE_SOURCE_DIR}/libc/inc/libgen.h
${CMAKE_SOURCE_DIR}/libc/inc/sched.h
${CMAKE_SOURCE_DIR}/libc/inc/assert.h
${CMAKE_SOURCE_DIR}/libc/inc/stddef.h
${CMAKE_SOURCE_DIR}/libc/inc/signal.h
${CMAKE_SOURCE_DIR}/libc/inc/errno.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/shm.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/bitops.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/types.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/sem.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/reboot.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/msg.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/ipc.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/wait.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/kernel_levels.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/ioctl.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/mman.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/utsname.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/stat.h
${CMAKE_SOURCE_DIR}/libc/inc/list_head.h
${CMAKE_SOURCE_DIR}/libc/inc/list_head_algorithm.h
${CMAKE_SOURCE_DIR}/libc/inc/grp.h
${CMAKE_SOURCE_DIR}/libc/inc/unistd.h
${CMAKE_SOURCE_DIR}/libc/inc/dirent.h
${CMAKE_SOURCE_DIR}/libc/inc/io/ansi_colors.h
${CMAKE_SOURCE_DIR}/libc/inc/io/mm_io.h
${CMAKE_SOURCE_DIR}/libc/inc/io/debug.h
${CMAKE_SOURCE_DIR}/libc/inc/io/port_io.h
${CMAKE_SOURCE_DIR}/libc/inc/ctype.h
${CMAKE_SOURCE_DIR}/libc/inc/system/syscall_types.h
${CMAKE_SOURCE_DIR}/libc/inc/array.h
${CMAKE_SOURCE_DIR}/libc/inc/strerror.h
${CMAKE_SOURCE_DIR}/libc/inc/math.h

${CMAKE_SOURCE_DIR}/mentos/kernel.lds
${CMAKE_SOURCE_DIR}/mentos/src/drivers/mouse.c
${CMAKE_SOURCE_DIR}/mentos/src/drivers/rtc.c
${CMAKE_SOURCE_DIR}/mentos/src/drivers/mem.c
Expand All @@ -169,24 +112,31 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/mentos/src/elf/elf.c
${CMAKE_SOURCE_DIR}/mentos/src/process/scheduler_feedback.c
${CMAKE_SOURCE_DIR}/mentos/src/process/process.c
${CMAKE_SOURCE_DIR}/mentos/src/process/user.S
${CMAKE_SOURCE_DIR}/mentos/src/process/scheduler_algorithm.c
${CMAKE_SOURCE_DIR}/mentos/src/process/scheduler.c
${CMAKE_SOURCE_DIR}/mentos/src/process/wait.c
${CMAKE_SOURCE_DIR}/mentos/src/crypt/sha256.c
${CMAKE_SOURCE_DIR}/mentos/src/mem/zone_allocator.c
${CMAKE_SOURCE_DIR}/mentos/src/mem/paging.c
${CMAKE_SOURCE_DIR}/mentos/src/mem/buddysystem.c
${CMAKE_SOURCE_DIR}/mentos/src/mem/libbuddysystem.a
${CMAKE_SOURCE_DIR}/mentos/src/mem/kheap.c
${CMAKE_SOURCE_DIR}/mentos/src/mem/slab.c
${CMAKE_SOURCE_DIR}/mentos/src/mem/vmem_map.c
${CMAKE_SOURCE_DIR}/mentos/src/hardware/timer.c
${CMAKE_SOURCE_DIR}/mentos/src/hardware/pic8259.c
${CMAKE_SOURCE_DIR}/mentos/src/hardware/cpuid.c
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/exception.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/idt.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/interrupt.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/gdt.c
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/interrupt.c
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/exception.c
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/gdt.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/tss.c
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/idt.c
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/tss.S
${CMAKE_SOURCE_DIR}/mentos/src/ipc/sem.c
${CMAKE_SOURCE_DIR}/mentos/src/ipc/msg.c
${CMAKE_SOURCE_DIR}/mentos/src/ipc/ipc.c
Expand All @@ -208,6 +158,7 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/mentos/src/klib/ctype.c
${CMAKE_SOURCE_DIR}/mentos/src/klib/spinlock.c
${CMAKE_SOURCE_DIR}/mentos/src/klib/math.c
${CMAKE_SOURCE_DIR}/mentos/src/boot.S
${CMAKE_SOURCE_DIR}/mentos/src/sys/utsname.c
${CMAKE_SOURCE_DIR}/mentos/src/sys/module.c
${CMAKE_SOURCE_DIR}/mentos/src/io/debug.c
Expand All @@ -233,14 +184,73 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/mentos/src/fs/readdir.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/ext2.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/read_write.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/fcntl.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/stat.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/ioctl.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/vfs.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/attr.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/pipe.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/procfs.c
${CMAKE_SOURCE_DIR}/mentos/src/fs/namei.c
${CMAKE_SOURCE_DIR}/mentos/src/multiboot.c
${CMAKE_SOURCE_DIR}/mentos/src/kernel/sys.c

${CMAKE_SOURCE_DIR}/libc/inc/errno.h
${CMAKE_SOURCE_DIR}/libc/inc/limits.h
${CMAKE_SOURCE_DIR}/libc/inc/stdbool.h
${CMAKE_SOURCE_DIR}/libc/inc/stdint.h
${CMAKE_SOURCE_DIR}/libc/inc/time.h
${CMAKE_SOURCE_DIR}/libc/inc/bits/termios-struct.h
${CMAKE_SOURCE_DIR}/libc/inc/bits/ioctls.h
${CMAKE_SOURCE_DIR}/libc/inc/bits/stat.h
${CMAKE_SOURCE_DIR}/libc/inc/shadow.h
${CMAKE_SOURCE_DIR}/libc/inc/fcvt.h
${CMAKE_SOURCE_DIR}/libc/inc/string.h
${CMAKE_SOURCE_DIR}/libc/inc/pwd.h
${CMAKE_SOURCE_DIR}/libc/inc/readline.h
${CMAKE_SOURCE_DIR}/libc/inc/crypt/sha256.h
${CMAKE_SOURCE_DIR}/libc/inc/termios.h
${CMAKE_SOURCE_DIR}/libc/inc/syslog.h
${CMAKE_SOURCE_DIR}/libc/inc/stdlib.h
${CMAKE_SOURCE_DIR}/libc/inc/fcntl.h
${CMAKE_SOURCE_DIR}/libc/inc/stdio.h
${CMAKE_SOURCE_DIR}/libc/inc/ring_buffer.h
${CMAKE_SOURCE_DIR}/libc/inc/err.h
${CMAKE_SOURCE_DIR}/libc/inc/stdarg.h
${CMAKE_SOURCE_DIR}/libc/inc/libgen.h
${CMAKE_SOURCE_DIR}/libc/inc/sched.h
${CMAKE_SOURCE_DIR}/libc/inc/assert.h
${CMAKE_SOURCE_DIR}/libc/inc/stddef.h
${CMAKE_SOURCE_DIR}/libc/inc/signal.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/shm.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/bitops.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/types.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/sem.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/reboot.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/msg.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/ipc.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/wait.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/kernel_levels.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/ioctl.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/mman.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/utsname.h
${CMAKE_SOURCE_DIR}/libc/inc/sys/stat.h
${CMAKE_SOURCE_DIR}/libc/inc/list_head.h
${CMAKE_SOURCE_DIR}/libc/inc/grp.h
${CMAKE_SOURCE_DIR}/libc/inc/ndtree.h
${CMAKE_SOURCE_DIR}/libc/inc/io/ansi_colors.h
${CMAKE_SOURCE_DIR}/libc/inc/io/mm_io.h
${CMAKE_SOURCE_DIR}/libc/inc/io/port_io.h
${CMAKE_SOURCE_DIR}/libc/inc/ctype.h
${CMAKE_SOURCE_DIR}/libc/inc/dirent.h
${CMAKE_SOURCE_DIR}/libc/inc/hashmap.h
${CMAKE_SOURCE_DIR}/libc/inc/system/syscall_types.h
${CMAKE_SOURCE_DIR}/libc/inc/list.h
${CMAKE_SOURCE_DIR}/libc/inc/array.h
${CMAKE_SOURCE_DIR}/libc/inc/strerror.h
${CMAKE_SOURCE_DIR}/libc/inc/math.h
${CMAKE_SOURCE_DIR}/libc/inc/unistd.h
${CMAKE_SOURCE_DIR}/libc/inc/list_head_algorithm.h
${CMAKE_SOURCE_DIR}/libc/src/stdlib.c
${CMAKE_SOURCE_DIR}/libc/src/libc_start.c
${CMAKE_SOURCE_DIR}/libc/src/setenv.c
Expand All @@ -256,6 +266,7 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/libc/src/unistd/symlink.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/getsid.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/read.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/fcntl.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/readlink.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/chmod.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/mkdir.c
Expand All @@ -273,6 +284,7 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/libc/src/unistd/close.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/waitpid.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/chown.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/pipe.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/creat.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/nice.c
${CMAKE_SOURCE_DIR}/libc/src/unistd/lseek.c
Expand All @@ -292,10 +304,15 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/libc/src/pwd.c
${CMAKE_SOURCE_DIR}/libc/src/libgen.c
${CMAKE_SOURCE_DIR}/libc/src/string.c
${CMAKE_SOURCE_DIR}/libc/src/crt0.S
${CMAKE_SOURCE_DIR}/libc/src/hashmap.c
${CMAKE_SOURCE_DIR}/libc/src/ndtree.c
${CMAKE_SOURCE_DIR}/libc/src/assert.c
${CMAKE_SOURCE_DIR}/libc/src/grp.c
${CMAKE_SOURCE_DIR}/libc/src/shadow.c
${CMAKE_SOURCE_DIR}/libc/src/sched.c
${CMAKE_SOURCE_DIR}/libc/src/list.c
${CMAKE_SOURCE_DIR}/libc/src/syslog.c
${CMAKE_SOURCE_DIR}/libc/src/strerror.c
${CMAKE_SOURCE_DIR}/libc/src/sys/mman.c
${CMAKE_SOURCE_DIR}/libc/src/sys/errno.c
Expand All @@ -306,17 +323,7 @@ if (DOXYGEN_FOUND)
${CMAKE_SOURCE_DIR}/libc/src/ctype.c
${CMAKE_SOURCE_DIR}/libc/src/readline.c
${CMAKE_SOURCE_DIR}/libc/src/termios.c
${CMAKE_SOURCE_DIR}/libc/src/io/debug.c
${CMAKE_SOURCE_DIR}/libc/src/io/mm_io.c
${CMAKE_SOURCE_DIR}/libc/src/math.c

${CMAKE_SOURCE_DIR}/mentos/src/process/user.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/exception.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/idt.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/interrupt.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/gdt.S
${CMAKE_SOURCE_DIR}/mentos/src/descriptor_tables/tss.S
${CMAKE_SOURCE_DIR}/mentos/src/boot.S
${CMAKE_SOURCE_DIR}/libc/src/crt0.S
)
endif (DOXYGEN_FOUND)
2 changes: 1 addition & 1 deletion libc/inc/hashmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <stddef.h>

// Define the size of the hashmap
/// Define the size of the hashmap.
#define HASHMAP_SIZE 1024

/// @brief Structure representing a hashmap entry.
Expand Down
12 changes: 6 additions & 6 deletions libc/inc/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@

/// @brief Represents the node of a list.
typedef struct listnode_t {
list_head list; // List structure for this node
void *value; // Pointer to node's value
list_head list; ///< List structure for this node.
void *value; ///< Pointer to node's value.
} listnode_t;

/// @brief Represents the list.
typedef struct list_t {
list_head head; // Head of the list
unsigned int size; // Size of the list
listnode_t *(*alloc)(void); // Node allocation function
void (*dealloc)(listnode_t *); // Node deallocation function
list_head head; ///< Head of the list.
unsigned int size; ///< Size of the list.
listnode_t *(*alloc)(void); ///< Node allocation function.
void (*dealloc)(listnode_t *); ///< Node deallocation function.
} list_t;

/// @brief Initializes the list with custom alloc and dealloc functions.
Expand Down
3 changes: 0 additions & 3 deletions libc/inc/ndtree.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ typedef struct ndtree_node {
} ndtree_node_t;

/// @brief Function pointer type for comparing elements in the tree.
/// @param tree The tree containing the elements to compare.
/// @param lhs Left-hand side value to compare.
/// @param rhs Right-hand side value to compare.
/// @return Comparison result: <0 if lhs < rhs, 0 if lhs == rhs, >0 if lhs > rhs.
typedef int (*ndtree_tree_compare_f)(void *lhs, void *rhs);

/// @brief Callback function type for operating on tree nodes.
/// @param tree The tree containing the node.
/// @param node The node to operate on.
typedef void (*ndtree_tree_node_f)(ndtree_node_t *node);

Expand Down Expand Up @@ -51,7 +49,6 @@ typedef struct ndtree {
/// @param compare_node Comparison function for nodes.
/// @param alloc_node Custom allocator for nodes.
/// @param free_node Custom deallocator for nodes.
/// @return Pointer to the initialized tree.
void ndtree_tree_init(ndtree_t *tree, ndtree_tree_compare_f compare_node, ndtree_alloc_node_f alloc_node, ndtree_free_node_f free_node);

/// @brief Initializes a tree node with a given value.
Expand Down
4 changes: 4 additions & 0 deletions libc/inc/sys/mman.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#define MAP_SHARED 0x01 ///< The memory is shared.
#define MAP_PRIVATE 0x02 ///< The memory is private.

#if 0

/// @brief creates a new mapping in the virtual address space of the calling process.
/// @param addr the starting address for the new mapping.
/// @param length specifies the length of the mapping (which must be greater than 0).
Expand All @@ -29,3 +31,5 @@ void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
/// @param length the length of the mapped area.
/// @return 0 on success, -1 on falure and errno is set.
int munmap(void *addr, size_t length);

#endif
15 changes: 4 additions & 11 deletions libc/inc/syslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,15 @@ void closelog(void);
int __syslog(const char *file, const char *fun, int line, short log_level, const char *format, ...);

/// @brief Extracts the relative path of the current file from the project root.
///
/// This macro calculates the relative path of the file (`__FILE__`) by skipping
/// the prefix defined by `MENTOS_ROOT`. It is used to simplify file path
/// logging by removing the absolute path up to the project root.
///
/// @note Ensure that `MENTOS_ROOT` is correctly defined as the root path of the
/// project. If `__FILE__` does not start with `MENTOS_ROOT`, the behavior is
/// undefined.
///
/// @example
/// @details This macro calculates the relative path of the file (`__FILE__`) by
/// skipping the prefix defined by `MENTOS_ROOT`. It is used to simplify file
/// path logging by removing the absolute path up to the project root.
/// If
/// MENTOS_ROOT = "/path/to/mentos" and
/// __FILE__ = "/path/to/mentos/src/kernel/main.c", the result will be
/// "src/kernel/main.c".
#define __RELATIVE_PATH__ \
(strncmp(__FILE__, MENTOS_ROOT, sizeof(MENTOS_ROOT) - 1) == 0 ? (&__FILE__[sizeof(MENTOS_ROOT)]) : __FILE__)

// Wrapper macro to simplify usage
/// @brief Wrapper macro to simplify usage.
#define syslog(...) __syslog(__RELATIVE_PATH__, __func__, __LINE__, __VA_ARGS__)
Loading

0 comments on commit 6c1f84b

Please sign in to comment.