summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-05 13:38:32 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-05 13:38:32 +0100
commitddb13ae6d87f92264e48ebd3bdbe1ded33437600 (patch)
tree7367dd766afdfc956511c88dbc0db5799a1c657d
parentcaff611ca3bc90b4cf7ba93491d74e8ed975d44e (diff)
downloadserenity-ddb13ae6d87f92264e48ebd3bdbe1ded33437600.zip
LibC: Add some integer functionality needed for NASM.
-rw-r--r--LibC/inttypes.h6
-rw-r--r--LibC/stdint.h2
-rw-r--r--LibC/stdlib.cpp16
-rw-r--r--LibC/stdlib.h5
4 files changed, 29 insertions, 0 deletions
diff --git a/LibC/inttypes.h b/LibC/inttypes.h
index 9a6118bd85..1510aa0920 100644
--- a/LibC/inttypes.h
+++ b/LibC/inttypes.h
@@ -1 +1,7 @@
+#pragma once
+
#include <stdint.h>
+
+#define PRId8 "d"
+#define PRId16 "d"
+#define PRId32 "d"
diff --git a/LibC/stdint.h b/LibC/stdint.h
index 551bef265c..29af12f654 100644
--- a/LibC/stdint.h
+++ b/LibC/stdint.h
@@ -4,10 +4,12 @@
__BEGIN_DECLS
+typedef unsigned long long int uint64_t;
typedef unsigned int uint32_t;
typedef unsigned short uint16_t;
typedef unsigned char uint8_t;
+typedef signed long long int int64_t;
typedef signed int int32_t;
typedef signed short int16_t;
typedef signed char int8_t;
diff --git a/LibC/stdlib.cpp b/LibC/stdlib.cpp
index 74fcfd9436..7afa23b98a 100644
--- a/LibC/stdlib.cpp
+++ b/LibC/stdlib.cpp
@@ -267,4 +267,20 @@ int system(const char* command)
return execl("/bin/sh", "sh", "-c", command, nullptr);
}
+div_t div(int numerator, int denominator)
+{
+ div_t result;
+ result.quot = numerator / denominator;
+ result.rem = numerator % denominator;
+ return result;
+}
+
+ldiv_t ldiv(long numerator, long denominator)
+{
+ ldiv_t result;
+ result.quot = numerator / denominator;
+ result.rem = numerator % denominator;
+ return result;
+}
+
}
diff --git a/LibC/stdlib.h b/LibC/stdlib.h
index 26b3a8739d..27f4d2dc81 100644
--- a/LibC/stdlib.h
+++ b/LibC/stdlib.h
@@ -30,5 +30,10 @@ void srand(unsigned seed);
long int random();
void srandom(unsigned seed);
+typedef struct { int quot; int rem; } div_t;
+div_t div(int, int);
+typedef struct { long quot; long rem; } ldiv_t;
+ldiv_t ldiv(long, long);
+
__END_DECLS