mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 11:09:05 +03:00
LibC: Implement enough missing stuff to get bash-5.0 running. :^)
This commit is contained in:
parent
5158bee08c
commit
736e852525
Notes:
sideshowbarker
2024-07-19 15:49:53 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/736e8525259
@ -1678,7 +1678,6 @@ bool Process::validate_write(void* address, size_t size) const
|
||||
if (check_kernel_memory_access(LinearAddress((dword)address), true))
|
||||
return true;
|
||||
}
|
||||
ASSERT(size);
|
||||
if (!size)
|
||||
return false;
|
||||
LinearAddress first_address((dword)address);
|
||||
|
2
Launcher/.gitignore
vendored
2
Launcher/.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
*.o
|
||||
*.d
|
||||
FontEditor
|
||||
Launcher
|
||||
|
Binary file not shown.
@ -44,6 +44,7 @@ LIBC_OBJS = \
|
||||
gui.o \
|
||||
sys/select.o \
|
||||
poll.o \
|
||||
locale.o \
|
||||
entry.o
|
||||
|
||||
ASM_OBJS = setjmp.no
|
||||
|
25
LibC/fcntl.h
25
LibC/fcntl.h
@ -25,6 +25,31 @@ __BEGIN_DECLS
|
||||
#define O_NOFOLLOW 00400000
|
||||
#define O_CLOEXEC 02000000
|
||||
|
||||
#define S_IFMT 0170000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFREG 0100000
|
||||
#define S_IFIFO 0010000
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFSOCK 0140000
|
||||
|
||||
#define S_ISUID 04000
|
||||
#define S_ISGID 02000
|
||||
#define S_ISVTX 01000
|
||||
#define S_IRUSR 0400
|
||||
#define S_IWUSR 0200
|
||||
#define S_IXUSR 0100
|
||||
#define S_IRGRP 0040
|
||||
#define S_IWGRP 0020
|
||||
#define S_IXGRP 0010
|
||||
#define S_IROTH 0004
|
||||
#define S_IWOTH 0002
|
||||
#define S_IXOTH 0001
|
||||
|
||||
#define S_IRWXG (S_IRWXU >> 3)
|
||||
#define S_IRWXO (S_IRWXG >> 3)
|
||||
|
||||
int fcntl(int fd, int cmd, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
0
LibC/float.h
Normal file
0
LibC/float.h
Normal file
13
LibC/locale.cpp
Normal file
13
LibC/locale.cpp
Normal file
@ -0,0 +1,13 @@
|
||||
#include <locale.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
char* setlocale(int category, const char* locale)
|
||||
{
|
||||
dbgprintf("FIXME(LibC): setlocale(%d, %s)\n", category, locale);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
enum {
|
||||
LC_ALL,
|
||||
LC_NUMERIC,
|
||||
LC_CTYPE,
|
||||
};
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
@ -3,7 +3,7 @@
|
||||
global setjmp
|
||||
setjmp:
|
||||
mov eax, [esp + 4]
|
||||
mov [eax * 4], ebx
|
||||
mov [eax + 0 * 4], ebx
|
||||
mov [eax + 1 * 4], esi
|
||||
mov [eax + 2 * 4], edi
|
||||
mov [eax + 3 * 4], ebp
|
||||
@ -18,7 +18,7 @@ global longjmp
|
||||
longjmp:
|
||||
mov edx, [esp + 4]
|
||||
mov eax, [esp + 8]
|
||||
mov ebx, [edx * 4]
|
||||
mov ebx, [edx + 0 * 4]
|
||||
mov esi, [edx + 1 * 4]
|
||||
mov edi, [edx + 2 * 4]
|
||||
mov ebp, [edx + 3 * 4]
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
|
||||
extern "C" {
|
||||
@ -21,5 +23,11 @@ int chmod(const char* pathname, mode_t mode)
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int fchmod(int fd, mode_t mode)
|
||||
{
|
||||
dbgprintf("FIXME(LibC): fchmod(%d, %o)\n", fd, mode);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
13
LibC/stdbool.h
Normal file
13
LibC/stdbool.h
Normal file
@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define bool _Bool
|
||||
#define true 1
|
||||
#define false 0
|
||||
#define __bool_true_false_are_Defined 1
|
||||
|
||||
__END_DECLS
|
||||
|
@ -14,6 +14,8 @@ typedef signed int int32_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed char int8_t;
|
||||
|
||||
typedef uint32_t uintptr_t;
|
||||
|
||||
#define INT8_MIN (-128)
|
||||
#define INT16_MIN (-32767-1)
|
||||
#define INT32_MIN (-2147483647-1)
|
||||
|
@ -365,5 +365,11 @@ int fclose(FILE* stream)
|
||||
return rc;
|
||||
}
|
||||
|
||||
int rename(const char* oldpath, const char* newpath)
|
||||
{
|
||||
dbgprintf("FIXME(LibC): rename(%s, %s)\n", oldpath, newpath);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -70,6 +70,7 @@ int fscanf(FILE*, const char* fmt, ...);
|
||||
int setvbuf(FILE*, char* buf, int mode, size_t);
|
||||
void setbuf(FILE*, char* buf);
|
||||
void setlinebuf(FILE*);
|
||||
int rename(const char* oldpath, const char* newpath);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -267,6 +267,17 @@ int system(const char* command)
|
||||
return execl("/bin/sh", "sh", "-c", command, nullptr);
|
||||
}
|
||||
|
||||
char* mktemp(char*)
|
||||
{
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void *, const void *))
|
||||
{
|
||||
dbgprintf("FIXME(LibC): bsearch(%p, %p, %u, %u, %p)\n", key, base, nmemb, size, compar);
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
div_t div(int numerator, int denominator)
|
||||
{
|
||||
div_t result;
|
||||
|
@ -7,6 +7,7 @@ __BEGIN_DECLS
|
||||
|
||||
#define EXIT_SUCCESS 0
|
||||
#define EXIT_FAILURE 1
|
||||
#define MB_CUR_MAX 1
|
||||
|
||||
void* malloc(size_t) __MALLOC;
|
||||
void free(void*);
|
||||
@ -22,6 +23,8 @@ char* ptsname(int fd);
|
||||
int ptsname_r(int fd, char* buffer, size_t);
|
||||
int abs(int);
|
||||
int system(const char* command);
|
||||
char* mktemp(char*);
|
||||
void* bsearch(const void* key, const void* base, size_t nmemb, size_t size, int (*compar)(const void *, const void *));
|
||||
|
||||
#define RAND_MAX 32767
|
||||
int rand();
|
||||
|
@ -285,5 +285,15 @@ char* strstr(const char* haystack, const char* needle)
|
||||
return const_cast<char*>(haystack);
|
||||
}
|
||||
|
||||
char* strpbrk(const char* s, const char* accept)
|
||||
{
|
||||
while (*s)
|
||||
if(strchr(accept, *s++))
|
||||
return (char*)--s;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -28,6 +28,7 @@ size_t strspn(const char*, const char* accept);
|
||||
size_t strcspn(const char*, const char* reject);
|
||||
char* strerror(int errnum);
|
||||
char* strsignal(int signum);
|
||||
char* strpbrk(const char*, const char* accept);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -2,11 +2,20 @@
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
|
||||
mode_t umask(mode_t);
|
||||
int chmod(const char* pathname, mode_t);
|
||||
int fchmod(int fd, mode_t);
|
||||
int mkdir(const char* pathname, mode_t);
|
||||
|
||||
inline dev_t makedev(unsigned int major, unsigned int minor) { return (minor & 0xffu) | (major << 8u) | ((minor & ~0xffu) << 12u); }
|
||||
|
@ -83,7 +83,10 @@ struct tm* localtime(const time_t* t)
|
||||
return &tm_buf;
|
||||
}
|
||||
|
||||
long timezone = 0;
|
||||
long timezone;
|
||||
long altzone;
|
||||
char* tzname[2];
|
||||
int daylight;
|
||||
|
||||
void tzset()
|
||||
{
|
||||
|
@ -23,6 +23,9 @@ struct tm {
|
||||
};
|
||||
|
||||
extern long timezone;
|
||||
extern long altzone;
|
||||
extern char* tzname[2];
|
||||
extern int daylight;
|
||||
|
||||
int gettimeofday(struct timeval*, struct timezone* tz);
|
||||
struct tm* localtime(const time_t*);
|
||||
|
@ -11,4 +11,3 @@ long ulimit(int cmd, long newlimit)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#include <grp.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
@ -186,6 +187,10 @@ int chdir(const char* path)
|
||||
|
||||
char* getcwd(char* buffer, size_t size)
|
||||
{
|
||||
if (!buffer) {
|
||||
size = size ? size : PATH_MAX;
|
||||
buffer = (char*)malloc(size);
|
||||
}
|
||||
int rc = syscall(SC_getcwd, buffer, size);
|
||||
__RETURN_WITH_ERRNO(rc, buffer, nullptr);
|
||||
}
|
||||
|
@ -73,37 +73,10 @@ enum {
|
||||
|
||||
#define HOST_NAME_MAX 64
|
||||
|
||||
#define S_IFMT 0170000
|
||||
#define S_IFDIR 0040000
|
||||
#define S_IFCHR 0020000
|
||||
#define S_IFBLK 0060000
|
||||
#define S_IFREG 0100000
|
||||
#define S_IFIFO 0010000
|
||||
#define S_IFLNK 0120000
|
||||
#define S_IFSOCK 0140000
|
||||
|
||||
#define S_ISUID 04000
|
||||
#define S_ISGID 02000
|
||||
#define S_ISVTX 01000
|
||||
#define S_IRUSR 0400
|
||||
#define S_IWUSR 0200
|
||||
#define S_IXUSR 0100
|
||||
#define S_IRGRP 0040
|
||||
#define S_IWGRP 0020
|
||||
#define S_IXGRP 0010
|
||||
#define S_IROTH 0004
|
||||
#define S_IWOTH 0002
|
||||
#define S_IXOTH 0001
|
||||
|
||||
#define S_IRWXG (S_IRWXU >> 3)
|
||||
#define S_IRWXO (S_IRWXG >> 3)
|
||||
|
||||
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
|
||||
#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
|
||||
#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
|
||||
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
|
||||
#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
|
||||
#define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
|
||||
#define R_OK 4
|
||||
#define W_OK 2
|
||||
#define X_OK 1
|
||||
#define F_OK 0
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include <string.h>
|
||||
#include <getopt.h>
|
||||
#include <time.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <AK/AKString.h>
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <termios.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <AK/FileSystemPath.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user