summaryrefslogtreecommitdiffhomepage
path: root/dev/LibC++
diff options
context:
space:
mode:
authorAmlal <amlal@nekernel.org>2025-04-25 13:14:01 +0200
committerAmlal <amlal@nekernel.org>2025-04-25 13:14:01 +0200
commit20042235d1f53ae428aa154e64afdbae5d8d91ad (patch)
tree6ea42d1b30505a57301f8ff2916c78ce94ff6eaf /dev/LibC++
parent0561a8d0a6ae7588309a6e3513bbfeeef5f0aa15 (diff)
meta: update .clang-format, format codebase.
Signed-off-by: Amlal <amlal@nekernel.org>
Diffstat (limited to 'dev/LibC++')
-rw-r--r--dev/LibC++/base_alloc.h74
-rw-r--r--dev/LibC++/base_exception.h32
-rw-r--r--dev/LibC++/base_math.h80
-rw-r--r--dev/LibC++/base_process.h16
-rw-r--r--dev/LibC++/defines.h57
-rw-r--r--dev/LibC++/filesystem.h17
-rw-r--r--dev/LibC++/lc_runtime+unreachable.cc10
-rw-r--r--dev/LibC++/lc_runtime.h4
-rw-r--r--dev/LibC++/utility.h45
9 files changed, 152 insertions, 183 deletions
diff --git a/dev/LibC++/base_alloc.h b/dev/LibC++/base_alloc.h
index b12fd0a..af5693b 100644
--- a/dev/LibC++/base_alloc.h
+++ b/dev/LibC++/base_alloc.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -8,42 +8,36 @@
#include <LibC++/defines.h>
-namespace std::base_alloc
-{
- /// @brief allocate a new class.
- /// @tparam KindClass the class type to allocate.
- template <typename KindClass, typename... Args>
- inline KindClass* allocate(Args&&... args)
- {
- return new KindClass(forward(args)...);
- }
-
- /// @brief allocate a new class.
- /// @note aborts on error.
- /// @tparam KindClass the class type to allocate.
- template <typename KindClass, typename... Args>
- inline KindClass* allocate_nothrow(Args&&... args) noexcept
- {
- return allocate(forward(args)...);
- }
-
- /// @brief free a class.
- /// @tparam KindClass the class type to allocate.
- template <typename KindClass>
- inline void release(KindClass ptr)
- {
- if (!ptr)
- return;
-
- delete ptr;
- }
-
- /// @brief destroy and free a class.
- /// @note aborts on error.
- /// @tparam KindClass the class type to allocate.
- template <typename KindClass>
- inline void release_nothrow(KindClass ptr) noexcept
- {
- release(ptr);
- }
-} // namespace std::base_alloc
+namespace std::base_alloc {
+/// @brief allocate a new class.
+/// @tparam KindClass the class type to allocate.
+template <typename KindClass, typename... Args>
+inline KindClass* allocate(Args&&... args) {
+ return new KindClass(forward(args)...);
+}
+
+/// @brief allocate a new class.
+/// @note aborts on error.
+/// @tparam KindClass the class type to allocate.
+template <typename KindClass, typename... Args>
+inline KindClass* allocate_nothrow(Args&&... args) noexcept {
+ return allocate(forward(args)...);
+}
+
+/// @brief free a class.
+/// @tparam KindClass the class type to allocate.
+template <typename KindClass>
+inline void release(KindClass ptr) {
+ if (!ptr) return;
+
+ delete ptr;
+}
+
+/// @brief destroy and free a class.
+/// @note aborts on error.
+/// @tparam KindClass the class type to allocate.
+template <typename KindClass>
+inline void release_nothrow(KindClass ptr) noexcept {
+ release(ptr);
+}
+} // namespace std::base_alloc
diff --git a/dev/LibC++/base_exception.h b/dev/LibC++/base_exception.h
index 30ec466..314ac12 100644
--- a/dev/LibC++/base_exception.h
+++ b/dev/LibC++/base_exception.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -9,22 +9,18 @@
#include <LibC++/defines.h>
#include <LibC++/process_base.h>
-namespace std::base_exception
-{
- inline void __throw_general(void)
- {
- exit(33);
- }
+namespace std::base_exception {
+inline void __throw_general(void) {
+ exit(33);
+}
- inline void __throw_domain_error(const char* error)
- {
- __throw_general();
- __builtin_unreachable(); // prevent from continuing.
- }
+inline void __throw_domain_error(const char* error) {
+ __throw_general();
+ __builtin_unreachable(); // prevent from continuing.
+}
- inline void __throw_bad_array_new_length(void)
- {
- __throw_general();
- __builtin_unreachable(); // prevent from continuing.
- }
-} // namespace std::base_exception
+inline void __throw_bad_array_new_length(void) {
+ __throw_general();
+ __builtin_unreachable(); // prevent from continuing.
+}
+} // namespace std::base_exception
diff --git a/dev/LibC++/base_math.h b/dev/LibC++/base_math.h
index ed1728e..ca6aace 100644
--- a/dev/LibC++/base_math.h
+++ b/dev/LibC++/base_math.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -17,46 +17,38 @@ typedef double real_type;
typedef float real_type;
#endif
-namespace std::base_math
-{
- /// @brief Power function, with Repeat argument.
- template <size_t Exponent>
- inline real_type pow(real_type in)
- {
- if (Exponent == 0)
- return 1; // Any number to the power of 0 is 1.
-
- if (Exponent == 1)
- return in; // Any number to the power of 1 is itself.
-
- size_t cnt = Exponent;
-
- real_type result = 1;
-
- for (auto i = 0; i < cnt; ++i)
- result *= in;
-
- return result;
- }
-
- /// @brief Square of function, with Base template argument.
- /// @param of Base argument to find sqquare of
- template <size_t Base>
- inline real_type sqr(real_type in)
- {
- if (in == 0)
- return 0;
-
- return pow<1 / Base>(in);
- }
-
- /// @brief Linear interpolation equation solver.
- /// @param from where?
- /// @param to to?
- /// @param Updated diff value according to difference.
- inline real_type lerp(real_type to, real_type from, real_type stat)
- {
- real_type diff = (to - from);
- return from + (diff * stat);
- }
-} // namespace std::base_math
+namespace std::base_math {
+/// @brief Power function, with Repeat argument.
+template <size_t Exponent>
+inline real_type pow(real_type in) {
+ if (Exponent == 0) return 1; // Any number to the power of 0 is 1.
+
+ if (Exponent == 1) return in; // Any number to the power of 1 is itself.
+
+ size_t cnt = Exponent;
+
+ real_type result = 1;
+
+ for (auto i = 0; i < cnt; ++i) result *= in;
+
+ return result;
+}
+
+/// @brief Square of function, with Base template argument.
+/// @param of Base argument to find sqquare of
+template <size_t Base>
+inline real_type sqr(real_type in) {
+ if (in == 0) return 0;
+
+ return pow<1 / Base>(in);
+}
+
+/// @brief Linear interpolation equation solver.
+/// @param from where?
+/// @param to to?
+/// @param Updated diff value according to difference.
+inline real_type lerp(real_type to, real_type from, real_type stat) {
+ real_type diff = (to - from);
+ return from + (diff * stat);
+}
+} // namespace std::base_math
diff --git a/dev/LibC++/base_process.h b/dev/LibC++/base_process.h
index 7008b86..757e592 100644
--- a/dev/LibC++/base_process.h
+++ b/dev/LibC++/base_process.h
@@ -1,6 +1,6 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
@@ -12,11 +12,9 @@
extern "C" int exit(int code);
/// @brief Standard C++ namespace
-namespace std::base_process
-{
- inline int exit(int code)
- {
- exit(code);
- return -1;
- }
-} // namespace std::base_process
+namespace std::base_process {
+inline int exit(int code) {
+ exit(code);
+ return -1;
+}
+} // namespace std::base_process
diff --git a/dev/LibC++/defines.h b/dev/LibC++/defines.h
index 43cefb9..c0459ac 100644
--- a/dev/LibC++/defines.h
+++ b/dev/LibC++/defines.h
@@ -1,16 +1,15 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
#ifndef __LIBCOMPILER_DEFINES_H__
#define __LIBCOMPILER_DEFINES_H__
-extern "C"
-{
-#include <stdint.h>
+extern "C" {
#include <stddef.h>
+#include <stdint.h>
}
#ifndef __GNUC__
@@ -21,9 +20,9 @@ typedef __SIZE_TYPE__ size_t;
typedef long int ssize_t;
#else
typedef int ssize_t;
-#endif // __LP64__
+#endif // __LP64__
-typedef void* ptr_type;
+typedef void* ptr_type;
typedef __SIZE_TYPE__ size_type;
typedef size_t ptrdiff_t;
@@ -33,8 +32,8 @@ typedef void* any_t;
typedef char* caddr_t;
#ifndef NULL
-#define NULL ((voidptr_t)0)
-#endif // !null
+#define NULL ((voidptr_t) 0)
+#endif // !null
#ifdef __GNUC__
#include <LibC++/alloca.h>
@@ -45,12 +44,10 @@ typedef char* caddr_t;
#define __deref(ptr) (*(ptr))
#ifdef __cplusplus
-#define __init_decl() \
- extern "C" \
- {
+#define __init_decl() extern "C" {
#define __fini_decl() \
- } \
- ;
+ } \
+ ;
#else
#define __init_decl()
#define __fini_decl()
@@ -66,31 +63,29 @@ typedef char* caddr_t;
#warning ! alloca not detected !
#endif
-typedef long long off_t;
+typedef long long off_t;
typedef unsigned long long uoff_t;
typedef union float_cast {
- struct
- {
- unsigned int mantissa : 23;
- unsigned int exponent : 8;
- unsigned int sign : 1;
- };
-
- float f;
+ struct {
+ unsigned int mantissa : 23;
+ unsigned int exponent : 8;
+ unsigned int sign : 1;
+ };
+
+ float f;
} __attribute__((packed)) float_cast_t;
typedef union double_cast {
- struct
- {
- unsigned long long int mantissa : 52;
- unsigned int exponent : 11;
- unsigned int sign : 1;
- };
-
- double f;
+ struct {
+ unsigned long long int mantissa : 52;
+ unsigned int exponent : 11;
+ unsigned int sign : 1;
+ };
+
+ double f;
} __attribute__((packed)) double_cast_t;
-#endif // ifndef __GNUC__
+#endif // ifndef __GNUC__
#endif /* __LIBCOMPILER_DEFINES_H__ */
diff --git a/dev/LibC++/filesystem.h b/dev/LibC++/filesystem.h
index b97bb1f..254bfab 100644
--- a/dev/LibC++/filesystem.h
+++ b/dev/LibC++/filesystem.h
@@ -1,18 +1,17 @@
/* -------------------------------------------
- Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
+ Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved.
------------------------------------------- */
#ifndef __LIBCOMPILER_FS_H__
#define __LIBCOMPILER_FS_H__
-namespace std
-{
- class path;
- class filesystem_error;
- class directory_entry;
- class directory_iterator;
-} // namespace std
+namespace std {
+class path;
+class filesystem_error;
+class directory_entry;
+class directory_iterator;
+} // namespace std
-#endif // __LIBCOMPILER_FS_H__ \ No newline at end of file
+#endif // __LIBCOMPILER_FS_H__ \ No newline at end of file
diff --git a/dev/LibC++/lc_runtime+unreachable.cc b/dev/LibC++/lc_runtime+unreachable.cc
index 125584e..2aaa3c1 100644
--- a/dev/LibC++/lc_runtime+unreachable.cc
+++ b/dev/LibC++/lc_runtime+unreachable.cc
@@ -1,13 +1,11 @@
/* -------------------------------------------
- \
+ \
Copyright (C) 2025 Amlal El Mahrouss, all rights reserved. \
- \
+ \
------------------------------------------- */
#include <LibC++/lc_runtime.h>
-extern "C" void __libcompiler_unreachable(void)
-{
- while (true)
- ;
+extern "C" void __libcompiler_unreachable(void) {
+ while (true);
} \ No newline at end of file
diff --git a/dev/LibC++/lc_runtime.h b/dev/LibC++/lc_runtime.h
index 0b58a58..d3d331f 100644
--- a/dev/LibC++/lc_runtime.h
+++ b/dev/LibC++/lc_runtime.h
@@ -1,7 +1,7 @@
/* -------------------------------------------
- \
+ \
Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. \
- \
+ \
------------------------------------------- */
#pragma once
diff --git a/dev/LibC++/utility.h b/dev/LibC++/utility.h
index 1b1b932..4f1d2d7 100644
--- a/dev/LibC++/utility.h
+++ b/dev/LibC++/utility.h
@@ -1,33 +1,30 @@
/* -------------------------------------------
- \
+ \
Copyright (C) 2024-2025 Amlal El Mahrouss, all rights reserved. \
- \
+ \
------------------------------------------- */
#ifndef LIBCXX_UTILITY_H
#define LIBCXX_UTILITY_H
-namespace std
-{
- /// @brief Forward object.
- /// @tparam Args the object type.
- /// @param arg the object.
- /// @return object's rvalue
- template <typename Args>
- inline Args&& forward(Args& arg)
- {
- return static_cast<Args&&>(arg);
- }
+namespace std {
+/// @brief Forward object.
+/// @tparam Args the object type.
+/// @param arg the object.
+/// @return object's rvalue
+template <typename Args>
+inline Args&& forward(Args& arg) {
+ return static_cast<Args&&>(arg);
+}
- /// @brief Move object.
- /// @tparam Args the object type.
- /// @param arg the object.
- /// @return object's rvalue
- template <typename Args>
- inline Args&& move(Args&& arg)
- {
- return static_cast<Args&&>(arg);
- }
-} // namespace std
+/// @brief Move object.
+/// @tparam Args the object type.
+/// @param arg the object.
+/// @return object's rvalue
+template <typename Args>
+inline Args&& move(Args&& arg) {
+ return static_cast<Args&&>(arg);
+}
+} // namespace std
-#endif // LIBCXX_UTILITY_H
+#endif // LIBCXX_UTILITY_H