mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-08-25 21:05:03 +00:00
Update userspace
This commit is contained in:
@@ -27,7 +27,7 @@ else ifeq ($(OSARCH), i386)
|
||||
ASM_ARCH := elf32
|
||||
endif
|
||||
|
||||
CFLAGS := -fvisibility=hidden -fPIC -I../include -I../../out/usr/include
|
||||
CFLAGS := -fvisibility=hidden -fPIC -I../include -I../../out/include
|
||||
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -DDEBUG -ggdb3 -O0 -fdiagnostics-color=always -fverbose-asm
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#include <sys/syscalls.h>
|
||||
#include <fennix/syscall.h>
|
||||
#include <sys/types.h> // For PUBLIC
|
||||
|
||||
extern void __libc_init_array(void);
|
||||
@@ -17,7 +17,7 @@ PUBLIC void _exit(int Code)
|
||||
{
|
||||
__libc_fini_std();
|
||||
__libc_fini_array();
|
||||
syscall1(_Exit, (long)Code);
|
||||
syscall1(sys_Exit, (long)Code);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
@@ -17,10 +17,10 @@ extern "C" int liballoc_unlock()
|
||||
|
||||
extern "C" void *liballoc_alloc(size_t Pages)
|
||||
{
|
||||
return (void *)syscall1(_RequestPages, Pages);
|
||||
return (void *)syscall1(sys_RequestPages, Pages);
|
||||
}
|
||||
|
||||
extern "C" int liballoc_free(void *Address, size_t Pages)
|
||||
{
|
||||
return syscall2(_FreePages, (uint64_t)Address, Pages);
|
||||
return syscall2(sys_FreePages, (uint64_t)Address, Pages);
|
||||
}
|
||||
|
11
libc/src/setjmp.c
Normal file
11
libc/src/setjmp.c
Normal file
@@ -0,0 +1,11 @@
|
||||
#include <setjmp.h>
|
||||
|
||||
PUBLIC int setjmp(jmp_buf env)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PUBLIC __attribute__((noreturn)) void longjmp(jmp_buf env, int value)
|
||||
{
|
||||
_exit(value);
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/syscalls.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <fennix/syscall.h>
|
||||
#include <sys/types.h> // For PUBLIC
|
||||
|
||||
PUBLIC FILE *stdin = NULL;
|
||||
@@ -12,12 +12,12 @@ PUBLIC FILE *stderr = NULL;
|
||||
|
||||
PUBLIC FILE *fopen(const char *filename, const char *mode)
|
||||
{
|
||||
void *KPrivate = (void *)syscall2(_FileOpen, (uint64_t)filename, (uint64_t)mode);
|
||||
if (IsSyscallError(KPrivate))
|
||||
int fd = syscall2(sys_FileOpen, (uint64_t)filename, (uint64_t)mode);
|
||||
if (fd < 0)
|
||||
return NULL;
|
||||
|
||||
FILE *FilePtr = malloc(sizeof(FILE));
|
||||
FilePtr->KernelPrivate = KPrivate;
|
||||
FilePtr->_fileno = fd;
|
||||
return FilePtr;
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ PUBLIC size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
return 0;
|
||||
}
|
||||
|
||||
syscall3(_FileSeek, stream->KernelPrivate, stream->_offset, SEEK_SET);
|
||||
return syscall3(_FileRead, (uint64_t)stream->KernelPrivate, (uint64_t)ptr, size * nmemb);
|
||||
syscall3(sys_FileSeek, stream->_fileno, stream->_offset, SEEK_SET);
|
||||
return syscall3(sys_FileRead, (uint64_t)stream->_fileno, (uint64_t)ptr, size * nmemb);
|
||||
}
|
||||
|
||||
PUBLIC size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
@@ -41,8 +41,8 @@ PUBLIC size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
return 0;
|
||||
}
|
||||
|
||||
syscall3(_FileSeek, stream->KernelPrivate, stream->_offset, SEEK_SET);
|
||||
return syscall3(_FileWrite, (uint64_t)stream->KernelPrivate, (uint64_t)ptr, size * nmemb);
|
||||
syscall3(sys_FileSeek, stream->_fileno, stream->_offset, SEEK_SET);
|
||||
return syscall3(sys_FileWrite, (uint64_t)stream->_fileno, (uint64_t)ptr, size * nmemb);
|
||||
}
|
||||
|
||||
PUBLIC int fclose(FILE *fp)
|
||||
@@ -53,9 +53,7 @@ PUBLIC int fclose(FILE *fp)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
void *KP = fp->KernelPrivate;
|
||||
free(fp);
|
||||
return syscall1(_FileClose, (uint64_t)KP);
|
||||
return syscall1(sys_FileClose, fp->_fileno);
|
||||
}
|
||||
|
||||
PUBLIC off_t fseek(FILE *stream, off_t offset, int whence)
|
||||
@@ -66,8 +64,8 @@ PUBLIC off_t fseek(FILE *stream, off_t offset, int whence)
|
||||
return -1;
|
||||
}
|
||||
|
||||
off_t new_offset = syscall3(_FileSeek, stream->KernelPrivate, offset, whence);
|
||||
if (IsSyscallError(new_offset))
|
||||
off_t new_offset = syscall3(sys_FileSeek, stream->_fileno, offset, whence);
|
||||
if (new_offset < 0)
|
||||
return -1;
|
||||
stream->_offset = new_offset;
|
||||
return new_offset;
|
||||
|
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/syscalls.h>
|
||||
#include <fennix/syscall.h>
|
||||
|
||||
#include <sys/types.h> // For PUBLIC
|
||||
|
||||
@@ -12,8 +12,8 @@ PUBLIC int fputc(int c, FILE *stream)
|
||||
// errno = EBADF;
|
||||
// return EOF;
|
||||
// }
|
||||
|
||||
return syscall2(_Print, c, 0);
|
||||
char str[2] = {c, '\0'};
|
||||
return syscall3(sys_KernelCTL, KCTL_PRINT, str, 0);
|
||||
}
|
||||
|
||||
PUBLIC int putc(int c, FILE *stream) { return fputc(c, stream); }
|
||||
|
@@ -2,13 +2,13 @@
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sys/syscalls.h>
|
||||
#include <fennix/syscall.h>
|
||||
|
||||
#include "../mem/liballoc_1_1.h"
|
||||
|
||||
PUBLIC void abort(void)
|
||||
{
|
||||
syscall1(_Exit, -0xAB057);
|
||||
syscall1(sys_Exit, -0xAB057);
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
@@ -47,5 +47,5 @@ PUBLIC int execve(const char *pathname, char *const argv[], char *const envp[])
|
||||
|
||||
PUBLIC pid_t fork(void)
|
||||
{
|
||||
return syscall0(_Fork);
|
||||
return syscall0(sys_Fork);
|
||||
}
|
||||
|
@@ -3,12 +3,12 @@
|
||||
#include <errno.h>
|
||||
#include "../../../Kernel/syscalls.h"
|
||||
|
||||
unsigned int sleep(unsigned int seconds)
|
||||
PUBLIC unsigned int sleep(unsigned int seconds)
|
||||
{
|
||||
return syscall1(_Sleep, seconds * 1000000);
|
||||
return syscall1(sys_Sleep, seconds * 1000000);
|
||||
}
|
||||
|
||||
int usleep(useconds_t usec)
|
||||
PUBLIC int usleep(useconds_t usec)
|
||||
{
|
||||
return syscall1(_Sleep, usec);
|
||||
return syscall1(sys_Sleep, usec);
|
||||
}
|
||||
|
Reference in New Issue
Block a user