summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/init/stdlib.c12
-rw-r--r--src/init/stdlib.h7
-rw-r--r--src/init/tar.c14
3 files changed, 20 insertions, 13 deletions
diff --git a/src/init/stdlib.c b/src/init/stdlib.c
new file mode 100644
index 0000000..6ed5a0a
--- /dev/null
+++ b/src/init/stdlib.c
@@ -0,0 +1,12 @@
+#include <init/stdlib.h>
+
+int memcmp(const void *s1, const void *s2, size_t n) {
+ const unsigned char *c1 = s1, *c2 = s2;
+ for (size_t i = 0; i < n; i++) {
+ if (c1[i] != c2[i]) {
+ if (c1[i] < c2[i]) return -1;
+ else return 1;
+ }
+ }
+ return 0;
+}
diff --git a/src/init/stdlib.h b/src/init/stdlib.h
new file mode 100644
index 0000000..1cabc7a
--- /dev/null
+++ b/src/init/stdlib.h
@@ -0,0 +1,7 @@
+#pragma once
+#include <stddef.h>
+
+// TODO since this is shared with the kernel, maybe i could turn this into an
+// stb-style header file
+
+int memcmp(const void *s1, const void *s2, size_t n);
diff --git a/src/init/tar.c b/src/init/tar.c
index 24adfce..a2b03df 100644
--- a/src/init/tar.c
+++ b/src/init/tar.c
@@ -1,11 +1,10 @@
+#include <init/stdlib.h>
#include <shared/syscalls.h>
#include <stdint.h>
extern int tty_fd;
static int oct_parse(char *str, size_t len);
-int memcmp(const void *s1, const void *s2, size_t n); // TODO move to a dedicated file
-
void tar_driver(void *base) {
// iterate over all sectors, printing filenames
@@ -30,14 +29,3 @@ static int oct_parse(char *str, size_t len) {
}
return res;
}
-
-int memcmp(const void *s1, const void *s2, size_t n) {
- const unsigned char *c1 = s1, *c2 = s2;
- for (size_t i = 0; i < n; i++) {
- if (c1[i] != c2[i]) {
- if (c1[i] < c2[i]) return -1;
- else return 1;
- }
- }
- return 0;
-}