mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 08:50:37 +00:00
Lots of minor compat stuff while seeing if bash would build.
We're quite far from bash building, but we'll get there eventually!
This commit is contained in:
parent
e4611248c4
commit
e76312ab63
Notes:
sideshowbarker
2024-07-19 18:33:25 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/e76312ab63e
21 changed files with 172 additions and 38 deletions
|
@ -20,6 +20,7 @@ LIBC_OBJS = \
|
|||
getopt.o \
|
||||
scanf.o \
|
||||
pwd.o \
|
||||
times.o \
|
||||
entry.o
|
||||
|
||||
OBJS = $(AK_OBJS) $(LIBC_OBJS)
|
||||
|
|
11
LibC/endian.h
Normal file
11
LibC/endian.h
Normal file
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define LITTLE_ENDIAN 1234
|
||||
#define BIG_ENDIAN 4321
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
__END_DECLS
|
13
LibC/fcntl.h
13
LibC/fcntl.h
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
#define F_DUPFD 0
|
||||
#define F_GETFD 1
|
||||
#define F_SETFD 2
|
||||
#define F_GETFL 3
|
||||
#define F_SETFL 4
|
||||
|
||||
__END_DECLS
|
|
@ -189,7 +189,7 @@ static int vsscanf(const char *buf, const char *s, va_list ap)
|
|||
for (tc = s; isdigit(*s); s++);
|
||||
strncpy (tmp, tc, s - tc);
|
||||
tmp[s - tc] = '\0';
|
||||
atob ((dword*)&width, tmp, 10);
|
||||
atob ((uint32_t*)&width, tmp, 10);
|
||||
s--;
|
||||
}
|
||||
}
|
||||
|
@ -232,7 +232,7 @@ static int vsscanf(const char *buf, const char *s, va_list ap)
|
|||
tmp[width] = '\0';
|
||||
buf += width;
|
||||
if (!noassign)
|
||||
atob(va_arg(ap, dword*), tmp, base);
|
||||
atob(va_arg(ap, uint32_t*), tmp, base);
|
||||
}
|
||||
if (!noassign)
|
||||
++count;
|
||||
|
|
0
LibC/setjmp.cpp
Normal file
0
LibC/setjmp.cpp
Normal file
|
@ -0,0 +1,13 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef uint32_t jmp_buf[6];
|
||||
|
||||
int setjmp(jmp_buf);
|
||||
void longjmp(jmp_buf, int val);
|
||||
|
||||
__END_DECLS
|
|
@ -1,5 +1,6 @@
|
|||
#include "unistd.h"
|
||||
#include "errno.h"
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
|
||||
extern "C" {
|
||||
|
|
|
@ -4,8 +4,31 @@
|
|||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef void (*__sighandler_t)(int);
|
||||
typedef __sighandler_t sighandler_t;
|
||||
|
||||
typedef uint32_t sigset_t;
|
||||
typedef void siginfo_t;
|
||||
|
||||
struct sigaction {
|
||||
void (*sa_handler)(int);
|
||||
void (*sa_sigaction)(int, siginfo_t*, void*);
|
||||
sigset_t sa_mask;
|
||||
int sa_flags;
|
||||
void (*sa_restorer)(void);
|
||||
};
|
||||
|
||||
int kill(pid_t, int sig);
|
||||
|
||||
#define SIG_DFL ((__sighandler_t)0)
|
||||
#define SIG_ERR ((__sighandler_t)-1)
|
||||
#define SIG_IGN ((__sighandler_t)1)
|
||||
|
||||
#define SIG_BLOCK 0
|
||||
#define SIG_UNBLOCK 1
|
||||
#define SIG_SETMASK 2
|
||||
|
||||
|
||||
#define SIGHUP 1
|
||||
#define SIGINT 2
|
||||
#define SIGQUIT 3
|
||||
|
|
0
LibC/stddef.h
Normal file
0
LibC/stddef.h
Normal file
16
LibC/stdint.h
Normal file
16
LibC/stdint.h
Normal file
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned char uint8_t;
|
||||
|
||||
typedef signed int int32_t;
|
||||
typedef signed short int16_t;
|
||||
typedef signed char int8_t;
|
||||
|
||||
__END_DECLS
|
||||
|
|
@ -43,6 +43,7 @@ int sprintf(char* buffer, const char* fmt, ...);
|
|||
int putchar(int ch);
|
||||
void perror(const char*);
|
||||
int sscanf (const char* buf, const char* fmt, ...);
|
||||
int fscanf(FILE*, const char* fmt, ...);
|
||||
|
||||
__END_DECLS
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ extern "C" {
|
|||
|
||||
void* memset(void* dest, int c, size_t n)
|
||||
{
|
||||
byte* bdest = (byte*)dest;
|
||||
uint8_t* bdest = (uint8_t*)dest;
|
||||
for (; n; --n)
|
||||
*(bdest++) = c;
|
||||
return dest;
|
||||
|
@ -57,8 +57,8 @@ int strcmp(const char* s1, const char* s2)
|
|||
|
||||
int memcmp(const void* v1, const void* v2, size_t n)
|
||||
{
|
||||
auto* s1 = (const byte*)v1;
|
||||
auto* s2 = (const byte*)v2;
|
||||
auto* s1 = (const uint8_t*)v1;
|
||||
auto* s2 = (const uint8_t*)v2;
|
||||
while (n-- > 0) {
|
||||
if (*s1++ != *s2++)
|
||||
return s1[-1] < s2[-1] ? -1 : 1;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#define _POSIX_VERSION 200809L
|
||||
|
||||
#define ALWAYS_INLINE inline __attribute__ ((always_inline))
|
||||
#define __NORETURN __attribute__ ((noreturn))
|
||||
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
#pragma once
|
||||
|
||||
#include <endian.h>
|
||||
|
17
LibC/sys/times.h
Normal file
17
LibC/sys/times.h
Normal file
|
@ -0,0 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
struct tms {
|
||||
clock_t tms_utime;
|
||||
clock_t tms_stime;
|
||||
clock_t tms_cutime;
|
||||
clock_t tms_cstime;
|
||||
};
|
||||
|
||||
clock_t times(struct tms*);
|
||||
|
||||
__END_DECLS
|
|
@ -1,34 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
#include <stdint.h>
|
||||
|
||||
__BEGIN_DECLS
|
||||
|
||||
typedef unsigned int dword;
|
||||
typedef unsigned short word;
|
||||
typedef unsigned char byte;
|
||||
|
||||
typedef signed int signed_dword;
|
||||
typedef signed short signed_word;
|
||||
typedef signed char signed_byte;
|
||||
|
||||
typedef dword uid_t;
|
||||
typedef dword gid_t;
|
||||
typedef uint32_t uid_t;
|
||||
typedef uint32_t gid_t;
|
||||
typedef int pid_t;
|
||||
|
||||
typedef dword size_t;
|
||||
typedef signed_dword ssize_t;
|
||||
typedef uint32_t size_t;
|
||||
typedef int32_t ssize_t;
|
||||
|
||||
typedef dword ino_t;
|
||||
typedef signed_dword off_t;
|
||||
typedef uint32_t ino_t;
|
||||
typedef int32_t off_t;
|
||||
|
||||
typedef dword dev_t;
|
||||
typedef dword mode_t;
|
||||
typedef dword nlink_t;
|
||||
typedef dword blksize_t;
|
||||
typedef dword blkcnt_t;
|
||||
typedef dword time_t;
|
||||
typedef dword suseconds_t;
|
||||
typedef uint32_t dev_t;
|
||||
typedef uint32_t mode_t;
|
||||
typedef uint32_t nlink_t;
|
||||
typedef uint32_t blksize_t;
|
||||
typedef uint32_t blkcnt_t;
|
||||
typedef uint32_t time_t;
|
||||
typedef uint32_t suseconds_t;
|
||||
|
||||
typedef uint32_t clock_t;
|
||||
|
||||
struct timeval {
|
||||
time_t tv_sec;
|
||||
|
|
|
@ -6,13 +6,14 @@ extern "C" {
|
|||
|
||||
time_t time(time_t* tloc)
|
||||
{
|
||||
timeval tv;
|
||||
if (gettimeofday(&tv) < 0)
|
||||
struct timeval tv;
|
||||
struct timezone tz;
|
||||
if (gettimeofday(&tv, &tz) < 0)
|
||||
return (time_t)-1;
|
||||
return tv.tv_sec;
|
||||
}
|
||||
|
||||
int gettimeofday(timeval* tv)
|
||||
int gettimeofday(struct timeval* tv, struct timezone*)
|
||||
{
|
||||
int rc = Syscall::invoke(Syscall::PosixGettimeofday, (dword)tv);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
|
|
|
@ -5,7 +5,12 @@
|
|||
|
||||
__BEGIN_DECLS
|
||||
|
||||
int gettimeofday(timeval*);
|
||||
typedef struct timezone {
|
||||
int tz_minuteswest;
|
||||
int tz_dsttime;
|
||||
};
|
||||
|
||||
int gettimeofday(struct timeval*, struct timezone* tz);
|
||||
time_t time(time_t*);
|
||||
|
||||
__END_DECLS
|
||||
|
|
8
LibC/times.cpp
Normal file
8
LibC/times.cpp
Normal file
|
@ -0,0 +1,8 @@
|
|||
#include <sys/times.h>
|
||||
#include <assert.h>
|
||||
|
||||
clock_t times(struct tms*)
|
||||
{
|
||||
assert(false);
|
||||
return 0;
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
#include "unistd.h"
|
||||
#include "string.h"
|
||||
#include "errno.h"
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdarg.h>
|
||||
#include <assert.h>
|
||||
#include <Kernel/Syscall.h>
|
||||
|
||||
extern "C" {
|
||||
|
@ -78,9 +80,12 @@ pid_t getpgrp()
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int open(const char* path, int options)
|
||||
int open(const char* path, int options, ...)
|
||||
{
|
||||
int rc = Syscall::invoke(Syscall::PosixOpen, (dword)path, (dword)options);
|
||||
va_list ap;
|
||||
va_start(ap, options);
|
||||
int rc = Syscall::invoke(Syscall::PosixOpen, (dword)path, (dword)options, (dword)ap);
|
||||
va_end(ap);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
|
@ -169,5 +174,15 @@ off_t lseek(int fd, off_t offset, int whence)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int link(const char*, const char*)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
int unlink(const char*)
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ gid_t getgid();
|
|||
pid_t getpid();
|
||||
pid_t tcgetpgrp(int fd);
|
||||
int tcsetpgrp(int fd, pid_t pgid);
|
||||
int open(const char* path, int options);
|
||||
int open(const char* path, int options, ...);
|
||||
ssize_t read(int fd, void* buf, size_t count);
|
||||
ssize_t write(int fd, const void* buf, size_t count);
|
||||
int close(int fd);
|
||||
|
@ -37,6 +37,8 @@ ssize_t readlink(const char* path, char* buffer, size_t);
|
|||
char* ttyname(int fd);
|
||||
int ttyname_r(int fd, char* buffer, size_t);
|
||||
off_t lseek(int fd, off_t, int whence);
|
||||
int link(const char* oldpath, const char* newpath);
|
||||
int unlink(const char* pathname);
|
||||
|
||||
#define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
|
||||
#define WTERMSIG(status) ((status) & 0x7f)
|
||||
|
@ -83,6 +85,12 @@ off_t lseek(int fd, off_t, int whence);
|
|||
#define O_RDONLY 0
|
||||
#define O_WRONLY 1
|
||||
#define O_RDWR 2
|
||||
#define O_CREAT 0100
|
||||
#define O_EXCL 0200
|
||||
#define O_NOCTTY 0400
|
||||
#define O_TRUNC 01000
|
||||
#define O_APPEND 02000
|
||||
#define O_NONBLOCK 04000
|
||||
#define O_DIRECTORY 00200000
|
||||
#define O_NOFOLLOW 00400000
|
||||
|
||||
|
|
Loading…
Reference in a new issue