Compare commits

...

13 Commits

Author SHA1 Message Date
0cc4d5096b
fix: accidentally hit CTRL+Z
Some checks failed
Build OS / Build Cross-Compiler & Toolchain (push) Has been cancelled
Deploy Website / Deploy Website to GitHub Pages (push) Has been cancelled
Build OS / Analyze (c-cpp) (push) Has been cancelled
Build OS / Build OS (push) Has been cancelled
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-25 15:20:57 +00:00
34bd348f25
fix(devcontainer): qemu cannot access /dev/kvm "failed to initialize kvm: Permission denied"
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-25 15:18:43 +00:00
d251d9d03f
refactor(rootfs): reorganize file structure and remove unnecessary .gitkeep files
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 15:33:07 +00:00
8f88d9028e
feat(devcontainer): add libtool and libltdl-dev packages
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 15:32:42 +00:00
fcdc26c1f7
refactor(tools): update boot configurations
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 15:07:22 +00:00
fc588f10bc
feat(kernel): enable SIMD by default
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 15:05:14 +00:00
527e1708ce
refactor(rootfs): change "initrd" to "rootfs"
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 00:51:00 +00:00
1286c4cd90
feat(userspace/libs): add libexpat, libffi and libxml2
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 00:42:47 +00:00
0d8c65e44b
feat(userspace/libc): implement functions for porting apps
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 00:40:07 +00:00
27356b7826
fix(userspace/libc): mark ABI and build ID notes as used to prevent optimization removal
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-24 00:38:03 +00:00
d06b6d3270
feat(kernel): add hot and cold attributes to optimize function performance
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-22 03:04:23 +00:00
f9476d8c57
fix(kernel/syscalls): cast syscall arguments to scarg type for call_time
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-22 01:44:46 +00:00
79f2faf55b
feat(devcontainer): install meson in Dockerfile
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
2025-03-21 22:59:58 +00:00
93 changed files with 1330 additions and 549 deletions

View File

@ -80,7 +80,9 @@ RUN apt-get -y install --no-install-recommends \
# Required packages for building test apps in userspace
RUN apt-get -y install --no-install-recommends \
mingw-w64
mingw-w64 \
libtool \
libltdl-dev
# Required packages for building the OS and misc
RUN apt-get -y install --no-install-recommends \
@ -100,6 +102,9 @@ RUN apt-get -y install --no-install-recommends \
# Install git-cliff
RUN pip install git-cliff --break-system-packages
# Install meson
RUN pip install meson --break-system-packages
# Configure git
RUN <<EOF
git config --global advice.detachedHead false
@ -115,3 +120,5 @@ ENV NO_AT_BRIDGE=1
RUN <<EOF
echo PATH=$PATH:/workspaces/Fennix/cross/bin >> /etc/profile
EOF
ENV CHMOD_KVM=1

View File

@ -32,7 +32,7 @@
"type": "bind"
},
{
"source": "${localEnv:XAUTHORITY}",
"source": "${env:XAUTHORITY}",
"target": "/home/vscode/.Xauthority",
"type": "bind"
},
@ -44,6 +44,5 @@
],
"runArgs": [
"--privileged"
],
"postAttachCommand": "sudo chmod 666 /dev/kvm"
]
}

8
.gitignore vendored
View File

@ -1,10 +1,10 @@
iso_tmp_data
artifacts
initrd_tmp_data
initrd/usr/include/*
!initrd/usr/include/.gitkeep
tmp_rootfs
rootfs/usr/include/*
!rootfs/usr/include/.gitkeep
doxygen-doc
initrd.tar
rootfs.tar
.dccache
*.log
*.log.*

16
.vscode/launch.json vendored
View File

@ -19,12 +19,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},
@ -52,12 +52,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},
@ -85,12 +85,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},
@ -118,12 +118,12 @@
"description": "Make breakpoint pending on future shared library load."
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/utest",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/utest",
"description": "/bin/utest (0x00400000)",
"ignoreFailures": true
},
{
"text": "add-symbol-file ${workspaceFolder}/../initrd_tmp_data/bin/libc_test",
"text": "add-symbol-file ${workspaceFolder}/../tmp_rootfs/bin/libc_test",
"description": "/bin/libc_test (0x00600000)",
"ignoreFailures": true
},

View File

@ -16,5 +16,6 @@
"**/tools/qemu/**": true,
"**/tools/cross/**": true,
"**/doxygen-doc/**": true,
}
}
},
"cmake.ignoreCMakeListsMissing": true
}

View File

@ -1807,7 +1807,7 @@ typedef enum
/* Time */
/** @copydoc SYS_TIME */
#define call_time(t) syscall1(SYS_TIME, t)
#define call_time(t) syscall1(SYS_TIME, (scarg)t)
/** @copydoc SYS_CLOCK_GETTIME */
#define call_clock_gettime(clockid, tp) syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)

View File

@ -11,7 +11,7 @@
"git.openRepositoryInParentFolders": "always",
"C_Cpp.autoAddFileAssociations": false,
"conventionalCommits.scopes": [
"initrd",
"rootfs",
"tools",
"devcontainer"
]

View File

