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:
parent
e48182d91b
commit
f394e3486a
14 changed files with 114 additions and 1 deletions
|
@ -26,6 +26,8 @@ LIBC_OBJS = \
|
|||
stat.o \
|
||||
mntent.o \
|
||||
ctype.o \
|
||||
fcntl.o \
|
||||
termios.o \
|
||||
entry.o
|
||||
|
||||
OBJS = $(AK_OBJS) $(LIBC_OBJS)
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
17
LibC/fcntl.cpp
Normal 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);
|
||||
}
|
||||
|
||||
}
|
|
@ -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
20
LibC/termios.cpp
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue