mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Changed a lot of files. Summary: profiler support; "SafeFunction"; UnlockDeadLock kernel config; Code optimization & more
This commit is contained in:
@ -19,15 +19,18 @@ extern "C"
|
||||
int atoi(const char *String);
|
||||
double atof(const char *String);
|
||||
char *itoa(int Value, char *Buffer, int Base);
|
||||
char *ltoa(long Value, char *Buffer, int Base);
|
||||
char *ultoa(unsigned long Value, char *Buffer, int Base);
|
||||
|
||||
void *memcpy(void *dest, const void *src, size_t n);
|
||||
void *memset(void *dest, int c, size_t n);
|
||||
void *memmove(void *dest, const void *src, size_t n);
|
||||
void *memcpy_unsafe(void *dest, const void *src, size_t n);
|
||||
void *memset_unsafe(void *dest, int c, size_t n);
|
||||
void *memmove_unsafe(void *dest, const void *src, size_t n);
|
||||
int memcmp(const void *vl, const void *vr, size_t n);
|
||||
|
||||
long unsigned strlen(const char s[]);
|
||||
int strncmp(const char *s1, const char *s2, unsigned long n);
|
||||
char *strcat(char *destination, const char *source);
|
||||
char *strcpy(char *destination, const char *source);
|
||||
char *strcat_unsafe(char *destination, const char *source);
|
||||
char *strcpy_unsafe(char *destination, const char *source);
|
||||
char *strncpy(char *destination, const char *source, unsigned long num);
|
||||
int strcmp(const char *l, const char *r);
|
||||
char *strstr(const char *haystack, const char *needle);
|
||||
@ -38,6 +41,32 @@ extern "C"
|
||||
int strcasecmp(const char *lhs, const char *rhs);
|
||||
char *strtok(char *src, const char *delim);
|
||||
|
||||
void *__memcpy_chk(void *dest, const void *src, size_t len, size_t slen);
|
||||
void *__memset_chk(void *dest, int val, size_t len, size_t slen);
|
||||
void *__memmove_chk(void *dest, const void *src, size_t len, size_t slen);
|
||||
char *__strcat_chk(char *dest, const char *src, size_t slen);
|
||||
char *__strcpy_chk(char *dest, const char *src, size_t slen);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#undef memcpy
|
||||
#define memcpy(dest, src, n) \
|
||||
__memcpy_chk(dest, src, n, __builtin_object_size(dest, 0))
|
||||
|
||||
#undef memset
|
||||
#define memset(dest, c, n) \
|
||||
__memset_chk(dest, c, n, __builtin_object_size(dest, 0))
|
||||
|
||||
#undef memmove
|
||||
#define memmove(dest, src, n) \
|
||||
__memmove_chk(dest, src, n, __builtin_object_size(dest, 0))
|
||||
|
||||
#undef strcat
|
||||
#define strcat(dest, src) \
|
||||
__strcat_chk(dest, src, __builtin_object_size(dest, 0))
|
||||
|
||||
#undef strcpy
|
||||
#define strcpy(dest, src) \
|
||||
__strcpy_chk(dest, src, __builtin_object_size(dest, 0))
|
||||
|
@ -143,7 +143,7 @@ namespace CPU
|
||||
/**
|
||||
* @brief Pause the CPU
|
||||
*/
|
||||
__no_stack_protector static inline void Pause(bool Loop = false)
|
||||
SafeFunction static inline void Pause(bool Loop = false)
|
||||
{
|
||||
do
|
||||
{
|
||||
@ -158,7 +158,7 @@ namespace CPU
|
||||
/**
|
||||
* @brief Stop the CPU (infinite loop)
|
||||
*/
|
||||
__no_stack_protector static inline void Stop()
|
||||
SafeFunction static inline void Stop()
|
||||
{
|
||||
while (1)
|
||||
{
|
||||
@ -177,7 +177,7 @@ namespace CPU
|
||||
/**
|
||||
* @brief Halt the CPU
|
||||
*/
|
||||
__no_stack_protector static inline void Halt(bool Loop = false)
|
||||
SafeFunction static inline void Halt(bool Loop = false)
|
||||
{
|
||||
do
|
||||
{
|
||||
@ -213,7 +213,7 @@ namespace CPU
|
||||
|
||||
namespace MemBar
|
||||
{
|
||||
__no_stack_protector static inline void Barrier()
|
||||
SafeFunction static inline void Barrier()
|
||||
{
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
asmv("" ::
|
||||
@ -224,7 +224,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void Fence()
|
||||
SafeFunction static inline void Fence()
|
||||
{
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
asmv("mfence" ::
|
||||
@ -235,7 +235,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void StoreFence()
|
||||
SafeFunction static inline void StoreFence()
|
||||
{
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
asmv("sfence" ::
|
||||
@ -246,7 +246,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void LoadFence()
|
||||
SafeFunction static inline void LoadFence()
|
||||
{
|
||||
#if defined(__amd64__) || defined(__i386__)
|
||||
asmv("lfence" ::
|
||||
@ -549,7 +549,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void invlpg(void *Address)
|
||||
SafeFunction static inline void invlpg(void *Address)
|
||||
{
|
||||
#if defined(__i386__)
|
||||
asmv("invlpg (%0)"
|
||||
@ -1670,7 +1670,7 @@ namespace CPU
|
||||
uint64_t raw;
|
||||
} SelectorErrorCode;
|
||||
|
||||
__no_stack_protector static inline void lgdt(void *gdt)
|
||||
SafeFunction static inline void lgdt(void *gdt)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("lgdt (%0)"
|
||||
@ -1679,7 +1679,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void lidt(void *idt)
|
||||
SafeFunction static inline void lidt(void *idt)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("lidt (%0)"
|
||||
@ -1688,7 +1688,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void ltr(uint16_t Segment)
|
||||
SafeFunction static inline void ltr(uint16_t Segment)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("ltr %0"
|
||||
@ -1697,7 +1697,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void invlpg(void *Address)
|
||||
SafeFunction static inline void invlpg(void *Address)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("invlpg (%0)"
|
||||
@ -1716,7 +1716,7 @@ namespace CPU
|
||||
* @param ecx ECX
|
||||
* @param edx EDX
|
||||
*/
|
||||
__no_stack_protector static inline void cpuid(uint32_t Function, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
|
||||
SafeFunction static inline void cpuid(uint32_t Function, uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("cpuid"
|
||||
@ -1732,14 +1732,14 @@ namespace CPU
|
||||
*
|
||||
* @return uint32_t
|
||||
*/
|
||||
__no_stack_protector static inline uint32_t GetHighestLeaf()
|
||||
SafeFunction static inline uint32_t GetHighestLeaf()
|
||||
{
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
cpuid(0x0, &eax, &ebx, &ecx, &edx);
|
||||
return eax;
|
||||
}
|
||||
|
||||
__no_stack_protector static inline uint64_t rdmsr(uint32_t msr)
|
||||
SafeFunction static inline uint64_t rdmsr(uint32_t msr)
|
||||
{
|
||||
uint32_t Low, High;
|
||||
#if defined(__amd64__)
|
||||
@ -1751,7 +1751,7 @@ namespace CPU
|
||||
return ((uint64_t)Low) | (((uint64_t)High) << 32);
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void wrmsr(uint32_t msr, uint64_t Value)
|
||||
SafeFunction static inline void wrmsr(uint32_t msr, uint64_t Value)
|
||||
{
|
||||
uint32_t Low = Value, High = Value >> 32;
|
||||
#if defined(__amd64__)
|
||||
@ -1762,7 +1762,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline CR0 readcr0()
|
||||
SafeFunction static inline CR0 readcr0()
|
||||
{
|
||||
uint64_t Result;
|
||||
#if defined(__amd64__)
|
||||
@ -1772,7 +1772,7 @@ namespace CPU
|
||||
return (CR0){.raw = Result};
|
||||
}
|
||||
|
||||
__no_stack_protector static inline CR2 readcr2()
|
||||
SafeFunction static inline CR2 readcr2()
|
||||
{
|
||||
uint64_t Result;
|
||||
#if defined(__amd64__)
|
||||
@ -1782,7 +1782,7 @@ namespace CPU
|
||||
return (CR2){.raw = Result};
|
||||
}
|
||||
|
||||
__no_stack_protector static inline CR3 readcr3()
|
||||
SafeFunction static inline CR3 readcr3()
|
||||
{
|
||||
uint64_t Result;
|
||||
#if defined(__amd64__)
|
||||
@ -1792,7 +1792,7 @@ namespace CPU
|
||||
return (CR3){.raw = Result};
|
||||
}
|
||||
|
||||
__no_stack_protector static inline CR4 readcr4()
|
||||
SafeFunction static inline CR4 readcr4()
|
||||
{
|
||||
uint64_t Result;
|
||||
#if defined(__amd64__)
|
||||
@ -1802,7 +1802,7 @@ namespace CPU
|
||||
return (CR4){.raw = Result};
|
||||
}
|
||||
|
||||
__no_stack_protector static inline CR8 readcr8()
|
||||
SafeFunction static inline CR8 readcr8()
|
||||
{
|
||||
uint64_t Result;
|
||||
#if defined(__amd64__)
|
||||
@ -1812,7 +1812,7 @@ namespace CPU
|
||||
return (CR8){.raw = Result};
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void writecr0(CR0 ControlRegister)
|
||||
SafeFunction static inline void writecr0(CR0 ControlRegister)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("mov %[ControlRegister], %%cr0"
|
||||
@ -1822,7 +1822,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void writecr2(CR2 ControlRegister)
|
||||
SafeFunction static inline void writecr2(CR2 ControlRegister)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("mov %[ControlRegister], %%cr2"
|
||||
@ -1832,7 +1832,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void writecr3(CR3 ControlRegister)
|
||||
SafeFunction static inline void writecr3(CR3 ControlRegister)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("mov %[ControlRegister], %%cr3"
|
||||
@ -1842,7 +1842,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void writecr4(CR4 ControlRegister)
|
||||
SafeFunction static inline void writecr4(CR4 ControlRegister)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("mov %[ControlRegister], %%cr4"
|
||||
@ -1852,7 +1852,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void writecr8(CR8 ControlRegister)
|
||||
SafeFunction static inline void writecr8(CR8 ControlRegister)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
asmv("mov %[ControlRegister], %%cr8"
|
||||
@ -1862,7 +1862,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void fxsave(char *FXSaveArea)
|
||||
SafeFunction static inline void fxsave(char *FXSaveArea)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
if (!FXSaveArea || FXSaveArea >= (char *)0xfffffffffffff000)
|
||||
@ -1876,7 +1876,7 @@ namespace CPU
|
||||
#endif
|
||||
}
|
||||
|
||||
__no_stack_protector static inline void fxrstor(char *FXRstorArea)
|
||||
SafeFunction static inline void fxrstor(char *FXRstorArea)
|
||||
{
|
||||
#if defined(__amd64__)
|
||||
if (!FXRstorArea || FXRstorArea >= (char *)0xfffffffffffff000)
|
||||
|
@ -156,8 +156,10 @@ namespace Video
|
||||
|
||||
void SetPixel(uint32_t X, uint32_t Y, uint32_t Color, int Index)
|
||||
{
|
||||
if (X >= this->Buffers[Index]->Width || Y >= this->Buffers[Index]->Height)
|
||||
return;
|
||||
if (X >= this->Buffers[Index]->Width)
|
||||
X = this->Buffers[Index]->Width - 1;
|
||||
if (Y >= this->Buffers[Index]->Height)
|
||||
Y = this->Buffers[Index]->Height - 1;
|
||||
uint32_t *Pixel = (uint32_t *)((uint64_t)this->Buffers[Index]->Buffer + (Y * this->Buffers[Index]->Width + X) * (this->framebuffer.BitsPerPixel / 8));
|
||||
*Pixel = Color;
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ namespace FileSystem
|
||||
FS_MOUNTPOINT = 0x08
|
||||
};
|
||||
|
||||
struct FileSystemOpeations
|
||||
struct FileSystemOperations
|
||||
{
|
||||
char Name[FILENAME_LENGTH];
|
||||
OperationMount Mount = nullptr;
|
||||
@ -113,7 +113,7 @@ namespace FileSystem
|
||||
uint64_t Address = 0;
|
||||
uint64_t Length = 0;
|
||||
FileSystemNode *Parent = nullptr;
|
||||
FileSystemOpeations *Operator = nullptr;
|
||||
FileSystemOperations *Operator = nullptr;
|
||||
/* For root node:
|
||||
0 - root "/"
|
||||
1 - etc
|
||||
@ -150,13 +150,13 @@ namespace FileSystem
|
||||
char *NormalizePath(FileSystemNode *Parent, const char *Path);
|
||||
|
||||
FileStatus FileExists(FileSystemNode *Parent, const char *Path);
|
||||
FILE *Mount(FileSystemOpeations *Operator, const char *Path);
|
||||
FILE *Mount(FileSystemOperations *Operator, const char *Path);
|
||||
FileStatus Unmount(FILE *File);
|
||||
FILE *Open(const char *Path, FileSystemNode *Parent = nullptr);
|
||||
uint64_t Read(FILE *File, uint64_t Offset, uint8_t *Buffer, uint64_t Size);
|
||||
uint64_t Write(FILE *File, uint64_t Offset, uint8_t *Buffer, uint64_t Size);
|
||||
FileStatus Close(FILE *File);
|
||||
FileSystemNode *CreateRoot(FileSystemOpeations *Operator, const char *RootName);
|
||||
FileSystemNode *CreateRoot(FileSystemOperations *Operator, const char *RootName);
|
||||
FileSystemNode *Create(FileSystemNode *Parent, const char *Path);
|
||||
|
||||
Virtual();
|
||||
|
@ -11,7 +11,7 @@ namespace FileSystem
|
||||
class Device
|
||||
{
|
||||
public:
|
||||
FileSystemNode *AddFileSystem(FileSystemOpeations *Operator, uint64_t Mode, const char *Name, int Flags);
|
||||
FileSystemNode *AddFileSystem(FileSystemOperations *Operator, uint64_t Mode, const char *Name, int Flags);
|
||||
Device();
|
||||
~Device();
|
||||
};
|
||||
@ -20,7 +20,7 @@ namespace FileSystem
|
||||
class Mount
|
||||
{
|
||||
public:
|
||||
FileSystemNode *MountFileSystem(FileSystemOpeations *Operator, uint64_t Mode, const char *Name);
|
||||
FileSystemNode *MountFileSystem(FileSystemOperations *Operator, uint64_t Mode, const char *Name);
|
||||
void DetectAndMountFS(void *drive);
|
||||
Mount();
|
||||
~Mount();
|
||||
@ -38,7 +38,7 @@ namespace FileSystem
|
||||
class Driver
|
||||
{
|
||||
public:
|
||||
FileSystemNode *AddDriver(struct FileSystemOpeations *Operator, uint64_t Mode, const char *Name, int Flags);
|
||||
FileSystemNode *AddDriver(struct FileSystemOperations *Operator, uint64_t Mode, const char *Name, int Flags);
|
||||
Driver();
|
||||
~Driver();
|
||||
};
|
||||
@ -47,7 +47,7 @@ namespace FileSystem
|
||||
class Network
|
||||
{
|
||||
public:
|
||||
FileSystemNode *AddNetworkCard(struct FileSystemOpeations *Operator, uint64_t Mode, const char *Name, int Flags);
|
||||
FileSystemNode *AddNetworkCard(struct FileSystemOperations *Operator, uint64_t Mode, const char *Name, int Flags);
|
||||
Network();
|
||||
~Network();
|
||||
};
|
||||
|
@ -6,17 +6,26 @@
|
||||
|
||||
namespace Interrupts
|
||||
{
|
||||
#ifdef DEBUG // For performance reasons
|
||||
#define INT_FRAMES_MAX 512
|
||||
#else
|
||||
#define INT_FRAMES_MAX 8
|
||||
#endif
|
||||
|
||||
#if defined(__amd64__)
|
||||
/* APIC::APIC */ extern void *apic[256]; // MAX_CPU
|
||||
/* APIC::APIC */ extern void *apic[256]; // MAX_CPU
|
||||
/* APIC::Timer */ extern void *apicTimer[256]; // MAX_CPU
|
||||
#elif defined(__i386__)
|
||||
/* APIC::APIC */ extern void *apic[256]; // MAX_CPU
|
||||
/* APIC::APIC */ extern void *apic[256]; // MAX_CPU
|
||||
/* APIC::Timer */ extern void *apicTimer[256]; // MAX_CPU
|
||||
#elif defined(__aarch64__)
|
||||
#endif
|
||||
extern void *InterruptFrames[INT_FRAMES_MAX];
|
||||
|
||||
void Initialize(int Core);
|
||||
void Enable(int Core);
|
||||
void InitializeTimer(int Core);
|
||||
void RemoveAll();
|
||||
|
||||
class Handler
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ struct KernelConfig
|
||||
char InitPath[256];
|
||||
bool InterruptsOnCrash;
|
||||
int Cores;
|
||||
bool UnlockDeadLock;
|
||||
};
|
||||
|
||||
KernelConfig ParseConfig(char *Config);
|
||||
|
11
include/recovery.hpp
Normal file
11
include/recovery.hpp
Normal file
@ -0,0 +1,11 @@
|
||||
#ifndef __FENNIX_KERNEL_RECOVERY_H__
|
||||
#define __FENNIX_KERNEL_RECOVERY_H__
|
||||
|
||||
#include <types.h>
|
||||
|
||||
namespace Recovery
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif // !__FENNIX_KERNEL_RECOVERY_H__
|
@ -101,6 +101,7 @@ namespace Tasking
|
||||
|
||||
void Rename(const char *name)
|
||||
{
|
||||
CriticalSection cs;
|
||||
if (!Name[0])
|
||||
{
|
||||
warn("Tried to rename thread %d to NULL", ID);
|
||||
@ -117,6 +118,7 @@ namespace Tasking
|
||||
|
||||
void SetPriority(int priority)
|
||||
{
|
||||
CriticalSection cs;
|
||||
trace("Setting priority of thread %s to %d", Name, priority);
|
||||
Info.Priority = priority;
|
||||
}
|
||||
@ -125,6 +127,7 @@ namespace Tasking
|
||||
|
||||
void SetCritical(bool critical)
|
||||
{
|
||||
CriticalSection cs;
|
||||
trace("Setting criticality of thread %s to %s", Name, critical ? "true" : "false");
|
||||
Security.IsCritical = critical;
|
||||
}
|
||||
@ -215,7 +218,13 @@ namespace Tasking
|
||||
Vector<PCB *> GetProcessList() { return ListProcess; }
|
||||
void Panic() { StopScheduler = true; }
|
||||
void Schedule();
|
||||
long GetUsage(int Core) { return 100 - IdleProcess->Info.Usage[Core]; }
|
||||
long GetUsage(int Core)
|
||||
{
|
||||
if (IdleProcess)
|
||||
return 100 - IdleProcess->Info.Usage[Core];
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
void KillThread(TCB *tcb, int Code)
|
||||
{
|
||||
tcb->Status = TaskStatus::Terminated;
|
||||
|
@ -207,7 +207,6 @@ typedef __SIZE_TYPE__ size_t;
|
||||
#define b48(x) (((((x)&0x0000000000ff) << 40) | (((x)&0x00000000ff00) << 24) | (((x)&0x000000ff0000) << 8) | (((x)&0x0000ff000000) >> 8) | (((x)&0x00ff00000000) >> 24) | (((x)&0xff0000000000) >> 40)))
|
||||
#define b64(x) __builtin_bswap64(x)
|
||||
|
||||
|
||||
#define O0 __attribute__((optimize("O0")))
|
||||
#define O1 __attribute__((optimize("O1")))
|
||||
#define O2 __attribute__((optimize("O2")))
|
||||
@ -220,6 +219,7 @@ typedef __SIZE_TYPE__ size_t;
|
||||
|
||||
#define __unused __attribute__((unused))
|
||||
#define __packed __attribute__((packed))
|
||||
#define __naked __attribute__((naked))
|
||||
#define __aligned(x) __attribute__((aligned(x)))
|
||||
#define __section(x) __attribute__((section(x)))
|
||||
#define __noreturn __attribute__((noreturn))
|
||||
@ -252,12 +252,17 @@ typedef __SIZE_TYPE__ size_t;
|
||||
#define __nonnull_all __attribute__((nonnull))
|
||||
#define __warn_unused_result __attribute__((warn_unused_result))
|
||||
#define __no_stack_protector __attribute__((no_stack_protector))
|
||||
#define __no_instrument_function __attribute__((no_instrument_function))
|
||||
|
||||
// sanitizer
|
||||
#define __no_sanitize_address __attribute__((no_sanitize_address))
|
||||
#define __no_sanitize_undefined __attribute__((no_sanitize_undefined))
|
||||
#define __no_address_safety_analysis __attribute__((no_address_safety_analysis))
|
||||
#define __no_sanitize_thread __attribute__((no_sanitize_thread))
|
||||
#define __no_sanitize_memory __attribute__((no_sanitize_memory))
|
||||
#define __no_sanitize_hwaddress __attribute__((no_sanitize_hwaddress))
|
||||
|
||||
#define likely(x) __builtin_expect(!!(x), 1)
|
||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||
|
||||
#define SafeFunction __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_address_safety_analysis __no_sanitize_thread
|
||||
|
||||
#endif // !__FENNIX_KERNEL_TYPES_H__
|
||||
|
@ -51,7 +51,7 @@ namespace UniversalAsynchronousReceiverTransmitter
|
||||
* @brief Get the Registered Port object
|
||||
* @return SerialPorts
|
||||
*/
|
||||
SerialPorts GetRegisteredPort() { return this->Port; }
|
||||
SafeFunction __no_instrument_function SerialPorts GetRegisteredPort() { return this->Port; }
|
||||
|
||||
/**
|
||||
* @brief Called when a character is sent.
|
||||
|
@ -13,7 +13,7 @@ private:
|
||||
public:
|
||||
typedef T *iterator;
|
||||
|
||||
Vector()
|
||||
__no_instrument_function Vector()
|
||||
{
|
||||
#ifdef DEBUG_MEM_ALLOCATION
|
||||
debug("VECTOR INIT: Vector( )");
|
||||
@ -23,7 +23,7 @@ public:
|
||||
VectorBuffer = 0;
|
||||
}
|
||||
|
||||
Vector(uint64_t Size)
|
||||
__no_instrument_function Vector(uint64_t Size)
|
||||
{
|
||||
VectorCapacity = Size;
|
||||
VectorSize = Size;
|
||||
@ -33,7 +33,7 @@ public:
|
||||
VectorBuffer = new T[Size];
|
||||
}
|
||||
|
||||
Vector(uint64_t Size, const T &Initial)
|
||||
__no_instrument_function Vector(uint64_t Size, const T &Initial)
|
||||
{
|
||||
VectorSize = Size;
|
||||
VectorCapacity = Size;
|
||||
@ -45,7 +45,7 @@ public:
|
||||
VectorBuffer[i] = Initial;
|
||||
}
|
||||
|
||||
Vector(const Vector<T> &Vector)
|
||||
__no_instrument_function Vector(const Vector<T> &Vector)
|
||||
{
|
||||
VectorSize = Vector.VectorSize;
|
||||
VectorCapacity = Vector.VectorCapacity;
|
||||
@ -57,7 +57,7 @@ public:
|
||||
VectorBuffer[i] = Vector.VectorBuffer[i];
|
||||
}
|
||||
|
||||
~Vector()
|
||||
__no_instrument_function ~Vector()
|
||||
{
|
||||
#ifdef DEBUG_MEM_ALLOCATION
|
||||
debug("VECTOR INIT: ~Vector( ~%lx )", VectorBuffer);
|
||||
@ -65,7 +65,7 @@ public:
|
||||
delete[] VectorBuffer;
|
||||
}
|
||||
|
||||
void remove(uint64_t Position)
|
||||
__no_instrument_function void remove(uint64_t Position)
|
||||
{
|
||||
if (Position >= VectorSize)
|
||||
return;
|
||||
@ -77,30 +77,30 @@ public:
|
||||
VectorSize--;
|
||||
}
|
||||
|
||||
uint64_t capacity() const { return VectorCapacity; }
|
||||
__no_instrument_function uint64_t capacity() const { return VectorCapacity; }
|
||||
|
||||
uint64_t size() const { return VectorSize; }
|
||||
__no_instrument_function uint64_t size() const { return VectorSize; }
|
||||
|
||||
bool empty() const;
|
||||
__no_instrument_function bool empty() const;
|
||||
|
||||
iterator begin() { return VectorBuffer; }
|
||||
__no_instrument_function iterator begin() { return VectorBuffer; }
|
||||
|
||||
iterator end() { return VectorBuffer + size(); }
|
||||
__no_instrument_function iterator end() { return VectorBuffer + size(); }
|
||||
|
||||
T &front() { return VectorBuffer[0]; }
|
||||
__no_instrument_function T &front() { return VectorBuffer[0]; }
|
||||
|
||||
T &back() { return VectorBuffer[VectorSize - 1]; }
|
||||
__no_instrument_function T &back() { return VectorBuffer[VectorSize - 1]; }
|
||||
|
||||
void push_back(const T &Value)
|
||||
__no_instrument_function void push_back(const T &Value)
|
||||
{
|
||||
if (VectorSize >= VectorCapacity)
|
||||
reserve(VectorCapacity + 5);
|
||||
VectorBuffer[VectorSize++] = Value;
|
||||
}
|
||||
|
||||
void pop_back() { VectorSize--; }
|
||||
__no_instrument_function void pop_back() { VectorSize--; }
|
||||
|
||||
void reverse()
|
||||
__no_instrument_function void reverse()
|
||||
{
|
||||
if (VectorSize <= 1)
|
||||
return;
|
||||
@ -112,7 +112,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void reserve(uint64_t Capacity)
|
||||
__no_instrument_function void reserve(uint64_t Capacity)
|
||||
{
|
||||
if (VectorBuffer == 0)
|
||||
{
|
||||
@ -134,15 +134,15 @@ public:
|
||||
VectorBuffer = Newbuffer;
|
||||
}
|
||||
|
||||
void resize(uint64_t Size)
|
||||
__no_instrument_function void resize(uint64_t Size)
|
||||
{
|
||||
reserve(Size);
|
||||
VectorSize = Size;
|
||||
}
|
||||
|
||||
T &operator[](uint64_t Index) { return VectorBuffer[Index]; }
|
||||
__no_instrument_function T &operator[](uint64_t Index) { return VectorBuffer[Index]; }
|
||||
|
||||
Vector<T> &operator=(const Vector<T> &Vector)
|
||||
__no_instrument_function Vector<T> &operator=(const Vector<T> &Vector)
|
||||
{
|
||||
delete[] VectorBuffer;
|
||||
VectorSize = Vector.VectorSize;
|
||||
@ -156,12 +156,12 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void clear()
|
||||
__no_instrument_function void clear()
|
||||
{
|
||||
VectorCapacity = 0;
|
||||
VectorSize = 0;
|
||||
VectorBuffer = 0;
|
||||
}
|
||||
|
||||
T *data() { return VectorBuffer; }
|
||||
__no_instrument_function T *data() { return VectorBuffer; }
|
||||
};
|
||||
|
Reference in New Issue
Block a user