summaryrefslogtreecommitdiff
path: root/src/libc/include
diff options
context:
space:
mode:
Diffstat (limited to 'src/libc/include')
-rw-r--r--src/libc/include/__errno.h3
-rw-r--r--src/libc/include/fcntl.h6
-rw-r--r--src/libc/include/inttypes.h18
-rw-r--r--src/libc/include/memory.h0
-rw-r--r--src/libc/include/sgtty.h0
-rw-r--r--src/libc/include/stdio.h3
-rw-r--r--src/libc/include/stdlib.h6
-rw-r--r--src/libc/include/string.h2
-rw-r--r--src/libc/include/sys/stat.h10
-rw-r--r--src/libc/include/sys/time.h8
-rw-r--r--src/libc/include/sys/types.h1
-rw-r--r--src/libc/include/sys/wait.h1
-rw-r--r--src/libc/include/time.h2
-rw-r--r--src/libc/include/unistd.h6
-rw-r--r--src/libc/include/utime.h9
-rw-r--r--src/libc/include/wchar.h7
16 files changed, 77 insertions, 5 deletions
diff --git a/src/libc/include/__errno.h b/src/libc/include/__errno.h
index 7551ce0..7976fba 100644
--- a/src/libc/include/__errno.h
+++ b/src/libc/include/__errno.h
@@ -23,4 +23,7 @@ E(205, "EINTR")
E(206, "EWOULDBLOCK")
E(207, "EEXIST")
E(208, "EAGAIN")
+E(209, "EIO")
+E(210, "EDOM domain error")
+E(211, "EFBIG file too large")
#endif
diff --git a/src/libc/include/fcntl.h b/src/libc/include/fcntl.h
index 6338d1f..ba9b9e0 100644
--- a/src/libc/include/fcntl.h
+++ b/src/libc/include/fcntl.h
@@ -11,10 +11,10 @@
#define O_CREAT 0
#define O_EXCL 0
#define O_NONBLOCK 0
-#define O_RDONLY 0
-#define O_RDWR 0
#define O_TRUNC 0
-#define O_WRONLY 0
+#define O_RDONLY 1
+#define O_WRONLY 2
+#define O_RDWR 3
#define R_OK 1
#define W_OK 2
diff --git a/src/libc/include/inttypes.h b/src/libc/include/inttypes.h
index 9a6118b..d44129a 100644
--- a/src/libc/include/inttypes.h
+++ b/src/libc/include/inttypes.h
@@ -1 +1,19 @@
#include <stdint.h>
+
+#define PRId64 "ld"
+#define PRIo64 "lo"
+#define PRIu64 "lu"
+#define PRIx64 "lx"
+#define SCNu64 "lu"
+
+#define PRId32 "d"
+#define PRIo32 "o"
+#define PRIu32 "u"
+#define PRIx32 "x"
+#define SCNu32 "u"
+
+#define PRId16 "d"
+#define PRIo16 "o"
+#define PRIu16 "u"
+#define PRIx16 "x"
+#define SCNu16 "u"
diff --git a/src/libc/include/memory.h b/src/libc/include/memory.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/libc/include/memory.h
diff --git a/src/libc/include/sgtty.h b/src/libc/include/sgtty.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/libc/include/sgtty.h
diff --git a/src/libc/include/stdio.h b/src/libc/include/stdio.h
index 48d5058..169646f 100644
--- a/src/libc/include/stdio.h
+++ b/src/libc/include/stdio.h
@@ -29,6 +29,7 @@ int fprintf(FILE *restrict f, const char *restrict fmt, ...);
int sprintf(char *restrict s, const char *restrict fmt, ...);
int vprintf(const char *restrict fmt, va_list ap);
+int vsprintf(char *restrict s, const char *restrict fmt, va_list ap);
int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap);
int _klogf(const char *fmt, ...); // for kernel debugging only
@@ -40,6 +41,7 @@ FILE *fopen(const char *path, const char *mode);
FILE *freopen(const char *path, const char *mode, FILE *);
FILE *fdopen(int fd, const char *mode);
FILE *file_clone(const FILE *, const char *mode);
+int fileno(FILE *f);
FILE *popen(const char *cmd, const char *mode);
int pclose(FILE *f);
FILE *tmpfile(void);
@@ -60,6 +62,7 @@ int putc(int c, FILE *f);
int ungetc(int c, FILE *f);
int fseek(FILE *f, long offset, int whence);
+void rewind(FILE *f);
int fseeko(FILE *f, off_t offset, int whence);
long ftell(FILE *f);
off_t ftello(FILE *f);
diff --git a/src/libc/include/stdlib.h b/src/libc/include/stdlib.h
index ee9d179..c3fd4bd 100644
--- a/src/libc/include/stdlib.h
+++ b/src/libc/include/stdlib.h
@@ -16,13 +16,15 @@ const char *getprogname(void);
void setprogname(const char *progname);
void setproctitle(const char *fmt, ...);
-int mkstemp(char *template);
+char *mktemp(char *tmpl);
+int mkstemp(char *tmpl);
char *getenv(const char *name);
int system(const char *cmd);
int abs(int i);
int atoi(const char *s);
+long atol(const char *s);
double atof(const char *s);
long strtol(const char *restrict s, char **restrict end, int base);
@@ -32,3 +34,5 @@ unsigned long long strtoull(const char *restrict s, char **restrict end, int bas
double strtod(const char *restrict s, char **restrict end);
void qsort(void *base, size_t nmemb, size_t size, int (*cmp)(const void *a, const void *b));
+void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg);
+void* bsearch(const void* key, const void* base_ptr, size_t nmemb, size_t size, int (*compare)(const void*, const void*));
diff --git a/src/libc/include/string.h b/src/libc/include/string.h
index 78bed9b..d9d2b74 100644
--- a/src/libc/include/string.h
+++ b/src/libc/include/string.h
@@ -17,8 +17,10 @@ int strcoll(const char *s1, const char *s2);
char *strstr(const char *s1, const char *s2);
+char *strcat(char *restrict dst, const char *restrict src);
char *strcpy(char *restrict s1, const char *restrict s2);
char *strncpy(char *restrict s1, const char *restrict s2, size_t n);
+char *strncat(char *restrict dst, const char *restrict src, size_t n);
char *stpncpy(char *restrict dst, const char *restrict src, size_t n);
char *strdup(const char *s);
diff --git a/src/libc/include/sys/stat.h b/src/libc/include/sys/stat.h
index 343db55..b9d0e8b 100644
--- a/src/libc/include/sys/stat.h
+++ b/src/libc/include/sys/stat.h
@@ -38,6 +38,8 @@ struct stat {
#define S_ISGID 02000
#define S_ISVTX 01000
+#define S_IRUSR 0x400
+
/* inode(7) */
#define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
@@ -54,7 +56,7 @@ int mkdir(const char *path, mode_t mode);
static inline mode_t umask(mode_t mask) {
(void)mask;
- __libc_panic("unimplemented");
+ return 0;
}
static inline int chmod(const char *path, mode_t mode) {
@@ -63,6 +65,12 @@ static inline int chmod(const char *path, mode_t mode) {
return -1;
}
+static inline int fchmod(int fd, mode_t mode) {
+ (void)fd; (void)mode;
+ errno = ENOSYS;
+ return -1;
+}
+
static inline int mknod(const char *path, mode_t mode, dev_t dev) {
(void)path; (void)mode; (void)dev;
errno = ENOSYS;
diff --git a/src/libc/include/sys/time.h b/src/libc/include/sys/time.h
index e69de29..54df6b3 100644
--- a/src/libc/include/sys/time.h
+++ b/src/libc/include/sys/time.h
@@ -0,0 +1,8 @@
+#pragma once
+#include <errno.h>
+#include <sys/types.h>
+
+struct timeval {
+ time_t tv_sec;
+ suseconds_t tv_usec;
+};
diff --git a/src/libc/include/sys/types.h b/src/libc/include/sys/types.h
index faf656a..2e7f54b 100644
--- a/src/libc/include/sys/types.h
+++ b/src/libc/include/sys/types.h
@@ -4,6 +4,7 @@
typedef long long off_t;
typedef int64_t time_t;
+typedef int64_t suseconds_t;
typedef uint64_t clock_t;
typedef int mode_t;
diff --git a/src/libc/include/sys/wait.h b/src/libc/include/sys/wait.h
index cff407e..5f0d2cc 100644
--- a/src/libc/include/sys/wait.h
+++ b/src/libc/include/sys/wait.h
@@ -10,4 +10,5 @@
#define WNOHANG 0
#define WUNTRACED 0
+pid_t wait(int *wstatus);
pid_t wait3(int *wstatus, int opts, struct rusage *rusage);
diff --git a/src/libc/include/time.h b/src/libc/include/time.h
index 5d03664..e2bf31e 100644
--- a/src/libc/include/time.h
+++ b/src/libc/include/time.h
@@ -29,6 +29,8 @@ time_t mktime(struct tm *timeptr);
double difftime(time_t time1, time_t time0);
+char *ctime(const time_t *timep);
+
size_t strftime(
char *restrict s, size_t maxsize,
const char *restrict format, const struct tm *restrict timeptr);
diff --git a/src/libc/include/unistd.h b/src/libc/include/unistd.h
index 005e79c..ac5afc0 100644
--- a/src/libc/include/unistd.h
+++ b/src/libc/include/unistd.h
@@ -16,10 +16,12 @@ _Noreturn void _exit(int);
ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
int link(const char *path1, const char *path2);
int unlink(const char *path);
+int rmdir(const char *path);
int symlink(const char *path1, const char *path2);
int isatty(int fd);
int execv(const char *path, char *const argv[]);
+int execvp(const char *path, char *const argv[]);
int execve(const char *path, char *const argv[], char *const envp[]);
int chdir(const char *path);
@@ -30,6 +32,7 @@ uid_t geteuid(void);
gid_t getgid(void);
gid_t getegid(void);
+int access(const char *path, int mode);
int chown(const char *path, uid_t owner, gid_t group);
int setpgid(pid_t pid, pid_t pgid);
@@ -44,8 +47,11 @@ int getgroups(int size, gid_t list[]);
ssize_t read(int fd, void *buf, size_t count);
ssize_t write(int fd, const void *buf, size_t count);
int pipe(int pipefd[2]);
+int dup(int oldfd);
int dup2(int oldfd, int newfd);
+unsigned int sleep(unsigned int seconds);
+
/* Converts a relative path to an absolute one, simplifying it if possible.
* If in == NULL - return the length of cwd. Doesn't include the trailing slash,
* except for the root dir. Includes the null byte.
diff --git a/src/libc/include/utime.h b/src/libc/include/utime.h
new file mode 100644
index 0000000..4ae34ed
--- /dev/null
+++ b/src/libc/include/utime.h
@@ -0,0 +1,9 @@
+#pragma once
+#include <sys/time.h>
+
+struct utimbuf {
+ time_t actime;
+ time_t modtime;
+};
+
+int utime(const char *fn, const struct utimbuf *times);
diff --git a/src/libc/include/wchar.h b/src/libc/include/wchar.h
new file mode 100644
index 0000000..3d4bc15
--- /dev/null
+++ b/src/libc/include/wchar.h
@@ -0,0 +1,7 @@
+#pragma once
+#include <bits/panic.h>
+
+static inline size_t mbstowcs(wchar_t *dst, const char *src, size_t n) {
+ (void)dst; (void)src; (void)n;
+ __libc_panic("unimplemented");
+}