summaryrefslogtreecommitdiff
path: root/userland/libc
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc')
-rw-r--r--userland/libc/include/signal.h1
-rw-r--r--userland/libc/include/syscall.h1
-rw-r--r--userland/libc/libc.c1
-rw-r--r--userland/libc/signal/kill.c11
-rw-r--r--userland/libc/time/clock_gettime.c17
5 files changed, 20 insertions, 11 deletions
diff --git a/userland/libc/include/signal.h b/userland/libc/include/signal.h
index 42702b2..e5f8d8b 100644
--- a/userland/libc/include/signal.h
+++ b/userland/libc/include/signal.h
@@ -39,6 +39,7 @@ struct siginfo {
typedef struct siginfo siginfo_t;
int kill(int fd, int sig);
+int kill_fd(int fd, int sig);
struct sigaction {
void (*sa_handler)(int); // Pointer to a signal-catching function or one of
diff --git a/userland/libc/include/syscall.h b/userland/libc/include/syscall.h
index e1c0b07..0396dce 100644
--- a/userland/libc/include/syscall.h
+++ b/userland/libc/include/syscall.h
@@ -47,6 +47,7 @@
#define SYS_SETSOCKOPT 39
#define SYS_GETPEERNAME 40
#define SYS_FCNTL 41
+#define SYS_CLOCK_GETTIME 42
int syscall(uint32_t eax, uint32_t ebx, uint32_t ecx, uint32_t edx,
uint32_t esi, uint32_t edi);
diff --git a/userland/libc/libc.c b/userland/libc/libc.c
index 31d8648..decd002 100644
--- a/userland/libc/libc.c
+++ b/userland/libc/libc.c
@@ -131,6 +131,7 @@ void _libc_setup(void) {
__stderr_FILE->read = read_fd;
__stderr_FILE->is_eof = 0;
__stderr_FILE->has_error = 0;
+ __stdout_FILE->seek = NULL;
__stderr_FILE->cookie = NULL;
__stderr_FILE->fd = 2;
__stderr_FILE->fflush = fflush_fd;
diff --git a/userland/libc/signal/kill.c b/userland/libc/signal/kill.c
index c5ed62b..c8a368f 100644
--- a/userland/libc/signal/kill.c
+++ b/userland/libc/signal/kill.c
@@ -1,6 +1,15 @@
+#include <fcntl.h>
+#include <unistd.h>
#include <signal.h>
#include <syscall.h>
-int kill(int fd, int sig) {
+int kill_fd(int fd, int sig) {
RC_ERRNO(syscall(SYS_KILL, fd, sig, 0, 0, 0))
}
+
+int kill(int pid, int sig) {
+ int fd = open_process(pid);
+ int rc = kill_fd(fd, sig);
+ close(fd);
+ return rc;
+}
diff --git a/userland/libc/time/clock_gettime.c b/userland/libc/time/clock_gettime.c
index 492b968..239b389 100644
--- a/userland/libc/time/clock_gettime.c
+++ b/userland/libc/time/clock_gettime.c
@@ -1,15 +1,12 @@
+#include <errno.h>
+#include <stdint.h>
#include <syscall.h>
#include <time.h>
+#include <unistd.h>
int clock_gettime(clockid_t clock_id, struct timespec *tp) {
- (void)clock_id;
- tp->tv_sec = 0;
- tp->tv_nsec = 0;
- return 0;
- /*
-SYS_CLOCK_GETTIME_PARAMS args = {
-.clk = clock_id,
-.ts = tp,
-};
-return syscall(SYS_CLOCK_GETTIME, &args);*/
+ uint32_t ms = uptime();
+ tp->tv_sec = ms / 1000;
+ tp->tv_nsec = ms * 1000000;
+ RC_ERRNO(syscall(SYS_CLOCK_GETTIME, clock_id, tp, 0, 0, 0));
}