@ -130,7 +130,7 @@ namespace KernelConsole
bool SetTheme(std::string Theme)
{
FileNode *rn = fs->GetByPath("/etc/term", thisProcess->Info.RootNode);
FileNode *rn = fs->GetByPath("/sys/cfg/term", thisProcess->Info.RootNode);
if (rn == nullptr)
return false;
@ -274,7 +274,7 @@ namespace KernelConsole
void LateInit()
{
FileNode *rn = fs->GetByPath("/etc/term", thisProcess->Info.RootNode);
FileNode *rn = fs->GetByPath("/sys/cfg/term", thisProcess->Info.RootNode);
if (rn == nullptr)
return;

View File

@ -264,7 +264,7 @@ namespace Interrupts
warn("IRQ%d not found.", InterruptNumber);
}
nsa inline void ReturnFromInterrupt()
nsa hot inline void ReturnFromInterrupt()
{
#if defined(__amd64__) || defined(__i386__)
CPUData *CoreData = GetCurrentCPU();
@ -309,7 +309,7 @@ namespace Interrupts
CPU::Stop();
}
extern "C" nsa void MainInterruptHandler(void *Data)
extern "C" nsa hot void MainInterruptHandler(void *Data)
{
class AutoSwitchPageTable
{
@ -384,7 +384,7 @@ namespace Interrupts
#endif
}
extern "C" nsa void SchedulerInterruptHandler(void *Data)
extern "C" nsa hot void SchedulerInterruptHandler(void *Data)
{
#if defined(__amd64__) || defined(__i386__)
KernelPageTable->Update();

View File

@ -115,10 +115,10 @@ nsa void DiagnosticDataCollection()
S_IROTH |
S_IFDIR;
FileNode *panicDir = fs->ForceCreate(nullptr, "/var/panic", mode);
FileNode *panicDir = fs->ForceCreate(nullptr, "/sys/log/panic", mode);
if (!panicDir)
{
ExPrint("\x1b[0;30;41mFailed to create /var/panic\x1b[0m\n");
ExPrint("\x1b[0;30;41mFailed to create /sys/log/panic\x1b[0m\n");
Display->UpdateBuffer();
return;
}
@ -145,6 +145,6 @@ nsa void DiagnosticDataCollection()
if (!WriteDiagDataToNode(dumpFile))
return;
ExPrint("You can find the diagnostic file in /var/panic/%s\n", filename);
ExPrint("You can find the diagnostic file in /sys/log/panic/%s\n", filename);
Display->UpdateBuffer();
}

View File

@ -1807,7 +1807,7 @@ typedef enum
/* Time */
/** @copydoc SYS_TIME */
#define call_time(t) syscall1(SYS_TIME, t)
#define call_time(t) syscall1(SYS_TIME, (scarg)t)
/** @copydoc SYS_CLOCK_GETTIME */
#define call_clock_gettime(clockid, tp) syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)

View File

@ -458,6 +458,9 @@ typedef uint48_t uint_fast48_t;
#define likely(x) __builtin_expect(!!(x), 1)
#define unlikely(x) __builtin_expect(!!(x), 0)
#define hot __attribute__((hot))
#define cold __attribute__((cold))
#define NoSecurityAnalysis __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_sanitize_thread
#define nsa NoSecurityAnalysis

View File

@ -41,14 +41,14 @@ __aligned(16) BootInfo bInfo{};
struct KernelConfig Config = {
.AllocatorType = Memory::liballoc11,
.SchedulerType = Multi,
.DriverDirectory = {'/', 'u', 's', 'r', '/', 'l', 'i', 'b', '/', 'd', 'r', 'i', 'v', 'e', 'r', 's', '\0'},
.InitPath = {'/', 'b', 'i', 'n', '/', 'i', 'n', 'i', 't', '\0'},
.DriverDirectory = {'/', 's', 'y', 's', '/', 'd', 'r', 'v', '\0'},
.InitPath = {'/', 's', 'y', 's', '/', 'b', 'i', 'n', '/', 'i', 'n', 'i', 't', '\0'},
.UseLinuxSyscalls = false,
.InterruptsOnCrash = true,
.Cores = 0,
.IOAPICInterruptCore = 0,
.UnlockDeadLock = false,
.SIMD = false,
.SIMD = true,
.Quiet = false,
};
@ -117,7 +117,7 @@ EXTERNC void KPrint(const char *Format, ...)
#endif
}
EXTERNC NIF void Main()
EXTERNC NIF cold void Main()
{
Display = new Video::Display(bInfo.Framebuffer[0]);
KernelConsole::EarlyInit();
@ -265,7 +265,7 @@ typedef void (*CallPtr)(void);
extern CallPtr __init_array_start[0], __init_array_end[0];
extern CallPtr __fini_array_start[0], __fini_array_end[0];
EXTERNC __no_stack_protector NIF void Entry(BootInfo *Info)
EXTERNC __no_stack_protector NIF cold void Entry(BootInfo *Info)
{
trace("Hello, World!");

View File

@ -31,7 +31,7 @@
#include <vm.hpp>
#include <vector>
int SpawnInit()
cold int SpawnInit()
{
const char *envp[6] = {
"PATH=/bin:/usr/bin",
@ -54,7 +54,7 @@ int SpawnInit()
nullptr, false, compat, true);
}
void KernelMainThread()
cold void KernelMainThread()
{
thisThread->SetPriority(Tasking::Critical);
@ -129,7 +129,7 @@ Exit:
}
NewLock(ShutdownLock);
void __no_stack_protector KernelShutdownThread(bool Reboot)
cold void __no_stack_protector KernelShutdownThread(bool Reboot)
{
SmartLock(ShutdownLock);
debug("KernelShutdownThread(%s)", Reboot ? "true" : "false");

View File

@ -31,10 +31,10 @@ void SearchForInitrd()
if (!initrdAddress)
continue;
if (strcmp(bInfo.Modules[i].CommandLine, "initrd") != 0)
if (strcmp(bInfo.Modules[i].CommandLine, "rootfs") != 0)
continue;
KPrint("initrd found at %#lx", initrdAddress);
KPrint("rootfs found at %#lx", initrdAddress);
Memory::Virtual vmm;
if (!vmm.Check((void *)initrdAddress))

View File

@ -843,9 +843,9 @@ bool TestAndInitializeUSTAR(uintptr_t Address, size_t Size)
ustar->DeviceID = fs->EarlyReserveDevice();
ustar->ReadArchive(Address, Size);
Inode *initrd = nullptr;
ustar->Lookup(nullptr, "/", &initrd);
assert(initrd != nullptr);
Inode *rootfs = nullptr;
ustar->Lookup(nullptr, "/", &rootfs);
assert(rootfs != nullptr);
FileSystemInfo *fsi = new FileSystemInfo;
fsi->Name = "ustar";
@ -861,8 +861,8 @@ bool TestAndInitializeUSTAR(uintptr_t Address, size_t Size)
fsi->Ops.ReadLink = __ustar_ReadLink;
fsi->Ops.Stat = __ustar_Stat;
fsi->PrivateData = ustar;
fs->LateRegisterFileSystem(ustar->DeviceID, fsi, initrd);
fs->LateRegisterFileSystem(ustar->DeviceID, fsi, rootfs);
fs->AddRoot(initrd);
fs->AddRoot(rootfs);
return true;
}

View File

@ -2133,7 +2133,7 @@ static int linux_uname(SysFrm *, struct utsname *buf)
#endif
};
FileNode *rn = fs->GetByPath("/etc/cross/linux", pcb->Info.RootNode);
FileNode *rn = fs->GetByPath("/sys/cfg/cross/linux", pcb->Info.RootNode);
if (rn)
{
struct kstat st
@ -2177,7 +2177,7 @@ static int linux_uname(SysFrm *, struct utsname *buf)
delete[] sh;
}
else
warn("Couldn't open /etc/cross/linux");
warn("Couldn't open /sys/cfg/cross/linux");
memcpy(pBuf, &uname, sizeof(struct utsname));
return 0;

View File

@ -234,7 +234,7 @@ namespace Tasking::Scheduler
#endif
}
void Custom::Yield()
hot void Custom::Yield()
{
/* This will trigger the IRQ16
instantly so we won't execute
@ -272,7 +272,7 @@ namespace Tasking::Scheduler
/* --------------------------------------------------------------- */
nsa void Custom::OneShot(int TimeSlice)
hot nsa void Custom::OneShot(int TimeSlice)
{
if (TimeSlice == 0)
TimeSlice = Tasking::TaskPriority::Normal;
@ -288,7 +288,7 @@ namespace Tasking::Scheduler
#endif
}
nsa void Custom::UpdateUsage(TaskInfo *Info, TaskExecutionMode Mode, int Core)
hot nsa void Custom::UpdateUsage(TaskInfo *Info, TaskExecutionMode Mode, int Core)
{
UNUSED(Core);
uint64_t CurrentTime = TimeManager->GetCounter();
@ -301,7 +301,7 @@ namespace Tasking::Scheduler
Info->KernelTime += TimePassed;
}
nsa NIF bool Custom::FindNewProcess(void *CPUDataPointer)
hot nsa NIF bool Custom::FindNewProcess(void *CPUDataPointer)
{
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
fnp_schedbg("%d processes", ProcessList.size());
@ -348,7 +348,7 @@ namespace Tasking::Scheduler
return false;
}
nsa NIF bool Custom::GetNextAvailableThread(void *CPUDataPointer)
hot nsa NIF bool Custom::GetNextAvailableThread(void *CPUDataPointer)
{
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
@ -397,7 +397,7 @@ namespace Tasking::Scheduler
return false;
}
nsa NIF bool Custom::GetNextAvailableProcess(void *CPUDataPointer)
hot nsa NIF bool Custom::GetNextAvailableProcess(void *CPUDataPointer)
{
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
@ -445,7 +445,7 @@ namespace Tasking::Scheduler
return false;
}
nsa NIF bool Custom::SchedulerSearchProcessThread(void *CPUDataPointer)
hot nsa NIF bool Custom::SchedulerSearchProcessThread(void *CPUDataPointer)
{
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
@ -564,7 +564,7 @@ namespace Tasking::Scheduler
}
}
nsa NIF void Custom::Schedule(CPU::SchedulerFrame *Frame)
hot nsa NIF void Custom::Schedule(CPU::SchedulerFrame *Frame)
{
if (unlikely(StopScheduler))
{
@ -721,7 +721,7 @@ namespace Tasking::Scheduler
this->SchedulerTicks.store(size_t(TimeManager->GetCounter() - SchedTmpTicks));
}
nsa NIF void Custom::OnInterruptReceived(CPU::SchedulerFrame *Frame)
hot nsa NIF void Custom::OnInterruptReceived(CPU::SchedulerFrame *Frame)
{
SmartCriticalSection(SchedulerLock);
this->Schedule(Frame);

View File

@ -107,9 +107,40 @@ prepare:
$(MAKE) --quiet -C Drivers prepare
$(MAKE) --quiet -C Userspace prepare
MKDIR_ROOTFS = mkdir -p rootfs
mkdir_rootfs:
$(MKDIR_ROOTFS)/home/root/apps/
$(MKDIR_ROOTFS)/home/root/cfg/
$(MKDIR_ROOTFS)/home/root/cache/
$(MKDIR_ROOTFS)/home/root/trash/
$(MKDIR_ROOTFS)/home/root/desktop/
$(MKDIR_ROOTFS)/home/root/documents/
$(MKDIR_ROOTFS)/home/root/downloads/
$(MKDIR_ROOTFS)/home/root/music/
$(MKDIR_ROOTFS)/home/root/pictures/
$(MKDIR_ROOTFS)/home/root/videos/
$(MKDIR_ROOTFS)/home/root/templates/
$(MKDIR_ROOTFS)/sys/bin/
$(MKDIR_ROOTFS)/sys/lib/
$(MKDIR_ROOTFS)/sys/drv/
$(MKDIR_ROOTFS)/sys/svc/
$(MKDIR_ROOTFS)/sys/cfg/
$(MKDIR_ROOTFS)/sys/inc/
$(MKDIR_ROOTFS)/sys/res/
$(MKDIR_ROOTFS)/sys/log/panic/
$(MKDIR_ROOTFS)/usr/bin/
$(MKDIR_ROOTFS)/usr/lib/
$(MKDIR_ROOTFS)/usr/share/
$(MKDIR_ROOTFS)/usr/include/
$(MKDIR_ROOTFS)/tmp/
setup:
$(MAKE) prepare
$(MAKE) tools
$(MAKE) mkdir_rootfs
setup-no-qemu:
$(MAKE) --quiet -C tools ci
@ -211,17 +242,22 @@ endif
build_image:
mkdir -p iso_tmp_data
mkdir -p initrd_tmp_data
cp -r initrd/* initrd_tmp_data/
mkdir -p tmp_rootfs
cp -r rootfs/* tmp_rootfs/
ifeq ($(BUILD_DRIVERS), 1)
cp -r Drivers/out/* initrd_tmp_data/usr/lib/drivers/
cp -r Drivers/out/* tmp_rootfs/sys/drv/
endif
ifeq ($(BUILD_USERSPACE), 1)
cp -r Userspace/out/* initrd_tmp_data/
cp -r Userspace/out/* tmp_rootfs/
endif
# tar czf initrd.tar -C initrd_tmp_data/ ./ --format=ustar
tar cf initrd.tar -C initrd_tmp_data/ ./ --format=ustar
cp Kernel/fennix.elf initrd.tar \
chmod -R 755 tmp_rootfs/sys/
chmod -R 755 tmp_rootfs/usr/
chmod 755 tmp_rootfs/home/
chmod -R 750 tmp_rootfs/home/root/
chmod -R 777 tmp_rootfs/tmp/
# tar czf rootfs.tar -C tmp_rootfs/ --owner=0 --group=0 ./ --format=ustar
tar cf rootfs.tar -C tmp_rootfs/ --owner=0 --group=0 ./ --format=ustar
cp Kernel/fennix.elf rootfs.tar \
iso_tmp_data/
ifeq ($(BOOTLOADER), limine)
cp tools/limine.cfg tools/limine/limine-bios.sys \
@ -301,7 +337,12 @@ clean_logs:
LPT1.dmp LPT2.dmp LPT3.dmp \
mouse.pcap kbd.pcap mousex.pcap kbdx.pcap
vscode_debug_only: clean_logs
check_chmod_kvm:
ifeq ($(CHMOD_KVM), 1)
sudo chmod 666 /dev/kvm
endif
vscode_debug_only: clean_logs check_chmod_kvm
ifneq ($(filter arm aarch64,$(OSARCH)),)
$(QEMU) -S -chardev socket,path=/tmp/gdb-fennix,server=on,wait=off,id=gdb0 -gdb chardev:gdb0 \
-d cpu_reset,int,unimp,guest_errors,mmu,fpu \
@ -318,19 +359,19 @@ vscode_debug: build_kernel build_userspace build_drivers build_image vscode_debu
debug: vscode_debug
qemu: qemu_vdisk clean_logs
qemu: qemu_vdisk clean_logs check_chmod_kvm
touch serial.log
# x-terminal-emulator -e tail -f serial.log &
$(QEMU) $(QEMU_UEFI_BIOS) -cpu host $(QEMUFLAGS) $(QEMUHWACCELERATION) $(QEMUMEMORY) $(QEMU_SMP)
qemubios: qemu_vdisk clean_logs
qemubios: qemu_vdisk clean_logs check_chmod_kvm
$(QEMU) -cpu host $(QEMUFLAGS) $(QEMUHWACCELERATION) $(QEMUMEMORY) $(QEMU_SMP)
run: build qemu
clean: clean_logs
rm -rf doxygen-doc iso_tmp_data initrd_tmp_data
rm -f initrd.tar $(OSNAME).iso $(OSNAME).img
rm -rf doxygen-doc iso_tmp_data tmp_rootfs
rm -f rootfs.tar $(OSNAME).iso $(OSNAME).img
$(MAKE) -C Kernel clean
$(MAKE) -C Userspace clean
$(MAKE) -C Drivers clean

View File

@ -6,7 +6,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
"${workspaceFolder}/out/include/**"
"${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",
@ -52,7 +52,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
"${workspaceFolder}/out/include/**"
"${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",
@ -98,7 +98,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
"${workspaceFolder}/out/include/**"
"${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",
@ -124,7 +124,7 @@
"${workspaceFolder}/libc/include/**",
"${workspaceFolder}/coreutils/include/**",
"${workspaceFolder}/libs/include/**",
"${workspaceFolder}/out/include/**"
"${workspaceFolder}/out/usr/include/**"
],
"defines": [
"__debug_vscode__",

View File

@ -13,7 +13,8 @@ export LDFLAGS := --sysroot=$(WORKSPACE_DIR)/out/ \
-ggdb3 -O0
export CFLAGS := \
--sysroot=$(WORKSPACE_DIR)/out/ \
-I$(WORKSPACE_DIR)/out/include \
-I$(WORKSPACE_DIR)/out/sys/inc \
-I$(WORKSPACE_DIR)/out/usr/include \
-DDEBUG -ggdb3 -O0 -fdiagnostics-color=always
else # DEBUG
@ -21,21 +22,22 @@ else # DEBUG
export LDFLAGS := --sysroot=$(WORKSPACE_DIR)/out/
export CFLAGS := \
--sysroot=$(WORKSPACE_DIR)/out/ \
-I$(WORKSPACE_DIR)/out/include
-I$(WORKSPACE_DIR)/out/sys/inc \
-I$(WORKSPACE_DIR)/out/usr/include
endif # DEBUG
create_out:
rm -rf out
mkdir -p out
mkdir -p out/bin
mkdir -p out/lib
mkdir -p out/include/fennix
mkdir -p out/sys/bin
mkdir -p out/sys/lib
mkdir -p out/sys/inc/fennix
mkdir -p out/usr/bin
mkdir -p out/usr/lib
mkdir -p out/usr/include
mkdir -p out/usr/share/doc
mkdir -p out/usr/share/info
mkdir -p out/usr/include
cp $(WORKSPACE_DIR)/../Kernel/include/interface/* $(WORKSPACE_DIR)/out/include/fennix/
cp $(WORKSPACE_DIR)/../Kernel/include/interface/* $(WORKSPACE_DIR)/out/sys/inc/fennix/
build_coreutils:
mkdir -p cache/coreutils
@ -43,11 +45,11 @@ build_coreutils:
cmake $(WORKSPACE_DIR)/coreutils \
-DCMAKE_INSTALL_PREFIX:PATH=$(WORKSPACE_DIR)/out \
-DCMAKE_SYSROOT=$(WORKSPACE_DIR)/out \
-DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \
-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \
-DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/sys/inc $(WORKSPACE_DIR)/out/usr/include \
-DCMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/sys/inc $(WORKSPACE_DIR)/out/usr/include \
&& \
make -j$(shell nproc) && \
make install
$(MAKE) -j$(shell nproc) && \
$(MAKE) install
define copy_generic_header
cp -f $(WORKSPACE_DIR)/../Kernel/include/interface/$(1) $(WORKSPACE_DIR)/libc/abis/fennix/generic/bits/$(1)
@ -62,26 +64,26 @@ build_libc:
cmake $(WORKSPACE_DIR)/libc \
-DCMAKE_INSTALL_PREFIX:PATH=$(WORKSPACE_DIR)/out \
-DCMAKE_SYSROOT=$(WORKSPACE_DIR)/out \
-DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/include \
-DCMAKE_C_STANDARD_INCLUDE_DIRECTORIES=$(WORKSPACE_DIR)/out/sys/inc $(WORKSPACE_DIR)/out/usr/include \
-DTARGET_OS=fennix \
-DTARGET_ARCH=$(OSARCH) \
&& \
make -j$(shell nproc) && \
make install
$(MAKE) -j$(shell nproc) && \
$(MAKE) install
build: create_out
$(MAKE) build_libc
make -C libs build
$(MAKE) -C libs build
$(MAKE) build_coreutils
make -C apps build
$(MAKE) -C apps build
prepare:
$(info Nothing to prepare)
$(MAKE) -C libs prepare
clean:
rm -rf out cache
mkdir -p cache
touch cache/.gitkeep
make -C libs clean
make -C apps clean
make -C docker clean
$(MAKE) -C libs clean
$(MAKE) -C apps clean
$(MAKE) -C docker clean

View File

@ -11,7 +11,7 @@ FILENAME = $(notdir $(shell pwd))
WARNCFLAG = -Wall -Wextra
build: $(FILENAME).elf
cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
cp $(FILENAME).elf $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)
$(FILENAME).elf: $(OBJ)
$(info Linking $@)

View File

@ -65,8 +65,8 @@ int main()
signal(SIGTERM, HandleSignal);
signal(SIGINT, HandleSignal);
char *shellArgs[] = {"/bin/sh", NULL};
StartProcess("/bin/sh", shellArgs);
char *shellArgs[] = {"/sys/bin/sh", NULL};
StartProcess("/sys/bin/sh", shellArgs);
// char *dummyServiceArgs[] = {"/usr/bin/dummy_service", NULL};
// StartProcess("/usr/bin/dummy_service", dummyServiceArgs);

View File

@ -1,33 +0,0 @@
default:
$(error Do not run this Makefile directly!)
S_SOURCES = $(shell find ./ -type f -name '*.S')
C_SOURCES = $(shell find ./ -type f -name '*.c')
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
OBJ = $(S_SOURCES:.S=.o) $(C_SOURCES:.c=.o) $(CXX_SOURCES:.cpp=.o)
FILENAME = $(notdir $(shell pwd))
WARNCFLAG = -Wall -Wextra
build: $(FILENAME).elf
cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
$(FILENAME).elf: $(OBJ)
$(info Linking $@)
$(CC) $(LDFLAGS) $(SYSROOT) $(OBJ) -o $@
%.o: %.c $(HEADERS)
$(info Compiling $<)
$(CC) $(CFLAGS) $(WARNCFLAG) -std=c17 -c $< -o $@
%.o: %.cpp $(HEADERS)
$(info Compiling $<)
$(CXX) $(CFLAGS) $(WARNCFLAG) -std=c++20 -fexceptions -c $< -o $@ -fno-rtti
%.o: %.S
$(info Compiling $<)
$(AS) -o $@ $<
clean:
rm -f $(OBJ) $(FILENAME).elf

View File

@ -1,114 +0,0 @@
/*
This file is part of Fennix Userspace.
Fennix Userspace is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix Userspace is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix Userspace. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/wait.h>
#include <signal.h>
#define MAX_INPUT_SIZE 1024
#define MAX_ARG_SIZE 100
void print_prompt()
{
printf("$ ");
fflush(stdout);
}
void read_input(char *input)
{
if (fgets(input, MAX_INPUT_SIZE, stdin) == NULL)
{
perror("fgets");
exit(EXIT_FAILURE);
}
input[strcspn(input, "\n")] = '\0';
}
void parse_input(char *input, char **args)
{
int i = 0;
args[i] = strtok(input, " ");
while (args[i] != NULL)
{
i++;
args[i] = strtok(NULL, " ");
}
}
void execute_command(char **args)
{
pid_t pid = fork();
if (pid < 0)
{
perror("fork");
exit(EXIT_FAILURE);
}
else if (pid == 0)
{
if (execvp(args[0], args) < 0)
{
perror("execvp");
exit(EXIT_FAILURE);
}
}
else
{
int status;
waitpid(pid, &status, 0);
if (WIFEXITED(status))
{
printf("Child exited with status %d\n", WEXITSTATUS(status));
}
else if (WIFSIGNALED(status))
{
printf("Child terminated by signal %d\n", WTERMSIG(status));
}
}
}
void handle_signal(int sig)
{
if (sig == SIGINT)
{
printf("\nCaught signal %d (SIGINT). Type 'exit' to quit the shell.\n", sig);
print_prompt();
fflush(stdout);
}
}
int main()
{
char input[MAX_INPUT_SIZE];
char *args[MAX_ARG_SIZE];
signal(SIGINT, handle_signal);
while (1)
{
print_prompt();
read_input(input);
if (strcmp(input, "exit") == 0)
break;
parse_input(input, args);
if (args[0] != NULL)
execute_command(args);
}
return 0;
}

View File

@ -13,7 +13,7 @@ ifneq ($(shell uname -s), Linux)
endif
$(info Compiling $(FILENAME)linux)
gcc linux_glibc.c $(CFLAGS) -o $(FILENAME)linux
cp $(FILENAME)linux $(WORKSPACE_DIR)/out/bin/$(FILENAME)linux
cp $(FILENAME)linux $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)linux
$(FILENAME)win.exe:
ifneq ($(shell uname -s), Linux)
@ -22,7 +22,7 @@ ifneq ($(shell uname -s), Linux)
endif
$(info Compiling $(FILENAME)win)
x86_64-w64-mingw32-gcc win_mingw.c $(CFLAGS) -o $(FILENAME)win.exe
cp $(FILENAME)win.exe $(WORKSPACE_DIR)/out/bin/$(FILENAME)win.exe
cp $(FILENAME)win.exe $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)win.exe
build: $(FILENAME)linux $(FILENAME)win.exe

View File

@ -11,7 +11,7 @@ FILENAME = $(notdir $(shell pwd))
WARNCFLAG = -Wall -Wextra
build: $(FILENAME).elf
cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
cp $(FILENAME).elf $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)
# Use static linking
LDFLAGS += -ggdb3 -g -static -fno-pic -fno-pie -Wl,-static -Wl,-Ttext=0x00600000

View File

@ -11,7 +11,7 @@ FILENAME = $(notdir $(shell pwd))
WARNCFLAG = -Wall -Wextra
build: $(FILENAME).elf
cp $(FILENAME).elf $(WORKSPACE_DIR)/out/bin/$(FILENAME)
cp $(FILENAME).elf $(WORKSPACE_DIR)/out/sys/bin/$(FILENAME)
# Use static linking
LDFLAGS += -static -fno-pic -fno-pie -Wl,-static

View File

@ -344,7 +344,7 @@ void test_file()
{
printf("- Testing file operations\n");
FILE *test = fopen("/etc/passwd", "r");
FILE *test = fopen("/sys/cfg/passwd", "r");
if (test == NULL)
{
perror("fopen");
@ -353,7 +353,7 @@ void test_file()
return;
}
printf("/etc/passwd contents: ");
printf("/sys/cfg/passwd contents: ");
char ch;
while (1)
{
@ -373,7 +373,7 @@ void test_stat()
printf("- Testing stat\n");
struct stat st;
if (stat("/etc/passwd", &st) == -1)
if (stat("/sys/cfg/passwd", &st) == -1)
{
perror("stat");
fflush(stdout);
@ -385,7 +385,7 @@ void test_stat()
printf("File mode: %o\n", st.st_mode);
printf("File inode: %ld\n", st.st_ino);
int fd = open("/etc/passwd", O_RDONLY);
int fd = open("/sys/cfg/passwd", O_RDONLY);
if (fd == -1)
{
perror("open");
@ -407,7 +407,7 @@ void test_stat()
printf("File inode: %ld\n", st.st_ino);
close(fd);
if (lstat("/etc/passwd", &st) == -1)
if (lstat("/sys/cfg/passwd", &st) == -1)
{
perror("lstat");
fflush(stdout);

View File

@ -31,7 +31,7 @@ foreach(file ${SINGLE_SOURCE})
PROGRAM_NAME="${name}"
PROGRAM_VERSION="${PROJECT_VERSION}"
)
install(TARGETS ${name} DESTINATION bin)
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/sys/bin)
endforeach()
file(GLOB_RECURSE GROUP_SOURCES "src/*/*.c")
@ -47,14 +47,14 @@ foreach(name IN LISTS GROUP_MAP_)
PROGRAM_NAME="${name}"
PROGRAM_VERSION="${PROJECT_VERSION}"
)
install(TARGETS ${name} DESTINATION bin)
install(TARGETS ${name} DESTINATION ${CMAKE_INSTALL_PREFIX}/sys/bin)
endforeach()
if(UNIX AND TARGET test)
install(CODE "execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
test
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/[\"
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sys/bin/[\"
)")
endif()
@ -62,6 +62,6 @@ if(UNIX AND TARGET sh)
install(CODE "execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
sh
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/bin/fsh\"
\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/sys/bin/fsh\"
)")
endif()

View File

@ -7,8 +7,8 @@ if(NOT DEFINED ENV{WORKSPACE_DIR})
message(STATUS "Compiling standalone")
if(NOT DEFINED ENV{CMAKE_INSTALL_PREFIX})
set(CMAKE_INSTALL_PREFIX "/usr")
message(STATUS "Using default install prefix: /usr")
set(CMAKE_INSTALL_PREFIX "/")
message(STATUS "Using default install prefix: /")
else()
message(STATUS "Using custom install prefix: $ENV{CMAKE_INSTALL_PREFIX}")
endif()
@ -18,8 +18,8 @@ else()
message(STATUS "Compiling within workspace")
if(NOT DEFINED ENV{CMAKE_INSTALL_PREFIX})
set(CMAKE_INSTALL_PREFIX "$ENV{WORKSPACE_DIR}/out")
message(STATUS "Using default install prefix: $ENV{WORKSPACE_DIR}/out")
set(CMAKE_INSTALL_PREFIX "$ENV{WORKSPACE_DIR}/out/sys")
message(STATUS "Using default install prefix: $ENV{WORKSPACE_DIR}/out/sys")
else()
message(STATUS "Using custom install prefix: $ENV{CMAKE_INSTALL_PREFIX}")
endif()
@ -105,18 +105,24 @@ add_subdirectory(interpreter)
add_subdirectory(src)
add_subdirectory(libs)
if(DEFINED ENV{WORKSPACE_DIR})
set(INC_OUTPUT "inc")
else()
set(INC_OUTPUT "include")
endif()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/
DESTINATION include
DESTINATION ${CMAKE_INSTALL_PREFIX}/${INC_OUTPUT}
FILES_MATCHING
PATTERN "*")
install(DIRECTORY ${ABIS_GENERIC}/
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/
DESTINATION ${CMAKE_INSTALL_PREFIX}/${INC_OUTPUT}
FILES_MATCHING
PATTERN "*")
install(DIRECTORY ${ABIS_PATH}/
DESTINATION ${CMAKE_INSTALL_PREFIX}/include/
DESTINATION ${CMAKE_INSTALL_PREFIX}/${INC_OUTPUT}
FILES_MATCHING
PATTERN "*")

View File

@ -31,4 +31,8 @@ struct sockaddr
char sa_data[14];
};
#ifdef _GNU_SOURCE
#define SO_PEERCRED 0x1029
#endif
#endif // _BITS_SOCKET_H

View File

@ -1807,7 +1807,7 @@ typedef enum
/* Time */
/** @copydoc SYS_TIME */
#define call_time(t) syscall1(SYS_TIME, t)
#define call_time(t) syscall1(SYS_TIME, (scarg)t)
/** @copydoc SYS_CLOCK_GETTIME */
#define call_clock_gettime(clockid, tp) syscall2(SYS_CLOCK_GETTIME, (scarg)clockid, (scarg)tp)

View File

@ -70,5 +70,10 @@ int sysdep(ChangeDirectory)(const char *Pathname);
char *sysdep(GetWorkingDirectory)(char *Buffer, size_t Size);
int sysdep(Brk)(void *Address);
int sysdep(FileControl)(int Descriptor, int Command, void *Arg);
int sysdep(ClockGetTime)(clockid_t ClockID, struct timespec *TP);
time_t sysdep(Time)(void);
clock_t sysdep(Clock)(void);
int sysdep(RemoveDirectory)(const char *Pathname);
int sysdep(Unlink)(const char *Pathname);
#endif // FENNIX_BITS_LIBC_H

View File

@ -0,0 +1,29 @@
/*
This file is part of Fennix C Library.
Fennix C Library is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _ICONV_H
#define _ICONV_H
#include <stddef.h>
typedef void *iconv_t;
iconv_t iconv_open(const char *tocode, const char *fromcode);
size_t iconv(iconv_t cd, char **restrict inbuf, size_t *restrict inbytesleft, char **restrict outbuf, size_t *restrict outbytesleft);
int iconv_close(iconv_t cd);
#endif // _ICONV_H

View File

@ -26,7 +26,7 @@ extern "C"
#include <sys/types.h>
/**
* /etc/passwd
* /sys/cfg/passwd
* name:passwd:uid:gid:gecos:dir:shell
*
* Example

View File

@ -27,6 +27,8 @@ extern "C"
#define NULL ((void *)0)
#endif
#define offsetof(TYPE, MEMBER) ((size_t)&((TYPE *)0)->MEMBER)
typedef struct
{
long long __a;

View File

@ -106,7 +106,7 @@ extern "C"
int fputs(const char *restrict s, FILE *restrict stream);
size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict stream);
FILE *freopen(const char *restrict, const char *restrict, FILE *restrict);
int fscanf(FILE *restrict, const char *restrict, ...);
int fscanf(FILE *restrict stream, const char *restrict format, ...);
int fseek(FILE *stream, long offset, int whence);
int fseeko(FILE *, off_t, int);
int fsetpos(FILE *, const fpos_t *);
@ -131,16 +131,16 @@ extern "C"
int putc_unlocked(int c, FILE *stream);
int putchar_unlocked(int c);
int puts(const char *s);
int remove(const char *);
int remove(const char *path);
int rename(const char *, const char *);
int renameat(int, const char *, int, const char *);
void rewind(FILE *);
int scanf(const char *restrict, ...);
int scanf(const char *restrict format, ...);
void setbuf(FILE *restrict, char *restrict);
int setvbuf(FILE *restrict, char *restrict, int, size_t);
int snprintf(char *restrict s, size_t n, const char *restrict format, ...);
int sprintf(char *restrict s, const char *restrict format, ...);
int sscanf(const char *restrict, const char *restrict, ...);
int sscanf(const char *restrict s, const char *restrict format, ...);
FILE *tmpfile(void);
char *tmpnam(char *);
int ungetc(int, FILE *);
@ -149,7 +149,7 @@ extern "C"
int vfscanf(FILE *restrict, const char *restrict, va_list);
int vprintf(const char *restrict, va_list);
int vscanf(const char *restrict, va_list);
int vsnprintf(char *restrict, size_t, const char *restrict, va_list);
int vsnprintf(char *restrict s, size_t n, const char *restrict format, va_list ap);
int vsprintf(char *restrict, const char *restrict, va_list);
int vsscanf(const char *restrict, const char *restrict, va_list);

View File

@ -102,7 +102,8 @@ extern "C"
double strtod(const char *, char **);
long strtol(const char *restrict nptr, char **restrict endptr, int base);
long long strtoll(const char *restrict nptr, char **restrict endptr, int base);
unsigned long int strtoul(const char *, char **, int);
unsigned long int strtoul(const char *restrict str, char **restrict endptr, int base);
unsigned long long strtoull(const char *restrict str, char **restrict endptr, int base);
int system(const char *command);
int ttyslot(void);
int unlockpt(int);

View File

@ -0,0 +1,41 @@
/*
This file is part of Fennix C Library.
Fennix C Library is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _SYS_SELECT_H
#define _SYS_SELECT_H
#include <sys/types.h>
#include <signal.h>
#include <time.h>
#include <sys/time.h>
#define FD_SETSIZE 1024
typedef struct
{
unsigned long fds_bits[(FD_SETSIZE + (8 * sizeof(unsigned long) - 1)) / (8 * sizeof(unsigned long))];
} fd_set;
#define FD_CLR(fd, fdset) ((fdset)->fds_bits[(fd) / (8 * sizeof(unsigned long))] &= ~(1UL << ((fd) % (8 * sizeof(unsigned long)))))
#define FD_ISSET(fd, fdset) (((fdset)->fds_bits[(fd) / (8 * sizeof(unsigned long))] & (1UL << ((fd) % (8 * sizeof(unsigned long))))) != 0)
#define FD_SET(fd, fdset) ((fdset)->fds_bits[(fd) / (8 * sizeof(unsigned long))] |= (1UL << ((fd) % (8 * sizeof(unsigned long)))))
#define FD_ZERO(fdset) (memset((fdset), 0, sizeof(fd_set)))
int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds, struct timeval *restrict timeout);
int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds, const struct timespec *restrict timeout, const sigset_t *restrict sigmask);
#endif // _SYS_SELECT_H

View File

@ -0,0 +1,51 @@
/*
This file is part of Fennix C Library.
Fennix C Library is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _SYS_TIME_H
#define _SYS_TIME_H
#include <bits/libc.h>
#include <sys/types.h>
#include <sys/select.h>
typedef long time_t;
typedef long suseconds_t;
struct timeval
{
time_t tv_sec; /* Seconds */
suseconds_t tv_usec; /* Microseconds */
};
struct itimerval
{
struct timeval it_interval; /* Timer interval */
struct timeval it_value; /* Current value */
};
/* Values for the which argument of getitimer() and setitimer() */
#define ITIMER_REAL 0
#define ITIMER_VIRTUAL 1
#define ITIMER_PROF 2
int getitimer(int which, struct itimerval *value);
int gettimeofday(struct timeval *restrict tp, void *restrict tzp);
// int select(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, fd_set *restrict exceptfds, struct timeval *restrict timeout);
int setitimer(int which, const struct itimerval *restrict new_value, struct itimerval *restrict old_value);
int utimes(const char *filename, const struct timeval times[2]);
#endif // _SYS_TIME_H

View File

@ -0,0 +1,31 @@
/*
This file is part of Fennix C Library.
Fennix C Library is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
Fennix C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Fennix C Library. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef _SYS_UN_H
#define _SYS_UN_H
#include <sys/socket.h>
#define SUN_PATH_SIZE 108
struct sockaddr_un
{
sa_family_t sun_family; /* Address family */
char sun_path[SUN_PATH_SIZE]; /* Socket pathname storage */
};
#endif // _SYS_UN_H

