diff options
author | Anton Kling <anton@kling.gg> | 2024-10-03 15:08:45 +0200 |
---|---|---|
committer | Anton Kling <anton@kling.gg> | 2024-10-03 15:08:45 +0200 |
commit | 226d861c9ebb7f09f95665d07d9ab5c6b7ed7d6f (patch) | |
tree | d900c3437d3d65ee7bd88474586dc6dd947b14ce /userland/libc/include | |
parent | 64b0b49a1f23da9faa680f8158cb8a12cd4d118c (diff) |
libc: small changes
Diffstat (limited to 'userland/libc/include')
-rw-r--r-- | userland/libc/include/math.h | 1 | ||||
-rw-r--r-- | userland/libc/include/signal.h | 55 | ||||
-rw-r--r-- | userland/libc/include/sys/mman.h | 1 | ||||
-rw-r--r-- | userland/libc/include/sys/time.h | 2 | ||||
-rw-r--r-- | userland/libc/include/sys/ucontext.h | 1 | ||||
-rw-r--r-- | userland/libc/include/syscall.h | 3 | ||||
-rw-r--r-- | userland/libc/include/tb/sb.h | 4 | ||||
-rw-r--r-- | userland/libc/include/tb/sv.h | 1 | ||||
-rw-r--r-- | userland/libc/include/time.h | 37 |
9 files changed, 12 insertions, 93 deletions
diff --git a/userland/libc/include/math.h b/userland/libc/include/math.h index d85b3a0..7168a5d 100644 --- a/userland/libc/include/math.h +++ b/userland/libc/include/math.h @@ -14,3 +14,4 @@ #define HUGE_VALL ((long double)INFINITY) double ldexp(double x, int exp); +double fmin(double x, double y); diff --git a/userland/libc/include/signal.h b/userland/libc/include/signal.h deleted file mode 100644 index e5f8d8b..0000000 --- a/userland/libc/include/signal.h +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef SIGNAL_H -#define SIGNAL_H -#include <sys/types.h> -#define SIGHUP 0 -#define SIGINT 1 -#define SIGWINCH 2 -#define SIGQUIT 3 -#define SIG_IGN 4 -#define SIGSEGV 5 -#define SIGILL 6 -#define SIGABRT 7 -#define SIGBUS 8 -#define SIGKILL 9 -#define SIGFPE 10 -#define SIGTERM 15 -#define SIG_DFL 16 - -typedef int pid_t; -typedef int sigset_t; - -union sigval { - int sival_int; // Integer signal value. - void *sival_ptr; // Pointer signal value. -}; - -struct siginfo { - int si_signo; // Signal number. - int si_code; // Signal code. - int si_errno; // If non-zero, an errno value associated with - // this signal, as described in <errno.h>. - pid_t si_pid; // Sending process ID. - uid_t si_uid; // Real user ID of sending process. - void *si_addr; // Address of faulting instruction. - int si_status; // Exit value or signal. - long si_band; // Band event for SIGPOL9 - union sigval si_value; // Signal value. -}; - -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 - // the macros SIG_IGN or SIG_DFL. - sigset_t sa_mask; // Additional set of signals to be blocked during execution - // of signal-catching function. - int sa_flags; // Special flags to affect behavior of signal. - void (*sa_sigaction)(int, siginfo_t *, - void *); // Pointer to a signal-catching function. -}; - -int sigaction(int sig, const struct sigaction *act, struct sigaction *oact); -#endif // SIGNAL_H diff --git a/userland/libc/include/sys/mman.h b/userland/libc/include/sys/mman.h index d60997d..91ee816 100644 --- a/userland/libc/include/sys/mman.h +++ b/userland/libc/include/sys/mman.h @@ -7,6 +7,7 @@ #define PROT_READ (1 << 0) #define PROT_WRITE (1 << 1) +#define PROT_EXEC (1 << 2) #define MAP_PRIVATE (1 << 0) #define MAP_ANONYMOUS (1 << 1) diff --git a/userland/libc/include/sys/time.h b/userland/libc/include/sys/time.h index a675d9e..4f5cbd7 100644 --- a/userland/libc/include/sys/time.h +++ b/userland/libc/include/sys/time.h @@ -2,9 +2,9 @@ #define TIME_H #include <stddef.h> #include <sys/types.h> -#include <time.h> #define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC_RAW 1 struct tm { int tm_sec; diff --git a/userland/libc/include/sys/ucontext.h b/userland/libc/include/sys/ucontext.h index e69de29..5fdbd63 100644 --- a/userland/libc/include/sys/ucontext.h +++ b/userland/libc/include/sys/ucontext.h @@ -0,0 +1 @@ +#include <ucontext.h> diff --git a/userland/libc/include/syscall.h b/userland/libc/include/syscall.h index 0396dce..87622c5 100644 --- a/userland/libc/include/syscall.h +++ b/userland/libc/include/syscall.h @@ -48,6 +48,9 @@ #define SYS_GETPEERNAME 40 #define SYS_FCNTL 41 #define SYS_CLOCK_GETTIME 42 +#define SYS_QUEUE_CREATE 43 +#define SYS_QUEUE_MOD_ENTRIES 44 +#define SYS_QUEUE_WAIT 45 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/include/tb/sb.h b/userland/libc/include/tb/sb.h index 84f8161..06aa084 100644 --- a/userland/libc/include/tb/sb.h +++ b/userland/libc/include/tb/sb.h @@ -11,13 +11,15 @@ struct sb { struct sv; -void sb_init(struct sb *ctx); +void sb_init(struct sb *ctx, size_t starting_capacity); void sb_free(struct sb *ctx); void sb_reset(struct sb *ctx); int sb_isempty(const struct sb *ctx); void sb_append_char(struct sb *ctx, char c); int sb_delete_right(struct sb *ctx, size_t n); void sb_append(struct sb *ctx, const char *s); +void sb_append_buffer(struct sb *ctx, const char *buffer, + size_t length); void sb_append_sv(struct sb *ctx, struct sv sv); void sb_prepend_sv(struct sb *ctx, struct sv sv); #endif diff --git a/userland/libc/include/tb/sv.h b/userland/libc/include/tb/sv.h index 54ec218..3d4f9fb 100644 --- a/userland/libc/include/tb/sv.h +++ b/userland/libc/include/tb/sv.h @@ -25,6 +25,7 @@ struct sv sv_skip_chars(const struct sv input, const char *chars); struct sv sv_split_function(const struct sv input, struct sv *rest, int (*function)(int)); struct sv sv_take(struct sv s, struct sv *rest, size_t n); +struct sv sv_take_end(struct sv s, struct sv *rest, size_t n); struct sv sv_next(struct sv s); int sv_isempty(struct sv s); char sv_peek(struct sv s); diff --git a/userland/libc/include/time.h b/userland/libc/include/time.h index b494f6c..18a03a5 100644 --- a/userland/libc/include/time.h +++ b/userland/libc/include/time.h @@ -1,36 +1 @@ -#ifndef TIME_H -#define TIME_H -#include <sys/types.h> -#include <stddef.h> - -#define CLOCK_REALTIME 0 -#define CLOCK_MONOTONIC_RAW 1 - -struct tm { - int tm_sec; - int tm_min; - int tm_hour; - int tm_mday; - int tm_mon; - int tm_year; - int tm_wday; - int tm_yday; - int tm_isdst; - long __tm_gmtoff; - const char *__tm_zone; -}; - -typedef int clockid_t; -struct timespec { - time_t tv_sec; // Seconds. - long tv_nsec; // Nanoseconds. -}; - -time_t time(time_t *tloc); -int clock_gettime(clockid_t clock_id, struct timespec *tp); -struct tm *localtime(const time_t *timer); -struct tm *gmtime(const time_t *timer); -size_t strftime(char *restrict s, size_t maxsize, - const char *restrict format, const struct tm *restrict timeptr); -char *ctime_r(const time_t *clock, char *buf); -#endif +#include <sys/time.h> |