mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-07-02 02:49:15 +00:00
Merge remote-tracking branch 'Kernel/master'
This commit is contained in:
28
Kernel/library/c/ctype.c
Normal file
28
Kernel/library/c/ctype.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel 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 Kernel 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 Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
int tolower(int c)
|
||||
{
|
||||
return _tolower(c);
|
||||
}
|
||||
|
||||
int toupper(int c)
|
||||
{
|
||||
return _toupper(c);
|
||||
}
|
100
Kernel/library/c/stdio.cpp
Normal file
100
Kernel/library/c/stdio.cpp
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel 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 Kernel 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 Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <debug.h>
|
||||
|
||||
FILE __local_stdin = {.st = 0};
|
||||
FILE __local_stdout = {.st = 1};
|
||||
FILE __local_stderr = {.st = 2};
|
||||
|
||||
FILE *stdin = &__local_stdin;
|
||||
FILE *stdout = &__local_stdout;
|
||||
FILE *stderr = &__local_stderr;
|
||||
|
||||
EXTERNC int asprintf(char **strp, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = vasprintf(strp, fmt, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define va_copy(dest, src) __builtin_va_copy(dest, src)
|
||||
|
||||
EXTERNC int vasprintf(char **strp, const char *fmt, va_list ap)
|
||||
{
|
||||
va_list ap2;
|
||||
va_copy(ap2, ap);
|
||||
int len = vsnprintf(NULL, 0, fmt, ap2);
|
||||
va_end(ap2);
|
||||
if (len < 0)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
*strp = (char *)malloc(len + 1);
|
||||
if (!*strp)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
int ret = vsnprintf(*strp, len + 1, fmt, ap);
|
||||
if (ret < 0)
|
||||
{
|
||||
free(*strp);
|
||||
*strp = NULL;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fprintf(FILE *stream, const char *format, ...)
|
||||
{
|
||||
switch (stream->st)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
error("fprintf() called with stdin");
|
||||
return -1;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
int ret = vprintf(format, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
int ret = vprintf(format, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
int fputs(const char *s, FILE *stream)
|
||||
{
|
||||
for (const char *c = s; *c; c++)
|
||||
uart_wrapper(*c, NULL);
|
||||
return 0;
|
||||
}
|
27
Kernel/library/c/stdlib.cpp
Normal file
27
Kernel/library/c/stdlib.cpp
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
This file is part of Fennix Kernel.
|
||||
|
||||
Fennix Kernel 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 Kernel 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 Kernel. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <debug.h>
|
||||
#include <cpu.hpp>
|
||||
|
||||
EXTERNC void abort()
|
||||
{
|
||||
error("abort() called");
|
||||
CPU::Stop();
|
||||
__builtin_unreachable();
|
||||
}
|
Reference in New Issue
Block a user