Renamed "__no_instrument_function"

This commit is contained in:
Alex 2023-02-27 22:19:40 +02:00
parent 81512f2b57
commit 392ebc9be2
Signed by untrusted user who does not match committer: enderice2
GPG Key ID: EACC3AD603BAB4DD
13 changed files with 84 additions and 83 deletions

View File

@ -42,7 +42,7 @@ static volatile struct limine_smbios_request SmbiosRequest = {
.id = LIMINE_SMBIOS_REQUEST, .id = LIMINE_SMBIOS_REQUEST,
.revision = 0}; .revision = 0};
SafeFunction __no_instrument_function void init_limine() SafeFunction NIF void init_limine()
{ {
struct BootInfo binfo; struct BootInfo binfo;
struct limine_bootloader_info_response *BootloaderInfoResponse = BootloaderInfoRequest.response; struct limine_bootloader_info_response *BootloaderInfoResponse = BootloaderInfoRequest.response;

View File

@ -8,13 +8,13 @@ NewLock(DebuggerLock);
using namespace UniversalAsynchronousReceiverTransmitter; using namespace UniversalAsynchronousReceiverTransmitter;
static inline __no_instrument_function void uart_wrapper(char c, void *unused) static inline NIF void uart_wrapper(char c, void *unused)
{ {
UART(COM1).Write(c); UART(COM1).Write(c);
UNUSED(unused); UNUSED(unused);
} }
static inline __no_instrument_function void WritePrefix(DebugLevel Level, const char *File, int Line, const char *Function) static inline NIF void WritePrefix(DebugLevel Level, const char *File, int Line, const char *Function)
{ {
const char *DbgLvlString; const char *DbgLvlString;
switch (Level) switch (Level)
@ -52,7 +52,7 @@ static inline __no_instrument_function void WritePrefix(DebugLevel Level, const
namespace SysDbg namespace SysDbg
{ {
__no_instrument_function void Write(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) NIF void Write(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);
va_list args; va_list args;
@ -61,7 +61,7 @@ namespace SysDbg
va_end(args); va_end(args);
} }
__no_instrument_function void WriteLine(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) NIF void WriteLine(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);
va_list args; va_list args;
@ -71,7 +71,7 @@ namespace SysDbg
uart_wrapper('\n', nullptr); uart_wrapper('\n', nullptr);
} }
__no_instrument_function void LockedWrite(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) NIF void LockedWrite(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
SmartTimeoutLock(DebuggerLock, 1000); SmartTimeoutLock(DebuggerLock, 1000);
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);
@ -81,7 +81,7 @@ namespace SysDbg
va_end(args); va_end(args);
} }
__no_instrument_function void LockedWriteLine(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) NIF void LockedWriteLine(DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
SmartTimeoutLock(DebuggerLock, 1000); SmartTimeoutLock(DebuggerLock, 1000);
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);
@ -94,7 +94,7 @@ namespace SysDbg
} }
// C compatibility // C compatibility
extern "C" __no_instrument_function void SysDbgWrite(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) extern "C" NIF void SysDbgWrite(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);
va_list args; va_list args;
@ -104,7 +104,7 @@ extern "C" __no_instrument_function void SysDbgWrite(enum DebugLevel Level, cons
} }
// C compatibility // C compatibility
extern "C" __no_instrument_function void SysDbgWriteLine(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) extern "C" NIF void SysDbgWriteLine(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);
va_list args; va_list args;
@ -115,7 +115,7 @@ extern "C" __no_instrument_function void SysDbgWriteLine(enum DebugLevel Level,
} }
// C compatibility // C compatibility
extern "C" __no_instrument_function void SysDbgLockedWrite(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) extern "C" NIF void SysDbgLockedWrite(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
SmartTimeoutLock(DebuggerLock, 1000); SmartTimeoutLock(DebuggerLock, 1000);
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);
@ -126,7 +126,7 @@ extern "C" __no_instrument_function void SysDbgLockedWrite(enum DebugLevel Level
} }
// C compatibility // C compatibility
extern "C" __no_instrument_function void SysDbgLockedWriteLine(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...) extern "C" NIF void SysDbgLockedWriteLine(enum DebugLevel Level, const char *File, int Line, const char *Function, const char *Format, ...)
{ {
SmartTimeoutLock(DebuggerLock, 1000); SmartTimeoutLock(DebuggerLock, 1000);
WritePrefix(Level, File, Line, Function); WritePrefix(Level, File, Line, Function);

View File

@ -35,7 +35,7 @@ static MemoryAllocatorType AllocatorType = MemoryAllocatorType::None;
Xalloc::V1 *XallocV1Allocator = nullptr; Xalloc::V1 *XallocV1Allocator = nullptr;
#ifdef DEBUG #ifdef DEBUG
__no_instrument_function void tracepagetable(PageTable4 *pt) NIF void tracepagetable(PageTable4 *pt)
{ {
for (int i = 0; i < 512; i++) for (int i = 0; i < 512; i++)
{ {
@ -54,7 +54,7 @@ __no_instrument_function void tracepagetable(PageTable4 *pt)
} }
#endif #endif
__no_instrument_function void MapFromZero(PageTable4 *PT, BootInfo *Info) NIF void MapFromZero(PageTable4 *PT, BootInfo *Info)
{ {
static int once = 0; static int once = 0;
if (!once++) if (!once++)
@ -79,7 +79,7 @@ __no_instrument_function void MapFromZero(PageTable4 *PT, BootInfo *Info)
} }
} }
__no_instrument_function void MapFramebuffer(PageTable4 *PT, BootInfo *Info) NIF void MapFramebuffer(PageTable4 *PT, BootInfo *Info)
{ {
Virtual va = Virtual(PT); Virtual va = Virtual(PT);
int itrfb = 0; int itrfb = 0;
@ -96,7 +96,7 @@ __no_instrument_function void MapFramebuffer(PageTable4 *PT, BootInfo *Info)
} }
} }
__no_instrument_function void MapKernel(PageTable4 *PT, BootInfo *Info) NIF void MapKernel(PageTable4 *PT, BootInfo *Info)
{ {
/* KernelStart KernelTextEnd KernelRoDataEnd KernelEnd /* KernelStart KernelTextEnd KernelRoDataEnd KernelEnd
Kernel Start & Text Start ------ Text End ------ Kernel Rodata End ------ Kernel Data End & Kernel End Kernel Start & Text Start ------ Text End ------ Kernel Rodata End ------ Kernel Data End & Kernel End
@ -143,7 +143,7 @@ __no_instrument_function void MapKernel(PageTable4 *PT, BootInfo *Info)
KernelStart, KernelTextEnd, KernelRoDataEnd, KernelEnd, Info->Kernel.PhysicalBase, BaseKernelMapAddress - PAGE_SIZE); KernelStart, KernelTextEnd, KernelRoDataEnd, KernelEnd, Info->Kernel.PhysicalBase, BaseKernelMapAddress - PAGE_SIZE);
} }
__no_instrument_function void InitializeMemoryManagement(BootInfo *Info) NIF void InitializeMemoryManagement(BootInfo *Info)
{ {
#ifdef DEBUG #ifdef DEBUG
for (uint64_t i = 0; i < Info->Memory.Entries; i++) for (uint64_t i = 0; i < Info->Memory.Entries; i++)
@ -190,7 +190,6 @@ __no_instrument_function void InitializeMemoryManagement(BootInfo *Info)
Type); Type);
} }
#endif #endif
trace("Initializing Physical Memory Manager"); trace("Initializing Physical Memory Manager");
// KernelAllocator = Physical(); <- Already called in the constructor // KernelAllocator = Physical(); <- Already called in the constructor
KernelAllocator.Init(Info); KernelAllocator.Init(Info);

View File

@ -92,7 +92,7 @@ namespace SymbolResolver
Symbols::~Symbols() {} Symbols::~Symbols() {}
const __no_instrument_function char *Symbols::GetSymbolFromAddress(uintptr_t Address) const NIF char *Symbols::GetSymbolFromAddress(uintptr_t Address)
{ {
Symbols::SymbolTable Result{0, (char *)"<unknown>"}; Symbols::SymbolTable Result{0, (char *)"<unknown>"};
for (uintptr_t i = 0; i < this->TotalEntries; i++) for (uintptr_t i = 0; i < this->TotalEntries; i++)
@ -101,7 +101,7 @@ namespace SymbolResolver
return Result.FunctionName; return Result.FunctionName;
} }
__no_instrument_function void Symbols::AddSymbol(uintptr_t Address, const char *Name) NIF void Symbols::AddSymbol(uintptr_t Address, const char *Name)
{ {
if (this->TotalEntries >= 0x10000) if (this->TotalEntries >= 0x10000)
{ {

View File

@ -7,7 +7,7 @@ volatile bool serialports[8] = {false, false, false, false, false, false, false,
Vector<UniversalAsynchronousReceiverTransmitter::Events *> RegisteredEvents; Vector<UniversalAsynchronousReceiverTransmitter::Events *> RegisteredEvents;
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
__no_instrument_function uint8_t NoProfiler_inportb(uint16_t Port) NIF uint8_t NoProfiler_inportb(uint16_t Port)
{ {
uint8_t Result; uint8_t Result;
asm("in %%dx, %%al" asm("in %%dx, %%al"
@ -16,7 +16,7 @@ __no_instrument_function uint8_t NoProfiler_inportb(uint16_t Port)
return Result; return Result;
} }
__no_instrument_function void NoProfiler_outportb(uint16_t Port, uint8_t Data) NIF void NoProfiler_outportb(uint16_t Port, uint8_t Data)
{ {
asmv("out %%al, %%dx" asmv("out %%al, %%dx"
: :
@ -37,7 +37,7 @@ namespace UniversalAsynchronousReceiverTransmitter
/* TODO: Serial Port implementation needs reword. https://wiki.osdev.org/Serial_Ports */ /* TODO: Serial Port implementation needs reword. https://wiki.osdev.org/Serial_Ports */
SafeFunction __no_instrument_function UART::UART(SerialPorts Port) SafeFunction NIF UART::UART(SerialPorts Port)
{ {
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
if (Port == COMNULL) if (Port == COMNULL)
@ -104,9 +104,9 @@ namespace UniversalAsynchronousReceiverTransmitter
#endif #endif
} }
SafeFunction __no_instrument_function UART::~UART() {} SafeFunction NIF UART::~UART() {}
SafeFunction __no_instrument_function void UART::Write(uint8_t Char) SafeFunction NIF void UART::Write(uint8_t Char)
{ {
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
while ((NoProfiler_inportb(Port + 5) & SERIAL_BUFFER_EMPTY) == 0) while ((NoProfiler_inportb(Port + 5) & SERIAL_BUFFER_EMPTY) == 0)
@ -118,7 +118,7 @@ namespace UniversalAsynchronousReceiverTransmitter
e->OnSent(Char); e->OnSent(Char);
} }
SafeFunction __no_instrument_function uint8_t UART::Read() SafeFunction NIF uint8_t UART::Read()
{ {
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
while ((NoProfiler_inportb(Port + 5) & 1) == 0) while ((NoProfiler_inportb(Port + 5) & 1) == 0)
@ -136,13 +136,13 @@ namespace UniversalAsynchronousReceiverTransmitter
} }
} }
SafeFunction __no_instrument_function Events::Events(SerialPorts Port) SafeFunction NIF Events::Events(SerialPorts Port)
{ {
this->Port = Port; this->Port = Port;
RegisteredEvents.push_back(this); RegisteredEvents.push_back(this);
} }
SafeFunction __no_instrument_function Events::~Events() SafeFunction NIF Events::~Events()
{ {
for (uintptr_t i = 0; i < RegisteredEvents.size(); i++) for (uintptr_t i = 0; i < RegisteredEvents.size(); i++)
if (RegisteredEvents[i] == this) if (RegisteredEvents[i] == this)

View File

@ -149,7 +149,7 @@ EXTERNC void KPrint(const char *Format, ...)
Display->SetBuffer(0); Display->SetBuffer(0);
} }
EXTERNC __no_instrument_function void Main(BootInfo *Info) EXTERNC NIF void Main(BootInfo *Info)
{ {
BootClock = Time::ReadClock(); BootClock = Time::ReadClock();
bInfo = (BootInfo *)KernelAllocator.RequestPages(TO_PAGES(sizeof(BootInfo))); bInfo = (BootInfo *)KernelAllocator.RequestPages(TO_PAGES(sizeof(BootInfo)));
@ -324,7 +324,7 @@ typedef void (*CallPtr)(void);
extern CallPtr __init_array_start[0], __init_array_end[0]; extern CallPtr __init_array_start[0], __init_array_end[0];
extern CallPtr __fini_array_start[0], __fini_array_end[0]; extern CallPtr __fini_array_start[0], __fini_array_end[0];
EXTERNC __no_stack_protector __no_instrument_function void Entry(BootInfo *Info) EXTERNC __no_stack_protector NIF void Entry(BootInfo *Info)
{ {
trace("Hello, World!"); trace("Hello, World!");
@ -350,7 +350,7 @@ EXTERNC __no_stack_protector __no_instrument_function void Entry(BootInfo *Info)
#pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor" #pragma GCC diagnostic ignored "-Wdelete-non-virtual-dtor"
EXTERNC __no_stack_protector __no_instrument_function void BeforeShutdown() EXTERNC __no_stack_protector NIF void BeforeShutdown()
{ {
/* TODO: Announce shutdown */ /* TODO: Announce shutdown */

View File

@ -266,14 +266,14 @@ typedef union
// 1. Some compilers are finicky about this; // 1. Some compilers are finicky about this;
// 2. Some people may want to convert this to C89; // 2. Some people may want to convert this to C89;
// 3. If you try to use it as C++, only C++20 supports compound literals // 3. If you try to use it as C++, only C++20 supports compound literals
static inline __no_instrument_function double_with_bit_access get_bit_access(double x) static inline NIF double_with_bit_access get_bit_access(double x)
{ {
double_with_bit_access dwba; double_with_bit_access dwba;
dwba.F = x; dwba.F = x;
return dwba; return dwba;
} }
static inline __no_instrument_function int get_sign_bit(double x) static inline NIF int get_sign_bit(double x)
{ {
// The sign is stored in the highest bit // The sign is stored in the highest bit
return (int)(get_bit_access(x).U >> (DOUBLE_SIZE_IN_BITS - 1)); return (int)(get_bit_access(x).U >> (DOUBLE_SIZE_IN_BITS - 1));
@ -317,7 +317,7 @@ typedef struct
// or alternatively, that '\0' can be passed to the function in the output // or alternatively, that '\0' can be passed to the function in the output
// gadget. The former assumption holds within the printf library. It also // gadget. The former assumption holds within the printf library. It also
// assumes that the output gadget has been properly initialized. // assumes that the output gadget has been properly initialized.
static inline __no_instrument_function void putchar_via_gadget(output_gadget_t *gadget, char c) static inline NIF void putchar_via_gadget(output_gadget_t *gadget, char c)
{ {
printf_size_t write_pos = gadget->pos++; printf_size_t write_pos = gadget->pos++;
// We're _always_ increasing pos, so as to count how may characters // We're _always_ increasing pos, so as to count how may characters
@ -340,7 +340,7 @@ static inline __no_instrument_function void putchar_via_gadget(output_gadget_t *
} }
// Possibly-write the string-terminating '\0' character // Possibly-write the string-terminating '\0' character
static inline __no_instrument_function void append_termination_with_gadget(output_gadget_t *gadget) static inline NIF void append_termination_with_gadget(output_gadget_t *gadget)
{ {
if (gadget->function != NULL || gadget->max_chars == 0) if (gadget->function != NULL || gadget->max_chars == 0)
{ {
@ -356,13 +356,13 @@ static inline __no_instrument_function void append_termination_with_gadget(outpu
// We can't use putchar_ as is, since our output gadget // We can't use putchar_ as is, since our output gadget
// only takes pointers to functions with an extra argument // only takes pointers to functions with an extra argument
static inline __no_instrument_function void putchar_wrapper(char c, void *unused) static inline NIF void putchar_wrapper(char c, void *unused)
{ {
putchar(c); putchar(c);
UNUSED(unused); UNUSED(unused);
} }
static inline __no_instrument_function output_gadget_t discarding_gadget(void) static inline NIF output_gadget_t discarding_gadget(void)
{ {
output_gadget_t gadget; output_gadget_t gadget;
gadget.function = NULL; gadget.function = NULL;
@ -373,7 +373,7 @@ static inline __no_instrument_function output_gadget_t discarding_gadget(void)
return gadget; return gadget;
} }
static inline __no_instrument_function output_gadget_t buffer_gadget(char *buffer, size_t buffer_size) static inline NIF output_gadget_t buffer_gadget(char *buffer, size_t buffer_size)
{ {
printf_size_t usable_buffer_size = (buffer_size > PRINTF_MAX_POSSIBLE_BUFFER_SIZE) ? PRINTF_MAX_POSSIBLE_BUFFER_SIZE : (printf_size_t)buffer_size; printf_size_t usable_buffer_size = (buffer_size > PRINTF_MAX_POSSIBLE_BUFFER_SIZE) ? PRINTF_MAX_POSSIBLE_BUFFER_SIZE : (printf_size_t)buffer_size;
output_gadget_t result = discarding_gadget(); output_gadget_t result = discarding_gadget();
@ -385,7 +385,7 @@ static inline __no_instrument_function output_gadget_t buffer_gadget(char *buffe
return result; return result;
} }
static inline __no_instrument_function output_gadget_t function_gadget(void (*function)(char, void *), void *extra_arg) static inline NIF output_gadget_t function_gadget(void (*function)(char, void *), void *extra_arg)
{ {
output_gadget_t result = discarding_gadget(); output_gadget_t result = discarding_gadget();
result.function = function; result.function = function;
@ -394,7 +394,7 @@ static inline __no_instrument_function output_gadget_t function_gadget(void (*fu
return result; return result;
} }
static inline __no_instrument_function output_gadget_t extern_putchar_gadget(void) static inline NIF output_gadget_t extern_putchar_gadget(void)
{ {
return function_gadget(putchar_wrapper, NULL); return function_gadget(putchar_wrapper, NULL);
} }
@ -403,7 +403,7 @@ static inline __no_instrument_function output_gadget_t extern_putchar_gadget(voi
// @return The length of the string (excluding the terminating 0) limited by 'maxsize' // @return The length of the string (excluding the terminating 0) limited by 'maxsize'
// @note strlen uses size_t, but wes only use this function with printf_size_t // @note strlen uses size_t, but wes only use this function with printf_size_t
// variables - hence the signature. // variables - hence the signature.
static inline __no_instrument_function printf_size_t strnlen_s_(const char *str, printf_size_t maxsize) static inline NIF printf_size_t strnlen_s_(const char *str, printf_size_t maxsize)
{ {
const char *s; const char *s;
for (s = str; *s && maxsize--; ++s) for (s = str; *s && maxsize--; ++s)
@ -413,13 +413,13 @@ static inline __no_instrument_function printf_size_t strnlen_s_(const char *str,
// internal test if char is a digit (0-9) // internal test if char is a digit (0-9)
// @return true if char is a digit // @return true if char is a digit
static inline __no_instrument_function bool is_digit_(char ch) static inline NIF bool is_digit_(char ch)
{ {
return (ch >= '0') && (ch <= '9'); return (ch >= '0') && (ch <= '9');
} }
// internal ASCII string to printf_size_t conversion // internal ASCII string to printf_size_t conversion
static __no_instrument_function printf_size_t atou_(const char **str) static NIF printf_size_t atou_(const char **str)
{ {
printf_size_t i = 0U; printf_size_t i = 0U;
while (is_digit_(**str)) while (is_digit_(**str))
@ -430,7 +430,7 @@ static __no_instrument_function printf_size_t atou_(const char **str)
} }
// output the specified string in reverse, taking care of any zero-padding // output the specified string in reverse, taking care of any zero-padding
static __no_instrument_function void out_rev_(output_gadget_t *output, const char *buf, printf_size_t len, printf_size_t width, printf_flags_t flags) static NIF void out_rev_(output_gadget_t *output, const char *buf, printf_size_t len, printf_size_t width, printf_flags_t flags)
{ {
const printf_size_t start_pos = output->pos; const printf_size_t start_pos = output->pos;
@ -461,7 +461,7 @@ static __no_instrument_function void out_rev_(output_gadget_t *output, const cha
// Invoked by print_integer after the actual number has been printed, performing necessary // Invoked by print_integer after the actual number has been printed, performing necessary
// work on the number's prefix (as the number is initially printed in reverse order) // work on the number's prefix (as the number is initially printed in reverse order)
static __no_instrument_function void print_integer_finalization(output_gadget_t *output, char *buf, printf_size_t len, bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags) static NIF void print_integer_finalization(output_gadget_t *output, char *buf, printf_size_t len, bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags)
{ {
printf_size_t unpadded_len = len; printf_size_t unpadded_len = len;
@ -545,7 +545,7 @@ static __no_instrument_function void print_integer_finalization(output_gadget_t
} }
// An internal itoa-like function // An internal itoa-like function
static __no_instrument_function void print_integer(output_gadget_t *output, printf_unsigned_value_t value, bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags) static NIF void print_integer(output_gadget_t *output, printf_unsigned_value_t value, bool negative, numeric_base_t base, printf_size_t precision, printf_size_t width, printf_flags_t flags)
{ {
char buf[PRINTF_INTEGER_BUFFER_SIZE]; char buf[PRINTF_INTEGER_BUFFER_SIZE];
printf_size_t len = 0U; printf_size_t len = 0U;
@ -604,7 +604,7 @@ static const double powers_of_10[NUM_DECIMAL_DIGITS_IN_INT64_T] = {
// Break up a double number - which is known to be a finite non-negative number - // Break up a double number - which is known to be a finite non-negative number -
// into its base-10 parts: integral - before the decimal point, and fractional - after it. // into its base-10 parts: integral - before the decimal point, and fractional - after it.
// Taken the precision into account, but does not change it even internally. // Taken the precision into account, but does not change it even internally.
static struct __no_instrument_function double_components get_components(double number, printf_size_t precision) static struct NIF double_components get_components(double number, printf_size_t precision)
{ {
struct double_components number_; struct double_components number_;
number_.is_negative = get_sign_bit(number); number_.is_negative = get_sign_bit(number);
@ -741,7 +741,7 @@ static struct double_components get_normalized_components(bool negative, printf_
} }
#endif // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS #endif // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
static __no_instrument_function void print_broken_up_decimal( static NIF void print_broken_up_decimal(
struct double_components number_, output_gadget_t *output, printf_size_t precision, struct double_components number_, output_gadget_t *output, printf_size_t precision,
printf_size_t width, printf_flags_t flags, char *buf, printf_size_t len) printf_size_t width, printf_flags_t flags, char *buf, printf_size_t len)
{ {
@ -843,7 +843,7 @@ static __no_instrument_function void print_broken_up_decimal(
} }
// internal ftoa for fixed decimal floating point // internal ftoa for fixed decimal floating point
static __no_instrument_function void print_decimal_number(output_gadget_t *output, double number, printf_size_t precision, printf_size_t width, printf_flags_t flags, char *buf, printf_size_t len) static NIF void print_decimal_number(output_gadget_t *output, double number, printf_size_t precision, printf_size_t width, printf_flags_t flags, char *buf, printf_size_t len)
{ {
struct double_components value_ = get_components(number, precision); struct double_components value_ = get_components(number, precision);
print_broken_up_decimal(value_, output, precision, width, flags, buf, len); print_broken_up_decimal(value_, output, precision, width, flags, buf, len);
@ -916,7 +916,7 @@ static double pow10_of_int(int floored_exp10)
return dwba.F; return dwba.F;
} }
static __no_instrument_function void print_exponential_number(output_gadget_t *output, double number, printf_size_t precision, printf_size_t width, printf_flags_t flags, char *buf, printf_size_t len) static NIF void print_exponential_number(output_gadget_t *output, double number, printf_size_t precision, printf_size_t width, printf_flags_t flags, char *buf, printf_size_t len)
{ {
const bool negative = get_sign_bit(number); const bool negative = get_sign_bit(number);
// This number will decrease gradually (by factors of 10) as we "extract" the exponent out of it // This number will decrease gradually (by factors of 10) as we "extract" the exponent out of it
@ -1039,7 +1039,7 @@ static __no_instrument_function void print_exponential_number(output_gadget_t *o
} }
#endif // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS #endif // PRINTF_SUPPORT_EXPONENTIAL_SPECIFIERS
static __no_instrument_function void print_floating_point(output_gadget_t *output, double value, printf_size_t precision, printf_size_t width, printf_flags_t flags, bool prefer_exponential) static NIF void print_floating_point(output_gadget_t *output, double value, printf_size_t precision, printf_size_t width, printf_flags_t flags, bool prefer_exponential)
{ {
char buf[PRINTF_DECIMAL_BUFFER_SIZE]; char buf[PRINTF_DECIMAL_BUFFER_SIZE];
printf_size_t len = 0U; printf_size_t len = 0U;
@ -1098,7 +1098,7 @@ static __no_instrument_function void print_floating_point(output_gadget_t *outpu
// Advances the format pointer past the flags, and returns the parsed flags // Advances the format pointer past the flags, and returns the parsed flags
// due to the characters passed // due to the characters passed
static __no_instrument_function printf_flags_t parse_flags(const char **format) static NIF printf_flags_t parse_flags(const char **format)
{ {
printf_flags_t flags = 0U; printf_flags_t flags = 0U;
do do
@ -1131,7 +1131,7 @@ static __no_instrument_function printf_flags_t parse_flags(const char **format)
} while (true); } while (true);
} }
static inline __no_instrument_function void format_string_loop(output_gadget_t *output, const char *format, va_list args) static inline NIF void format_string_loop(output_gadget_t *output, const char *format, va_list args)
{ {
#if PRINTF_CHECK_FOR_NUL_IN_FORMAT_SPECIFIER #if PRINTF_CHECK_FOR_NUL_IN_FORMAT_SPECIFIER
#define ADVANCE_IN_FORMAT_STRING(cptr_) \ #define ADVANCE_IN_FORMAT_STRING(cptr_) \
@ -1513,7 +1513,7 @@ static inline __no_instrument_function void format_string_loop(output_gadget_t *
} }
// internal vsnprintf - used for implementing _all library functions // internal vsnprintf - used for implementing _all library functions
static __no_instrument_function int vsnprintf_impl(output_gadget_t *output, const char *format, va_list args) static NIF int vsnprintf_impl(output_gadget_t *output, const char *format, va_list args)
{ {
// Note: The library only calls vsnprintf_impl() with output->pos being 0. However, it is // Note: The library only calls vsnprintf_impl() with output->pos being 0. However, it is
// possible to call this function with a non-zero pos value for some "remedial printing". // possible to call this function with a non-zero pos value for some "remedial printing".
@ -1528,30 +1528,30 @@ static __no_instrument_function int vsnprintf_impl(output_gadget_t *output, cons
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
__no_instrument_function int vprintf(const char *format, va_list arg) NIF int vprintf(const char *format, va_list arg)
{ {
output_gadget_t gadget = extern_putchar_gadget(); output_gadget_t gadget = extern_putchar_gadget();
return vsnprintf_impl(&gadget, format, arg); return vsnprintf_impl(&gadget, format, arg);
} }
__no_instrument_function int vsnprintf(char *s, size_t n, const char *format, va_list arg) NIF int vsnprintf(char *s, size_t n, const char *format, va_list arg)
{ {
output_gadget_t gadget = buffer_gadget(s, n); output_gadget_t gadget = buffer_gadget(s, n);
return vsnprintf_impl(&gadget, format, arg); return vsnprintf_impl(&gadget, format, arg);
} }
__no_instrument_function int vsprintf(char *s, const char *format, va_list arg) NIF int vsprintf(char *s, const char *format, va_list arg)
{ {
return vsnprintf(s, PRINTF_MAX_POSSIBLE_BUFFER_SIZE, format, arg); return vsnprintf(s, PRINTF_MAX_POSSIBLE_BUFFER_SIZE, format, arg);
} }
__no_instrument_function int vfctprintf(void (*out)(char c, void *extra_arg), void *extra_arg, const char *format, va_list arg) NIF int vfctprintf(void (*out)(char c, void *extra_arg), void *extra_arg, const char *format, va_list arg)
{ {
output_gadget_t gadget = function_gadget(out, extra_arg); output_gadget_t gadget = function_gadget(out, extra_arg);
return vsnprintf_impl(&gadget, format, arg); return vsnprintf_impl(&gadget, format, arg);
} }
__no_instrument_function int printf(const char *format, ...) NIF int printf(const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@ -1560,7 +1560,7 @@ __no_instrument_function int printf(const char *format, ...)
return ret; return ret;
} }
__no_instrument_function int sprintf(char *s, const char *format, ...) NIF int sprintf(char *s, const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@ -1569,7 +1569,7 @@ __no_instrument_function int sprintf(char *s, const char *format, ...)
return ret; return ret;
} }
__no_instrument_function int snprintf(char *s, size_t n, const char *format, ...) NIF int snprintf(char *s, size_t n, const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);
@ -1578,7 +1578,7 @@ __no_instrument_function int snprintf(char *s, size_t n, const char *format, ...
return ret; return ret;
} }
__no_instrument_function int fctprintf(void (*out)(char c, void *extra_arg), void *extra_arg, const char *format, ...) NIF int fctprintf(void (*out)(char c, void *extra_arg), void *extra_arg, const char *format, ...)
{ {
va_list args; va_list args;
va_start(args, format); va_start(args, format);

View File

@ -10,7 +10,7 @@ unsigned long long LogDepth = 0;
unsigned int Level = 0; unsigned int Level = 0;
using namespace UniversalAsynchronousReceiverTransmitter; using namespace UniversalAsynchronousReceiverTransmitter;
static inline SafeFunction __no_instrument_function void profiler_uart_wrapper(char c, void *unused) static inline SafeFunction NIF void profiler_uart_wrapper(char c, void *unused)
{ {
bool renable = EnableProfiler; bool renable = EnableProfiler;
EnableProfiler = false; EnableProfiler = false;
@ -20,7 +20,7 @@ static inline SafeFunction __no_instrument_function void profiler_uart_wrapper(c
EnableProfiler = true; EnableProfiler = true;
} }
EXTERNC SafeFunction __no_instrument_function void __cyg_profile_func_enter(void *Function, void *CallSite) EXTERNC SafeFunction NIF void __cyg_profile_func_enter(void *Function, void *CallSite)
{ {
if (!EnableProfiler) if (!EnableProfiler)
return; return;
@ -53,7 +53,7 @@ EXTERNC SafeFunction __no_instrument_function void __cyg_profile_func_enter(void
Wait = false; Wait = false;
} }
EXTERNC SafeFunction __no_instrument_function void __cyg_profile_func_exit(void *Function, void *CallSite) EXTERNC SafeFunction NIF void __cyg_profile_func_exit(void *Function, void *CallSite)
{ {
if (!EnableProfiler) if (!EnableProfiler)
return; return;

View File

@ -38,7 +38,7 @@ struct gcov_info
struct gcov_ctr_info counts[0]; struct gcov_ctr_info counts[0];
}; };
static inline SafeFunction __no_instrument_function void gcov_uart_wrapper(char c, void *unused) static inline SafeFunction NIF void gcov_uart_wrapper(char c, void *unused)
{ {
UART(COM2).Write(c); UART(COM2).Write(c);
UNUSED(unused); UNUSED(unused);
@ -46,25 +46,25 @@ static inline SafeFunction __no_instrument_function void gcov_uart_wrapper(char
// TODO: Implement // TODO: Implement
EXTERNC SafeFunction __no_instrument_function void __gcov_init(gcov_info *p __unused) EXTERNC SafeFunction NIF void __gcov_init(gcov_info *p __unused)
{ {
} }
EXTERNC SafeFunction __no_instrument_function void __gcov_exit(void) EXTERNC SafeFunction NIF void __gcov_exit(void)
{ {
} }
EXTERNC SafeFunction __no_instrument_function void __gcov_flush(void) EXTERNC SafeFunction NIF void __gcov_flush(void)
{ {
} }
EXTERNC SafeFunction __no_instrument_function void __gcov_merge_add(gcov_type *counters, unsigned int n_counters) EXTERNC SafeFunction NIF void __gcov_merge_add(gcov_type *counters, unsigned int n_counters)
{ {
UNUSED(counters); UNUSED(counters);
UNUSED(n_counters); UNUSED(n_counters);
} }
EXTERNC SafeFunction __no_instrument_function void __gcov_merge_single(gcov_type *counters, unsigned int n_counters) EXTERNC SafeFunction NIF void __gcov_merge_single(gcov_type *counters, unsigned int n_counters)
{ {
UNUSED(counters); UNUSED(counters);
UNUSED(n_counters); UNUSED(n_counters);

View File

@ -6,13 +6,13 @@
using namespace UniversalAsynchronousReceiverTransmitter; using namespace UniversalAsynchronousReceiverTransmitter;
static inline SafeFunction __no_instrument_function void gprof_uart_wrapper(char c, void *unused) static inline SafeFunction NIF void gprof_uart_wrapper(char c, void *unused)
{ {
UART(COM2).Write(c); UART(COM2).Write(c);
UNUSED(unused); UNUSED(unused);
} }
EXTERNC SafeFunction __no_instrument_function void mcount(unsigned long frompc, unsigned long selfpc) EXTERNC SafeFunction NIF void mcount(unsigned long frompc, unsigned long selfpc)
{ {
// TODO: Implement // TODO: Implement
/* https://docs.kernel.org/trace/ftrace-design.html */ /* https://docs.kernel.org/trace/ftrace-design.html */

View File

@ -41,7 +41,7 @@ namespace Tasking
// ((APIC::APIC *)Interrupts::apic[0])->IPI(GetCurrentCPU()->ID, icr); // ((APIC::APIC *)Interrupts::apic[0])->IPI(GetCurrentCPU()->ID, icr);
} }
__naked __used __no_stack_protector __no_instrument_function void IdleProcessLoop() __naked __used __no_stack_protector NIF void IdleProcessLoop()
{ {
#if defined(__amd64__) || defined(__i386__) #if defined(__amd64__) || defined(__i386__)
asmv("IdleLoop:\n" asmv("IdleLoop:\n"
@ -54,11 +54,11 @@ namespace Tasking
#endif #endif
} }
SafeFunction __no_instrument_function bool Task::InvalidPCB(PCB *pcb) SafeFunction NIF bool Task::InvalidPCB(PCB *pcb)
{ {
if (!pcb) if (!pcb)
return true; return true;
if (pcb >= (PCB *)(UINTPTR_MAX - 0x1000)) /* Uninitialized pointers may have uintptr_t max value instead of nullptr. */ if (pcb >= (PCB *)(UINTPTR_MAX - 0x1ffe)) /* Uninitialized pointers may have uintptr_t max value instead of nullptr. */
return true; return true;
if (pcb < (PCB *)(0x1000)) /* In this section of the memory is reserved by the kernel. */ if (pcb < (PCB *)(0x1000)) /* In this section of the memory is reserved by the kernel. */
return true; return true;
@ -67,11 +67,11 @@ namespace Tasking
return false; return false;
} }
SafeFunction __no_instrument_function bool Task::InvalidTCB(TCB *tcb) SafeFunction NIF bool Task::InvalidTCB(TCB *tcb)
{ {
if (!tcb) if (!tcb)
return true; return true;
if (tcb >= (TCB *)(UINTPTR_MAX - 0x1000)) /* Uninitialized pointers may have uintptr_t max value instead of nullptr. */ if (tcb >= (TCB *)(UINTPTR_MAX - 0x1ffe)) /* Uninitialized pointers may have uintptr_t max value instead of nullptr. */
return true; return true;
if (tcb < (TCB *)(0x1000)) /* In this section of the memory is reserved by the kernel. */ if (tcb < (TCB *)(0x1000)) /* In this section of the memory is reserved by the kernel. */
return true; return true;
@ -80,7 +80,7 @@ namespace Tasking
return false; return false;
} }
SafeFunction __no_instrument_function void Task::RemoveThread(TCB *Thread) SafeFunction NIF void Task::RemoveThread(TCB *Thread)
{ {
for (size_t i = 0; i < Thread->Parent->Threads.size(); i++) for (size_t i = 0; i < Thread->Parent->Threads.size(); i++)
if (Thread->Parent->Threads[i] == Thread) if (Thread->Parent->Threads[i] == Thread)
@ -98,7 +98,7 @@ namespace Tasking
} }
} }
SafeFunction __no_instrument_function void Task::RemoveProcess(PCB *Process) SafeFunction NIF void Task::RemoveProcess(PCB *Process)
{ {
if (Process == nullptr) if (Process == nullptr)
return; return;
@ -153,19 +153,19 @@ namespace Tasking
} }
} }
SafeFunction __no_instrument_function void Task::UpdateUserTime(TaskInfo *Info) SafeFunction NIF void Task::UpdateUserTime(TaskInfo *Info)
{ {
// TODO // TODO
Info->UserTime++; Info->UserTime++;
} }
SafeFunction __no_instrument_function void Task::UpdateKernelTime(TaskInfo *Info) SafeFunction NIF void Task::UpdateKernelTime(TaskInfo *Info)
{ {
// TODO // TODO
Info->KernelTime++; Info->KernelTime++;
} }
SafeFunction __no_instrument_function void Task::UpdateUsage(TaskInfo *Info, int Core) SafeFunction NIF void Task::UpdateUsage(TaskInfo *Info, int Core)
{ {
if (Info->Affinity[Core] == true) if (Info->Affinity[Core] == true)
{ {

View File

@ -298,6 +298,8 @@ typedef intptr_t ssize_t;
#define SafeFunction __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_address_safety_analysis __no_sanitize_thread #define SafeFunction __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_address_safety_analysis __no_sanitize_thread
#define NIF __no_instrument_function
#define int1 \ #define int1 \
__asm__ __volatile__("int $0x1" \ __asm__ __volatile__("int $0x1" \
: \ : \

View File

@ -51,7 +51,7 @@ namespace UniversalAsynchronousReceiverTransmitter
* @brief Get the Registered Port object * @brief Get the Registered Port object
* @return SerialPorts * @return SerialPorts
*/ */
SafeFunction __no_instrument_function SerialPorts GetRegisteredPort() { return this->Port; } SafeFunction NIF SerialPorts GetRegisteredPort() { return this->Port; }
/** /**
* @brief Called when a character is sent. * @brief Called when a character is sent.