summaryrefslogtreecommitdiff
path: root/userland/libc/stdlib
diff options
context:
space:
mode:
Diffstat (limited to 'userland/libc/stdlib')
-rw-r--r--userland/libc/stdlib/abort.c1
-rw-r--r--userland/libc/stdlib/getenv.c1
-rw-r--r--userland/libc/stdlib/realpath.c1
-rw-r--r--userland/libc/stdlib/strtol.c11
-rw-r--r--userland/libc/stdlib/strtoul.c11
-rw-r--r--userland/libc/stdlib/system.c4
6 files changed, 18 insertions, 11 deletions
diff --git a/userland/libc/stdlib/abort.c b/userland/libc/stdlib/abort.c
index 7fd747e..90368a9 100644
--- a/userland/libc/stdlib/abort.c
+++ b/userland/libc/stdlib/abort.c
@@ -1,5 +1,6 @@
#include <assert.h>
#include <stdlib.h>
+#include <stdio.h>
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/abort.html
void abort(void) {
diff --git a/userland/libc/stdlib/getenv.c b/userland/libc/stdlib/getenv.c
index 9a6a4e5..13d871c 100644
--- a/userland/libc/stdlib/getenv.c
+++ b/userland/libc/stdlib/getenv.c
@@ -1,6 +1,7 @@
#include <stdlib.h>
char *getenv(const char *name) {
+ (void)name;
// FIXME
return NULL;
}
diff --git a/userland/libc/stdlib/realpath.c b/userland/libc/stdlib/realpath.c
index 438ed8d..5589032 100644
--- a/userland/libc/stdlib/realpath.c
+++ b/userland/libc/stdlib/realpath.c
@@ -1,6 +1,7 @@
#include <assert.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
// FIXME: This is nowhere near complete
char *realpath(const char *filename, char *resolvedname) {
diff --git a/userland/libc/stdlib/strtol.c b/userland/libc/stdlib/strtol.c
index 7aa7760..09a5ad7 100644
--- a/userland/libc/stdlib/strtol.c
+++ b/userland/libc/stdlib/strtol.c
@@ -1,7 +1,8 @@
+#include <assert.h>
+#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdlib.h>
-#include <assert.h>
extern int errno;
extern int get_value(char c, long base);
@@ -10,17 +11,17 @@ extern int get_value(char c, long base);
long strtol(const char *str, char **restrict endptr, int base) {
long ret_value = 0;
if (endptr)
- *endptr = str;
+ *endptr = (char *)str;
// Ignore inital white-space sequence
for (; *str && isspace(*str); str++)
;
if (!*str)
return ret_value;
- int sign = 0;
+ // int sign = 0;
if ('-' == *str) {
// FIXME
- sign = 1;
+ // sign = 1;
str++;
assert(0);
} else if ('+' == *str) {
@@ -47,6 +48,6 @@ long strtol(const char *str, char **restrict endptr, int base) {
return 0;
}
if (endptr)
- *endptr = str;
+ *endptr = (char*)str;
return ret_value;
}
diff --git a/userland/libc/stdlib/strtoul.c b/userland/libc/stdlib/strtoul.c
index 4d9a51d..c490aeb 100644
--- a/userland/libc/stdlib/strtoul.c
+++ b/userland/libc/stdlib/strtoul.c
@@ -1,7 +1,8 @@
#include <assert.h>
+#include <ctype.h>
#include <errno.h>
-#include <stdlib.h>
#include <limits.h>
+#include <stdlib.h>
extern int errno;
int get_value(char c, long base) {
@@ -24,17 +25,17 @@ unsigned long strtoul(const char *restrict str, char **restrict endptr,
int base) {
unsigned long ret_value = 0;
if (endptr)
- *endptr = str;
+ *endptr = (char *)str;
// Ignore inital white-space sequence
for (; *str && isspace(*str); str++)
;
if (!*str)
return ret_value;
- int sign = 0;
+ // int sign = 0;
if ('-' == *str) {
// FIXME
- sign = 1;
+ // sign = 1;
str++;
assert(0);
} else if ('+' == *str) {
@@ -67,6 +68,6 @@ unsigned long strtoul(const char *restrict str, char **restrict endptr,
return 0;
}
if (endptr)
- *endptr = str;
+ *endptr = (char*)str;
return ret_value;
}
diff --git a/userland/libc/stdlib/system.c b/userland/libc/stdlib/system.c
index d951c5c..1cba966 100644
--- a/userland/libc/stdlib/system.c
+++ b/userland/libc/stdlib/system.c
@@ -1,4 +1,6 @@
#include <stdlib.h>
+#include <unistd.h>
+#include <sys/wait.h>
int system(const char *command) {
if (!command)
@@ -7,7 +9,7 @@ int system(const char *command) {
if (0 == pid) {
char *argv[2];
argv[0] = "/sh";
- argv[1] = command;
+ argv[1] = (char *)command;
execv("/sh", argv);
}
// FIXME: Use waitpid