1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:47:44 +00:00

Stub out a bunch more functions to get closer to that sweet bash build.

This commit is contained in:
Andreas Kling 2018-11-11 10:38:33 +01:00
parent e48182d91b
commit f394e3486a
14 changed files with 114 additions and 1 deletions

View file

@ -26,6 +26,8 @@ LIBC_OBJS = \
stat.o \
mntent.o \
ctype.o \
fcntl.o \
termios.o \
entry.o
OBJS = $(AK_OBJS) $(LIBC_OBJS)

View file

@ -6,3 +6,8 @@ int ispunct(int c)
const char* punctuation_characters = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
return !!strchr(punctuation_characters, c);
}
int isprint(int c)
{
return isdigit(c) || isupper(c) || islower(c) || ispunct(c) || isspace(c);
}

View file

@ -44,5 +44,6 @@ ALWAYS_INLINE int isdigit(int c)
}
int ispunct(int c);
int isprint(int c);
__END_DECLS

17
LibC/fcntl.cpp Normal file
View file

@ -0,0 +1,17 @@
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
#include <Kernel/Syscall.h>
extern "C" {
int fcntl(int fd, int cmd, ...)
{
va_list ap;
va_start(ap, cmd);
dword extra_arg = va_arg(ap, dword);
int rc = Syscall::invoke(Syscall::SC_fcntl, (dword)fd, (dword)cmd, extra_arg);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -10,4 +10,6 @@ __BEGIN_DECLS
#define F_GETFL 3
#define F_SETFL 4
int fcntl(int fd, int cmd, ...);
__END_DECLS

20
LibC/termios.cpp Normal file
View file

@ -0,0 +1,20 @@
#include <errno.h>
#include <termios.h>
#include <Kernel/Syscall.h>
extern "C" {
int tcgetattr(int fd, struct termios* t)
{
int rc = Syscall::invoke(Syscall::SC_tcgetattr, (dword)fd, (dword)t);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
int tcsetattr(int fd, int optional_actions, const struct termios* t)
{
int rc = Syscall::invoke(Syscall::SC_tcsetattr, (dword)fd, (dword)optional_actions, (dword)t);
__RETURN_WITH_ERRNO(rc, rc, -1);
}
}

View file

@ -5,7 +5,6 @@
__BEGIN_DECLS
#define NCCS 32
typedef uint32_t tcflag_t;
@ -19,6 +18,9 @@ struct termios {
cc_t c_cc[NCCS];
};
int tcgetattr(int fd, struct termios*);
int tcsetattr(int fd, int optional_actions, const struct termios*);
/* c_cc characters */
#define VINTR 0
#define VQUIT 1

View file

@ -21,4 +21,9 @@ int gettimeofday(struct timeval* tv, struct timezone*)
__RETURN_WITH_ERRNO(rc, rc, -1);
}
char* ctime(const time_t*)
{
return const_cast<char*>("ctime() not implemented");
}
}

View file

@ -12,6 +12,7 @@ struct timezone {
int gettimeofday(struct timeval*, struct timezone* tz);
time_t time(time_t*);
char* ctime(const time_t*);
__END_DECLS