View File

@ -49,7 +49,7 @@ extern "C"
struct timespec it_value; /* Timer expiration. */
} itimerspec;
#define CLOCKS_PER_SEC
#define CLOCKS_PER_SEC 1000000
#define TIME_UTC
#define CLOCK_MONOTONIC __SYS_CLOCK_MONOTONIC
#define CLOCK_PROCESS_CPUTIME_ID __SYS_CLOCK_PROCESS_CPUTIME_ID
@ -64,10 +64,10 @@ extern "C"
char *asctime(const struct tm *);
clock_t clock(void);
int clock_getcpuclockid(pid_t, clockid_t *);
int clock_getres(clockid_t, struct timespec *);
int clock_gettime(clockid_t, struct timespec *);
int clock_getres(clockid_t clock_id, struct timespec *res);
int clock_gettime(clockid_t clock_id, struct timespec *tp);
int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
int clock_settime(clockid_t, const struct timespec *);
int clock_settime(clockid_t clock_id, const struct timespec *tp);
char *ctime(const time_t *);
double difftime(time_t, time_t);
struct tm *getdate(const char *);
@ -81,7 +81,7 @@ extern "C"
size_t strftime(char *restrict, size_t, const char *restrict, const struct tm *restrict);
size_t strftime_l(char *restrict, size_t, const char *restrict, const struct tm *restrict, locale_t);
char *strptime(const char *restrict, const char *restrict, struct tm *restrict);
time_t time(time_t *);
time_t time(time_t *tloc);
int timer_create(clockid_t, struct sigevent *restrict, timer_t *restrict);
int timer_delete(timer_t);
int timer_getoverrun(timer_t);

