mirror of
https://github.com/Fennix-Project/Userspace.git
synced 2025-08-26 05:15:01 +00:00
Updated libc
This commit is contained in:
70
libc/src/std/io.c
Normal file
70
libc/src/std/io.c
Normal file
@@ -0,0 +1,70 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
FILE *stdin;
|
||||
FILE *stdout;
|
||||
FILE *stderr;
|
||||
|
||||
int fclose(FILE *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fflush(FILE *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
FILE *fopen(const char *filename, const char *mode)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
return 0; // sprintf(char *s, const char *format, ...)
|
||||
}
|
||||
|
||||
// int printf(const char *format, ...)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fseek(FILE *stream, long offset, int whence)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
long ftell(FILE *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setbuf(FILE *stream, char *buf)
|
||||
{
|
||||
}
|
||||
|
||||
// int vfprintf(FILE *stream, const char *format, va_list arg)
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int puts(const char *s)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int putchar(int c)
|
||||
{
|
||||
return 0;
|
||||
}
|
53
libc/src/std/lib.c
Normal file
53
libc/src/std/lib.c
Normal file
@@ -0,0 +1,53 @@
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "../mem/liballoc_1_1.h"
|
||||
|
||||
void abort(void)
|
||||
{
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
int atexit(void (*function)(void))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void exit(int status)
|
||||
{
|
||||
while (1)
|
||||
;
|
||||
}
|
||||
|
||||
int atoi(const char *nptr)
|
||||
{
|
||||
// uint64_t Length = strlen((char *)nptr);
|
||||
uint64_t Length = 0;
|
||||
if (nptr)
|
||||
while (nptr[Length] != '\0')
|
||||
++Length;
|
||||
uint64_t OutBuffer = 0;
|
||||
uint64_t Power = 1;
|
||||
for (uint64_t i = Length; i > 0; --i)
|
||||
{
|
||||
OutBuffer += (nptr[i - 1] - 48) * Power;
|
||||
Power *= 10;
|
||||
}
|
||||
return OutBuffer;
|
||||
}
|
||||
|
||||
char *getenv(const char *name)
|
||||
{
|
||||
static char *env = "PATH=/bin";
|
||||
return env;
|
||||
}
|
||||
|
||||
void *malloc(size_t Size) { return PREFIX(malloc)(Size); }
|
||||
void *realloc(void *Address, size_t Size) { return PREFIX(realloc)(Address, Size); }
|
||||
void *calloc(size_t Count, size_t Size) { return PREFIX(calloc)(Count, Size); }
|
||||
void free(void *Address)
|
||||
{
|
||||
PREFIX(free)
|
||||
(Address);
|
||||
}
|
Reference in New Issue
Block a user