summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaweł Cholewa <DaMcpg@protonmail.com>2019-11-08 21:39:31 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-09 20:52:34 +0100
commitc2a8c4cedd8c682fb861b446d4bf1f151e97ee2d (patch)
tree71a6ea87295d8ef75657132b9cf7e0bb1fb58a4b
parentaba6e6de6a60f216548f0560ce719745998ee564 (diff)
downloadserenity-c2a8c4cedd8c682fb861b446d4bf1f151e97ee2d.zip
LibC: Minor changes to make nasm work
* Added some missing macros to headers * Stubbed strftime() time function to not assert * Added "rt" mode to fopen(), working just like "r" or "rb"
-rw-r--r--Libraries/LibC/bits/stdint.h9
-rw-r--r--Libraries/LibC/inttypes.h2
-rw-r--r--Libraries/LibC/stdio.cpp4
-rw-r--r--Libraries/LibC/stdio.h1
-rw-r--r--Libraries/LibC/time.cpp7
5 files changed, 20 insertions, 3 deletions
diff --git a/Libraries/LibC/bits/stdint.h b/Libraries/LibC/bits/stdint.h
index 8e1fbcba4d..4fc2865904 100644
--- a/Libraries/LibC/bits/stdint.h
+++ b/Libraries/LibC/bits/stdint.h
@@ -101,6 +101,15 @@ typedef __INTMAX_TYPE__ intmax_t;
#define UINT_LEAST32_MAX UINT32_MAX
#define UINT_LEAST64_MAX UINT64_MAX
+#define INT8_C(x) x
+#define UINT8_C(x) x
+
+#define INT16_C(x) x
+#define UINT16_C(x) x
+
+#define INT32_C(x) x
+#define UINT32_C(x) x
+
#define INT64_C(x) x##LL
#define UINT64_C(x) x##ULL
diff --git a/Libraries/LibC/inttypes.h b/Libraries/LibC/inttypes.h
index 7f27521caa..fb6b932765 100644
--- a/Libraries/LibC/inttypes.h
+++ b/Libraries/LibC/inttypes.h
@@ -17,7 +17,9 @@
#define PRIx8 "b"
#define PRIx16 "w"
#define PRIx32 "x"
+#define PRIX32 "X"
#define PRIx64 "llx"
+#define PRIX64 "llX"
#define __PRI64_PREFIX "ll"
#define __PRIPTR_PREFIX
diff --git a/Libraries/LibC/stdio.cpp b/Libraries/LibC/stdio.cpp
index ae9872c877..7a1cdc9069 100644
--- a/Libraries/LibC/stdio.cpp
+++ b/Libraries/LibC/stdio.cpp
@@ -437,7 +437,9 @@ void perror(const char* s)
FILE* fopen(const char* pathname, const char* mode)
{
int flags = 0;
- if (!strcmp(mode, "r") || !strcmp(mode, "rb"))
+ // NOTE: rt is a non-standard mode which opens a file for read, explicitly
+ // specifying that it's a text file
+ if (!strcmp(mode, "r") || !strcmp(mode, "rb") || !strcmp(mode, "rt"))
flags = O_RDONLY;
else if (!strcmp(mode, "r+") || !strcmp(mode, "rb+"))
flags = O_RDWR;
diff --git a/Libraries/LibC/stdio.h b/Libraries/LibC/stdio.h
index 18214fb0e8..dd71933720 100644
--- a/Libraries/LibC/stdio.h
+++ b/Libraries/LibC/stdio.h
@@ -7,6 +7,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
+#define FILENAME_MAX 1024
#define BUFSIZ 1024
__BEGIN_DECLS
diff --git a/Libraries/LibC/time.cpp b/Libraries/LibC/time.cpp
index 8a301b3bb5..cdc48f0f08 100644
--- a/Libraries/LibC/time.cpp
+++ b/Libraries/LibC/time.cpp
@@ -4,6 +4,7 @@
#include <sys/time.h>
#include <sys/times.h>
#include <time.h>
+#include <string.h>
extern "C" {
@@ -96,9 +97,11 @@ char* asctime(const struct tm*)
ASSERT_NOT_REACHED();
}
-size_t strftime(char*, size_t, const char*, const struct tm*)
+size_t strftime(char* destination, size_t, const char*, const struct tm*)
{
- ASSERT_NOT_REACHED();
+ // FIXME: Stubbed function to make nasm work. Should be properly implemented
+ strcpy(destination, "strftime_unimplemented");
+ return strlen("strftime_unimplemented");
}
long timezone;