View File

@ -121,7 +121,7 @@ extern "C"
ssize_t pwrite(int fildes, const void *buf, size_t nbyte, off_t offset);
ssize_t read(int fildes, void *buf, size_t nbyte);
int readlink(const char *, char *, size_t);
int rmdir(const char *);
int rmdir(const char *path);
void *sbrk(intptr_t incr);
int setgid(gid_t);
int setpgid(pid_t, pid_t);
@ -141,7 +141,7 @@ extern "C"
char *ttyname(int);
int ttyname_r(int, char *, size_t);
useconds_t ualarm(useconds_t, useconds_t);
int unlink(const char *);
int unlink(const char *path);
int usleep(useconds_t);
pid_t vfork(void);
ssize_t write(int fildes, const void *buf, size_t nbyte);

View File

@ -69,7 +69,7 @@ const struct
Elf_Nhdr header;
char name[4];
__UINT32_TYPE__ desc[4];
} __abi_tag __attribute__((aligned(4), section(".note.ABI-tag"))) = {
} __abi_tag __attribute__((used, aligned(4), section(".note.ABI-tag"))) = {
.header = {
.n_namesz = 4, /* "FNX" + '\0' */
.n_descsz = sizeof(__UINT32_TYPE__) * 4, /* Description Size */
@ -84,7 +84,7 @@ const struct
Elf_Nhdr header;
char name[4];
__UINT8_TYPE__ desc[20];
} __build_id __attribute__((aligned(4), section(".note.build-id"))) = {
} __build_id __attribute__((used, aligned(4), section(".note.build-id"))) = {
.header = {
.n_namesz = 4, /* "FNX" + '\0' */
.n_descsz = sizeof(__UINT8_TYPE__) * 20, /* Description Size */

View File

@ -2,4 +2,6 @@ cmake_minimum_required(VERSION 3.10)
project(FennixStandardLibraries)
add_subdirectory(libm)
add_subdirectory(librt)
add_subdirectory(libpthread)
add_subdirectory(libstdc++)

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10)
project(FennixRealTimeLibrary)
set(SOURCES libpthread.c)
add_library(pthread STATIC ${SOURCES})
add_library(pthread_shared SHARED ${SOURCES})
target_link_options(pthread_shared PRIVATE -nostdlib)
set_target_properties(pthread_shared PROPERTIES OUTPUT_NAME "pthread")
install(TARGETS pthread pthread_shared
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include)

View File

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

View File

@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.10)
project(FennixRealTimeLibrary)
set(SOURCES librt.c)
add_library(rt STATIC ${SOURCES})
add_library(rt_shared SHARED ${SOURCES})
target_link_options(rt_shared PRIVATE -nostdlib)
set_target_properties(rt_shared PROPERTIES OUTPUT_NAME "rt")
install(TARGETS rt rt_shared
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
PUBLIC_HEADER DESTINATION include)

View File

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

View File

@ -90,7 +90,7 @@ const struct
Elf_Nhdr header;
char name[4];
__UINT32_TYPE__ desc[4];
} __abi_tag __attribute__((aligned(4), section(".note.ABI-tag"))) = {
} __abi_tag __attribute__((used, aligned(4), section(".note.ABI-tag"))) = {
.header = {
.n_namesz = 4, /* "FNX" + '\0' */
.n_descsz = sizeof(__UINT32_TYPE__) * 4, /* Description Size */

View File

@ -90,7 +90,7 @@ const struct
Elf_Nhdr header;
char name[4];
__UINT32_TYPE__ desc[4];
} __abi_tag __attribute__((aligned(4), section(".note.ABI-tag"))) = {
} __abi_tag __attribute__((used, aligned(4), section(".note.ABI-tag"))) = {
.header = {
.n_namesz = 4, /* "FNX" + '\0' */
.n_descsz = sizeof(__UINT32_TYPE__) * 4, /* Description Size */

View File

@ -67,7 +67,7 @@ const struct
Elf_Nhdr header;
char name[4];
__UINT8_TYPE__ desc[20];
} __build_id __attribute__((aligned(4), section(".note.build-id"))) = {
} __build_id __attribute__((used, aligned(4), section(".note.build-id"))) = {
.header = {
.n_namesz = 4, /* "FNX" + '\0' */
.n_descsz = sizeof(__UINT8_TYPE__) * 20, /* Description Size */

View File

@ -33,7 +33,7 @@ export struct passwd *getpwent(void)
if (pwfile == NULL)
{
pwfile = fopen("/etc/passwd", "r");
pwfile = fopen("/sys/cfg/passwd", "r"); /* FIXME: this path should be OS dependent */
if (pwfile == NULL)
return NULL;
}

View File

@ -19,6 +19,7 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <ctype.h>
#include <bits/libc.h>
#include <fcntl.h>
#include "../print/printf.h"
@ -466,7 +467,24 @@ export int puts(const char *s)
return 0;
}
export int remove(const char *);
export int remove(const char *path)
{
if (!path)
{
errno = EINVAL;
return -1;
}
struct stat path_stat;
if (sysdep(Stat)(path, &path_stat) < 0)
return -1;
if (S_ISDIR(path_stat.st_mode))
return sysdep(RemoveDirectory)(path);
else
return sysdep(Unlink)(path);
}
export int rename(const char *, const char *);
export int renameat(int, const char *, int, const char *);
export void rewind(FILE *);
@ -492,7 +510,117 @@ export int sprintf(char *restrict s, const char *restrict format, ...)
return ret;
}
export int sscanf(const char *restrict, const char *restrict, ...);
export int sscanf(const char *restrict s, const char *restrict format, ...)
{
va_list args;
va_start(args, format);
const char *p = format;
int matchedItems = 0;
while (*p)
{
if (isspace(*p))
{
while (isspace(*p))
p++;
while (isspace(*s))
s++;
}
else if (*p == '%')
{
p++;
if (*p == '\0')
break;
int suppress_assignment = 0;
if (*p == '*')
{
suppress_assignment = 1;
p++;
}
int width = 0;
while (isdigit(*p))
{
width = width * 10 + (*p - '0');
p++;
}
char specifier = *p++;
if (specifier == '\0')
break;
if (specifier == 'd' || specifier == 'i')
{
int value = 0;
while (isdigit(*s) || (*s == '-' && value == 0))
{
if (*s == '-')
{
s++;
continue;
}
value = value * 10 + (*s - '0');
s++;
}
if (!suppress_assignment)
{
int *arg = va_arg(args, int *);
*arg = value;
matchedItems++;
}
}
else if (specifier == 's')
{
char *str = va_arg(args, char *);
while (*s && !isspace(*s) && (width == 0 || width-- > 0))
{
if (!suppress_assignment)
*str++ = *s;
s++;
}
if (!suppress_assignment)
*str = '\0';
matchedItems++;
}
else if (specifier == 'c')
{
char *ch = va_arg(args, char *);
if (*s && (width == 0 || width-- > 0))
{
if (!suppress_assignment)
*ch = *s;
s++;
matchedItems++;
}
}
else if (specifier == '%')
{
if (*s == '%')
s++;
else
break;
}
else
break;
}
else
{
if (*s == *p)
{
s++;
p++;
}
else
break;
}
}
va_end(args);
return matchedItems;
}
export FILE *tmpfile(void);
export char *tmpnam(char *);
export int ungetc(int, FILE *);
@ -526,6 +654,14 @@ export int vfprintf(FILE *restrict stream, const char *restrict format, va_list
export int vfscanf(FILE *restrict, const char *restrict, va_list);
export int vprintf(const char *restrict, va_list);
export int vscanf(const char *restrict, va_list);
export int vsnprintf(char *restrict, size_t, const char *restrict, va_list);
export int vsnprintf(char *restrict s, size_t n, const char *restrict format, va_list ap)
{
int ret = vsnprintf_(s, n, format, ap);
if (ret < 0)
return ret;
return ret;
}
export int vsprintf(char *restrict, const char *restrict, va_list);
export int vsscanf(const char *restrict, const char *restrict, va_list);

View File

@ -334,7 +334,161 @@ export long long strtoll(const char *restrict nptr, char **restrict endptr, int
return acc;
}
export unsigned long int strtoul(const char *, char **, int);
export unsigned long int strtoul(const char *restrict str, char **restrict endptr, int base)
{
const char *s = str;
unsigned long acc = 0;
int c;
unsigned long cutoff;
int any, cutlim;
if (base < 0 || base == 1 || base > 36)
{
errno = EINVAL;
if (endptr)
*endptr = (char *)str;
return 0;
}
while (isspace((unsigned char)*s))
s++;
if (*s == '+')
s++;
else if (*s == '-')
{
errno = EINVAL;
if (endptr)
*endptr = (char *)str;
return 0;
}
if ((base == 0 || base == 16) && *s == '0' && (s[1] == 'x' || s[1] == 'X'))
{
s += 2;
base = 16;
}
else if (base == 0)
base = *s == '0' ? 8 : 10;
cutoff = ULONG_MAX / base;
cutlim = ULONG_MAX % base;
for (acc = 0, any = 0;; c = *s++)
{
if (isdigit(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else
{
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0)
{
acc = ULONG_MAX;
errno = ERANGE;
}
else if (any == 0)
{
errno = EINVAL;
}
if (endptr)
*endptr = (char *)(any ? s - 1 : str);
return acc;
}
export unsigned long long strtoull(const char *restrict str, char **restrict endptr, int base)
{
const char *s = str;
unsigned long long acc = 0;
int c;
unsigned long long cutoff;
int any, cutlim;
if (base < 0 || base == 1 || base > 36)
{
errno = EINVAL;
if (endptr)
*endptr = (char *)str;
return 0;
}
while (isspace((unsigned char)*s))
s++;
if (*s == '+')
s++;
else if (*s == '-')
{
errno = EINVAL;
if (endptr)
*endptr = (char *)str;
return 0;
}
if ((base == 0 || base == 16) && *s == '0' && (s[1] == 'x' || s[1] == 'X'))
{
s += 2;
base = 16;
}
else if (base == 0)
base = *s == '0' ? 8 : 10;
cutoff = ULLONG_MAX / base;
cutlim = ULLONG_MAX % base;
for (acc = 0, any = 0;; c = *s++)
{
if (isdigit(c))
c -= '0';
else if (isalpha(c))
c -= isupper(c) ? 'A' - 10 : 'a' - 10;
else
break;
if (c >= base)
break;
if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
any = -1;
else
{
any = 1;
acc *= base;
acc += c;
}
}
if (any < 0)
{
acc = ULLONG_MAX;
errno = ERANGE;
}
else if (any == 0)
{
errno = EINVAL;
}
if (endptr)
*endptr = (char *)(any ? s - 1 : str);
return acc;
}
export int system(const char *command)
{

View File

@ -30,12 +30,29 @@ export long timezone;
export char *tzname[2];
export char *asctime(const struct tm *);
export clock_t clock(void);
export clock_t clock(void)
{
clock_t processor_time = sysdep(Clock)();
if (processor_time == (clock_t)-1)
{
errno = EOVERFLOW;
return (clock_t)-1;
}
return processor_time;
}
export int clock_getcpuclockid(pid_t, clockid_t *);
export int clock_getres(clockid_t, struct timespec *);
export int clock_gettime(clockid_t, struct timespec *);
export int clock_getres(clockid_t clock_id, struct timespec *res);
export int clock_gettime(clockid_t clock_id, struct timespec *tp)
{
return sysdep(ClockGetTime)(clock_id, tp);
}
export int clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *);
export int clock_settime(clockid_t, const struct timespec *);
export int clock_settime(clockid_t clock_id, const struct timespec *tp);
;
export char *ctime(const time_t *);
export double difftime(time_t, time_t);
export struct tm *getdate(const char *);
@ -193,7 +210,20 @@ export int nanosleep(const struct timespec *, struct timespec *);
export size_t strftime(char *restrict, size_t, const char *restrict, const struct tm *restrict);
export size_t strftime_l(char *restrict, size_t, const char *restrict, const struct tm *restrict, locale_t);
export char *strptime(const char *restrict, const char *restrict, struct tm *restrict);
export time_t time(time_t *);
export time_t time(time_t *tloc)
{
time_t current_time = sysdep(Time)();
if (current_time == (time_t)-1)
{
errno = EOVERFLOW;
return (time_t)-1;
}
if (tloc)
*tloc = current_time;
return current_time;
}
export int timer_create(clockid_t, struct sigevent *restrict, timer_t *restrict);
export int timer_delete(timer_t);
export int timer_getoverrun(timer_t);

View File

@ -209,7 +209,7 @@ export int gethostname(char *name, size_t namelen)
return 0;
}
int fd = open("/etc/hostname", O_RDONLY);
int fd = open("/sys/cfg/hostname", O_RDONLY); /* FIXME: this path should be OS dependent */
if (fd == -1)
return -1;
@ -293,7 +293,12 @@ export ssize_t read(int fildes, void *buf, size_t nbyte)
}
export int readlink(const char *, char *, size_t);
export int rmdir(const char *);
export int rmdir(const char *path)
{
return __check_errno(sysdep(RemoveDirectory)(path), -1);
}
export void *sbrk(intptr_t incr);
export int setgid(gid_t);
export int setpgid(pid_t, pid_t);
@ -334,7 +339,12 @@ export int truncate(const char *, off_t);
export char *ttyname(int);
export int ttyname_r(int, char *, size_t);
export useconds_t ualarm(useconds_t, useconds_t);
export int unlink(const char *);
export int unlink(const char *path)
{
return __check_errno(sysdep(Unlink)(path), -1);
}
export int usleep(useconds_t);
export pid_t vfork(void);

View File

@ -19,6 +19,8 @@
#include <bits/libc.h>
#include <string.h>
extern int printf(const char *restrict format, ...);
void sysdep(Exit)(int Status)
{
call_exit(Status);
@ -209,3 +211,29 @@ int sysdep(FileControl)(int Descriptor, int Command, void *Arg)
{
return call_fcntl(Descriptor, Command, Arg);
}
int sysdep(ClockGetTime)(clockid_t ClockID, struct timespec *TP)
{
return call_clock_gettime(ClockID, TP);
}
time_t sysdep(Time)(void)
{
return call_time(NULL);
}
clock_t sysdep(Clock)()
{
printf("sysdep(Clock): unimplemented\n");
return 0;
}
int sysdep(RemoveDirectory)(const char *Pathname)
{
return call_rmdir(Pathname);
}
int sysdep(Unlink)(const char *Pathname)
{
return call_unlink(Pathname);
}

View File

@ -1,8 +1,16 @@
build:
cp -a $(CURDIR)/include/. $(WORKSPACE_DIR)/out/include
make -C libgcc build
make -C libexample build
MAKE_TARGETS := build clean
DIRECTORIES := $(sort $(filter-out ./include/,$(dir $(wildcard ./*/))))
clean:
make -C libgcc clean
make -C libexample clean
.PHONY: $(MAKE_TARGETS) $(DIRECTORIES) prepare
build: copy_includes $(DIRECTORIES)
clean: $(DIRECTORIES)
copy_includes:
cp -a $(CURDIR)/include/. $(WORKSPACE_DIR)/out/usr/include
prepare:
$(info Nothing to prepare)
$(DIRECTORIES):
$(MAKE) -C $@ $(MAKECMDGOALS)

View File

@ -1,10 +1,10 @@
default:
$(error Do not run this Makefile directly!)
DYNAMIC_NAME := $(notdir $(shell pwd)).so
STATIC_NAME := $(notdir $(shell pwd)).a
DYNAMIC_NAME := lib$(notdir $(shell pwd)).so
STATIC_NAME := lib$(notdir $(shell pwd)).a
OUTPUT_DIR=$(WORKSPACE_DIR)/out/lib/
OUTPUT_DIR=$(WORKSPACE_DIR)/out/usr/lib/
SYSROOT = --sysroot=$(WORKSPACE_DIR)/out/
S_SOURCES = $(shell find ./ -type f -name '*.S')
@ -12,7 +12,7 @@ C_SOURCES = $(shell find ./ -type f -name '*.c')
CXX_SOURCES = $(shell find ./ -type f -name '*.cpp')
OBJ = ${S_SOURCES:.S=.o} ${C_SOURCES:.c=.o} ${CXX_SOURCES:.cpp=.o}
CFLAGS := -fvisibility=hidden -fPIC -I../include -I$(WORKSPACE_DIR)/out/include -DLIBC_GIT_COMMIT='"$(shell git rev-parse HEAD)"'
CFLAGS := -fvisibility=hidden -fPIC -I../include -I$(WORKSPACE_DIR)/out/sys/inc -DLIBC_GIT_COMMIT='"$(shell git rev-parse HEAD)"'
ifeq ($(DEBUG), 1)
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always

View File

@ -1,6 +1,6 @@
NAME=gcc
OBJECT_NAME=lib$(NAME).a
OUTPUT_DIR=$(WORKSPACE_DIR)/out/lib/
OUTPUT_DIR=$(WORKSPACE_DIR)/out/sys/lib/
CRTBEGIN_PATH = $(shell $(CC) -print-file-name=libgcc.a)
build: $(OBJECT_NAME)

View File

View File

View File

View File

View File

View File

@ -86,7 +86,6 @@ __patch_cross_gcc: __clone_gcc
$(info > TOOLS: Running autoconf for gcc/libstdc++-v3)
cd $(GCC_CLONE_PATH)/libstdc++-v3 && autoconf
__patch_cross_qemu: __clone_qemu
$(info > TOOLS: Patching qemu)
cd $(QEMU_CLONE_PATH) && git apply $(CURDIR)/qemu.patch
@ -166,6 +165,10 @@ __do_gcc:
--enable-static-link \
--disable-tls \
--disable-pie \
--enable-libada \
--enable-libgm2 \
--enable-libssp \
--enable-libstdcxx \
&& \
$(MAKE) --quiet all-gcc -j$(shell nproc) && \
$(MAKE) --quiet all-target-libgcc -j$(shell nproc) && \

View File

@ -44,7 +44,7 @@ index 6553aac1..39008568 100644
bpf-*-*)
echo "*** Configuration $targ is not fully supported." >&2
diff --git a/binutils/readelf.c b/binutils/readelf.c
index 5d1cf9c3..2606967f 100644
index 5d1cf9c3..f09b448f 100644
--- a/binutils/readelf.c
+++ b/binutils/readelf.c
@@ -20909,6 +20909,30 @@ get_gnu_elf_note_type (unsigned e_type)
@ -144,8 +144,8 @@ index 5d1cf9c3..2606967f 100644
+
+ case NT_FNX_ARCH:
+ {
+ /* TODO */
+ printf (_(" Unimplemented NT_FNX_ARCH note\n"));
+ /* TODO */
+ printf (_(" Unimplemented NT_FNX_ARCH note\n"));
+ }
+ break;
+
@ -288,10 +288,18 @@ index 6a9833e5..bf4c134d 100644
eelf_x86_64_sol2.c \
ehppa64linux.c \
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 8639e782..24738803 100644
index 8639e782..f82ec216 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -676,6 +676,7 @@ ALL_EMULATION_SOURCES = \
@@ -543,6 +543,7 @@ pdfdir = @pdfdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+runstatedir = @runstatedir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -676,6 +677,7 @@ ALL_EMULATION_SOURCES = \
earcv2elfx.c \
earm_wince_pe.c \
earmelf.c \
@ -299,7 +307,7 @@ index 8639e782..24738803 100644
earmelf_fbsd.c \
earmelf_fuchsia.c \
earmelf_haiku.c \
@@ -790,6 +791,7 @@ ALL_EMULATION_SOURCES = \
@@ -790,6 +792,7 @@ ALL_EMULATION_SOURCES = \
eelf_i386.c \
eelf_i386_be.c \
eelf_i386_fbsd.c \
@ -307,7 +315,7 @@ index 8639e782..24738803 100644
eelf_i386_haiku.c \
eelf_i386_ldso.c \
eelf_i386_sol2.c \
@@ -893,6 +895,7 @@ ALL_64_EMULATION_SOURCES = \
@@ -893,6 +896,7 @@ ALL_64_EMULATION_SOURCES = \
eaarch64elf32.c \
eaarch64elf32b.c \
eaarch64elfb.c \
@ -315,7 +323,7 @@ index 8639e782..24738803 100644
eaarch64fbsd.c \
eaarch64fbsdb.c \
eaarch64haiku.c \
@@ -973,6 +976,7 @@ ALL_64_EMULATION_SOURCES = \
@@ -973,6 +977,7 @@ ALL_64_EMULATION_SOURCES = \
eelf_x86_64.c \
eelf_x86_64_cloudabi.c \
eelf_x86_64_fbsd.c \
@ -323,7 +331,7 @@ index 8639e782..24738803 100644
eelf_x86_64_haiku.c \
eelf_x86_64_sol2.c \
ehppa64linux.c \
@@ -1279,6 +1283,7 @@ distclean-compile:
@@ -1279,6 +1284,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64elfb.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64fbsd.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64fbsdb.Po@am__quote@
@ -331,7 +339,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linux.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linux32.Po@am__quote@
@@ -1301,6 +1306,7 @@ distclean-compile:
@@ -1301,6 +1307,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earm_wince_pe.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fbsd.Po@am__quote@
@ -339,7 +347,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_fuchsia.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_linux.Po@am__quote@
@@ -1480,6 +1486,7 @@ distclean-compile:
@@ -1480,6 +1487,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_be.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_fbsd.Po@am__quote@
@ -347,7 +355,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_haiku.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_ldso.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_i386_sol2.Po@am__quote@
@@ -1490,6 +1497,7 @@ distclean-compile:
@@ -1490,6 +1498,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_cloudabi.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_fbsd.Po@am__quote@
@ -356,7 +364,7 @@ index 8639e782..24738803 100644
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf_x86_64_sol2.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eh8300elf.Po@am__quote@
diff --git a/ld/configure.tgt b/ld/configure.tgt
index f937f78b..3aa8c738 100644
index f937f78b..57858cc8 100644
--- a/ld/configure.tgt
+++ b/ld/configure.tgt
@@ -92,6 +92,9 @@ aarch64-*-elf | aarch64-*-rtems* | aarch64-*-genode*)
@ -407,7 +415,7 @@ index f937f78b..3aa8c738 100644
;;
+*-*-fennix*)
+ NATIVE_LIB_DIRS='/lib /usr/lib'
+ NATIVE_LIB_DIRS='/sys/lib /usr/lib'
+ ;;
+
*-*-freebsd*)

View File

@ -21,25 +21,26 @@ index 38f3d037a..e15a98ae9 100755
# This one is extra strict with allowed versions
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 95c91ee02..cbcaac06b 100644
index 95c91ee02..c887980e0 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -825,6 +825,14 @@ case ${target} in
@@ -825,6 +825,15 @@ case ${target} in
rust_target_objs="${rust_target_objs} dragonfly-rust.o"
target_has_targetrustm=yes
;;
+*-*-fennix*)
+ extra_options="$extra_options gnu-user.opt"
+ tmake_file="t-fennix "
+ gas=yes
+ gnu_ld=yes
+ default_use_cxa_atexit=yes
+ use_gcc_stdint=provide
+ native_system_header_dir=/include
+ native_system_header_dir=/usr/include
+ ;;
*-*-freebsd*)
# This is the generic ELF configuration of FreeBSD. Later
# machine-specific sections may refine and add to this
@@ -1227,6 +1235,16 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
@@ -1227,6 +1236,16 @@ aarch64*-*-elf | aarch64*-*-fuchsia* | aarch64*-*-rtems*)
done
TM_MULTILIB_CONFIG=`echo $TM_MULTILIB_CONFIG | sed 's/^,//'`
;;
@ -56,7 +57,7 @@ index 95c91ee02..cbcaac06b 100644
aarch64*-*-freebsd*)
tm_file="${tm_file} elfos.h ${fbsd_tm_file}"
tm_file="${tm_file} aarch64/aarch64-elf.h aarch64/aarch64-errata.h aarch64/aarch64-freebsd.h"
@@ -1358,6 +1376,30 @@ arm-wrs-vxworks7*)
@@ -1358,6 +1377,30 @@ arm-wrs-vxworks7*)
target_cpu_cname="generic-armv7-a"
need_64bit_hwint=yes
;;
@ -87,7 +88,7 @@ index 95c91ee02..cbcaac06b 100644
arm*-*-freebsd*) # ARM FreeBSD EABI
tm_file="elfos.h ${fbsd_tm_file} arm/elf.h"
case $target in
@@ -1953,6 +1995,14 @@ x86_64-*-dragonfly*)
@@ -1953,6 +1996,14 @@ x86_64-*-dragonfly*)
tm_file="${tm_file} i386/unix.h i386/att.h elfos.h dragonfly.h dragonfly-stdint.h i386/x86-64.h i386/dragonfly.h"
tmake_file="${tmake_file} i386/t-crtstuff"
;;
@ -183,10 +184,10 @@ index 000000000..f93866693
+# <http://www.gnu.org/licenses/>.
diff --git a/gcc/config/fennix.h b/gcc/config/fennix.h
new file mode 100644
index 000000000..4cd35f5a0
index 000000000..136b89d25
--- /dev/null
+++ b/gcc/config/fennix.h
@@ -0,0 +1,77 @@
@@ -0,0 +1,83 @@
+/* Base configuration file for all Fennix targets.
+ Copyright (C) 2016-2024 Free Software Foundation, Inc.
+
@ -235,8 +236,14 @@ index 000000000..4cd35f5a0
+ } \
+ %{static:crtend.o%s}"
+
+#undef STANDARD_STARTFILE_PREFIX
+#define STANDARD_STARTFILE_PREFIX "/lib/"
+// #undef STANDARD_STARTFILE_PREFIX
+// #define STANDARD_STARTFILE_PREFIX "/lib/"
+
+#undef STANDARD_STARTFILE_PREFIX_1
+#define STANDARD_STARTFILE_PREFIX_1 "/sys/lib/"
+
+#undef STANDARD_STARTFILE_PREFIX_2
+#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib/"
+
+#undef LINK_SPEC
+#define LINK_SPEC \
@ -249,7 +256,7 @@ index 000000000..4cd35f5a0
+ } \
+ %{!static: \
+ %{!dynamic-linker: \
+ -dynamic-linker=/lib/ld.so \
+ -dynamic-linker=/sys/lib/ld.so \
+ } \
+ } \
+ -z max-page-size=4096"
@ -342,220 +349,198 @@ index e75a7af64..10d8017b0 100644
tmake_file="${tmake_file} i386/t-freebsd i386/t-crtstuff"
md_unwind_header=i386/freebsd-unwind.h
diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure
index 21abaeb07..8dcc519be 100755
index 21abaeb07..fdafb5656 100755
--- a/libstdc++-v3/configure
+++ b/libstdc++-v3/configure
@@ -38122,6 +38122,3224 @@ done
@@ -893,6 +893,7 @@ infodir
docdir
oldincludedir
includedir
+runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -1027,6 +1028,7 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1279,6 +1281,15 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
;;
+ -runstatedir | --runstatedir | --runstatedi | --runstated \
+ | --runstate | --runstat | --runsta | --runst | --runs \
+ | --run | --ru | --r)
+ ac_prev=runstatedir ;;
+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+ | --run=* | --ru=* | --r=*)
+ runstatedir=$ac_optarg ;;
+
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1416,7 +1427,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir
+ libdir localedir mandir runstatedir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1569,6 +1580,7 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -5080,7 +5092,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -5126,7 +5138,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -5150,7 +5162,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -5195,7 +5207,7 @@ else
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -5219,7 +5231,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
We can't simply define LARGE_OFF_T to be 9223372036854775807,
since some C++ compilers masquerading as C compilers
incorrectly reject 9223372036854775807. */
-#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62))
+#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31))
int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721
&& LARGE_OFF_T % 2147483647 == 1)
? 1 : -1];
@@ -12280,7 +12292,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12283 "configure"
+#line 12295 "configure"
#include "confdefs.h"
+ *-fennix*)
#if HAVE_DLFCN_H
@@ -12386,7 +12398,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12389 "configure"
+#line 12401 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -16182,7 +16194,7 @@ $as_echo "$glibcxx_cv_atomic_long_long" >&6; }
# Fake what AC_TRY_COMPILE does.
cat > conftest.$ac_ext << EOF
-#line 16185 "configure"
+#line 16197 "configure"
int main()
{
typedef bool atomic_type;
@@ -16217,7 +16229,7 @@ $as_echo "$glibcxx_cv_atomic_bool" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16220 "configure"
+#line 16232 "configure"
int main()
{
typedef short atomic_type;
@@ -16252,7 +16264,7 @@ $as_echo "$glibcxx_cv_atomic_short" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16255 "configure"
+#line 16267 "configure"
int main()
{
// NB: _Atomic_word not necessarily int.
@@ -16288,7 +16300,7 @@ $as_echo "$glibcxx_cv_atomic_int" >&6; }
rm -f conftest*
cat > conftest.$ac_ext << EOF
-#line 16291 "configure"
+#line 16303 "configure"
int main()
{
typedef long long atomic_type;
@@ -16444,7 +16456,7 @@ $as_echo "mutex" >&6; }
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16447 "configure"
+#line 16459 "configure"
int main()
{
_Decimal32 d1;
@@ -16486,7 +16498,7 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
# unnecessary for this test.
cat > conftest.$ac_ext << EOF
-#line 16489 "configure"
+#line 16501 "configure"
template<typename T1, typename T2>
struct same
{ typedef T2 type; };
@@ -35067,24 +35079,3268 @@ done
CXXFLAGS="$ac_save_CXXFLAGS"
- $as_echo "#define _GLIBCXX_USE_DEV_RANDOM 1" >>confdefs.h
+ $as_echo "#define _GLIBCXX_USE_DEV_RANDOM 1" >>confdefs.h
+
+ # All these tests are for C++; save the language and the compiler flags.
+ # The CXXFLAGS thing is suspicious, but based on similar bits previously
+ # found in GLIBCXX_CONFIGURE.
+ $as_echo "#define _GLIBCXX_USE_RANDOM_TR1 1" >>confdefs.h
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ ac_save_CXXFLAGS="$CXXFLAGS"
+
+ # Check for -ffunction-sections -fdata-sections
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for g++ that supports -ffunction-sections -fdata-sections" >&5
+$as_echo_n "checking for g++ that supports -ffunction-sections -fdata-sections... " >&6; }
+ CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo; void bar() { };
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_fdsections=yes
+else
+ ac_fdsections=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ else
+ # this is the suspicious part
+ CXXFLAGS=''
+ fi
+ if test x"$ac_fdsections" = x"yes"; then
+ SECTION_FLAGS='-ffunction-sections -fdata-sections'
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_fdsections" >&5
+$as_echo "$ac_fdsections" >&6; }
+
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ # We don't yet support AIX's TLS ABI.
+ #GCC_CHECK_TLS
+
+
+ $as_echo "#define HAVE_USELOCALE 1" >>confdefs.h
+
+ ;;
+
+ # If we're not using GNU ld, then there's no point in even trying these
+ # tests. Check for that first. We should have already tested for gld
+ # by now (in libtool), but require it now just to be safe...
+ test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
+ test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
+
+
+
+ # The name set by libtool depends on the version of libtool. Shame on us
+ # for depending on an impl detail, but c'est la vie. Older versions used
+ # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
+ # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
+ # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
+ # set (hence we're using an older libtool), then set it.
+ if test x${with_gnu_ld+set} != xset; then
+ if test x${ac_cv_prog_gnu_ld+set} != xset; then
+ # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
+ with_gnu_ld=no
+ else
+ with_gnu_ld=$ac_cv_prog_gnu_ld
+ fi
+ fi
+
+ # Start by getting the version number. I think the libtool test already
+ # does some of this, but throws away the result.
+ glibcxx_ld_is_gold=no
+ glibcxx_ld_is_mold=no
+ if test x"$with_gnu_ld" = x"yes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
+$as_echo_n "checking for ld version... " >&6; }
+
+ if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
+ glibcxx_ld_is_gold=yes
+ elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+ glibcxx_ld_is_mold=yes
+ fi
+ ldver=`$LD --version 2>/dev/null |
+ sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
+
+ glibcxx_gnu_ld_version=`echo $ldver | \
+ $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_gnu_ld_version" >&5
+$as_echo "$glibcxx_gnu_ld_version" >&6; }
+ fi
+
+ # Set --gc-sections.
+ glibcxx_have_gc_sections=no
+ if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
+ if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
+ glibcxx_have_gc_sections=yes
+ fi
+ else
+ glibcxx_gcsections_min_ld=21602
+ if test x"$with_gnu_ld" = x"yes" &&
+ test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
+ glibcxx_have_gc_sections=yes
+ fi
+ fi
+ if test "$glibcxx_have_gc_sections" = "yes"; then
+ # Sufficiently young GNU ld it is! Joy and bunny rabbits!
+ # NB: This flag only works reliably after 2.16.1. Configure tests
+ # for this are difficult, so hard wire a value that should work.
+
+ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS='-Wl,--gc-sections'
+
+ # Check for -Wl,--gc-sections
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,--gc-sections" >&5
+$as_echo_n "checking for ld that supports -Wl,--gc-sections... " >&6; }
+ if test x$gcc_no_link = xyes; then
+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+ int one(void) { return 1; }
+ int two(void) { return 2; }
+
+int
+main ()
+{
+ two();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_gcsections=yes
+else
+ ac_gcsections=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test "$ac_gcsections" = "yes"; then
+ rm -f conftest.c
+ touch conftest.c
+ if $CC -c conftest.c; then
+ if $LD --gc-sections -o conftest conftest.o 2>&1 | \
+ grep "Warning: gc-sections option ignored" > /dev/null; then
+ ac_gcsections=no
+ fi
+ fi
+ rm -f conftest.c conftest.o conftest
+ fi
+ if test "$ac_gcsections" = "yes"; then
+ SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_gcsections" >&5
+$as_echo "$ac_gcsections" >&6; }
+
+ if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+ else
+ # this is the suspicious part
+ CFLAGS=''
+ fi
+ fi
+
+ # Set -z,relro.
+ # Note this is only for shared objects.
+ ac_ld_relro=no
+ if test x"$with_gnu_ld" = x"yes"; then
+ # cygwin and mingw uses PE, which has no ELF relro support,
+ # multi target ld may confuse configure machinery
+ case "$host" in
+ *-*-cygwin*)
+ ;;
+ *-*-mingw*)
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,-z,relro" >&5
+$as_echo_n "checking for ld that supports -Wl,-z,relro... " >&6; }
+ cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
+ if test -n "$cxx_z_relo"; then
+ OPT_LDFLAGS="-Wl,-z,relro"
+ ac_ld_relro=yes
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ld_relro" >&5
+$as_echo "$ac_ld_relro" >&6; }
+ esac
+ fi
+
+ # Set linker optimization flags.
+ if test x"$with_gnu_ld" = x"yes"; then
+ OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
+ fi
+
+
+
+ *-darwin*)
+ # Darwin versions vary, but the linker should work in a cross environment,
+ # so we just check for all the features here.
+ # Check for available headers.
+
+ # Don't call GLIBCXX_CHECK_LINKER_FEATURES, Darwin doesn't have a GNU ld
+
+ ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ ac_save_CXXFLAGS="$CXXFLAGS"
@ -3565,11 +3550,286 @@ index 21abaeb07..8dcc519be 100755
+
+ CXXFLAGS="$ac_save_CXXFLAGS"
+
+ ;;
+
*-freebsd*)
SECTION_FLAGS='-ffunction-sections -fdata-sections'
- $as_echo "#define _GLIBCXX_USE_RANDOM_TR1 1" >>confdefs.h
+ for ac_func in uselocale
+do :
+ ac_fn_c_check_func "$LINENO" "uselocale" "ac_cv_func_uselocale"
+if test "x$ac_cv_func_uselocale" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_USELOCALE 1
+_ACEOF
- # We don't yet support AIX's TLS ABI.
- #GCC_CHECK_TLS
+fi
+done
+ ;;
- $as_echo "#define HAVE_USELOCALE 1" >>confdefs.h
+ *djgpp)
+ # GLIBCXX_CHECK_MATH_SUPPORT
+ $as_echo "#define HAVE_ISINF 1" >>confdefs.h
+
+ $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
+
+ $as_echo "#define HAVE_FINITE 1" >>confdefs.h
+
+ $as_echo "#define HAVE_SINCOS 1" >>confdefs.h
+
+ $as_echo "#define HAVE_HYPOT 1" >>confdefs.h
;;
- *-darwin*)
- # Darwin versions vary, but the linker should work in a cross environment,
- # so we just check for all the features here.
- # Check for available headers.
+ *-fennix*)
+
+ # All these tests are for C++; save the language and the compiler flags.
+ # The CXXFLAGS thing is suspicious, but based on similar bits previously
+ # found in GLIBCXX_CONFIGURE.
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ ac_test_CXXFLAGS="${CXXFLAGS+set}"
+ ac_save_CXXFLAGS="$CXXFLAGS"
+
+ # Check for -ffunction-sections -fdata-sections
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for g++ that supports -ffunction-sections -fdata-sections" >&5
+$as_echo_n "checking for g++ that supports -ffunction-sections -fdata-sections... " >&6; }
+ CXXFLAGS='-g -Werror -ffunction-sections -fdata-sections'
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo; void bar() { };
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_fdsections=yes
+else
+ ac_fdsections=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS="$ac_save_CXXFLAGS"
+ else
+ # this is the suspicious part
+ CXXFLAGS=''
+ fi
+ if test x"$ac_fdsections" = x"yes"; then
+ SECTION_FLAGS='-ffunction-sections -fdata-sections'
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_fdsections" >&5
+$as_echo "$ac_fdsections" >&6; }
+
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+ # If we're not using GNU ld, then there's no point in even trying these
+ # tests. Check for that first. We should have already tested for gld
+ # by now (in libtool), but require it now just to be safe...
+ test -z "$SECTION_LDFLAGS" && SECTION_LDFLAGS=''
+ test -z "$OPT_LDFLAGS" && OPT_LDFLAGS=''
+
+
+
+ # The name set by libtool depends on the version of libtool. Shame on us
+ # for depending on an impl detail, but c'est la vie. Older versions used
+ # ac_cv_prog_gnu_ld, but now it's lt_cv_prog_gnu_ld, and is copied back on
+ # top of with_gnu_ld (which is also set by --with-gnu-ld, so that actually
+ # makes sense). We'll test with_gnu_ld everywhere else, so if that isn't
+ # set (hence we're using an older libtool), then set it.
+ if test x${with_gnu_ld+set} != xset; then
+ if test x${ac_cv_prog_gnu_ld+set} != xset; then
+ # We got through "ac_require(ac_prog_ld)" and still not set? Huh?
+ with_gnu_ld=no
+ else
+ with_gnu_ld=$ac_cv_prog_gnu_ld
+ fi
+ fi
+
+ # Start by getting the version number. I think the libtool test already
+ # does some of this, but throws away the result.
+ glibcxx_ld_is_gold=no
+ glibcxx_ld_is_mold=no
+ if test x"$with_gnu_ld" = x"yes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld version" >&5
+$as_echo_n "checking for ld version... " >&6; }
+
+ if $LD --version 2>/dev/null | grep 'GNU gold' >/dev/null 2>&1; then
+ glibcxx_ld_is_gold=yes
+ elif $LD --version 2>/dev/null | grep 'mold' >/dev/null 2>&1; then
+ glibcxx_ld_is_mold=yes
+ fi
+ ldver=`$LD --version 2>/dev/null |
+ sed -e 's/[. ][0-9]\{8\}$//;s/.* \([^ ]\{1,\}\)$/\1/; q'`
+
+ glibcxx_gnu_ld_version=`echo $ldver | \
+ $AWK -F. '{ if (NF<3) $3=0; print ($1*100+$2)*100+$3 }'`
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $glibcxx_gnu_ld_version" >&5
+$as_echo "$glibcxx_gnu_ld_version" >&6; }
+ fi
+
+ # Set --gc-sections.
+ glibcxx_have_gc_sections=no
+ if test "$glibcxx_ld_is_gold" = "yes" || test "$glibcxx_ld_is_mold" = "yes" ; then
+ if $LD --help 2>/dev/null | grep gc-sections >/dev/null 2>&1; then
+ glibcxx_have_gc_sections=yes
+ fi
+ else
+ glibcxx_gcsections_min_ld=21602
+ if test x"$with_gnu_ld" = x"yes" &&
+ test $glibcxx_gnu_ld_version -gt $glibcxx_gcsections_min_ld ; then
+ glibcxx_have_gc_sections=yes
+ fi
+ fi
+ if test "$glibcxx_have_gc_sections" = "yes"; then
+ # Sufficiently young GNU ld it is! Joy and bunny rabbits!
+ # NB: This flag only works reliably after 2.16.1. Configure tests
+ # for this are difficult, so hard wire a value that should work.
+
+ ac_test_CFLAGS="${CFLAGS+set}"
+ ac_save_CFLAGS="$CFLAGS"
+ CFLAGS='-Wl,--gc-sections'
+
+ # Check for -Wl,--gc-sections
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,--gc-sections" >&5
+$as_echo_n "checking for ld that supports -Wl,--gc-sections... " >&6; }
+ if test x$gcc_no_link = xyes; then
+ as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+ int one(void) { return 1; }
+ int two(void) { return 2; }
+
+int
+main ()
+{
+ two();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_gcsections=yes
+else
+ ac_gcsections=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ if test "$ac_gcsections" = "yes"; then
+ rm -f conftest.c
+ touch conftest.c
+ if $CC -c conftest.c; then
+ if $LD --gc-sections -o conftest conftest.o 2>&1 | \
+ grep "Warning: gc-sections option ignored" > /dev/null; then
+ ac_gcsections=no
+ fi
+ fi
+ rm -f conftest.c conftest.o conftest
+ fi
+ if test "$ac_gcsections" = "yes"; then
+ SECTION_LDFLAGS="-Wl,--gc-sections $SECTION_LDFLAGS"
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_gcsections" >&5
+$as_echo "$ac_gcsections" >&6; }
+
+ if test "$ac_test_CFLAGS" = set; then
+ CFLAGS="$ac_save_CFLAGS"
+ else
+ # this is the suspicious part
+ CFLAGS=''
+ fi
+ fi
+
+ # Set -z,relro.
+ # Note this is only for shared objects.
+ ac_ld_relro=no
+ if test x"$with_gnu_ld" = x"yes"; then
+ # cygwin and mingw uses PE, which has no ELF relro support,
+ # multi target ld may confuse configure machinery
+ case "$host" in
+ *-*-cygwin*)
+ ;;
+ *-*-mingw*)
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld that supports -Wl,-z,relro" >&5
+$as_echo_n "checking for ld that supports -Wl,-z,relro... " >&6; }
+ cxx_z_relo=`$LD -v --help 2>/dev/null | grep "z relro"`
+ if test -n "$cxx_z_relo"; then
+ OPT_LDFLAGS="-Wl,-z,relro"
+ ac_ld_relro=yes
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ld_relro" >&5
+$as_echo "$ac_ld_relro" >&6; }
+ esac
+ fi
+
+ # Set linker optimization flags.
+ if test x"$with_gnu_ld" = x"yes"; then
+ OPT_LDFLAGS="-Wl,-O1 $OPT_LDFLAGS"
+ fi
+
+
+
- # Don't call GLIBCXX_CHECK_LINKER_FEATURES, Darwin doesn't have a GNU ld
ac_test_CXXFLAGS="${CXXFLAGS+set}"
ac_save_CXXFLAGS="$CXXFLAGS"
@@ -38094,32 +41350,6 @@ done
CXXFLAGS="$ac_save_CXXFLAGS"
-
- for ac_func in uselocale
-do :
- ac_fn_c_check_func "$LINENO" "uselocale" "ac_cv_func_uselocale"
-if test "x$ac_cv_func_uselocale" = xyes; then :
- cat >>confdefs.h <<_ACEOF
-#define HAVE_USELOCALE 1
-_ACEOF
-
-fi
-done
-
- ;;
-
- *djgpp)
- # GLIBCXX_CHECK_MATH_SUPPORT
- $as_echo "#define HAVE_ISINF 1" >>confdefs.h
-
- $as_echo "#define HAVE_ISNAN 1" >>confdefs.h
-
- $as_echo "#define HAVE_FINITE 1" >>confdefs.h
-
- $as_echo "#define HAVE_SINCOS 1" >>confdefs.h
-
- $as_echo "#define HAVE_HYPOT 1" >>confdefs.h
-
;;
*-freebsd*)
diff --git a/libstdc++-v3/crossconfig.m4 b/libstdc++-v3/crossconfig.m4
index b3269cb88..de1f886b9 100644
--- a/libstdc++-v3/crossconfig.m4

