summaryrefslogtreecommitdiff
path: root/euler/include
diff options
context:
space:
mode:
Diffstat (limited to 'euler/include')
-rw-r--r--euler/include/ctime20
-rw-r--r--euler/include/euler/syscall.hpp5
-rw-r--r--euler/include/std/string.hpp10
3 files changed, 35 insertions, 0 deletions
diff --git a/euler/include/ctime b/euler/include/ctime
new file mode 100644
index 0000000..9cf1b1f
--- /dev/null
+++ b/euler/include/ctime
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <cstdint>
+
+typedef uint64_t time_t;
+
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
+
+time_t time(time_t *arg);
+tm *gmtime(const time_t *time);
diff --git a/euler/include/euler/syscall.hpp b/euler/include/euler/syscall.hpp
index 4a3daa4..043dcd4 100644
--- a/euler/include/euler/syscall.hpp
+++ b/euler/include/euler/syscall.hpp
@@ -159,6 +159,11 @@ namespace euler::syscall {
void set_thread_name(const std::string &name);
+ void sleep(uint64_t mibiseconds);
+
+ //out is mibiseconds since january 1st 2000
+ uint64_t get_time();
+
}
#include <string>
diff --git a/euler/include/std/string.hpp b/euler/include/std/string.hpp
index 505ee69..c5a3d99 100644
--- a/euler/include/std/string.hpp
+++ b/euler/include/std/string.hpp
@@ -12,6 +12,8 @@ namespace std {
std::vector<char> characters;
public:
+ static const size_t npos = (size_t)-1;
+
constexpr string() : characters({'\0'}) {}
constexpr string(const string &other)
@@ -74,6 +76,14 @@ namespace std {
return characters[pos];
}
+ constexpr string &erase(size_t index = 0, size_t count = npos) {
+ count = std::min(count, size() - index);
+ for (size_t i = index; i + count < size(); ++i)
+ characters[i] = characters[i + count];
+ resize(size() - count);
+ return *this;
+ }
+
};
}