Move all std related headers to "include_std"

This commit is contained in:
Alex
2023-04-10 06:08:58 +03:00
parent e414804445
commit 41dafe32fb
38 changed files with 16 additions and 42 deletions

View File

@ -1,50 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_ASSERT_H__
#define __FENNIX_KERNEL_ASSERT_H__
#include <debug.h>
#define assert(x) \
do \
{ \
if (!(x)) \
{ \
void *CallerAddress = __builtin_extract_return_addr(__builtin_return_address(0)); \
error("Assertion failed! [%s] [%#lx => %s:%s:%d]", #x, CallerAddress, __FILE__, __FUNCTION__, __LINE__); \
while (1) \
; \
} \
} while (0)
#define assert_allow_continue(x) \
do \
{ \
if (!(x)) \
{ \
void *CallerAddress = __builtin_extract_return_addr(__builtin_return_address(0)); \
error("Assertion failed! [%s] [%#lx => %s:%s:%d]", #x, CallerAddress, __FILE__, __FUNCTION__, __LINE__); \
} \
} while (0)
#define static_assert(x) \
switch (x) \
case 0: \
case (x):
#endif // !__FENNIX_KERNEL_ASSERT_H__

View File

@ -1,19 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <std/atomic.hpp>

View File

@ -1,24 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
namespace std
{
typedef unsigned long size_t;
typedef long ptrdiff_t;
}

View File

@ -1,19 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <convert.h>

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _DLFCN_H
#define _DLFCN_H
#endif // !_DLFCN_H

View File

@ -1,59 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _ERRNO_H
#define _ERRNO_H
#define EPERM 1 /* Operation not permitted */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* Interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Argument list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No child processes */
#define EAGAIN 11 /* Try again */
#define ENOMEM 12 /* Out of memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device or resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
#define EDOM 33 /* Math argument out of domain of func */
#define ERANGE 34 /* Math result not representable */
extern int *__errno_location(void) __attribute__((const));
#define errno (*__errno_location())
#endif // !_ERRNO_H

View File

@ -1,136 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_LIMITS_H__
#define __FENNIX_KERNEL_LIMITS_H__
#undef CHAR_BIT
#define CHAR_BIT __CHAR_BIT__
#ifndef MB_LEN_MAX
#define MB_LEN_MAX 1
#endif
#undef SCHAR_MIN
#define SCHAR_MIN (-SCHAR_MAX - 1)
#undef SCHAR_MAX
#define SCHAR_MAX __SCHAR_MAX__
#undef UCHAR_MAX
#if __SCHAR_MAX__ == __INT_MAX__
#define UCHAR_MAX (SCHAR_MAX * 2U + 1U)
#else
#define UCHAR_MAX (SCHAR_MAX * 2 + 1)
#endif
#ifdef __CHAR_UNSIGNED__
#undef CHAR_MIN
#if __SCHAR_MAX__ == __INT_MAX__
#define CHAR_MIN 0U
#else
#define CHAR_MIN 0
#endif
#undef CHAR_MAX
#define CHAR_MAX UCHAR_MAX
#else
#undef CHAR_MIN
#define CHAR_MIN SCHAR_MIN
#undef CHAR_MAX
#define CHAR_MAX SCHAR_MAX
#endif
#undef SHRT_MIN
#define SHRT_MIN (-SHRT_MAX - 1)
#undef SHRT_MAX
#define SHRT_MAX __SHRT_MAX__
#undef USHRT_MAX
#if __SHRT_MAX__ == __INT_MAX__
#define USHRT_MAX (SHRT_MAX * 2U + 1U)
#else
#define USHRT_MAX (SHRT_MAX * 2 + 1)
#endif
#undef INT_MIN
#define INT_MIN (-INT_MAX - 1)
#undef INT_MAX
#define INT_MAX __INT_MAX__
#undef UINT_MAX
#define UINT_MAX (INT_MAX * 2U + 1U)
#undef LONG_MIN
#define LONG_MIN (-LONG_MAX - 1L)
#undef LONG_MAX
#define LONG_MAX __LONG_MAX__
#undef ULONG_MAX
#define ULONG_MAX (LONG_MAX * 2UL + 1UL)
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#undef LLONG_MIN
#define LLONG_MIN (-LLONG_MAX - 1LL)
#undef LLONG_MAX
#define LLONG_MAX __LONG_LONG_MAX__
#undef ULLONG_MAX
#define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
#endif
#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
#undef LONG_LONG_MIN
#define LONG_LONG_MIN (-LONG_LONG_MAX - 1LL)
#undef LONG_LONG_MAX
#define LONG_LONG_MAX __LONG_LONG_MAX__
#undef ULONG_LONG_MAX
#define ULONG_LONG_MAX (LONG_LONG_MAX * 2ULL + 1ULL)
#endif
#if (defined __STDC_WANT_IEC_60559_BFP_EXT__ || (defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L))
#undef CHAR_WIDTH
#define CHAR_WIDTH __SCHAR_WIDTH__
#undef SCHAR_WIDTH
#define SCHAR_WIDTH __SCHAR_WIDTH__
#undef UCHAR_WIDTH
#define UCHAR_WIDTH __SCHAR_WIDTH__
#undef SHRT_WIDTH
#define SHRT_WIDTH __SHRT_WIDTH__
#undef USHRT_WIDTH
#define USHRT_WIDTH __SHRT_WIDTH__
#undef INT_WIDTH
#define INT_WIDTH __INT_WIDTH__
#undef UINT_WIDTH
#define UINT_WIDTH __INT_WIDTH__
#undef LONG_WIDTH
#define LONG_WIDTH __LONG_WIDTH__
#undef ULONG_WIDTH
#define ULONG_WIDTH __LONG_WIDTH__
#undef LLONG_WIDTH
#define LLONG_WIDTH __LONG_LONG_WIDTH__
#undef ULLONG_WIDTH
#define ULLONG_WIDTH __LONG_LONG_WIDTH__
#endif
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
#undef BOOL_MAX
#define BOOL_MAX 1
#undef BOOL_WIDTH
#define BOOL_WIDTH 1
#endif
#endif // !__FENNIX_KERNEL_LIMITS_H__

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _MATH_H
#define _MATH_H
#endif // !_MATH_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _PTHREAD_H
#define _PTHREAD_H
#endif // !_PTHREAD_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _SCHED_H
#define _SCHED_H
#endif // !_SCHED_H

View File

@ -1,77 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
/* This function includes all the standard headers and defines some useful macros.
* Note: This std implementation is not complete.
*/
#ifndef __FENNIX_KERNEL_STD_H__
#define __FENNIX_KERNEL_STD_H__
#include <types.h>
#include <std/atomic.hpp>
#include <std/functional.hpp>
#include <std/list.hpp>
#include <std/smart_ptr.hpp>
#include <std/stdexcept.hpp>
#include <std/string.hpp>
#include <std/unordered_map.hpp>
#include <std/utility.hpp>
#include <std/vector.hpp>
/**
* @brief // stub namespace for std::align_val_t and new operator
* @note // Found on https://gcc.gnu.org/legacy-ml/gcc-patches/2016-09/msg00628.html for "_ZnwmSt11align_val_t" compiler error
*/
namespace std
{
typedef __SIZE_TYPE__ size_t;
static const size_t npos = -1;
enum class align_val_t : std::size_t
{
};
template <typename InputIt, typename OutputIt, typename UnaryOperation>
OutputIt transform(InputIt first, InputIt last, OutputIt result, UnaryOperation op)
{
while (first != last)
{
*result = op(*first);
++first;
++result;
}
return result;
};
inline __always_inline int tolower(int c)
{
if (c >= 'A' && c <= 'Z')
return c + ('a' - 'A');
else
return c;
}
inline __always_inline int toupper(int c)
{
if (c >= 'a' && c <= 'z')
return c - ('a' - 'A');
else
return c;
}
}
#endif // !__FENNIX_KERNEL_STD_H__

View File

@ -1,521 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_ATOMIC_H__
#define __FENNIX_KERNEL_STD_ATOMIC_H__
#include <types.h>
#include <cstddef>
#include <debug.h>
namespace std
{
#define _atomic(T) T
#define builtin_atomic_n(name) __atomic_##name##_n
#define builtin_atomic(name) __atomic_##name
/**
* @brief Specifies the memory ordering constraints for atomic operations.
*
* This enum specifies the possible values for the memory order parameter of atomic operations.
*
* Possible values are:
*
* - memory_order_relaxed: There are no synchronization
* or ordering constraints imposed on other reads or writes,
* only this operation's atomicity is guaranteed.
*
* - memory_order_consume: A load operation with this
* memory order performs a consume operation on the
* affected memory location: no reads or writes in the
* current thread dependent on the value currently loaded
* can be reordered before this load.
*
* - memory_order_acquire: A load operation with this
* memory order performs the acquire operation on the
* affected memory location: no reads or writes in the
* current thread can be reordered before this load.
*
* - memory_order_release: A store operation with this
* memory order performs the release operation: no reads
* or writes in the current thread can be reordered after
* this store.
*
* - memory_order_acq_rel: A read-modify-write operation
* with this memory order is both an acquire operation
* and a release operation.
*
* - memory_order_seq_cst: A load operation with this
* memory order performs an acquire operation, a store
* performs a release operation, and read-modify-write
* performs both an acquire operation and a release
* operation, plus a single total order exists in which
* all threads observe all modifications in the same order.
*/
enum class memory_order : int
{
relaxed,
consume,
acquire,
release,
acq_rel,
seq_cst
};
inline constexpr memory_order memory_order_relaxed = memory_order::relaxed;
inline constexpr memory_order memory_order_consume = memory_order::consume;
inline constexpr memory_order memory_order_acquire = memory_order::acquire;
inline constexpr memory_order memory_order_release = memory_order::release;
inline constexpr memory_order memory_order_acq_rel = memory_order::acq_rel;
inline constexpr memory_order memory_order_seq_cst = memory_order::seq_cst;
template <typename T>
class atomic
{
_atomic(T) value;
public:
atomic() noexcept : value(0) {}
atomic(T desired) noexcept : value(desired) {}
// atomic(const atomic &) = delete;
/**
* @brief Load the value of the atomic variable
*
* @note Order must be one of memory_order::relaxed, memory_order::consume, memory_order::acquire or memory_order::seq_cst
*
* @param order Memory order constraint to use
* @return The value of the atomic variable
*/
T load(memory_order order = memory_order::seq_cst) const noexcept
{
return builtin_atomic_n(load)(&this->value, static_cast<int>(order));
}
/**
* @copydoc load()
*/
T load(memory_order order = memory_order::seq_cst) const volatile noexcept
{
return builtin_atomic_n(load)(&this->value, static_cast<int>(order));
}
/**
* @brief Store the value of the atomic variable
*
* @note Order must be one of memory_order::relaxed, memory_order::release or memory_order::seq_cst
*
* @param desired The value to store
* @param order Memory order constraint to use
*/
void store(T desired, memory_order order = memory_order::seq_cst) noexcept
{
builtin_atomic_n(store)(&this->value, desired, static_cast<int>(order));
}
/**
* @copydoc store()
*/
void store(T desired, memory_order order = memory_order::seq_cst) volatile noexcept
{
builtin_atomic_n(store)(&this->value, desired, static_cast<int>(order));
}
/**
* @brief Exchange the value of the atomic variable
*
* @param desired The value to exchange
* @param order Memory order constraint to use
* @return The value of the atomic variable before the exchange
*/
T exchange(T desired, memory_order order = memory_order::seq_cst) noexcept
{
return builtin_atomic_n(exchange)(&this->value, desired, static_cast<int>(order));
}
/**
* @copydoc exchange()
*/
T exchange(T desired, memory_order order = memory_order::seq_cst) volatile noexcept
{
return builtin_atomic_n(exchange)(&this->value, desired, static_cast<int>(order));
}
/**
* @brief Compare and exchange the value of the atomic variable
*
* @param expected The expected value
* @param desired The desired value
* @param success Memory order constraint to use if the exchange succeeds
* @param failure Memory order constraint to use if the exchange fails
* @return True if the exchange succeeded, false otherwise
*/
bool compare_exchange_weak(T &expected, T desired, std::memory_order success, std::memory_order failure) noexcept
{
return builtin_atomic(compare_exchange_weak)(&this->value, &expected, desired, false, success, failure);
}
/**
* @copydoc compare_exchange_weak()
*/
bool compare_exchange_weak(T &expected, T desired, std::memory_order success, std::memory_order failure) volatile noexcept
{
return builtin_atomic(compare_exchange_weak)(&this->value, &expected, desired, false, success, failure);
}
/**
* @brief Compare and exchange the value of the atomic variable
*
* @param expected The expected value
* @param desired The desired value
* @param order Memory order constraint to use
* @return True if the exchange succeeded, false otherwise
*/
bool compare_exchange_weak(T &expected, T desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(compare_exchange_weak)(&this->value, &expected, desired, false, order, static_cast<int>(order));
}
/**
* @copydoc compare_exchange_weak()
*/
bool compare_exchange_weak(T &expected, T desired, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(compare_exchange_weak)(&this->value, &expected, desired, false, order, static_cast<int>(order));
}
/**
* @brief Compare and exchange the value of the atomic variable
*
* @param expected The expected value
* @param desired The desired value
* @param success Memory order constraint to use if the exchange succeeds
* @param failure Memory order constraint to use if the exchange fails
* @return True if the exchange succeeded, false otherwise
*/
bool compare_exchange_strong(T &expected, T desired, std::memory_order success, std::memory_order failure) noexcept
{
return builtin_atomic(compare_exchange_strong)(&this->value, &expected, desired, true, success, failure);
}
/**
* @copydoc compare_exchange_strong()
*/
bool compare_exchange_strong(T &expected, T desired, std::memory_order success, std::memory_order failure) volatile noexcept
{
return builtin_atomic(compare_exchange_strong)(&this->value, &expected, desired, true, success, failure);
}
/**
* @brief Compare and exchange the value of the atomic variable
*
* @param expected The expected value
* @param desired The desired value
* @param order Memory order constraint to use
* @return True if the exchange succeeded, false otherwise
*/
bool compare_exchange_strong(T &expected, T desired, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(compare_exchange_strong)(&this->value, &expected, desired, true, order, static_cast<int>(order));
}
/**
* @copydoc compare_exchange_strong()
*/
bool compare_exchange_strong(T &expected, T desired, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(compare_exchange_strong)(&this->value, &expected, desired, true, order, static_cast<int>(order));
}
/**
* @brief Fetch and add the value of the atomic variable
*
* @param arg The value to add
* @param order Memory order constraint to use
* @return The value of the atomic variable before the addition
*/
T fetch_add(T arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(fetch_add)(&this->value, arg, static_cast<int>(order));
}
/**
* @copydoc fetch_add()
*/
T fetch_add(T arg, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(fetch_add)(&this->value, arg, static_cast<int>(order));
}
/**
* @brief Fetch and subtract the value of the atomic variable
*
* @param arg The value to subtract
* @param order Memory order constraint to use
* @return The value of the atomic variable before the subtraction
*/
T fetch_sub(T arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(fetch_sub)(&this->value, arg, static_cast<int>(order));
}
/**
* @copydoc fetch_sub()
*/
T fetch_sub(T arg, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(fetch_sub)(&this->value, arg, static_cast<int>(order));
}
/**
* @brief Fetch and bitwise AND the value of the atomic variable
*
* @param arg The value to AND
* @param order Memory order constraint to use
* @return The value of the atomic variable before the AND
*/
T fetch_and(T arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(fetch_and)(&this->value, arg, static_cast<int>(order));
}
/**
* @copydoc fetch_and()
*/
T fetch_and(T arg, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(fetch_and)(&this->value, arg, static_cast<int>(order));
}
/**
* @brief Fetch and bitwise OR the value of the atomic variable
*
* @param arg The value to OR
* @param order Memory order constraint to use
* @return The value of the atomic variable before the OR
*/
T fetch_or(T arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(fetch_or)(&this->value, arg, static_cast<int>(order));
}
/**
* @copydoc fetch_or()
*/
T fetch_or(T arg, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(fetch_or)(&this->value, arg, static_cast<int>(order));
}
/**
* @brief Fetch and bitwise XOR the value of the atomic variable
*
* @param arg The value to XOR
* @param order Memory order constraint to use
* @return The value of the atomic variable before the XOR
*/
T fetch_xor(T arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(fetch_xor)(&this->value, arg, static_cast<int>(order));
}
/**
* @copydoc fetch_xor()
*/
T fetch_xor(T arg, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(fetch_xor)(&this->value, arg, static_cast<int>(order));
}
/**
* @brief Fetch and bitwise NAND the value of the atomic variable
*
* @param arg The value to NAND
* @param order Memory order constraint to use
* @return The value of the atomic variable before the NAND
*/
T fetch_nand(T arg, std::memory_order order = std::memory_order_seq_cst) noexcept
{
return builtin_atomic(fetch_nand)(&this->value, arg, static_cast<int>(order));
}
/**
* @copydoc fetch_nand()
*/
T fetch_nand(T arg, std::memory_order order = std::memory_order_seq_cst) volatile noexcept
{
return builtin_atomic(fetch_nand)(&this->value, arg, static_cast<int>(order));
}
/**
* @brief Notify all threads waiting on this atomic variable
*/
void notify_all() noexcept
{
fixme("not implemented");
}
/**
* @copydoc notify_all()
*/
void notify_all() volatile noexcept
{
fixme("not implemented");
}
/**
* @brief Notify one thread waiting on this atomic variable
*/
void notify_one() noexcept
{
fixme("not implemented");
}
/**
* @copydoc notify_one()
*/
void notify_one() volatile noexcept
{
fixme("not implemented");
}
/**
* @brief Wait for the atomic variable to change
*
* @param old The value to wait for
* @param order Memory order constraint to use
*/
void wait(T old, std::memory_order order = std::memory_order::seq_cst) const noexcept
{
fixme("not implemented");
}
/**
* @copydoc wait()
*/
void wait(T old, std::memory_order order = std::memory_order::seq_cst) const volatile noexcept
{
fixme("not implemented");
}
/**
* @brief Check whether this atomic type is lock-free
* @return True if this atomic type is lock-free
*/
bool is_lock_free() const noexcept
{
fixme("not implemented");
return true;
}
/**
* @copydoc is_lock_free()
*/
bool is_lock_free() const volatile noexcept
{
fixme("not implemented");
return true;
}
/**
* @brief Equals true if this atomic type is always lock-free
*/
static constexpr bool is_always_lock_free = true;
T operator++() noexcept { return this->fetch_add(1) + 1; }
T operator--() noexcept { return this->fetch_sub(1) - 1; }
T operator++(int) noexcept { return this->fetch_add(1); }
T operator--(int) noexcept { return this->fetch_sub(1); }
T operator+=(T desired) noexcept { return this->fetch_add(desired) + desired; }
T operator-=(T desired) noexcept { return this->fetch_sub(desired) - desired; }
// T operator+=(std::ptrdiff_t desired) noexcept { return this->fetch_add(desired) + desired; }
// T operator-=(std::ptrdiff_t desired) noexcept { return this->fetch_sub(desired) - desired; }
T operator&=(T desired) noexcept { return this->fetch_and(desired) & desired; }
T operator|=(T desired) noexcept { return this->fetch_or(desired) | desired; }
T operator^=(T desired) noexcept { return this->fetch_xor(desired) ^ desired; }
T operator->() noexcept { return this->load(); }
T operator~() noexcept { return this->fetch_nand(-1); }
bool operator==(const atomic &other) const noexcept { return this->load() == other.load(); }
bool operator==(T other) const noexcept { return this->load() == other; }
atomic &operator=(const atomic &) = delete;
T operator=(T desired) noexcept
{
this->store(desired);
return desired;
}
operator bool() noexcept { return this->load() != 0; }
// operator T() noexcept { return this->load(); }
operator T() const noexcept { return this->load(); }
};
typedef atomic<bool> atomic_bool;
typedef atomic<char> atomic_char;
typedef atomic<signed char> atomic_schar;
typedef atomic<unsigned char> atomic_uchar;
typedef atomic<short> atomic_short;
typedef atomic<unsigned short> atomic_ushort;
typedef atomic<int> atomic_int;
typedef atomic<unsigned int> atomic_uint;
typedef atomic<long> atomic_long;
typedef atomic<unsigned long> atomic_ulong;
typedef atomic<long long> atomic_llong;
typedef atomic<unsigned long long> atomic_ullong;
typedef atomic<char16_t> atomic_char16_t;
typedef atomic<char32_t> atomic_char32_t;
typedef atomic<wchar_t> atomic_wchar_t;
typedef atomic<int8_t> atomic_int8_t;
typedef atomic<uint8_t> atomic_uint8_t;
typedef atomic<int16_t> atomic_int16_t;
typedef atomic<uint16_t> atomic_uint16_t;
typedef atomic<int32_t> atomic_int32_t;
typedef atomic<uint32_t> atomic_uint32_t;
typedef atomic<int64_t> atomic_int64_t;
typedef atomic<uint64_t> atomic_uint64_t;
typedef atomic<int_least8_t> atomic_int_least8_t;
typedef atomic<uint_least8_t> atomic_uint_least8_t;
typedef atomic<int_least16_t> atomic_int_least16_t;
typedef atomic<uint_least16_t> atomic_uint_least16_t;
typedef atomic<int_least32_t> atomic_int_least32_t;
typedef atomic<uint_least32_t> atomic_uint_least32_t;
typedef atomic<int_least64_t> atomic_int_least64_t;
typedef atomic<uint_least64_t> atomic_uint_least64_t;
typedef atomic<int_fast8_t> atomic_int_fast8_t;
typedef atomic<uint_fast8_t> atomic_uint_fast8_t;
typedef atomic<int_fast16_t> atomic_int_fast16_t;
typedef atomic<uint_fast16_t> atomic_uint_fast16_t;
typedef atomic<int_fast32_t> atomic_int_fast32_t;
typedef atomic<uint_fast32_t> atomic_uint_fast32_t;
typedef atomic<int_fast64_t> atomic_int_fast64_t;
typedef atomic<uint_fast64_t> atomic_uint_fast64_t;
typedef atomic<intptr_t> atomic_intptr_t;
typedef atomic<uintptr_t> atomic_uintptr_t;
typedef atomic<size_t> atomic_size_t;
typedef atomic<ptrdiff_t> atomic_ptrdiff_t;
typedef atomic<intmax_t> atomic_intmax_t;
typedef atomic<uintmax_t> atomic_uintmax_t;
}
#undef builtin_atomic_n
#undef builtin_atomic
#endif // !__FENNIX_KERNEL_STD_ATOMIC_H__

View File

@ -1,50 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_FUNCTIONAL_H__
#define __FENNIX_KERNEL_STD_FUNCTIONAL_H__
#include <types.h>
#include <assert.h>
namespace std
{
template <typename Key>
struct hash
{
size_t operator()(const Key &key) const
{
static_assert(sizeof(size_t) == sizeof(uint64_t)); // size_t and uint64_t must have the same size
const uint64_t fnv_offset_basis = 14695981039346656037ull;
const uint64_t fnv_prime = 1099511628211ull;
const uint8_t *data = reinterpret_cast<const uint8_t *>(&key);
const size_t size = sizeof(Key);
uint64_t ret = fnv_offset_basis;
for (size_t i = 0; i < size; ++i)
{
ret ^= static_cast<uint64_t>(data[i]);
ret *= fnv_prime;
}
return static_cast<size_t>(ret);
}
};
}
#endif // !__FENNIX_KERNEL_STD_FUNCTIONAL_H__

View File

@ -1,224 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_LIST_H__
#define __FENNIX_KERNEL_STD_LIST_H__
#include <types.h>
#include <std/stdexcept.hpp>
namespace std
{
template <typename T>
class list
{
private:
struct Node
{
T value;
Node *prev;
Node *next;
Node(const T &v, Node *p = nullptr, Node *n = nullptr)
: value(v), prev(p), next(n) {}
};
Node *head;
Node *tail;
size_t size;
public:
list() : head(nullptr), tail(nullptr), size(0) {}
~list() { clear(); }
list(const list &other) : head(nullptr), tail(nullptr), size(0) { *this = other; }
void push_back(const T &value)
{
Node *new_node = new Node(value, tail, nullptr);
if (empty())
{
head = tail = new_node;
}
else
{
tail->next = new_node;
tail = new_node;
}
++size;
}
void pop_back()
{
if (empty())
{
throw std::runtime_error("list is empty");
}
else if (head == tail)
{
delete tail;
head = tail = nullptr;
--size;
}
else
{
Node *old_tail = tail;
tail = tail->prev;
tail->next = nullptr;
delete old_tail;
--size;
}
}
void push_front(const T &value)
{
Node *new_node = new Node(value, nullptr, head);
if (empty())
{
head = tail = new_node;
}
else
{
head->prev = new_node;
head = new_node;
}
++size;
}
void pop_front()
{
if (empty())
{
throw std::runtime_error("list is empty");
}
else if (head == tail)
{
delete head;
head = tail = nullptr;
--size;
}
else
{
Node *old_head = head;
head = head->next;
head->prev = nullptr;
delete old_head;
--size;
}
}
bool empty() const { return size == 0; }
void clear()
{
while (!empty())
pop_back();
}
list &operator=(const list &other)
{
if (this != &other)
{
clear();
for (const T &value : other)
{
push_back(value);
}
}
return *this;
}
class iterator
{
private:
Node *node;
friend class list;
public:
iterator(Node *p = nullptr) : node(p) {}
T &operator*() const { return node->value; }
T *operator->() const { return &node->value; }
iterator &operator++()
{
node = node->next;
return *this;
}
iterator &operator--()
{
node = node->prev;
return *this;
}
iterator operator++(int)
{
iterator tmp = *this;
++*this;
return tmp;
}
iterator operator--(int)
{
iterator tmp = *this;
--*this;
return tmp;
}
bool operator==(const iterator &rhs) const { return node == rhs.node; }
bool operator!=(const iterator &rhs) const { return node != rhs.node; }
};
iterator begin() { return iterator(head); }
iterator end() { return iterator(nullptr); }
iterator insert(iterator pos, const T &value)
{
if (pos == end())
{
push_back(value);
return iterator(tail);
}
else if (pos == begin())
{
push_front(value);
return iterator(head);
}
else
{
Node *p = pos.node;
Node *new_node = new Node(value, p->prev, p);
p->prev->next = new_node;
p->prev = new_node;
++size;
return iterator(new_node);
}
}
iterator erase(iterator pos)
{
Node *p = pos.node;
iterator next(p->next);
p->prev->next = p->next;
p->next->prev = p->prev;
delete p;
--size;
return next;
}
};
}
#endif // !__FENNIX_KERNEL_STD_LIST_H__

View File

@ -1,292 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_SMART_POINTER_H__
#define __FENNIX_KERNEL_STD_SMART_POINTER_H__
#include <types.h>
#include <debug.h>
// show debug messages
// #define DEBUG_SMARTPOINTERS 1
#ifdef DEBUG_SMARTPOINTERS
#define spdbg(m, ...) debug(m, ##__VA_ARGS__)
#else
#define spdbg(m, ...)
#endif
namespace std
{
/**
* @brief A smart pointer class
*
* This class is a smart pointer class. It is used to manage the lifetime of
* objects. It is a reference counted pointer, so when the last reference to
* the object is removed, the object is deleted.
*
* Basic Usage:
* smart_ptr<char> pointer(new char());
* *pointer = 'a';
* printf("%c", *pointer); // Prints "a"
*/
template <class T>
class smart_ptr
{
T *RealPointer;
public:
explicit smart_ptr(T *Pointer = nullptr)
{
spdbg("Smart pointer created (%#lx)", this->RealPointer);
this->RealPointer = Pointer;
}
~smart_ptr()
{
spdbg("Smart pointer deleted (%#lx)", this->RealPointer);
delete this->RealPointer, this->RealPointer = nullptr;
}
T &operator*()
{
spdbg("Smart pointer dereferenced (%#lx)", this->RealPointer);
return *this->RealPointer;
}
T *operator->()
{
spdbg("Smart pointer dereferenced (%#lx)", this->RealPointer);
return this->RealPointer;
}
T *get()
{
spdbg("Smart pointer returned (%#lx)", this->RealPointer);
return this->RealPointer;
}
};
template <class T>
class auto_ptr
{
};
template <class T>
class unique_ptr
{
};
template <class T>
class weak_ptr
{
};
template <typename T>
class shared_ptr
{
private:
class counter
{
private:
unsigned int RefCount{};
public:
counter() : RefCount(0) { spdbg("Counter %#lx created", this); };
counter(const counter &) = delete;
counter &operator=(const counter &) = delete;
~counter() { spdbg("Counter %#lx deleted", this); }
void reset()
{
this->RefCount = 0;
spdbg("reset");
}
unsigned int get()
{
return this->RefCount;
spdbg("return");
}
void operator++()
{
this->RefCount++;
spdbg("increment");
}
void operator++(int)
{
this->RefCount++;
spdbg("increment");
}
void operator--()
{
this->RefCount--;
spdbg("decrement");
}
void operator--(int)
{
this->RefCount--;
spdbg("decrement");
}
};
counter *ReferenceCounter;
T *RealPointer;
public:
explicit shared_ptr(T *Pointer = nullptr)
{
this->RealPointer = Pointer;
this->ReferenceCounter = new counter();
spdbg("[%#lx] Shared pointer created (ptr=%#lx, ref=%#lx)", this, Pointer, this->ReferenceCounter);
if (Pointer)
(*this->ReferenceCounter)++;
}
shared_ptr(shared_ptr<T> &SPtr)
{
spdbg("[%#lx] Shared pointer copied (ptr=%#lx, ref=%#lx)", this, SPtr.RealPointer, SPtr.ReferenceCounter);
this->RealPointer = SPtr.RealPointer;
this->ReferenceCounter = SPtr.ReferenceCounter;
(*this->ReferenceCounter)++;
}
~shared_ptr()
{
spdbg("[%#lx] Shared pointer destructor called", this);
(*this->ReferenceCounter)--;
if (this->ReferenceCounter->get() == 0)
{
spdbg("[%#lx] Shared pointer deleted (ptr=%#lx, ref=%#lx)", this, this->RealPointer, this->ReferenceCounter);
delete this->ReferenceCounter, this->ReferenceCounter = nullptr;
delete this->RealPointer, this->RealPointer = nullptr;
}
}
unsigned int get_count()
{
spdbg("[%#lx] Shared pointer count (%d)", this, this->ReferenceCounter->get());
return this->ReferenceCounter->get();
}
T *get()
{
spdbg("[%#lx] Shared pointer get (%#lx)", this, this->RealPointer);
return this->RealPointer;
}
T &operator*()
{
spdbg("[%#lx] Shared pointer dereference (ptr*=%#lx)", this, *this->RealPointer);
return *this->RealPointer;
}
T *operator->()
{
spdbg("[%#lx] Shared pointer dereference (ptr->%#lx)", this, this->RealPointer);
return this->RealPointer;
}
void reset(T *Pointer = nullptr)
{
if (this->RealPointer == Pointer)
return;
spdbg("[%#lx] Shared pointer reset (ptr=%#lx, ref=%#lx)", this, Pointer, this->ReferenceCounter);
(*this->ReferenceCounter)--;
if (this->ReferenceCounter->get() == 0)
{
delete this->RealPointer;
delete this->ReferenceCounter;
}
this->RealPointer = Pointer;
this->ReferenceCounter = new counter();
if (Pointer)
(*this->ReferenceCounter)++;
}
void reset()
{
spdbg("[%#lx] Shared pointer reset (ptr=%#lx, ref=%#lx)", this, this->RealPointer, this->ReferenceCounter);
if (this->ReferenceCounter->get() == 1)
{
delete this->RealPointer, this->RealPointer = nullptr;
delete this->ReferenceCounter, this->ReferenceCounter = nullptr;
}
else
{
(*this->ReferenceCounter)--;
}
}
void swap(shared_ptr<T> &Other)
{
spdbg("[%#lx] Shared pointer swap (ptr=%#lx, ref=%#lx <=> ptr=%#lx, ref=%#lx)",
this, this->RealPointer, this->ReferenceCounter, Other.RealPointer, Other.ReferenceCounter);
T *tempRealPointer = this->RealPointer;
counter *tempReferenceCounter = this->ReferenceCounter;
this->RealPointer = Other.RealPointer;
this->ReferenceCounter = Other.ReferenceCounter;
Other.RealPointer = tempRealPointer;
Other.ReferenceCounter = tempReferenceCounter;
}
};
template <typename T>
struct remove_reference
{
typedef T type;
};
template <typename T>
struct remove_reference<T &>
{
typedef T type;
};
template <typename T>
struct remove_reference<T &&>
{
typedef T type;
};
template <typename T>
using remove_reference_t = typename remove_reference<T>::type;
template <typename T>
T &&forward(remove_reference_t<T> &t) { return static_cast<T &&>(t); };
template <typename T>
T &&forward(remove_reference_t<T> &&t) { return static_cast<T &&>(t); };
template <typename T, typename... Args>
shared_ptr<T> make_shared(Args &&...args)
{
return shared_ptr<T>(new T(forward<Args>(args)...));
};
template <typename T, typename... Args>
smart_ptr<T> make_smart(Args &&...args)
{
return smart_ptr<T>(new T(forward<Args>(args)...));
};
}
#endif // !__FENNIX_KERNEL_STD_SMART_POINTER_H__

View File

@ -1,36 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_STDEXCEPT_H__
#define __FENNIX_KERNEL_STD_STDEXCEPT_H__
#include <types.h>
namespace std
{
class runtime_error
{
private:
const char *m_what;
public:
runtime_error(const char *what_arg) : m_what(what_arg) {}
const char *what() const { return this->m_what; }
};
}
#endif // !__FENNIX_KERNEL_STD_STDEXCEPT_H__

View File

@ -1,553 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_STRING_H__
#define __FENNIX_KERNEL_STD_STRING_H__
#include <types.h>
#include <convert.h>
#include <debug.h>
// show debug messages
// #define DEBUG_CPP_STRING 1
#ifdef DEBUG_CPP_STRING
#define strdbg(m, ...) debug(m, ##__VA_ARGS__)
#else
#define strdbg(m, ...)
#endif
// TODO: Somewhere the delete is called twice, causing a double free error.
namespace std
{
/**
* @brief String class
* String class that can be used to store strings.
*/
class string
{
private:
char *Data;
size_t Length;
size_t Capacity;
public:
static const size_t npos = -1;
string(const char *Str = "")
{
this->Length = strlen(Str);
this->Capacity = this->Length + 1;
this->Data = new char[this->Capacity];
strcpy(this->Data, Str);
strdbg("New string created: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
}
~string()
{
strdbg("String deleted: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
delete[] this->Data, this->Data = nullptr;
}
size_t length() const
{
strdbg("String length: %d", this->Length);
return this->Length;
}
size_t capacity() const
{
strdbg("String capacity: %d", this->Capacity);
return this->Capacity;
}
const char *c_str() const
{
strdbg("String data: \"%s\"", this->Data);
return this->Data;
}
void resize(size_t NewLength)
{
strdbg("String resize: %d", NewLength);
if (NewLength > this->Capacity)
{
size_t newCapacity = NewLength + 1;
char *newData = new char[newCapacity];
strcpy(newData, this->Data);
strdbg("old: %#lx, new: %#lx", this->Data, newData);
delete[] this->Data;
this->Data = newData;
this->Capacity = newCapacity;
}
this->Length = NewLength;
this->Data[this->Length] = '\0';
strdbg("String resized: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
}
void concat(const string &Other)
{
size_t NewLength = this->Length + Other.Length;
this->resize(NewLength);
strcat(this->Data, Other.Data);
strdbg("String concatenated: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
}
bool empty() const
{
strdbg("String empty: %d", this->Length == 0);
return this->Length == 0;
}
size_t size() const
{
strdbg("String size: %d", this->Length);
return this->Length;
}
void clear()
{
strdbg("String clear");
this->resize(0);
}
size_t find(const char *Str, size_t Pos = 0) const
{
strdbg("String find: \"%s\", %d", Str, Pos);
if (Pos >= this->Length)
return npos;
for (size_t i = Pos; i < this->Length; i++)
{
bool found = true;
for (size_t j = 0; Str[j] != '\0'; j++)
{
if (this->Data[i + j] != Str[j])
{
found = false;
break;
}
}
if (found)
return i;
}
return npos;
}
size_t find(const string &Str, size_t Pos = 0) const
{
strdbg("String find: \"%s\", %d", Str.c_str(), Pos);
return this->find(Str.c_str(), Pos);
}
void erase(int Index, int Count = 1)
{
strdbg("String erase: %d, %d", Index, Count);
if (Index < 0 || (size_t)Index >= this->Length)
return;
if (Count < 0)
return;
if ((size_t)(Index + Count) > this->Length)
Count = (int)this->Length - Index;
for (size_t i = Index; i < this->Length - Count; i++)
this->Data[i] = this->Data[i + Count];
this->Length -= Count;
this->Data[this->Length] = '\0';
strdbg("String erased: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
}
size_t find_last_not_of(const char *Str, size_t Pos = npos) const
{
strdbg("String find_last_not_of: \"%s\", %d", Str, Pos);
if (Pos == npos)
Pos = this->Length - 1;
for (int i = (int)Pos; i >= 0; i--)
{
bool found = false;
for (size_t j = 0; Str[j] != '\0'; j++)
{
if (this->Data[i] == Str[j])
{
found = true;
break;
}
}
if (!found)
return i;
}
return npos;
}
size_t find_first_not_of(const char *Str, size_t Pos = 0) const
{
strdbg("String find_first_not_of: \"%s\", %d", Str, Pos);
if (Pos >= this->Length)
return npos;
for (size_t i = Pos; i < this->Length; i++)
{
bool found = false;
for (size_t j = 0; Str[j] != '\0'; j++)
{
if (this->Data[i] == Str[j])
{
found = true;
break;
}
}
if (!found)
return i;
}
return npos;
}
size_t find_first_of(const char *Str, size_t Pos = 0) const
{
strdbg("String find_first_of: \"%s\", %d", Str, Pos);
if (Pos >= this->Length)
return npos;
for (size_t i = Pos; i < this->Length; i++)
{
bool found = false;
for (size_t j = 0; Str[j] != '\0'; j++)
{
if (this->Data[i] == Str[j])
{
found = true;
break;
}
}
if (found)
return i;
}
return npos;
}
size_t find_last_of(const char *Str, size_t Pos = npos) const
{
strdbg("String find_last_of: \"%s\", %d", Str, Pos);
if (Pos == npos)
Pos = this->Length - 1;
for (int i = (int)Pos; i >= 0; i--)
{
bool found = false;
for (int j = 0; Str[j] != '\0'; j++)
{
if (this->Data[i] == Str[j])
{
found = true;
break;
}
}
if (found)
return i;
}
return npos;
}
size_t find_first_of(char C, size_t Pos = 0) const
{
strdbg("String find_first_of: '%c', %d", C, Pos);
if (Pos >= this->Length)
return npos;
for (size_t i = Pos; i < this->Length; i++)
{
if (this->Data[i] == C)
return i;
}
return npos;
}
size_t find_last_of(char C, size_t Pos = npos) const
{
strdbg("String find_last_of: '%c', %d", C, Pos);
if (Pos == npos)
Pos = this->Length - 1;
for (int i = (int)Pos; i >= 0; i--)
{
if (this->Data[i] == C)
return i;
}
return npos;
}
size_t substr(const char *Str, size_t Pos = 0) const
{
strdbg("String substr: \"%s\", %d", Str, Pos);
if (Pos >= this->Length)
return npos;
for (size_t i = Pos; i < this->Length; i++)
{
bool found = true;
for (size_t j = 0; Str[j] != '\0'; j++)
{
if (this->Data[i + j] != Str[j])
{
found = false;
break;
}
}
if (found)
return i;
}
return npos;
}
size_t substr(const string &Str, size_t Pos = 0) const
{
strdbg("String substr: \"%s\", %d", Str.c_str(), Pos);
return this->substr(Str.c_str(), Pos);
}
string substr(size_t Pos = 0, size_t Count = npos) const
{
strdbg("String substr: %d, %d", Pos, Count);
if (Pos >= this->Length)
return string();
if (Count == npos)
Count = this->Length - Pos;
if (Pos + Count > this->Length)
Count = this->Length - Pos;
string ret;
ret.resize(Count);
for (size_t i = 0; i < Count; i++)
ret.Data[i] = this->Data[Pos + i];
ret.Data[Count] = '\0';
return ret;
}
void replace(size_t Pos, size_t Count, const char *Str)
{
strdbg("String replace: %d, %d, \"%s\"", Pos, Count, Str);
if (Pos >= this->Length)
return;
if ((int64_t)Count < 0)
return;
if (Pos + Count > this->Length)
Count = this->Length - Pos;
size_t NewLength = this->Length - Count + strlen(Str);
this->resize(NewLength);
for (size_t i = this->Length - 1; i >= Pos + strlen(Str); i--)
this->Data[i] = this->Data[i - strlen(Str) + Count];
for (unsigned long i = 0; i < strlen(Str); i++)
this->Data[Pos + i] = Str[i];
strdbg("String replaced: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
}
void replace(size_t Pos, size_t Count, const string &Str)
{
strdbg("String replace: %d, %d, \"%s\"", Pos, Count, Str.Data);
if (Pos >= this->Length)
return;
if ((int64_t)Count < 0)
return;
if (Pos + Count > this->Length)
Count = this->Length - Pos;
size_t NewLength = this->Length - Count + Str.Length;
this->resize(NewLength);
for (size_t i = this->Length - 1; i >= Pos + Str.Length; i--)
this->Data[i] = this->Data[i - Str.Length + Count];
for (size_t i = 0; i < Str.Length; i++)
this->Data[Pos + i] = Str.Data[i];
strdbg("String replaced: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
}
string operator+(const string &Other) const
{
string result = *this;
result.concat(Other);
strdbg("String added: \"%s\" (data: %#lx, length: %d, capacity: %d)", result.Data, result.Data, result.Length, result.Capacity);
return result;
}
string operator+(const char *Other) const
{
string result = *this;
result.concat(Other);
strdbg("String added: \"%s\" (data: %#lx, length: %d, capacity: %d)", result.Data, result.Data, result.Length, result.Capacity);
return result;
}
string &operator+=(const string &Other)
{
this->concat(Other);
strdbg("String appended: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
return *this;
}
string &operator+=(const char *Other)
{
this->concat(Other);
strdbg("String appended: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
return *this;
}
/* warning: implicitly-declared constexpr String::String(const String&) is deprecated [-Wdeprecated-copy] */
string &operator=(const string &Other) = default;
// string &operator=(const string &Other)
// {
// if (this != &Other)
// {
// delete[] this->Data;
// this->Data = Other.Data;
// this->Length = Other.Length;
// this->Capacity = Other.Capacity;
// strdbg("String assigned: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
// }
// return *this;
// }
string &operator=(const char *Other)
{
this->Length = strlen(Other);
this->Capacity = this->Length + 1;
delete[] this->Data;
this->Data = new char[this->Capacity];
strcpy(this->Data, Other);
strdbg("String assigned: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
return *this;
}
string &operator<<(const string &Other)
{
this->concat(Other);
strdbg("String appended: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
return *this;
}
string &operator<<(const char *Other)
{
this->concat(Other);
strdbg("String appended: \"%s\" (data: %#lx, length: %d, capacity: %d)", this->Data, this->Data, this->Length, this->Capacity);
return *this;
}
char &operator[](int Index)
{
strdbg("String index: %d", Index);
return this->Data[Index];
}
const char &operator[](int Index) const
{
strdbg("String index: %d", Index);
return this->Data[Index];
}
bool operator==(const string &Other) const
{
strdbg("String compared: \"%s\" == \"%s\"", this->Data, Other.Data);
return strcmp(this->Data, Other.Data) == 0;
}
bool operator!=(const char *Other) const
{
strdbg("String compared: \"%s\" != \"%s\"", this->Data, Other);
return strcmp(this->Data, Other) != 0;
}
bool operator!=(const string &Other) const
{
strdbg("String compared: \"%s\" != \"%s\"", this->Data, Other.Data);
return strcmp(this->Data, Other.Data) != 0;
}
bool operator==(const char *Other) const
{
strdbg("String compared: \"%s\" == \"%s\"", this->Data, Other);
return strcmp(this->Data, Other) == 0;
}
class iterator
{
private:
char *Pointer;
public:
iterator(char *Pointer) : Pointer(Pointer) {}
iterator &operator++()
{
++this->Pointer;
strdbg("String iterator incremented: %#lx", this->Pointer);
return *this;
}
char &operator*()
{
strdbg("String iterator dereferenced: %#lx", this->Pointer);
return *this->Pointer;
}
bool operator!=(const iterator &Other) const
{
strdbg("String iterator compared: %#lx != %#lx", this->Pointer, Other.Pointer);
return this->Pointer != Other.Pointer;
}
bool operator==(const iterator &Other) const
{
strdbg("String iterator compared: %#lx == %#lx", this->Pointer, Other.Pointer);
return this->Pointer == Other.Pointer;
}
};
iterator begin()
{
strdbg("String iterator begin: %#lx", this->Data);
return iterator(this->Data);
}
iterator end()
{
strdbg("String iterator end: %#lx", this->Data + this->Length);
return iterator(this->Data + this->Length);
}
};
}
#endif // !__FENNIX_KERNEL_STD_STRING_H__

View File

@ -1,131 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_UNORDERED_MAP_H__
#define __FENNIX_KERNEL_STD_UNORDERED_MAP_H__
#include <types.h>
#include <std/functional.hpp>
#include <std/utility.hpp>
#include <std/vector.hpp>
#include <std/list.hpp>
namespace std
{
template <typename key_type, typename value_type>
class unordered_map
{
public:
typedef std::pair<key_type, value_type> key_value_pair;
typedef std::list<key_value_pair> bucket;
typedef typename std::vector<bucket>::iterator iterator;
typedef typename std::vector<bucket>::const_iterator const_iterator;
private:
static const size_t DEFAULT_NUM_BUCKETS = 10;
std::vector<bucket> bkts;
size_t hash(const key_type &key) const
{
std::hash<key_type> hash_function;
return hash_function(key) % this->bkts.size();
}
public:
unordered_map() : bkts(DEFAULT_NUM_BUCKETS) {}
unordered_map(size_t num_buckets) : bkts(num_buckets) {}
void insert(const key_value_pair &pair)
{
size_t bucket_index = hash(pair.first);
bucket &bkt = this->bkts[bucket_index];
for (auto it = bkt.begin(); it != bkt.end(); ++it)
{
if (it->first == pair.first)
{
it->second = pair.second;
return;
}
}
bkt.push_back(pair);
}
bool contains(const key_type &key) const
{
size_t bucket_index = hash(key);
const bucket &bkt = this->bkts[bucket_index];
for (auto it = bkt.begin(); it != bkt.end(); ++it)
{
if (it->first == key)
{
return true;
}
}
return false;
}
iterator find(const key_type &k)
{
size_t bucket_index = hash(k);
bucket &bkt = this->bkts[bucket_index];
for (auto it = bkt.begin(); it != bkt.end(); ++it)
{
if (it->first == k)
return it;
}
return bkt.end();
}
const_iterator find(const key_type &k) const
{
size_t bucket_index = hash(k);
const bucket &bkt = this->bkts[bucket_index];
for (auto it = bkt.begin(); it != bkt.end(); ++it)
{
if (it->first == k)
return it;
}
return bkt.end();
}
iterator end() noexcept { return this->bkts.end(); }
size_t size() const
{
size_t count = 0;
foreach (const auto &bkt in this->bkts)
count += bkt.size();
return count;
}
value_type &operator[](const key_type &key)
{
size_t bucket_index = hash(key);
bucket &bkt = this->bkts[bucket_index];
for (auto it = bkt.begin(); it != bkt.end(); ++it)
{
if (it->first == key)
return it->second;
}
bkt.emplace_back(key, value_type());
return bkt.back().second;
}
};
}
#endif // !__FENNIX_KERNEL_STD_UNORDERED_MAP_H__

View File

@ -1,39 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_UTILITY_H__
#define __FENNIX_KERNEL_STD_UTILITY_H__
#include <types.h>
namespace std
{
template <typename T1, typename T2>
struct pair
{
typedef T1 first_type;
typedef T2 second_type;
T1 first;
T2 second;
pair() : first(T1()), second(T2()) {}
pair(const T1 &x, const T2 &y) : first(x), second(y) {}
};
}
#endif // !__FENNIX_KERNEL_STD_UTILITY_H__

View File

@ -1,284 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STD_VECTOR_H__
#define __FENNIX_KERNEL_STD_VECTOR_H__
#include <types.h>
#include <assert.h>
#include <cstring>
namespace std
{
template <class T>
class vector
{
private:
size_t VectorSize = 0;
size_t VectorCapacity = 0;
T *VectorBuffer = nullptr;
public:
typedef T *iterator;
typedef const T *const_iterator;
NIF vector()
{
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR INIT: vector( )");
#endif
VectorCapacity = 0;
VectorSize = 0;
VectorBuffer = 0;
}
NIF vector(size_t Size)
{
VectorCapacity = Size;
VectorSize = Size;
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR INIT: vector( %lld )", Size);
#endif
VectorBuffer = new T[Size];
}
NIF vector(size_t Size, const T &Initial)
{
VectorSize = Size;
VectorCapacity = Size;
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR INIT: vector( %lld %llx )", Size, Initial);
#endif
assert(Size > 0);
VectorBuffer = new T[Size];
for (size_t i = 0; i < Size; i++)
VectorBuffer[i] = Initial;
}
NIF vector(const vector<T> &v)
{
VectorSize = v.VectorSize;
VectorCapacity = v.VectorCapacity;
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR INIT: vector( <vector> )->Size: %lld", VectorSize);
#endif
assert(VectorSize > 0);
VectorBuffer = new T[VectorSize];
for (size_t i = 0; i < VectorSize; i++)
VectorBuffer[i] = v.VectorBuffer[i];
}
NIF ~vector()
{
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR INIT: ~vector( ~%lx )", VectorBuffer);
#endif
VectorSize = 0;
VectorCapacity = 0;
if (VectorBuffer != nullptr)
{
delete[] VectorBuffer, VectorBuffer = nullptr;
}
}
NIF void remove(size_t Position)
{
if (Position >= VectorSize)
return;
memset(&*(VectorBuffer + Position), 0, sizeof(T));
for (size_t i = 0; i < VectorSize - 1; i++)
{
*(VectorBuffer + Position + i) = *(VectorBuffer + Position + i + 1);
}
VectorSize--;
}
NIF void remove(const T &Value)
{
for (size_t i = 0; i < VectorSize; i++)
{
if (VectorBuffer[i] == Value)
{
remove(i);
return;
}
}
}
NIF T &null_elem()
{
static T null_elem;
return null_elem;
}
NIF bool null_elem(size_t Index)
{
if (!reinterpret_cast<uintptr_t>(&VectorBuffer[Index]))
return false;
return true;
}
NIF T &next(size_t Position)
{
if (Position + 1 < VectorSize && reinterpret_cast<uintptr_t>(&VectorBuffer[Position + 1]))
return VectorBuffer[Position + 1];
warn("next( %lld ) is null (requested by %#lx)", Position, __builtin_return_address(0));
return this->null_elem();
}
NIF T &prev(size_t Position)
{
if (Position > 0 && reinterpret_cast<uintptr_t>(&VectorBuffer[Position - 1]))
return VectorBuffer[Position - 1];
warn("prev( %lld ) is null (requested by %#lx)", Position, __builtin_return_address(0));
return this->null_elem();
}
NIF T &next(const T &Value)
{
for (size_t i = 0; i < VectorSize; i++)
{
if (VectorBuffer[i] == Value)
{
if (i + 1 < VectorSize && reinterpret_cast<uintptr_t>(&VectorBuffer[i + 1]))
return VectorBuffer[i + 1];
else
break;
}
}
warn("next( %#lx ) is null (requested by %#lx)", Value, __builtin_return_address(0));
return this->null_elem();
}
NIF T &prev(const T &Value)
{
for (size_t i = 0; i < VectorSize; i++)
{
if (VectorBuffer[i] == Value)
{
if (i > 0 && reinterpret_cast<uintptr_t>(&VectorBuffer[i - 1]))
return VectorBuffer[i - 1];
else
break;
}
}
warn("prev( %#lx ) is null (requested by %#lx)", Value, __builtin_return_address(0));
return this->null_elem();
}
NIF size_t capacity() const { return VectorCapacity; }
NIF size_t size() const { return VectorSize; }
NIF bool empty() const;
NIF iterator begin() { return VectorBuffer; }
NIF iterator end() { return VectorBuffer + size(); }
NIF T &front() { return VectorBuffer[0]; }
NIF T &back() { return VectorBuffer[VectorSize - 1]; }
NIF void push_back(const T &Value)
{
if (VectorSize >= VectorCapacity)
reserve(VectorCapacity + 5);
VectorBuffer[VectorSize++] = Value;
}
NIF void pop_back() { VectorSize--; }
NIF void reverse()
{
if (VectorSize <= 1)
return;
for (size_t i = 0, j = VectorSize - 1; i < j; i++, j--)
{
T c = *(VectorBuffer + i);
*(VectorBuffer + i) = *(VectorBuffer + j);
*(VectorBuffer + j) = c;
}
}
NIF void reserve(size_t Capacity)
{
if (VectorBuffer == 0)
{
VectorSize = 0;
VectorCapacity = 0;
}
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR ALLOCATION: reverse( %lld )", Capacity);
#endif
T *NewBuffer = new T[Capacity];
size_t _Size = Capacity < VectorSize ? Capacity : VectorSize;
for (size_t i = 0; i < _Size; i++)
NewBuffer[i] = VectorBuffer[i];
VectorCapacity = Capacity;
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR ALLOCATION: reverse( <Capacity> )->Buffer:~%lld", VectorBuffer);
#endif
delete[] VectorBuffer;
VectorBuffer = NewBuffer;
}
NIF void resize(size_t Size)
{
reserve(Size);
VectorSize = Size;
}
NIF void clear()
{
VectorCapacity = 0;
VectorSize = 0;
if (VectorBuffer != nullptr)
{
delete[] VectorBuffer, VectorBuffer = nullptr;
}
}
NIF T *data() { return VectorBuffer; }
NIF T &operator[](size_t Index)
{
if (!reinterpret_cast<uintptr_t>(&VectorBuffer[Index]))
{
warn("operator[]( %lld ) is null (requested by %#lx)", Index, __builtin_return_address(0));
return this->null_elem();
}
return VectorBuffer[Index];
}
NIF vector<T> &operator=(const vector<T> &v)
{
delete[] VectorBuffer;
VectorSize = v.VectorSize;
VectorCapacity = v.VectorCapacity;
#ifdef DEBUG_MEM_ALLOCATION
debug("VECTOR ALLOCATION: operator=( <vector> )->Size:%lld", VectorSize);
#endif
VectorBuffer = new T[VectorSize];
for (size_t i = 0; i < VectorSize; i++)
VectorBuffer[i] = v.VectorBuffer[i];
return *this;
}
};
}
#endif // !__FENNIX_KERNEL_STD_VECTOR_H__

View File

@ -1,23 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_STDDEF_STUB_H__
#define __FENNIX_KERNEL_STDDEF_STUB_H__
#include <types.h>
#endif // !__FENNIX_KERNEL_STDDEF_STUB_H__

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _STDINT_H
#define _STDINT_H
#endif // !_STDINT_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _STDIO_H
#define _STDIO_H
#endif // !_STDIO_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _STDLIB_H
#define _STDLIB_H
#endif // !_STDLIB_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _STRING_H
#define _STRING_H
#endif // !_STRING_H

View File

@ -1,19 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <std/string.hpp>

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _STRINGS_H
#define _STRINGS_H
#endif // !_STRINGS_H

View File

@ -1,31 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef __FENNIX_KERNEL_SYSTEM_H__
#define __FENNIX_KERNEL_SYSTEM_H__
#include <types.h>
#include <cpu.hpp>
// TODO: Add actual panic screen
#define panic(msg) \
{ \
error(msg); \
CPU::Stop(); \
}
#endif // !__FENNIX_KERNEL_SYSTEM_H__

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _SYS_STAT_H
#define _SYS_STAT_H
#endif // !_SYS_STAT_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _SYS_TIME_H
#define _SYS_TIME_H
#endif // !_SYS_TIME_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _SYS_TYPES_H
#define _SYS_TYPES_H
#endif // !_SYS_TYPES_H

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _UNISTD_H
#define _UNISTD_H
#endif // !_UNISTD_H

View File

@ -1,19 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#pragma once
#include <std/vector.hpp>

View File

@ -1,21 +0,0 @@
/*
This file is part of Fennix Kernel.
Fennix Kernel is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Kernel is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Kernel. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _WCHAR_H
#define _WCHAR_H
#endif // !_WCHAR_H