View File

@ -7,9 +7,9 @@ menuentry "Fennix" {
load_video
clear
echo "Loading kernel"
multiboot2 /fennix.elf --ioapicirq=1 --udl=true --simd=true --init=/bin/init
echo "Loading initrd"
module2 /initrd.tar initrd
multiboot2 /fennix.elf --init=/sys/bin/init
echo "Loading rootfs"
module2 /rootfs.tar rootfs
echo "Booting..."
boot
}

View File

@ -1,12 +1,12 @@
TIMEOUT=1
TIMEOUT=5
INTERFACE_BRANDING=Fennix
:Fennix (limine)
# DO NOT EDIT!
COMMENT=Boot Fennix using limine protocol
PROTOCOL=limine
KERNEL_CMDLINE=--ioapicirq=1 --udl=true --simd=true
KERNEL_CMDLINE=--init=/sys/bin/init
KERNEL_PATH=boot:///fennix.elf
MODULE_PATH=boot:///initrd.tar
MODULE_CMDLINE=initrd
MODULE_PATH=boot:///rootfs.tar
MODULE_CMDLINE=rootfs

View File

@ -1,2 +1,2 @@
CMDLINE=debug
INITRD=initrd.tar
CMDLINE=--init=/sys/bin/init
INITRD=rootfs.tar