summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorAmlal El Mahrouss <amlal@nekernel.org>2025-12-20 13:01:24 +0100
committerAmlal El Mahrouss <amlal@nekernel.org>2025-12-20 13:01:57 +0100
commit34fc5336b50c6ae490546ee8f5c95eedb80b49e8 (patch)
tree2a3004c5c54899747a43a336774bf78e89d8126a
parent2a40debc078efdcacb23762aae89ae307e8b81e9 (diff)
feat: new types `callable_type`, `complex_domain`, and `real_domain` for LibC++/Nectar.v0.1.0
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
-rw-r--r--include/LibC++/base_math.h28
-rw-r--r--include/LibC++/base_process.h2
-rw-r--r--include/LibC++/filesystem.h9
-rw-r--r--include/LibC++/new.h13
4 files changed, 35 insertions, 17 deletions
diff --git a/include/LibC++/base_math.h b/include/LibC++/base_math.h
index 97f24ee..22c9ab9 100644
--- a/include/LibC++/base_math.h
+++ b/include/LibC++/base_math.h
@@ -6,14 +6,14 @@
#pragma once
-#include <LibC++/defines.h>
+#include <defines>
#ifndef NAN
#define NAN (__builtin_nanf(""))
#endif // !NAN
-/// @file Math.h
-/// @brief Math functions.
+/// @file base_math.h
+/// @brief Base Mathematic functions.
#ifdef __LIBCXX_USE_DOUBLE__
typedef double real_type;
@@ -25,19 +25,16 @@ namespace std::base_math {
inline constexpr static auto not_a_number = NAN;
/// =========================================================== ///
-/// @brief Power function, with Repeat argument.
+/// @brief Power of Exponent function.
/// =========================================================== ///
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 == 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;
+ for (auto i = 0UL; i < Exponent; ++i) result *= in;
return result;
}
@@ -85,4 +82,17 @@ inline real_type lerp(real_type to, real_type from, real_type stat) {
real_type diff = (to - from);
return from + (diff * stat);
}
+
+using real_domain = double;
+
+struct complex_domain final {
+ double Re;
+ double Im;
+};
+
+typename<class Result> using callable_type = Result (*)(size_t n, ...);
} // namespace std::base_math
+
+#ifdef __cpp_lib_base_math
+#define __cpp_lib_base_math 1
+#endif
diff --git a/include/LibC++/base_process.h b/include/LibC++/base_process.h
index 96ca42f..8fbe7b7 100644
--- a/include/LibC++/base_process.h
+++ b/include/LibC++/base_process.h
@@ -6,7 +6,7 @@
#pragma once
-#include <LibC++/defines.h>
+#include <defines>
__init_decl()
diff --git a/include/LibC++/filesystem.h b/include/LibC++/filesystem.h
index af9fd79..91218e8 100644
--- a/include/LibC++/filesystem.h
+++ b/include/LibC++/filesystem.h
@@ -7,7 +7,8 @@
#ifndef __NECTAR_FS_H__
#define __NECTAR_FS_H__
-#include <LibC++/defines.h>
+#include <chrono>
+#include <defines>
namespace std {
class path;
@@ -16,4 +17,8 @@ class directory_entry;
class directory_iterator;
} // namespace std
-#endif // __NECTAR_FS_H__ \ No newline at end of file
+#ifndef __cpp_lib_filesystem
+#define __cpp_lib_filesystem 201703L
+#endif
+
+#endif // __NECTAR_FS_H__
diff --git a/include/LibC++/new.h b/include/LibC++/new.h
index 2c5715f..db25b82 100644
--- a/include/LibC++/new.h
+++ b/include/LibC++/new.h
@@ -6,7 +6,7 @@
#pragma once
-#include <LibC++/defines.h>
+#include <defines>
namespace std {
struct nothrow_t final {
@@ -38,15 +38,18 @@ void* operator new(size_t);
void* operator new[](size_t);
/// \brief placement_t new and delete operators. Governs how the memory shall be placed.
-/// \note This is a feature that shall be used wisely, failure to do so will produce Undefined Behaviors at runtime.
+/// \note This is a feature that shall be used wisely, failure to do so will produce Undefined
+/// Behaviors at runtime.
void* operator _placement_new(struct placement_t*);
void operator _placement_delete(struct placement_t*, void*);
/// \brief For all offsets within the base range and alignement 'align'
-/// \brief Allocate offsets with respect to the `base` interval, apply alignement of `align` value. Return `offsets` of length n as an aligned value within the domain of `base`.
-using placeable_callable_type = void*/*offsets*/(*)(void* base, size_t n, const int& align);
+/// \brief Allocate offsets with respect to the `base` interval, apply alignement of `align` value.
+/// Return `offsets` of length n as an aligned value within the domain of `base`.
+using placeable_callable_type = void* /*offsets*/ (*) (void* base, size_t n, const int& align);
-/// \note This should NOT fail, failure to meet the conditions will cause the program's state to be aborted.
+/// \note This should NOT fail, failure to meet the conditions will cause the program's state to be
+/// aborted.
/// \brief Set the placement policy of future memory allocations.
template <class PlaceableCallable>
void set_placement_policy(const PlaceableCallable&) noexcept;