summaryrefslogtreecommitdiff
path: root/src/user/lib/libc/std/stdlib.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/lib/libc/std/stdlib.c')
-rw-r--r--src/user/lib/libc/std/stdlib.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/user/lib/libc/std/stdlib.c b/src/user/lib/libc/std/stdlib.c
index 9d46b5c..15f9ddc 100644
--- a/src/user/lib/libc/std/stdlib.c
+++ b/src/user/lib/libc/std/stdlib.c
@@ -1,8 +1,38 @@
#include <stdlib.h>
#include <stdio.h>
+#include <ctype.h>
volatile int errno;
+void exit(int k) {
+ process_exit(k);
+}
+
void abort() {
- process_exit(100 + errno);
+ process_exit(300 + errno);
+}
+
+
+// Random generator
+
+static unsigned int rnd;
+
+void srand(unsigned int l) {
+ rnd = l;
+}
+
+int rand() {
+ rnd = rnd * 1103515245 + 12345;
+ return (unsigned int)(rnd / 65536) % (RAND_MAX + 1);
+}
+
+// ASCII to int
+
+int atoi(char *s) {
+ int r = 0;
+ while (*s >= '0' && *s <= '9') {
+ r *= 10;
+ r += (*s) - '0';
+ };
+ return r;
}