From fb790b07aeba8e22e4190cf3e1834d11ecde6c96 Mon Sep 17 00:00:00 2001 From: Amlal Date: Fri, 25 Apr 2025 13:08:33 +0200 Subject: dev: better .clang-format, ran format command. Signed-off-by: Amlal --- dev/user/src/SystemCalls.cc | 127 +++++++++++++++++++------------------------- 1 file changed, 54 insertions(+), 73 deletions(-) (limited to 'dev/user/src') diff --git a/dev/user/src/SystemCalls.cc b/dev/user/src/SystemCalls.cc index 6b32bd70..d8366d42 100644 --- a/dev/user/src/SystemCalls.cc +++ b/dev/user/src/SystemCalls.cc @@ -1,114 +1,95 @@ /* ------------------------------------------- - Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. + Copyright (C) 2024-2025, Amlal El Mahrouss, all rights reserved. ------------------------------------------- */ -#include #include +#include /// @file SystemCalls.cc /// @brief Source file for the memory functions of the user.sys. /// @brief Copy memory region. -IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) -{ - if (!len || - !dest || - !src) - { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) - { - ((Char*)dest)[i] = ((Char*)src)[i]; - } - - return dest; +IMPORT_C VoidPtr MmCopyMemory(_Input VoidPtr dest, _Input VoidPtr src, _Input SizeT len) { + if (!len || !dest || !src) { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) { + ((Char*) dest)[i] = ((Char*) src)[i]; + } + + return dest; } /// @brief Get string length. -IMPORT_C SInt64 MmStrLen(const Char* in) -{ - if (!in) - return 0; +IMPORT_C SInt64 MmStrLen(const Char* in) { + if (!in) return 0; - SizeT len{0}; + SizeT len{0}; - do - { - ++len; - } while (in[len] != '\0'); + do { + ++len; + } while (in[len] != '\0'); - return len; + return len; } /// @brief Fill memory region **dest** with **value**. -IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) -{ - if (!len || - !dest) - { - return nullptr; - } - - for (SizeT i = 0; i < len; i++) - { - ((Char*)dest)[i] = value; - } - - return dest; +IMPORT_C VoidPtr MmFillMemory(_Input VoidPtr dest, _Input SizeT len, _Input UInt8 value) { + if (!len || !dest) { + return nullptr; + } + + for (SizeT i = 0; i < len; i++) { + ((Char*) dest)[i] = value; + } + + return dest; } -IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) -{ - return sci_syscall_arg_3(1, reinterpret_cast(const_cast(path)), - reinterpret_cast(const_cast(drv_letter))); +IMPORT_C Ref IoOpenFile(_Input const Char* path, _Input const Char* drv_letter) { + return sci_syscall_arg_3(1, reinterpret_cast(const_cast(path)), + reinterpret_cast(const_cast(drv_letter))); } -IMPORT_C Void IoCloseFile(_Input Ref desc) -{ - sci_syscall_arg_2(2, desc); +IMPORT_C Void IoCloseFile(_Input Ref desc) { + sci_syscall_arg_2(2, desc); } -IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) -{ - auto ret = (UInt64*)sci_syscall_arg_3(3, reinterpret_cast(desc), - reinterpret_cast(&off)); +IMPORT_C UInt64 IoSeekFile(_Input Ref desc, _Input UInt64 off) { + auto ret = (UInt64*) sci_syscall_arg_3(3, reinterpret_cast(desc), + reinterpret_cast(&off)); - MUST_PASS((*ret) != ~0UL); - return *ret; + MUST_PASS((*ret) != ~0UL); + return *ret; } -IMPORT_C UInt64 IoTellFile(_Input Ref desc) -{ - auto ret = (UInt64*)sci_syscall_arg_2(4, reinterpret_cast(desc)); - return *ret; +IMPORT_C UInt64 IoTellFile(_Input Ref desc) { + auto ret = (UInt64*) sci_syscall_arg_2(4, reinterpret_cast(desc)); + return *ret; } /// @brief Print to the file descriptor. /// @param desc the file descriptor. -IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) -{ - va_list args; +IMPORT_C SInt32 PrintOut(_Input IORef desc, const char* fmt, ...) { + va_list args; - va_start(args, fmt); + va_start(args, fmt); - auto ret = (UInt64*)sci_syscall_arg_4(5, reinterpret_cast(desc), - reinterpret_cast(const_cast(fmt)), args); + auto ret = (UInt64*) sci_syscall_arg_4(5, reinterpret_cast(desc), + reinterpret_cast(const_cast(fmt)), args); - va_end(args); + va_end(args); - return *ret; + return *ret; } /// @internal -IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) -{ - if (!expr) - { - PrintOut(nullptr, "Assertion failed: %s\r", origin); - PrintOut(nullptr, "Origin: %s\r", origin); - } +IMPORT_C Void _rtl_assert(Bool expr, const Char* origin) { + if (!expr) { + PrintOut(nullptr, "Assertion failed: %s\r", origin); + PrintOut(nullptr, "Origin: %s\r", origin); + } } \ No newline at end of file -- cgit v1.2.3