Implement enough runtime for binutils to compile
This commit is contained in:
parent
497a52dd82
commit
534500cda0
@ -126,7 +126,7 @@ void InitRD::for_each(void (*callback)(File& f))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#define INITRD_MAX_FILES_IN_DIR 16
|
#define INITRD_MAX_FILES_IN_DIR 32
|
||||||
#define INITRD_MAX_FILES 64
|
#define INITRD_MAX_FILES 64
|
||||||
|
|
||||||
namespace InitRD
|
namespace InitRD
|
||||||
@ -378,7 +378,7 @@ static bool initrd_register_file(InitRD::File& f, uint64_t inode)
|
|||||||
static void initrd_scan()
|
static void initrd_scan()
|
||||||
{
|
{
|
||||||
initrd_for_each_dir([](InitRD::Directory& dir) {
|
initrd_for_each_dir([](InitRD::Directory& dir) {
|
||||||
if (total_dirs >= 32)
|
if (total_dirs >= INITRD_MAX_FILES)
|
||||||
{
|
{
|
||||||
kwarnln("Failed to register directory %s: Too many directories in initrd", dir.name);
|
kwarnln("Failed to register directory %s: Too many directories in initrd", dir.name);
|
||||||
return;
|
return;
|
||||||
@ -387,7 +387,7 @@ static void initrd_scan()
|
|||||||
if (initrd_register_dir(dir, inode)) dirs[total_dirs++] = dir;
|
if (initrd_register_dir(dir, inode)) dirs[total_dirs++] = dir;
|
||||||
});
|
});
|
||||||
InitRD::for_each([](InitRD::File& f) {
|
InitRD::for_each([](InitRD::File& f) {
|
||||||
if (total_files >= 32)
|
if (total_files >= INITRD_MAX_FILES)
|
||||||
{
|
{
|
||||||
kwarnln("Failed to register file %s: Too many files in initrd", f.name);
|
kwarnln("Failed to register file %s: Too many files in initrd", f.name);
|
||||||
return;
|
return;
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef _LOCALE_H
|
||||||
|
#define _LOCALE_H
|
||||||
|
|
||||||
|
#define LC_ALL 0
|
||||||
|
#define LC_CTYPE 1
|
||||||
|
#define LC_COLLATE 2
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
char* setlocale(int category, const char* locale); // Not implemented.
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
0
libs/libc/include/memory.h
Normal file
0
libs/libc/include/memory.h
Normal file
@ -48,6 +48,9 @@ extern "C"
|
|||||||
/* Registers a handler function to be run at normal program termination. */
|
/* Registers a handler function to be run at normal program termination. */
|
||||||
int atexit(void (*handler)(void));
|
int atexit(void (*handler)(void));
|
||||||
|
|
||||||
|
/* Returns a floating point number parsed from the string str. */
|
||||||
|
float atof(const char* str);
|
||||||
|
|
||||||
/* Returns an integer (of type int) parsed from the string str. */
|
/* Returns an integer (of type int) parsed from the string str. */
|
||||||
int atoi(const char* str);
|
int atoi(const char* str);
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@ extern "C"
|
|||||||
mode_t umask(mode_t cmask);
|
mode_t umask(mode_t cmask);
|
||||||
|
|
||||||
int chmod(const char* pathname, mode_t mode); // Not implemented.
|
int chmod(const char* pathname, mode_t mode); // Not implemented.
|
||||||
|
int fchmod(int fd, mode_t mode); // Not implemented.
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,9 @@ extern "C"
|
|||||||
char* getcwd(char* buf, size_t size);
|
char* getcwd(char* buf, size_t size);
|
||||||
|
|
||||||
int unlink(const char* path); // Not implemented.
|
int unlink(const char* path); // Not implemented.
|
||||||
|
int rmdir(const char* path); // Not implemented.
|
||||||
|
int chdir(const char* path); // Not implemented.
|
||||||
|
int pipe(int fd[2]); // Not implemented.
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
23
libs/libc/include/utime.h
Normal file
23
libs/libc/include/utime.h
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
#ifndef _UTIME_H
|
||||||
|
#define _UTIME_H
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
struct utimbuf
|
||||||
|
{
|
||||||
|
time_t actime;
|
||||||
|
time_t modtime;
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int utime(const char*, const struct utimbuf*); // Not implemented.
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -4,6 +4,8 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
char** environ = {nullptr};
|
||||||
|
|
||||||
static void terminate_libc()
|
static void terminate_libc()
|
||||||
{
|
{
|
||||||
fclose(stdout);
|
fclose(stdout);
|
||||||
|
12
libs/libc/src/locale.cpp
Normal file
12
libs/libc/src/locale.cpp
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <locale.h>
|
||||||
|
#include <luna.h>
|
||||||
|
|
||||||
|
static char default_locale[] = "C";
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
char* setlocale(int, const char*)
|
||||||
|
{
|
||||||
|
return default_locale;
|
||||||
|
}
|
||||||
|
}
|
@ -26,6 +26,40 @@ template <typename T> static T string_to_integer_type(const char* str)
|
|||||||
return (neg ? -val : val);
|
return (neg ? -val : val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T> static T string_to_float_type(const char* str)
|
||||||
|
{
|
||||||
|
bool neg = false;
|
||||||
|
T val = 0;
|
||||||
|
|
||||||
|
T small = 0;
|
||||||
|
|
||||||
|
switch (*str)
|
||||||
|
{
|
||||||
|
case '-':
|
||||||
|
neg = true;
|
||||||
|
str++;
|
||||||
|
break;
|
||||||
|
case '+': str++; break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (isdigit(*str)) { val = (10 * val) + (T)(*str++ - '0'); }
|
||||||
|
if (*str == '.')
|
||||||
|
{
|
||||||
|
str++;
|
||||||
|
T div = 10;
|
||||||
|
while (isdigit(*str))
|
||||||
|
{
|
||||||
|
small = small + (T)(*str++ - '0') / div;
|
||||||
|
div *= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
val += small;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (neg ? -val : val);
|
||||||
|
}
|
||||||
|
|
||||||
template <typename Arg, typename Struct> static inline Struct common_div(Arg a, Arg b)
|
template <typename Arg, typename Struct> static inline Struct common_div(Arg a, Arg b)
|
||||||
{
|
{
|
||||||
Struct result;
|
Struct result;
|
||||||
@ -48,6 +82,11 @@ extern "C"
|
|||||||
_Exit(-1);
|
_Exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float atof(const char* str)
|
||||||
|
{
|
||||||
|
return string_to_float_type<float>(str);
|
||||||
|
}
|
||||||
|
|
||||||
int atoi(const char* str)
|
int atoi(const char* str)
|
||||||
{
|
{
|
||||||
return string_to_integer_type<int>(str);
|
return string_to_integer_type<int>(str);
|
||||||
|
@ -29,4 +29,9 @@ extern "C"
|
|||||||
{
|
{
|
||||||
NOT_IMPLEMENTED("chmod");
|
NOT_IMPLEMENTED("chmod");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int fchmod(int, mode_t)
|
||||||
|
{
|
||||||
|
NOT_IMPLEMENTED("fchmod");
|
||||||
|
}
|
||||||
}
|
}
|
@ -148,4 +148,19 @@ extern "C"
|
|||||||
{
|
{
|
||||||
NOT_IMPLEMENTED("unlink");
|
NOT_IMPLEMENTED("unlink");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int rmdir(const char*)
|
||||||
|
{
|
||||||
|
NOT_IMPLEMENTED("rmdir");
|
||||||
|
}
|
||||||
|
|
||||||
|
int chdir(const char*)
|
||||||
|
{
|
||||||
|
NOT_IMPLEMENTED("chdir");
|
||||||
|
}
|
||||||
|
|
||||||
|
int pipe(int[2])
|
||||||
|
{
|
||||||
|
NOT_IMPLEMENTED("pipe");
|
||||||
|
}
|
||||||
}
|
}
|
10
libs/libc/src/utime.cpp
Normal file
10
libs/libc/src/utime.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <luna.h>
|
||||||
|
#include <utime.h>
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
int utime(const char*, const struct utimbuf*)
|
||||||
|
{
|
||||||
|
NOT_IMPLEMENTED("utime");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user