C userspace programs
This commit is contained in:
@ -2,14 +2,14 @@ include $(ROOT)/mk/grabsrc.mk
|
||||
|
||||
.PHONY: all clean
|
||||
|
||||
ARCH ?= x86_64
|
||||
PUTCHAR_ ?= fb
|
||||
|
||||
CFLAGS := -ffreestanding -Wall -Wextra -g -fcommon -nostdinc
|
||||
|
||||
CFLAGS += -I. \
|
||||
-I$(ROOT)/limine \
|
||||
-I./std/include \
|
||||
-I$(ROOT)/std/include \
|
||||
-I./std \
|
||||
-I./flanterm/src \
|
||||
-DPRINTF_INCLUDE_CONFIG_H=1 \
|
||||
-DLFS_NO_ASSERT \
|
||||
|
@ -1,5 +1,4 @@
|
||||
CC := x86_64-elf-gcc
|
||||
LD := x86_64-elf-ld
|
||||
include $(ROOT)/mk/arch/toolchain-x86_64.mk
|
||||
|
||||
CFLAGS += -m64 \
|
||||
-fPIE \
|
||||
|
@ -6,8 +6,6 @@
|
||||
#include "hal/hal.h"
|
||||
#include "bootinfo/bootinfo.h"
|
||||
|
||||
LocalCpuData HAL_CPUS[HAL_CPUS_MAX];
|
||||
|
||||
uint64_t hal_cpu_rdmsr(uint32_t id) {
|
||||
uint32_t lo, hi;
|
||||
asm volatile("rdmsr" : "=a"(lo), "=d"(hi) : "c"(id));
|
||||
@ -21,8 +19,3 @@ uint64_t hal_cpu_wrmsr(uint32_t id, uint64_t val) {
|
||||
return val;
|
||||
}
|
||||
|
||||
void hal_cpu_init(uint32_t cpu) {
|
||||
void *addr = pmm_alloc(16) + (16 * HAL_PAGE_SIZE);
|
||||
HAL_CPUS[cpu].syscall_kstack = (uint64_t *)VIRT(addr);
|
||||
HAL_CPUS[cpu].kcr3 = hal_vmm_current_cr3();
|
||||
}
|
||||
|
@ -13,24 +13,13 @@
|
||||
#define HAL_CPU_STAR 0xC0000081
|
||||
#define HAL_CPU_LSTAR 0xC0000082
|
||||
#define HAL_CPU_CSTAR 0xC0000083
|
||||
#define HAL_CPU_SFMASK 0xC0000084
|
||||
#define HAL_CPU_FMASK 0xC0000084
|
||||
|
||||
#define HAL_CPU_FSBASE 0xC0000100
|
||||
#define HAL_CPU_GSBASE 0xC0000101
|
||||
#define HAL_CPU_KGSBASE 0xC0000102
|
||||
|
||||
typedef struct {
|
||||
uint64_t *syscall_kstack;
|
||||
uint64_t *syscall_ustack;
|
||||
PgTable *kcr3;
|
||||
PgTable *pcr3;
|
||||
IntrStackFrame *frame;
|
||||
} PACKED LocalCpuData;
|
||||
|
||||
uint64_t hal_cpu_rdmsr(uint32_t id);
|
||||
uint64_t hal_cpu_wrmsr(uint32_t id, uint64_t val);
|
||||
void hal_cpu_init(uint32_t cpu);
|
||||
|
||||
extern LocalCpuData HAL_CPUS[HAL_CPUS_MAX];
|
||||
|
||||
#endif // HAL_CPU_H_
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "pic.h"
|
||||
#include "apic.h"
|
||||
#include "pit.h"
|
||||
#include "syscall.h"
|
||||
|
||||
void hal_init(void) {
|
||||
if (!serial_init()) {
|
||||
@ -33,7 +32,6 @@ void hal_init_withmalloc(void) {
|
||||
pit_init();
|
||||
ioapic_setentry(IOAPIC, acpi_remapirq(0x00), INTR_TIMER);
|
||||
hal_intr_disable();
|
||||
hal_syscall_init();
|
||||
}
|
||||
|
||||
void hal_wait(uint32_t ms) {
|
||||
|
@ -11,6 +11,8 @@
|
||||
#include "apic.h"
|
||||
#include "pit.h"
|
||||
#include "proc/proc.h"
|
||||
#include "syscall/syscall.h"
|
||||
#include "errors.h"
|
||||
|
||||
void hal_intr_disable(void) {
|
||||
asm volatile("cli");
|
||||
@ -122,6 +124,9 @@ void intr_init(void) {
|
||||
MKINTR(45, 0);
|
||||
MKINTR(46, 0);
|
||||
MKINTR(47, 0);
|
||||
|
||||
extern void intr_vec128(void);
|
||||
idt_setentry(0x80, (uint64_t)&intr_vec128, 0, 0xEE);
|
||||
|
||||
idt_init();
|
||||
}
|
||||
@ -149,14 +154,33 @@ void intr_dumpframe(IntrStackFrame *frame) {
|
||||
);
|
||||
}
|
||||
|
||||
void hal_syscalldispatch(IntrStackFrame *frame) {
|
||||
uint64_t sysnum = frame->regs.rax;
|
||||
if (sysnum < SYSCALLS_MAX) {
|
||||
SyscallFn fn = SYSCALL_TABLE[sysnum];
|
||||
if (fn == NULL) {
|
||||
frame->regs.rax = E_BADSYSCALL;
|
||||
return;
|
||||
}
|
||||
int32_t ret = fn(frame->regs.rdi, frame->regs.rsi, frame->regs.rdx,
|
||||
frame->regs.r10, frame->regs.r8, frame->regs.r9);
|
||||
|
||||
if (sysnum == SYS_QUITPROC) {
|
||||
proc_sched((void *)frame);
|
||||
}
|
||||
frame->regs.rax = *(uint64_t *)&ret;
|
||||
}
|
||||
}
|
||||
|
||||
void intr_handleintr(IntrStackFrame *frame) {
|
||||
if (frame->trapnum <= 31) {
|
||||
kprintf("ERROR %s, 0x%lX\n", exceptions[frame->trapnum], frame->errnum);
|
||||
intr_dumpframe(frame);
|
||||
if (frame->trapnum == 14 && frame->errnum & 0x4) {
|
||||
kprintf("killed pid %ld %s\n", PROCS.current->pid, PROCS.current->name);
|
||||
proc_killself();
|
||||
proc_sched((void *)frame);
|
||||
}
|
||||
kprintf("ERROR %s, 0x%lX\n", exceptions[frame->trapnum], frame->errnum);
|
||||
intr_dumpframe(frame);
|
||||
hal_hang();
|
||||
} else if (frame->trapnum >= 32 && frame->trapnum <= 47) {
|
||||
if (frame->trapnum == INTR_TIMER) {
|
||||
@ -167,6 +191,8 @@ void intr_handleintr(IntrStackFrame *frame) {
|
||||
lapic_write(LAPIC_EOI, 0x00);
|
||||
|
||||
proc_sched((void *)frame);
|
||||
} else if (frame->trapnum == 0x80) {
|
||||
hal_syscalldispatch(frame);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,6 +50,7 @@
|
||||
.global intr_vec45
|
||||
.global intr_vec46
|
||||
.global intr_vec47
|
||||
.global intr_vec128
|
||||
|
||||
.macro _vecintr_errorcode_present_save num
|
||||
pushq $\num
|
||||
@ -215,3 +216,6 @@ intr_vec46:
|
||||
intr_vec47:
|
||||
_vecintr_plain_save 47
|
||||
_vecintr_bodygen
|
||||
intr_vec128:
|
||||
_vecintr_plain_save 128
|
||||
_vecintr_bodygen
|
||||
|
@ -1,43 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include "syscall.h"
|
||||
#include "cpu.h"
|
||||
#include "intr.h"
|
||||
#include "syscall/syscall.h"
|
||||
#include "proc/proc.h"
|
||||
#include "kprintf.h"
|
||||
#include "errors.h"
|
||||
|
||||
extern void hal_enable_syscallentry(void);
|
||||
extern void hal_syscallentry(void);
|
||||
|
||||
void hal_syscalldispatch(IntrStackFrame *frame) {
|
||||
uint64_t sysnum = frame->regs.rax;
|
||||
if (sysnum < SYSCALLS_MAX) {
|
||||
SyscallFn fn = SYSCALL_TABLE[sysnum];
|
||||
if (fn == NULL) {
|
||||
frame->regs.rax = E_BADSYSCALL;
|
||||
return;
|
||||
}
|
||||
int32_t ret = fn(frame->regs.rdi, frame->regs.rsi, frame->regs.rdx,
|
||||
frame->regs.r10, frame->regs.r8, frame->regs.r9);
|
||||
|
||||
if (sysnum == SYS_QUITPROC) {
|
||||
proc_sched((void *)frame);
|
||||
}
|
||||
frame->regs.rax = *(uint64_t *)&ret;
|
||||
}
|
||||
}
|
||||
|
||||
void hal_syscall_init(void) {
|
||||
hal_cpu_init(0);
|
||||
LocalCpuData *lcd = &HAL_CPUS[0];
|
||||
|
||||
hal_cpu_wrmsr(HAL_CPU_EFER, hal_cpu_rdmsr(HAL_CPU_EFER) | 0x1);
|
||||
hal_enable_syscallentry();
|
||||
|
||||
hal_cpu_wrmsr(HAL_CPU_GSBASE, (uint64_t)lcd);
|
||||
hal_cpu_wrmsr(HAL_CPU_KGSBASE, (uint64_t)lcd);
|
||||
hal_cpu_wrmsr(HAL_CPU_SFMASK, (uint64_t)0);
|
||||
|
||||
hal_cpu_wrmsr(HAL_CPU_LSTAR, (uint64_t)&hal_syscallentry);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#ifndef HAL_SYSCALL_H_
|
||||
#define HAL_SYSCALL_H_
|
||||
|
||||
void hal_syscall_init(void);
|
||||
|
||||
#endif // HAL_SYSCALL_H_
|
@ -1,48 +0,0 @@
|
||||
#include "regs.S"
|
||||
|
||||
.extern hal_syscalldispatch
|
||||
|
||||
.global hal_enable_syscallentry
|
||||
hal_enable_syscallentry:
|
||||
movq $0xC0000080, %rcx
|
||||
rdmsr
|
||||
or $0x1, %eax
|
||||
wrmsr
|
||||
movq $0xC0000081, %rcx
|
||||
rdmsr
|
||||
movl $0x180008, %edx
|
||||
wrmsr
|
||||
ret
|
||||
|
||||
.global hal_syscallentry
|
||||
hal_syscallentry:
|
||||
cli
|
||||
swapgs
|
||||
|
||||
movq %rsp, %gs:0x8
|
||||
movq %gs:0x0, %rsp
|
||||
|
||||
pushq $0x23
|
||||
pushq %gs:0x8
|
||||
|
||||
swapgs
|
||||
|
||||
pushq %r11
|
||||
pushq $0x1b
|
||||
pushq %rcx
|
||||
|
||||
_push_regs
|
||||
|
||||
mov %rsp, %rdi
|
||||
mov $0x0, %rbp
|
||||
|
||||
call hal_syscalldispatch
|
||||
cli
|
||||
|
||||
_pop_regs
|
||||
|
||||
popq %rcx
|
||||
add $0x8, %rsp
|
||||
popq %r11
|
||||
popq %rsp
|
||||
sysret
|
@ -155,7 +155,7 @@ Proc *proc_spawnuser(char *mountpoint, char *path) {
|
||||
ElfAuxval aux = proc_load_elf_segs(proc, data);
|
||||
|
||||
proc->platformdata.trapframe.ss = 0x20 | 0x3;
|
||||
proc->platformdata.trapframe.rsp = (uint64_t)VIRT(sp);
|
||||
proc->platformdata.trapframe.rsp = (uint64_t)sp;
|
||||
proc->platformdata.trapframe.rflags = 0x202;
|
||||
proc->platformdata.trapframe.cs = 0x18 | 0x3;
|
||||
proc->platformdata.trapframe.rip = aux.entry;
|
||||
@ -231,13 +231,10 @@ void proc_sched(void *cpustate) {
|
||||
IntrStackFrame *frame = cpustate;
|
||||
|
||||
PROCS.current->platformdata.trapframe = *frame;
|
||||
PROCS.current->platformdata.fsbase = hal_cpu_rdmsr(HAL_CPU_FSBASE);
|
||||
|
||||
PROCS.current = proc_nextready();
|
||||
PROCS.current->state = PROC_RUNNING;
|
||||
|
||||
hal_cpu_wrmsr(HAL_CPU_FSBASE, PROCS.current->platformdata.fsbase);
|
||||
HAL_CPUS[0].syscall_kstack = VIRT(PROCS.current->platformdata.kstack);
|
||||
hal_switchproc(&PROCS.current->platformdata.trapframe, (void *)PROCS.current->platformdata.cr3);
|
||||
}
|
||||
|
||||
@ -282,8 +279,8 @@ void proc_init(void) {
|
||||
proc_register(idle);
|
||||
PROCS.current = idle;
|
||||
|
||||
proc_register(proc_spawnkern(&proc_status, "status"));
|
||||
proc_register(proc_spawnuser("base", "/bin/hello"));
|
||||
/* proc_register(proc_spawnkern(&proc_status, "status")); */
|
||||
proc_register(proc_spawnuser("base", "/bin/init"));
|
||||
|
||||
hal_switchproc(&PROCS.current->platformdata.trapframe, (void *)PROCS.current->platformdata.cr3);
|
||||
}
|
||||
|
@ -14,7 +14,6 @@
|
||||
#define PROC_MAX 0x100 // max amount of processes
|
||||
|
||||
typedef struct {
|
||||
uint64_t fsbase;
|
||||
IntrStackFrame trapframe;
|
||||
uint8_t *kstack;
|
||||
PgTable *cr3;
|
||||
|
@ -1,12 +0,0 @@
|
||||
Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
@ -1,3 +0,0 @@
|
||||
This is a collection of 0BSD-licensed freestanding C headers, for use with GCC or Clang.
|
||||
|
||||
kamkow1: Added stdatomic.h
|
@ -1,124 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_FLOAT_H
|
||||
#define __FREESTND_C_HDRS_FLOAT_H 1
|
||||
|
||||
#undef FLT_ROUNDS
|
||||
#define FLT_ROUNDS 1
|
||||
|
||||
#undef FLT_RADIX
|
||||
#define FLT_RADIX __FLT_RADIX__
|
||||
|
||||
#undef FLT_MANT_DIG
|
||||
#define FLT_MANT_DIG __FLT_MANT_DIG__
|
||||
#undef DBL_MANT_DIG
|
||||
#define DBL_MANT_DIG __DBL_MANT_DIG__
|
||||
#undef LDBL_MANT_DIG
|
||||
#define LDBL_MANT_DIG __LDBL_MANT_DIG__
|
||||
|
||||
#if (defined(__cplusplus) && __cplusplus >= 201103L) \
|
||||
|| (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L)
|
||||
|
||||
#undef DECIMAL_DIG
|
||||
#define DECIMAL_DIG __DECIMAL_DIG__
|
||||
|
||||
#undef FLT_EVAL_METHOD
|
||||
#define FLT_EVAL_METHOD __FLT_EVAL_METHOD__
|
||||
|
||||
#endif
|
||||
|
||||
#undef FLT_DIG
|
||||
#define FLT_DIG __FLT_DIG__
|
||||
#undef DBL_DIG
|
||||
#define DBL_DIG __DBL_DIG__
|
||||
#undef LDBL_DIG
|
||||
#define LDBL_DIG __LDBL_DIG__
|
||||
|
||||
#undef FLT_MIN_EXP
|
||||
#define FLT_MIN_EXP __FLT_MIN_EXP__
|
||||
#undef DBL_MIN_EXP
|
||||
#define DBL_MIN_EXP __DBL_MIN_EXP__
|
||||
#undef LDBL_MIN_EXP
|
||||
#define LDBL_MIN_EXP __LDBL_MIN_EXP__
|
||||
|
||||
#undef FLT_MIN_10_EXP
|
||||
#define FLT_MIN_10_EXP __FLT_MIN_10_EXP__
|
||||
#undef DBL_MIN_10_EXP
|
||||
#define DBL_MIN_10_EXP __DBL_MIN_10_EXP__
|
||||
#undef LDBL_MIN_10_EXP
|
||||
#define LDBL_MIN_10_EXP __LDBL_MIN_10_EXP__
|
||||
|
||||
#undef FLT_MAX_EXP
|
||||
#define FLT_MAX_EXP __FLT_MAX_EXP__
|
||||
#undef DBL_MAX_EXP
|
||||
#define DBL_MAX_EXP __DBL_MAX_EXP__
|
||||
#undef LDBL_MAX_EXP
|
||||
#define LDBL_MAX_EXP __LDBL_MAX_EXP__
|
||||
|
||||
#undef FLT_MAX_10_EXP
|
||||
#define FLT_MAX_10_EXP __FLT_MAX_10_EXP__
|
||||
#undef DBL_MAX_10_EXP
|
||||
#define DBL_MAX_10_EXP __DBL_MAX_10_EXP__
|
||||
#undef LDBL_MAX_10_EXP
|
||||
#define LDBL_MAX_10_EXP __LDBL_MAX_10_EXP__
|
||||
|
||||
#undef FLT_MAX
|
||||
#define FLT_MAX __FLT_MAX__
|
||||
#undef DBL_MAX
|
||||
#define DBL_MAX __DBL_MAX__
|
||||
#undef LDBL_MAX
|
||||
#define LDBL_MAX __LDBL_MAX__
|
||||
|
||||
#undef FLT_EPSILON
|
||||
#define FLT_EPSILON __FLT_EPSILON__
|
||||
#undef DBL_EPSILON
|
||||
#define DBL_EPSILON __DBL_EPSILON__
|
||||
#undef LDBL_EPSILON
|
||||
#define LDBL_EPSILON __LDBL_EPSILON__
|
||||
|
||||
#undef FLT_MIN
|
||||
#define FLT_MIN __FLT_MIN__
|
||||
#undef DBL_MIN
|
||||
#define DBL_MIN __DBL_MIN__
|
||||
#undef LDBL_MIN
|
||||
#define LDBL_MIN __LDBL_MIN__
|
||||
|
||||
#if (defined(__cplusplus) && __cplusplus >= 201703L) \
|
||||
|| (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L)
|
||||
|
||||
#undef FLT_DECIMAL_DIG
|
||||
#define FLT_DECIMAL_DIG __FLT_DECIMAL_DIG__
|
||||
#undef DBL_DECIMAL_DIG
|
||||
#define DBL_DECIMAL_DIG __DBL_DECIMAL_DIG__
|
||||
#undef LDBL_DECIMAL_DIG
|
||||
#define LDBL_DECIMAL_DIG __LDBL_DECIMAL_DIG__
|
||||
|
||||
#undef FLT_TRUE_MIN
|
||||
#define FLT_TRUE_MIN __FLT_DENORM_MIN__
|
||||
#undef DBL_TRUE_MIN
|
||||
#define DBL_TRUE_MIN __DBL_DENORM_MIN__
|
||||
#undef LDBL_TRUE_MIN
|
||||
#define LDBL_TRUE_MIN __LDBL_DENORM_MIN__
|
||||
|
||||
#undef FLT_HAS_SUBNORM
|
||||
#define FLT_HAS_SUBNORM __FLT_HAS_DENORM__
|
||||
#undef DBL_HAS_SUBNORM
|
||||
#define DBL_HAS_SUBNORM __DBL_HAS_DENORM__
|
||||
#undef LDBL_HAS_SUBNORM
|
||||
#define LDBL_HAS_SUBNORM __LDBL_HAS_DENORM__
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,210 +0,0 @@
|
||||
#ifndef STD_INTTYPES_H_
|
||||
#define STD_INTTYPES_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define __PRI8 "hh"
|
||||
#define __PRI16 "h"
|
||||
#define __PRI32 ""
|
||||
#define __PRI64 "ll"
|
||||
|
||||
#define PRId8 __PRI8 "d"
|
||||
#define PRIi8 __PRI8 "i"
|
||||
#define PRIo8 __PRI8 "o"
|
||||
#define PRIu8 __PRI8 "u"
|
||||
#define PRIx8 __PRI8 "x"
|
||||
#define PRIX8 __PRI8 "X"
|
||||
|
||||
#define PRId16 __PRI16 "d"
|
||||
#define PRIi16 __PRI16 "i"
|
||||
#define PRIo16 __PRI16 "o"
|
||||
#define PRIu16 __PRI16 "u"
|
||||
#define PRIx16 __PRI16 "x"
|
||||
#define PRIX16 __PRI16 "X"
|
||||
|
||||
#define PRId32 __PRI32 "d"
|
||||
#define PRIi32 __PRI32 "i"
|
||||
#define PRIo32 __PRI32 "o"
|
||||
#define PRIu32 __PRI32 "u"
|
||||
#define PRIx32 __PRI32 "x"
|
||||
#define PRIX32 __PRI32 "X"
|
||||
|
||||
#define PRId64 __PRI64 "d"
|
||||
#define PRIi64 __PRI64 "i"
|
||||
#define PRIo64 __PRI64 "o"
|
||||
#define PRIu64 __PRI64 "u"
|
||||
#define PRIx64 __PRI64 "x"
|
||||
#define PRIX64 __PRI64 "X"
|
||||
|
||||
#define PRIdLEAST8 PRId8
|
||||
#define PRIiLEAST8 PRIi8
|
||||
#define PRIoLEAST8 PRIo8
|
||||
#define PRIuLEAST8 PRIu8
|
||||
#define PRIxLEAST8 PRIx8
|
||||
#define PRIXLEAST8 PRIX8
|
||||
|
||||
#define PRIdLEAST16 PRId16
|
||||
#define PRIiLEAST16 PRIi16
|
||||
#define PRIoLEAST16 PRIo16
|
||||
#define PRIuLEAST16 PRIu16
|
||||
#define PRIxLEAST16 PRIx16
|
||||
#define PRIXLEAST16 PRIX16
|
||||
|
||||
#define PRIdLEAST32 PRId32
|
||||
#define PRIiLEAST32 PRIi32
|
||||
#define PRIoLEAST32 PRIo32
|
||||
#define PRIuLEAST32 PRIu32
|
||||
#define PRIxLEAST32 PRIx32
|
||||
#define PRIXLEAST32 PRIX32
|
||||
|
||||
#define PRIdLEAST64 PRId64
|
||||
#define PRIiLEAST64 PRIi64
|
||||
#define PRIoLEAST64 PRIo64
|
||||
#define PRIuLEAST64 PRIu64
|
||||
#define PRIxLEAST64 PRIx64
|
||||
#define PRIXLEAST64 PRIX64
|
||||
|
||||
#define PRIdFAST8 PRIdLEAST8
|
||||
#define PRIiFAST8 PRIiLEAST8
|
||||
#define PRIoFAST8 PRIoLEAST8
|
||||
#define PRIuFAST8 PRIuLEAST8
|
||||
#define PRIxFAST8 PRIxLEAST8
|
||||
#define PRIXFAST8 PRIXLEAST8
|
||||
|
||||
#define PRIdFAST16 PRIdLEAST16
|
||||
#define PRIiFAST16 PRIiLEAST16
|
||||
#define PRIoFAST16 PRIoLEAST16
|
||||
#define PRIuFAST16 PRIuLEAST16
|
||||
#define PRIxFAST16 PRIxLEAST16
|
||||
#define PRIXFAST16 PRIXLEAST16
|
||||
|
||||
#define PRIdFAST32 PRIdLEAST32
|
||||
#define PRIiFAST32 PRIiLEAST32
|
||||
#define PRIoFAST32 PRIoLEAST32
|
||||
#define PRIuFAST32 PRIuLEAST32
|
||||
#define PRIxFAST32 PRIxLEAST32
|
||||
#define PRIXFAST32 PRIXLEAST32
|
||||
|
||||
#define PRIdFAST64 PRIdLEAST64
|
||||
#define PRIiFAST64 PRIiLEAST64
|
||||
#define PRIoFAST64 PRIoLEAST64
|
||||
#define PRIuFAST64 PRIuLEAST64
|
||||
#define PRIxFAST64 PRIxLEAST64
|
||||
#define PRIXFAST64 PRIXLEAST64
|
||||
|
||||
#if __SIZEOF_POINTER__ == 8
|
||||
# define PRIdPTR PRId64
|
||||
# define PRIiPTR PRIi64
|
||||
# define PRIoPTR PRIo64
|
||||
# define PRIuPTR PRIu64
|
||||
# define PRIxPTR PRIx64
|
||||
# define PRIXPTR PRIX64
|
||||
#else
|
||||
# define PRIdPTR PRId32
|
||||
# define PRIiPTR PRIi32
|
||||
# define PRIoPTR PRIo32
|
||||
# define PRIuPTR PRIu32
|
||||
# define PRIxPTR PRIx32
|
||||
# define PRIXPTR PRIX32
|
||||
#endif
|
||||
|
||||
#define PRIdMAX PRId64
|
||||
#define PRIiMAX PRIi64
|
||||
#define PRIoMAX PRIo64
|
||||
#define PRIuMAX PRIu64
|
||||
#define PRIxMAX PRIx64
|
||||
#define PRIXMAX PRIX64
|
||||
|
||||
#define SCNd8 __PRI8 "d"
|
||||
#define SCNi8 __PRI8 "i"
|
||||
#define SCNo8 __PRI8 "o"
|
||||
#define SCNu8 __PRI8 "u"
|
||||
#define SCNx8 __PRI8 "x"
|
||||
|
||||
#define SCNd16 __PRI16 "d"
|
||||
#define SCNi16 __PRI16 "i"
|
||||
#define SCNo16 __PRI16 "o"
|
||||
#define SCNu16 __PRI16 "u"
|
||||
#define SCNx16 __PRI16 "x"
|
||||
|
||||
#define SCNd32 __PRI32 "d"
|
||||
#define SCNi32 __PRI32 "i"
|
||||
#define SCNo32 __PRI32 "o"
|
||||
#define SCNu32 __PRI32 "u"
|
||||
#define SCNx32 __PRI32 "x"
|
||||
|
||||
#define SCNd64 __PRI64 "d"
|
||||
#define SCNi64 __PRI64 "i"
|
||||
#define SCNo64 __PRI64 "o"
|
||||
#define SCNu64 __PRI64 "u"
|
||||
#define SCNx64 __PRI64 "x"
|
||||
|
||||
#define SCNdLEAST8 SCNd8
|
||||
#define SCNiLEAST8 SCNi8
|
||||
#define SCNoLEAST8 SCNo8
|
||||
#define SCNuLEAST8 SCNu8
|
||||
#define SCNxLEAST8 SCNx8
|
||||
|
||||
#define SCNdLEAST16 SCNd16
|
||||
#define SCNiLEAST16 SCNi16
|
||||
#define SCNoLEAST16 SCNo16
|
||||
#define SCNuLEAST16 SCNu16
|
||||
#define SCNxLEAST16 SCNx16
|
||||
|
||||
#define SCNdLEAST32 SCNd32
|
||||
#define SCNiLEAST32 SCNi32
|
||||
#define SCNoLEAST32 SCNo32
|
||||
#define SCNuLEAST32 SCNu32
|
||||
#define SCNxLEAST32 SCNx32
|
||||
|
||||
#define SCNdLEAST64 SCNd64
|
||||
#define SCNiLEAST64 SCNi64
|
||||
#define SCNoLEAST64 SCNo64
|
||||
#define SCNuLEAST64 SCNu64
|
||||
#define SCNxLEAST64 SCNx64
|
||||
|
||||
#define SCNdFAST8 SCNdLEAST8
|
||||
#define SCNiFAST8 SCNiLEAST8
|
||||
#define SCNoFAST8 SCNoLEAST8
|
||||
#define SCNuFAST8 SCNuLEAST8
|
||||
#define SCNxFAST8 SCNxLEAST8
|
||||
|
||||
#define SCNdFAST16 SCNdLEAST16
|
||||
#define SCNiFAST16 SCNiLEAST16
|
||||
#define SCNoFAST16 SCNoLEAST16
|
||||
#define SCNuFAST16 SCNuLEAST16
|
||||
#define SCNxFAST16 SCNxLEAST16
|
||||
|
||||
#define SCNdFAST32 SCNdLEAST32
|
||||
#define SCNiFAST32 SCNiLEAST32
|
||||
#define SCNoFAST32 SCNoLEAST32
|
||||
#define SCNuFAST32 SCNuLEAST32
|
||||
#define SCNxFAST32 SCNxLEAST32
|
||||
|
||||
#define SCNdFAST64 SCNdLEAST64
|
||||
#define SCNiFAST64 SCNiLEAST64
|
||||
#define SCNoFAST64 SCNoLEAST64
|
||||
#define SCNuFAST64 SCNuLEAST64
|
||||
#define SCNxFAST64 SCNxLEAST64
|
||||
|
||||
#if __SIZEOF_POINTER__ == 8
|
||||
# define SCNdPTR SCNd64
|
||||
# define SCNiPTR SCNi64
|
||||
# define SCNoPTR SCNo64
|
||||
# define SCNuPTR SCNu64
|
||||
# define SCNxPTR SCNx64
|
||||
#else
|
||||
# define SCNdPTR SCNd32
|
||||
# define SCNiPTR SCNi32
|
||||
# define SCNoPTR SCNo32
|
||||
# define SCNuPTR SCNu32
|
||||
# define SCNxPTR SCNx32
|
||||
#endif
|
||||
|
||||
#define SCNdMAX SCNd64
|
||||
#define SCNiMAX SCNi64
|
||||
#define SCNoMAX SCNo64
|
||||
#define SCNuMAX SCNu64
|
||||
#define SCNxMAX SCNx64
|
||||
|
||||
#endif // STD_INTTYPES_H_
|
@ -1,45 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_ISO646_H
|
||||
#define __FREESTND_C_HDRS_ISO646_H 1
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#undef and
|
||||
#define and &&
|
||||
#undef and_eq
|
||||
#define and_eq &=
|
||||
#undef bitand
|
||||
#define bitand &
|
||||
#undef bitor
|
||||
#define bitor |
|
||||
#undef compl
|
||||
#define compl ~
|
||||
#undef not
|
||||
#define not !
|
||||
#undef not_eq
|
||||
#define not_eq !=
|
||||
#undef or
|
||||
#define or ||
|
||||
#undef or_eq
|
||||
#define or_eq |=
|
||||
#undef xor
|
||||
#define xor ^
|
||||
#undef xor_eq
|
||||
#define xor_eq ^=
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,93 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_LIMITS_H
|
||||
#define __FREESTND_C_HDRS_LIMITS_H 1
|
||||
|
||||
#undef CHAR_BIT
|
||||
#define CHAR_BIT __CHAR_BIT__
|
||||
|
||||
#ifndef MB_LEN_MAX
|
||||
# define MB_LEN_MAX 1
|
||||
#endif
|
||||
|
||||
#undef SCHAR_MAX
|
||||
#define SCHAR_MAX __SCHAR_MAX__
|
||||
#undef SCHAR_MIN
|
||||
#define SCHAR_MIN (-SCHAR_MAX - 1)
|
||||
|
||||
#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_MAX
|
||||
# define CHAR_MAX UCHAR_MAX
|
||||
# undef CHAR_MIN
|
||||
# if __SCHAR_MAX__ == __INT_MAX__
|
||||
# define CHAR_MIN 0U
|
||||
# else
|
||||
# define CHAR_MIN 0
|
||||
# endif
|
||||
#else
|
||||
# undef CHAR_MAX
|
||||
# define CHAR_MAX SCHAR_MAX
|
||||
# undef CHAR_MIN
|
||||
# define CHAR_MIN SCHAR_MIN
|
||||
#endif
|
||||
|
||||
#undef SHRT_MAX
|
||||
#define SHRT_MAX __SHRT_MAX__
|
||||
#undef SHRT_MIN
|
||||
#define SHRT_MIN (-SHRT_MAX - 1)
|
||||
|
||||
#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_MAX
|
||||
#define INT_MAX __INT_MAX__
|
||||
#undef INT_MIN
|
||||
#define INT_MIN (-INT_MAX - 1)
|
||||
|
||||
#undef UINT_MAX
|
||||
#define UINT_MAX (INT_MAX * 2U + 1U)
|
||||
|
||||
#undef LONG_MAX
|
||||
#define LONG_MAX __LONG_MAX__
|
||||
#undef LONG_MIN
|
||||
#define LONG_MIN (-LONG_MAX - 1L)
|
||||
|
||||
#undef ULONG_MAX
|
||||
#define ULONG_MAX (LONG_MAX * 2UL + 1UL)
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
||||
|
||||
#undef LLONG_MAX
|
||||
#define LLONG_MAX __LONG_LONG_MAX__
|
||||
#undef LLONG_MIN
|
||||
#define LLONG_MIN (-LLONG_MAX - 1LL)
|
||||
|
||||
#undef ULLONG_MAX
|
||||
#define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,36 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_STDALIGN_H
|
||||
#define __FREESTND_C_HDRS_STDALIGN_H 1
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
|
||||
/* These do not need to be defined for C23+ */
|
||||
#else
|
||||
# undef alignas
|
||||
# define alignas _Alignas
|
||||
# undef alignof
|
||||
# define alignof _Alignof
|
||||
|
||||
# undef __alignof_is_defined
|
||||
# define __alignof_is_defined 1
|
||||
# undef __alignas_is_defined
|
||||
# define __alignas_is_defined 1
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,35 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_STDARG_H
|
||||
#define __FREESTND_C_HDRS_STDARG_H 1
|
||||
|
||||
typedef __builtin_va_list va_list;
|
||||
|
||||
#undef va_start
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
|
||||
# define va_start(v, ...) __builtin_va_start(v, 0)
|
||||
#else
|
||||
# define va_start(v, l) __builtin_va_start(v, l)
|
||||
#endif
|
||||
#undef va_end
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#undef va_arg
|
||||
#define va_arg(v, l) __builtin_va_arg(v, l)
|
||||
#if (defined(__cplusplus) && (__cplusplus >= 201103L)) || (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))
|
||||
# undef va_copy
|
||||
# define va_copy(d, s) __builtin_va_copy(d, s)
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,25 +0,0 @@
|
||||
#ifndef __FREESTND_C_HDRS_STDATOMIC_H
|
||||
#define __FREESTND_C_HDRS_STDATOMIC_H
|
||||
|
||||
#define memory_order_relaxed __ATOMIC_RELAXED
|
||||
#define memory_order_consume __ATOMIC_CONSUME
|
||||
#define memory_order_acquire __ATOMIC_ACQUIRE
|
||||
#define memory_order_release __ATOMIC_RELEASE
|
||||
#define memory_order_acq_rel __ATOMIC_ACQ_REL
|
||||
#define memory_order_seq_cst __ATOMIC_SEQ_CST
|
||||
|
||||
#define atomic_load_explicit __atomic_load_n
|
||||
#define atomic_store_explicit __atomic_store_n
|
||||
|
||||
#define atomic_store(p, v) atomic_store_explicit(p, v, memory_order_relaxed)
|
||||
#define atomic_load(p) atomic_load_explicit(p, memory_order_relaxed)
|
||||
|
||||
#define atomic_compare_exchange_weak(p, old, new) \
|
||||
__atomic_compare_exchange_n(p, old, new, true, memory_order_relaxed, memory_order_relaxed)
|
||||
|
||||
#define atomic_compare_exchange_strong(p, old, new) \
|
||||
__atomic_compare_exchange_n(p, old, new, false, memory_order_relaxed, memory_order_relaxed)
|
||||
|
||||
#define atomic_bool volatile bool
|
||||
|
||||
#endif
|
@ -1,37 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_STDBOOL_H
|
||||
#define __FREESTND_C_HDRS_STDBOOL_H 1
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
|
||||
/* These do not need to be defined for C23+ */
|
||||
#else
|
||||
# undef bool
|
||||
# define bool _Bool
|
||||
|
||||
# undef true
|
||||
# define true 1
|
||||
# undef false
|
||||
# define false 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#undef __bool_true_false_are_defined
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif
|
@ -1,51 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_STDDEF_H
|
||||
#define __FREESTND_C_HDRS_STDDEF_H 1
|
||||
|
||||
typedef __SIZE_TYPE__ size_t;
|
||||
typedef __PTRDIFF_TYPE__ ptrdiff_t;
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef __WCHAR_TYPE__ wchar_t;
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
|
||||
typedef typeof(nullptr) nullptr_t;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef decltype(nullptr) nullptr_t;
|
||||
#endif
|
||||
|
||||
#undef NULL
|
||||
#ifndef __cplusplus
|
||||
# define NULL ((void *)0)
|
||||
#else
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#undef offsetof
|
||||
#define offsetof(s, m) __builtin_offsetof(s, m)
|
||||
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ > 201710L
|
||||
# undef unreachable
|
||||
# define unreachable() __builtin_unreachable()
|
||||
|
||||
# define __STDC_VERSION_STDDEF_H__ 202311L
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,274 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_STDINT_H
|
||||
#define __FREESTND_C_HDRS_STDINT_H 1
|
||||
|
||||
#ifdef __UINT8_TYPE__
|
||||
typedef __UINT8_TYPE__ uint8_t;
|
||||
#endif
|
||||
#ifdef __UINT16_TYPE__
|
||||
typedef __UINT16_TYPE__ uint16_t;
|
||||
#endif
|
||||
#ifdef __UINT32_TYPE__
|
||||
typedef __UINT32_TYPE__ uint32_t;
|
||||
#endif
|
||||
#ifdef __UINT64_TYPE__
|
||||
typedef __UINT64_TYPE__ uint64_t;
|
||||
#endif
|
||||
|
||||
typedef __UINT_LEAST8_TYPE__ uint_least8_t;
|
||||
typedef __UINT_LEAST16_TYPE__ uint_least16_t;
|
||||
typedef __UINT_LEAST32_TYPE__ uint_least32_t;
|
||||
typedef __UINT_LEAST64_TYPE__ uint_least64_t;
|
||||
|
||||
typedef __UINT_FAST8_TYPE__ uint_fast8_t;
|
||||
typedef __UINT_FAST16_TYPE__ uint_fast16_t;
|
||||
typedef __UINT_FAST32_TYPE__ uint_fast32_t;
|
||||
typedef __UINT_FAST64_TYPE__ uint_fast64_t;
|
||||
|
||||
#ifdef __INT8_TYPE__
|
||||
typedef __INT8_TYPE__ int8_t;
|
||||
#endif
|
||||
#ifdef __INT16_TYPE__
|
||||
typedef __INT16_TYPE__ int16_t;
|
||||
#endif
|
||||
#ifdef __INT32_TYPE__
|
||||
typedef __INT32_TYPE__ int32_t;
|
||||
#endif
|
||||
#ifdef __INT64_TYPE__
|
||||
typedef __INT64_TYPE__ int64_t;
|
||||
#endif
|
||||
|
||||
typedef __INT_LEAST8_TYPE__ int_least8_t;
|
||||
typedef __INT_LEAST16_TYPE__ int_least16_t;
|
||||
typedef __INT_LEAST32_TYPE__ int_least32_t;
|
||||
typedef __INT_LEAST64_TYPE__ int_least64_t;
|
||||
|
||||
typedef __INT_FAST8_TYPE__ int_fast8_t;
|
||||
typedef __INT_FAST16_TYPE__ int_fast16_t;
|
||||
typedef __INT_FAST32_TYPE__ int_fast32_t;
|
||||
typedef __INT_FAST64_TYPE__ int_fast64_t;
|
||||
|
||||
#ifdef __UINTPTR_TYPE__
|
||||
typedef __UINTPTR_TYPE__ uintptr_t;
|
||||
#endif
|
||||
#ifdef __INTPTR_TYPE__
|
||||
typedef __INTPTR_TYPE__ intptr_t;
|
||||
#endif
|
||||
|
||||
typedef __UINTMAX_TYPE__ uintmax_t;
|
||||
typedef __INTMAX_TYPE__ intmax_t;
|
||||
|
||||
/* Clang and GCC have different mechanisms for INT32_C and friends. */
|
||||
#ifdef __clang__
|
||||
# ifndef __FREESTND_C_HDRS_C_JOIN
|
||||
# define __FREESTND_C_HDRS_C_EXPAND_JOIN(x, suffix) x ## suffix
|
||||
# define __FREESTND_C_HDRS_C_JOIN(x, suffix) __FREESTND_C_HDRS_C_EXPAND_JOIN(x, suffix)
|
||||
# endif
|
||||
|
||||
# undef INT8_C
|
||||
# define INT8_C(x) __FREESTND_C_HDRS_C_JOIN(x, __INT8_C_SUFFIX__)
|
||||
# undef INT16_C
|
||||
# define INT16_C(x) __FREESTND_C_HDRS_C_JOIN(x, __INT16_C_SUFFIX__)
|
||||
# undef INT32_C
|
||||
# define INT32_C(x) __FREESTND_C_HDRS_C_JOIN(x, __INT32_C_SUFFIX__)
|
||||
# undef INT64_C
|
||||
# define INT64_C(x) __FREESTND_C_HDRS_C_JOIN(x, __INT64_C_SUFFIX__)
|
||||
|
||||
# undef UINT8_C
|
||||
# define UINT8_C(x) __FREESTND_C_HDRS_C_JOIN(x, __UINT8_C_SUFFIX__)
|
||||
# undef UINT16_C
|
||||
# define UINT16_C(x) __FREESTND_C_HDRS_C_JOIN(x, __UINT16_C_SUFFIX__)
|
||||
# undef UINT32_C
|
||||
# define UINT32_C(x) __FREESTND_C_HDRS_C_JOIN(x, __UINT32_C_SUFFIX__)
|
||||
# undef UINT64_C
|
||||
# define UINT64_C(x) __FREESTND_C_HDRS_C_JOIN(x, __UINT64_C_SUFFIX__)
|
||||
|
||||
# undef INTMAX_C
|
||||
# define INTMAX_C(x) __FREESTND_C_HDRS_C_JOIN(x, __INTMAX_C_SUFFIX__)
|
||||
# undef UINTMAX_C
|
||||
# define UINTMAX_C(x) __FREESTND_C_HDRS_C_JOIN(x, __UINTMAX_C_SUFFIX__)
|
||||
#else
|
||||
# undef INT8_C
|
||||
# define INT8_C(x) __INT8_C(x)
|
||||
# undef INT16_C
|
||||
# define INT16_C(x) __INT16_C(x)
|
||||
# undef INT32_C
|
||||
# define INT32_C(x) __INT32_C(x)
|
||||
# undef INT64_C
|
||||
# define INT64_C(x) __INT64_C(x)
|
||||
|
||||
# undef UINT8_C
|
||||
# define UINT8_C(x) __UINT8_C(x)
|
||||
# undef UINT16_C
|
||||
# define UINT16_C(x) __UINT16_C(x)
|
||||
# undef UINT32_C
|
||||
# define UINT32_C(x) __UINT32_C(x)
|
||||
# undef UINT64_C
|
||||
# define UINT64_C(x) __UINT64_C(x)
|
||||
|
||||
# undef INTMAX_C
|
||||
# define INTMAX_C(x) __INTMAX_C(x)
|
||||
# undef UINTMAX_C
|
||||
# define UINTMAX_C(x) __UINTMAX_C(x)
|
||||
#endif
|
||||
|
||||
#ifdef __UINT8_MAX__
|
||||
# undef UINT8_MAX
|
||||
# define UINT8_MAX __UINT8_MAX__
|
||||
#endif
|
||||
#ifdef __UINT16_MAX__
|
||||
# undef UINT16_MAX
|
||||
# define UINT16_MAX __UINT16_MAX__
|
||||
#endif
|
||||
#ifdef __UINT32_MAX__
|
||||
# undef UINT32_MAX
|
||||
# define UINT32_MAX __UINT32_MAX__
|
||||
#endif
|
||||
#ifdef __UINT64_MAX__
|
||||
# undef UINT64_MAX
|
||||
# define UINT64_MAX __UINT64_MAX__
|
||||
#endif
|
||||
|
||||
#ifdef __INT8_MAX__
|
||||
# undef INT8_MAX
|
||||
# define INT8_MAX __INT8_MAX__
|
||||
#endif
|
||||
#ifdef __INT16_MAX__
|
||||
# undef INT16_MAX
|
||||
# define INT16_MAX __INT16_MAX__
|
||||
#endif
|
||||
#ifdef __INT32_MAX__
|
||||
# undef INT32_MAX
|
||||
# define INT32_MAX __INT32_MAX__
|
||||
#endif
|
||||
#ifdef __INT64_MAX__
|
||||
# undef INT64_MAX
|
||||
# define INT64_MAX __INT64_MAX__
|
||||
#endif
|
||||
|
||||
#ifdef __INT8_MAX__
|
||||
# undef INT8_MIN
|
||||
# define INT8_MIN (-INT8_MAX - 1)
|
||||
#endif
|
||||
#ifdef __INT16_MAX__
|
||||
# undef INT16_MIN
|
||||
# define INT16_MIN (-INT16_MAX - 1)
|
||||
#endif
|
||||
#ifdef __INT32_MAX__
|
||||
# undef INT32_MIN
|
||||
# define INT32_MIN (-INT32_MAX - 1)
|
||||
#endif
|
||||
#ifdef __INT64_MAX__
|
||||
# undef INT64_MIN
|
||||
# define INT64_MIN (-INT64_MAX - 1)
|
||||
#endif
|
||||
|
||||
#undef UINT_LEAST8_MAX
|
||||
#define UINT_LEAST8_MAX __UINT_LEAST8_MAX__
|
||||
#undef UINT_LEAST16_MAX
|
||||
#define UINT_LEAST16_MAX __UINT_LEAST16_MAX__
|
||||
#undef UINT_LEAST32_MAX
|
||||
#define UINT_LEAST32_MAX __UINT_LEAST32_MAX__
|
||||
#undef UINT_LEAST64_MAX
|
||||
#define UINT_LEAST64_MAX __UINT_LEAST64_MAX__
|
||||
|
||||
#undef INT_LEAST8_MAX
|
||||
#define INT_LEAST8_MAX __INT_LEAST8_MAX__
|
||||
#undef INT_LEAST16_MAX
|
||||
#define INT_LEAST16_MAX __INT_LEAST16_MAX__
|
||||
#undef INT_LEAST32_MAX
|
||||
#define INT_LEAST32_MAX __INT_LEAST32_MAX__
|
||||
#undef INT_LEAST64_MAX
|
||||
#define INT_LEAST64_MAX __INT_LEAST64_MAX__
|
||||
|
||||
#undef INT_LEAST8_MIN
|
||||
#define INT_LEAST8_MIN (-INT_LEAST8_MAX - 1)
|
||||
#undef INT_LEAST16_MIN
|
||||
#define INT_LEAST16_MIN (-INT_LEAST16_MAX - 1)
|
||||
#undef INT_LEAST32_MIN
|
||||
#define INT_LEAST32_MIN (-INT_LEAST32_MAX - 1)
|
||||
#undef INT_LEAST64_MIN
|
||||
#define INT_LEAST64_MIN (-INT_LEAST64_MAX - 1)
|
||||
|
||||
#undef UINT_FAST8_MAX
|
||||
#define UINT_FAST8_MAX __UINT_FAST8_MAX__
|
||||
#undef UINT_FAST16_MAX
|
||||
#define UINT_FAST16_MAX __UINT_FAST16_MAX__
|
||||
#undef UINT_FAST32_MAX
|
||||
#define UINT_FAST32_MAX __UINT_FAST32_MAX__
|
||||
#undef UINT_FAST64_MAX
|
||||
#define UINT_FAST64_MAX __UINT_FAST64_MAX__
|
||||
|
||||
#undef INT_FAST8_MAX
|
||||
#define INT_FAST8_MAX __INT_FAST8_MAX__
|
||||
#undef INT_FAST16_MAX
|
||||
#define INT_FAST16_MAX __INT_FAST16_MAX__
|
||||
#undef INT_FAST32_MAX
|
||||
#define INT_FAST32_MAX __INT_FAST32_MAX__
|
||||
#undef INT_FAST64_MAX
|
||||
#define INT_FAST64_MAX __INT_FAST64_MAX__
|
||||
|
||||
#undef INT_FAST8_MIN
|
||||
#define INT_FAST8_MIN (-INT_FAST8_MAX - 1)
|
||||
#undef INT_FAST16_MIN
|
||||
#define INT_FAST16_MIN (-INT_FAST16_MAX - 1)
|
||||
#undef INT_FAST32_MIN
|
||||
#define INT_FAST32_MIN (-INT_FAST32_MAX - 1)
|
||||
#undef INT_FAST64_MIN
|
||||
#define INT_FAST64_MIN (-INT_FAST64_MAX - 1)
|
||||
|
||||
#ifdef __UINTPTR_MAX__
|
||||
# undef UINTPTR_MAX
|
||||
# define UINTPTR_MAX __UINTPTR_MAX__
|
||||
#endif
|
||||
#ifdef __INTPTR_MAX__
|
||||
# undef INTPTR_MAX
|
||||
# define INTPTR_MAX __INTPTR_MAX__
|
||||
# undef INTPTR_MIN
|
||||
# define INTPTR_MIN (-INTPTR_MAX - 1)
|
||||
#endif
|
||||
|
||||
#undef UINTMAX_MAX
|
||||
#define UINTMAX_MAX __UINTMAX_MAX__
|
||||
#undef INTMAX_MAX
|
||||
#define INTMAX_MAX __INTMAX_MAX__
|
||||
#undef INTMAX_MIN
|
||||
#define INTMAX_MIN (-INTMAX_MAX - 1)
|
||||
|
||||
#undef PTRDIFF_MAX
|
||||
#define PTRDIFF_MAX __PTRDIFF_MAX__
|
||||
#undef PTRDIFF_MIN
|
||||
#define PTRDIFF_MIN (-PTRDIFF_MAX - 1)
|
||||
|
||||
#undef SIG_ATOMIC_MAX
|
||||
#define SIG_ATOMIC_MAX __SIG_ATOMIC_MAX__
|
||||
#undef SIG_ATOMIC_MIN
|
||||
#define SIG_ATOMIC_MIN (-SIG_ATOMIC_MAX - 1)
|
||||
|
||||
#undef SIZE_MAX
|
||||
#define SIZE_MAX __SIZE_MAX__
|
||||
|
||||
#undef WCHAR_MAX
|
||||
#define WCHAR_MAX __WCHAR_MAX__
|
||||
#undef WCHAR_MIN
|
||||
#define WCHAR_MIN (-WCHAR_MAX - 1)
|
||||
|
||||
#undef WINT_MAX
|
||||
#define WINT_MAX __WINT_MAX__
|
||||
#undef WINT_MIN
|
||||
#define WINT_MIN (-WINT_MAX - 1)
|
||||
|
||||
#endif
|
@ -1,24 +0,0 @@
|
||||
/* Copyright (C) 2022-2025 Mintsuki and contributors.
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
|
||||
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
|
||||
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __FREESTND_C_HDRS_STDNORETURN_H
|
||||
#define __FREESTND_C_HDRS_STDNORETURN_H 1
|
||||
|
||||
#ifndef __cplusplus
|
||||
|
||||
#define noreturn _Noreturn
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
@ -5,14 +5,9 @@
|
||||
#include "kprintf.h"
|
||||
#include "proc/proc.h"
|
||||
|
||||
int32_t SYSCALL2(sys_debugprint, string1, len) {
|
||||
char *buf = dlmalloc(len);
|
||||
if (buf == NULL) {
|
||||
return E_NOMEMORY;
|
||||
}
|
||||
ksnprintf(buf, len, "%s", string1);
|
||||
kprintf("%s\n", buf);
|
||||
dlfree(buf);
|
||||
int32_t SYSCALL1(sys_debugprint, string) {
|
||||
char *p = (char *)string;
|
||||
kprintf("%s\n", p);
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user