mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-10 23:09:18 +00:00
Update kernel
This commit is contained in:
69
include_std/cxxabi.h
Normal file
69
include_std/cxxabi.h
Normal file
@ -0,0 +1,69 @@
|
||||
/*
|
||||
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_CXXABI_H__
|
||||
#define __FENNIX_KERNEL_CXXABI_H__
|
||||
|
||||
#include <types.h>
|
||||
#include <unwind.h>
|
||||
#include <typeinfo>
|
||||
|
||||
namespace __cxxabiv1
|
||||
{
|
||||
#define ATEXIT_MAX_FUNCS 128
|
||||
|
||||
typedef unsigned uarch_t;
|
||||
|
||||
struct atexit_func_entry_t
|
||||
{
|
||||
void (*destructor_func)(void *);
|
||||
void *obj_ptr;
|
||||
void *dso_handle;
|
||||
};
|
||||
|
||||
struct __cxa_exception
|
||||
{
|
||||
std::type_info *exceptionType;
|
||||
void (*exceptionDestructor)(void *);
|
||||
std::terminate_handler unexpectedHandler;
|
||||
std::terminate_handler terminateHandler;
|
||||
__cxa_exception *nextException;
|
||||
int handlerCount;
|
||||
#ifdef __ARM_EABI_UNWINDER__
|
||||
__cxa_exception *nextPropagatingException;
|
||||
int propagationCount;
|
||||
#else
|
||||
int handlerSwitchValue;
|
||||
const unsigned char *actionRecord;
|
||||
const unsigned char *languageSpecificData;
|
||||
_Unwind_Ptr catchTemp;
|
||||
void *adjustedPtr;
|
||||
#endif
|
||||
_Unwind_Exception unwindHeader;
|
||||
};
|
||||
}
|
||||
|
||||
struct __cxa_eh_globals
|
||||
{
|
||||
__cxxabiv1::__cxa_exception *caughtExceptions;
|
||||
unsigned int uncaughtExceptions;
|
||||
#ifdef __ARM_EABI_UNWINDER__
|
||||
__cxxabiv1::__cxa_exception *propagatingExceptions;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif // !__FENNIX_KERNEL_CXXABI_H__
|
41
include_std/exception
Normal file
41
include_std/exception
Normal file
@ -0,0 +1,41 @@
|
||||
/*
|
||||
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_EXCEPTION_H__
|
||||
#define __FENNIX_KERNEL_EXCEPTION_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
namespace std
|
||||
{
|
||||
class exception
|
||||
{
|
||||
public:
|
||||
exception() noexcept {}
|
||||
virtual ~exception() noexcept;
|
||||
exception(const exception &) = default;
|
||||
exception &operator=(const exception &) = default;
|
||||
exception(exception &&) = default;
|
||||
exception &operator=(exception &&) = default;
|
||||
|
||||
virtual const char *what() const noexcept;
|
||||
};
|
||||
|
||||
typedef void (*terminate_handler)();
|
||||
}
|
||||
|
||||
#endif // !__FENNIX_KERNEL_EXCEPTION_H__
|
@ -123,7 +123,7 @@ namespace std
|
||||
|
||||
NIF T &null_elem()
|
||||
{
|
||||
static T null_elem;
|
||||
static T null_elem{};
|
||||
return null_elem;
|
||||
}
|
||||
|
||||
|
25
include_std/stdarg.h
Normal file
25
include_std/stdarg.h
Normal file
@ -0,0 +1,25 @@
|
||||
/*
|
||||
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_STDARG_H__
|
||||
#define __FENNIX_KERNEL_STDARG_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
|
||||
|
||||
#endif // !__FENNIX_KERNEL_STDARG_H__
|
@ -18,18 +18,4 @@
|
||||
#ifndef _STDLIB_H
|
||||
#define _STDLIB_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
void *malloc(__SIZE_TYPE__ Size);
|
||||
void *calloc(__SIZE_TYPE__ n, __SIZE_TYPE__ Size);
|
||||
void *realloc(void *Address, __SIZE_TYPE__ Size);
|
||||
void free(void *Address);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // !_STDLIB_H
|
||||
|
337
include_std/typeinfo
Normal file
337
include_std/typeinfo
Normal file
@ -0,0 +1,337 @@
|
||||
/*
|
||||
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_TYPEINFO_H__
|
||||
#define __FENNIX_KERNEL_TYPEINFO_H__
|
||||
|
||||
#include <types.h>
|
||||
#include <exception>
|
||||
|
||||
namespace __cxxabiv1
|
||||
{
|
||||
class __class_type_info;
|
||||
class __si_class_type_info;
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
class type_info
|
||||
{
|
||||
public:
|
||||
virtual ~type_info();
|
||||
|
||||
bool operator==(const type_info &Argument) const noexcept
|
||||
{
|
||||
return ((Name == Argument.Name) ||
|
||||
(Name[0] != '*' &&
|
||||
__builtin_strcmp(Name, Argument.Name) == 0));
|
||||
}
|
||||
|
||||
bool operator!=(const type_info &Argument) const noexcept
|
||||
{
|
||||
return !operator==(Argument);
|
||||
}
|
||||
|
||||
bool before(const type_info &Argument) const noexcept
|
||||
{
|
||||
return (Name[0] == '*' && Argument.Name[0] == '*')
|
||||
? Name < Argument.Name
|
||||
: __builtin_strcmp(Name, Argument.Name) < 0;
|
||||
}
|
||||
|
||||
const char *name() const noexcept
|
||||
{
|
||||
return Name[0] == '*' ? Name + 1 : Name;
|
||||
}
|
||||
|
||||
virtual bool __is_pointer_p() const
|
||||
{
|
||||
return Name[0] == '*';
|
||||
}
|
||||
|
||||
virtual bool __is_function_p() const
|
||||
{
|
||||
return Name[0] == '(';
|
||||
}
|
||||
|
||||
virtual bool __do_catch(const type_info *ThrowType,
|
||||
void **ThrowObject,
|
||||
unsigned Outer) const;
|
||||
|
||||
virtual bool __do_upcast(const __cxxabiv1::__class_type_info *Target,
|
||||
void **ObjectPointer) const;
|
||||
|
||||
protected:
|
||||
const char *Name;
|
||||
explicit type_info(const char *n) : Name(n) {}
|
||||
|
||||
private:
|
||||
type_info &operator=(const type_info &);
|
||||
type_info(const type_info &);
|
||||
};
|
||||
|
||||
class bad_cast : public exception
|
||||
{
|
||||
public:
|
||||
bad_cast() noexcept {}
|
||||
virtual ~bad_cast() noexcept;
|
||||
virtual const char *what() const noexcept;
|
||||
};
|
||||
|
||||
class bad_typeid : public exception
|
||||
{
|
||||
public:
|
||||
bad_typeid() noexcept {}
|
||||
virtual ~bad_typeid() noexcept;
|
||||
virtual const char *what() const noexcept;
|
||||
};
|
||||
}
|
||||
|
||||
namespace __cxxabiv1
|
||||
{
|
||||
class __pbase_type_info : public std::type_info
|
||||
{
|
||||
public:
|
||||
unsigned int Flags;
|
||||
const std::type_info *Pointee;
|
||||
|
||||
explicit __pbase_type_info(const char *n, int Qualifiers,
|
||||
const std::type_info *Type)
|
||||
: std::type_info(n),
|
||||
Flags(Qualifiers),
|
||||
Pointee(Type) {}
|
||||
virtual ~__pbase_type_info();
|
||||
|
||||
enum __masks
|
||||
{
|
||||
__const_mask = 0x1,
|
||||
__volatile_mask = 0x2,
|
||||
__restrict_mask = 0x4,
|
||||
__incomplete_mask = 0x8,
|
||||
__incomplete_class_mask = 0x10,
|
||||
__transaction_safe_mask = 0x20,
|
||||
__noexcept_mask = 0x40
|
||||
};
|
||||
|
||||
protected:
|
||||
__pbase_type_info(const __pbase_type_info &);
|
||||
|
||||
__pbase_type_info &operator=(const __pbase_type_info &);
|
||||
|
||||
virtual bool __do_catch(const std::type_info *ThrowType,
|
||||
void **ThrowObject,
|
||||
unsigned int Outer) const;
|
||||
|
||||
inline bool __pointer_catch(const __pbase_type_info *ThrownType,
|
||||
void **ThrowObject,
|
||||
unsigned Outer) const
|
||||
{
|
||||
return Pointee->__do_catch(ThrownType->Pointee, ThrowObject, Outer + 2);
|
||||
}
|
||||
};
|
||||
|
||||
class __pointer_type_info : public __pbase_type_info
|
||||
{
|
||||
public:
|
||||
explicit __pointer_type_info(const char *n,
|
||||
int Qualifiers,
|
||||
const std::type_info *Type)
|
||||
: __pbase_type_info(n, Qualifiers, Type) {}
|
||||
virtual ~__pointer_type_info();
|
||||
|
||||
protected:
|
||||
virtual bool __is_pointer_p() const;
|
||||
|
||||
virtual bool __pointer_catch(const __pbase_type_info *ThrowType,
|
||||
void **ThrowObject,
|
||||
unsigned Outer) const;
|
||||
};
|
||||
|
||||
/* FIXME: stub */
|
||||
class __pointer_to_member_type_info : public __pbase_type_info
|
||||
{
|
||||
};
|
||||
|
||||
class __fundamental_type_info : public std::type_info
|
||||
{
|
||||
public:
|
||||
explicit __fundamental_type_info(const char *n) : std::type_info(n) {}
|
||||
virtual ~__fundamental_type_info();
|
||||
};
|
||||
|
||||
class __base_class_type_info
|
||||
{
|
||||
public:
|
||||
const __class_type_info *BaseType;
|
||||
#ifdef __LP64__
|
||||
long long OffsetFlags;
|
||||
#else
|
||||
long OffsetFlags;
|
||||
#endif
|
||||
|
||||
enum __offset_flags_masks
|
||||
{
|
||||
__virtual_mask = 0x1,
|
||||
__public_mask = 0x2,
|
||||
__hwm_bit = 0x2,
|
||||
__offset_shift = 0x8
|
||||
};
|
||||
|
||||
bool __is_virtual_p() const
|
||||
{
|
||||
return OffsetFlags & __virtual_mask;
|
||||
}
|
||||
|
||||
bool __is_public_p() const
|
||||
{
|
||||
return OffsetFlags & __public_mask;
|
||||
}
|
||||
|
||||
ptrdiff_t __offset() const
|
||||
{
|
||||
return static_cast<ptrdiff_t>(OffsetFlags) >> __offset_shift;
|
||||
}
|
||||
};
|
||||
|
||||
/* FIXME: stub */
|
||||
class __vmi_class_type_info /* : public __class_type_info */
|
||||
{
|
||||
public:
|
||||
enum __flags_masks
|
||||
{
|
||||
__non_diamond_repeat_mask = 0x1,
|
||||
__diamond_shaped_mask = 0x2,
|
||||
__flags_unknown_mask = 0x10
|
||||
};
|
||||
};
|
||||
|
||||
class __class_type_info : public std::type_info
|
||||
{
|
||||
public:
|
||||
explicit __class_type_info(const char *n)
|
||||
: std::type_info(n) {}
|
||||
virtual ~__class_type_info();
|
||||
|
||||
enum __sub_kind
|
||||
{
|
||||
__unknown = 0,
|
||||
__not_contained,
|
||||
__contained_ambig,
|
||||
__contained_virtual_mask = __base_class_type_info::__virtual_mask,
|
||||
__contained_public_mask = __base_class_type_info::__public_mask,
|
||||
__contained_mask = 1 << __base_class_type_info::__hwm_bit,
|
||||
__contained_private = __contained_mask,
|
||||
__contained_public = __contained_mask | __contained_public_mask
|
||||
};
|
||||
|
||||
struct __upcast_result
|
||||
{
|
||||
const void *dst_ptr;
|
||||
__sub_kind part2dst;
|
||||
int src_details;
|
||||
const __class_type_info *base_type;
|
||||
|
||||
__upcast_result(int d)
|
||||
: dst_ptr(NULL),
|
||||
part2dst(__unknown),
|
||||
src_details(d),
|
||||
base_type(NULL) {}
|
||||
};
|
||||
|
||||
struct __dyncast_result
|
||||
{
|
||||
const void *dst_ptr;
|
||||
__sub_kind whole2dst;
|
||||
__sub_kind whole2src;
|
||||
__sub_kind dst2src;
|
||||
int whole_details;
|
||||
|
||||
__dyncast_result(int details_ = __vmi_class_type_info::__flags_unknown_mask)
|
||||
: dst_ptr(NULL),
|
||||
whole2dst(__unknown),
|
||||
whole2src(__unknown),
|
||||
dst2src(__unknown),
|
||||
whole_details(details_) {}
|
||||
|
||||
protected:
|
||||
__dyncast_result(const __dyncast_result &);
|
||||
|
||||
__dyncast_result &
|
||||
operator=(const __dyncast_result &);
|
||||
};
|
||||
|
||||
virtual __sub_kind __do_find_public_src(ptrdiff_t SourceToDestination,
|
||||
const void *ObjectPointer,
|
||||
const __class_type_info *SourceType,
|
||||
const void *SubroutinePointer) const;
|
||||
|
||||
virtual bool __do_upcast(const __class_type_info *Destination,
|
||||
const void *Object,
|
||||
__upcast_result &__restrict Result) const;
|
||||
|
||||
virtual bool __do_dyncast(ptrdiff_t SourceToDestination,
|
||||
__sub_kind AccessPath,
|
||||
const __class_type_info *DestinationType,
|
||||
const void *ObjectPointer,
|
||||
const __class_type_info *SourceType,
|
||||
const void *SourcePointer,
|
||||
__dyncast_result &Result) const;
|
||||
|
||||
protected:
|
||||
virtual bool __do_upcast(const __class_type_info *DestinationType,
|
||||
void **ObjectPointer) const;
|
||||
|
||||
virtual bool __do_catch(const type_info *ThrowType,
|
||||
void **ThrowObject,
|
||||
unsigned Outer) const;
|
||||
};
|
||||
|
||||
class __si_class_type_info : public __class_type_info
|
||||
{
|
||||
public:
|
||||
const __class_type_info *BaseType;
|
||||
|
||||
explicit __si_class_type_info(const char *n,
|
||||
const __class_type_info *Base)
|
||||
: __class_type_info(n),
|
||||
BaseType(Base) {}
|
||||
virtual ~__si_class_type_info();
|
||||
|
||||
protected:
|
||||
__si_class_type_info(const __si_class_type_info &);
|
||||
|
||||
__si_class_type_info &operator=(const __si_class_type_info &);
|
||||
|
||||
virtual bool __do_dyncast(ptrdiff_t SourceToDestination, __sub_kind AccessPath,
|
||||
const __class_type_info *DestinationType, const void *ObjectPointer,
|
||||
const __class_type_info *SourceType, const void *SourcePointer,
|
||||
__dyncast_result &Result) const;
|
||||
|
||||
virtual __sub_kind __do_find_public_src(ptrdiff_t SourceToDestination,
|
||||
const void *ObjectPointer,
|
||||
const __class_type_info *SourceType,
|
||||
const void *SubroutinePointer) const;
|
||||
|
||||
virtual bool __do_upcast(const __class_type_info *Destination,
|
||||
const void *Object,
|
||||
__upcast_result &__restrict Result) const;
|
||||
};
|
||||
|
||||
static const __class_type_info *const nonvirtual_base_type = static_cast<const __class_type_info *>(0) + 1;
|
||||
}
|
||||
|
||||
#endif // !__FENNIX_KERNEL_TYPEINFO_H__
|
78
include_std/unwind.h
Normal file
78
include_std/unwind.h
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
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_UNWIND_H__
|
||||
#define __FENNIX_KERNEL_UNWIND_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
enum _Unwind_Reason_Code
|
||||
{
|
||||
_URC_NO_REASON = 0,
|
||||
_URC_FOREIGN_EXCEPTION_CAUGHT = 1,
|
||||
_URC_FATAL_PHASE2_ERROR = 2,
|
||||
_URC_FATAL_PHASE1_ERROR = 3,
|
||||
_URC_NORMAL_STOP = 4,
|
||||
_URC_END_OF_STACK = 5,
|
||||
_URC_HANDLER_FOUND = 6,
|
||||
_URC_INSTALL_CONTEXT = 7,
|
||||
_URC_CONTINUE_UNWIND = 8
|
||||
};
|
||||
|
||||
typedef void *_Unwind_Context_Reg_Val;
|
||||
typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
|
||||
typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
|
||||
typedef unsigned _Unwind_Word __attribute__((__mode__(__unwind_word__)));
|
||||
typedef signed _Unwind_Sword __attribute__((__mode__(__unwind_word__)));
|
||||
typedef int _Unwind_Action;
|
||||
|
||||
enum _UA : _Unwind_Action
|
||||
{
|
||||
_UA_SEARCH_PHASE = 1,
|
||||
_UA_CLEANUP_PHASE = 2,
|
||||
_UA_HANDLER_FRAME = 4,
|
||||
_UA_FORCE_UNWIND = 8,
|
||||
_UA_END_OF_STACK = 16
|
||||
};
|
||||
|
||||
typedef void (*_Unwind_Exception_Cleanup_Fn)(_Unwind_Reason_Code,
|
||||
struct _Unwind_Exception *);
|
||||
|
||||
typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)(int,
|
||||
_Unwind_Action,
|
||||
_Unwind_Exception_Class,
|
||||
struct _Unwind_Exception *,
|
||||
struct _Unwind_Context *);
|
||||
|
||||
struct _Unwind_Exception
|
||||
{
|
||||
_Unwind_Exception_Class exception_class;
|
||||
_Unwind_Exception_Cleanup_Fn exception_cleanup;
|
||||
_Unwind_Word private_1;
|
||||
_Unwind_Word private_2;
|
||||
} __attribute__((__aligned__));
|
||||
|
||||
struct _Unwind_Context;
|
||||
|
||||
struct _Unwind_FrameState
|
||||
{
|
||||
_Unwind_Personality_Fn personality;
|
||||
};
|
||||
|
||||
EXTERNC _Unwind_Reason_Code _Unwind_RaiseException(_Unwind_Exception *Exception);
|
||||
|
||||
#endif // !__FENNIX_KERNEL_UNWIND_H__
|
Reference in New Issue
Block a user