summaryrefslogtreecommitdiff
path: root/euler/include
diff options
context:
space:
mode:
Diffstat (limited to 'euler/include')
-rw-r--r--euler/include/euler/start_process.hpp30
-rw-r--r--euler/include/euler/syscall.hpp28
-rw-r--r--euler/include/type_traits23
-rw-r--r--euler/include/utility12
-rw-r--r--euler/include/vector62
5 files changed, 155 insertions, 0 deletions
diff --git a/euler/include/euler/start_process.hpp b/euler/include/euler/start_process.hpp
new file mode 100644
index 0000000..00ebbab
--- /dev/null
+++ b/euler/include/euler/start_process.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <euler/syscall.hpp>
+#include <vector>
+
+namespace euler {
+
+ struct start_process {
+
+ private:
+ const char *path;
+ uint64_t path_len;
+ std::vector<__euler_env_var_spec> env_var_specs;
+ std::vector<__euler_gift_stream_spec> gift_stream_specs;
+
+ public:
+ //path needs to stay valid through any call to start
+ start_process(const char *path);
+
+ //name and value need to stay valid through any call to start
+ void add_env_variable(const char *name, const char *value);
+
+ void gift_stream(
+ __euler_stream_handle to_gifter, __euler_stream_handle to_giftee);
+
+ __euler_stream_result start(__euler_process_handle &handle_out);
+
+ };
+
+}
diff --git a/euler/include/euler/syscall.hpp b/euler/include/euler/syscall.hpp
index 761dbcc..981925f 100644
--- a/euler/include/euler/syscall.hpp
+++ b/euler/include/euler/syscall.hpp
@@ -27,6 +27,7 @@ enum __euler_seek_from : uint8_t {
};
typedef uint64_t __euler_stream_handle;
+typedef uint64_t __euler_process_handle;
extern "C" __euler_stream_result __euler_open_file(
const char *path, uint64_t path_len, __euler_stream_handle &handle_out,
@@ -72,3 +73,30 @@ enum __euler_input_packet_type : uint8_t {
extern "C" __euler_input_packet_type __euler_get_input_packet(
__euler_mouse_buttons &buttons_out, int16_t &x_change_out,
int16_t &y_change_out, uint32_t &keyboard_packet_out);
+
+struct [[gnu::packed]] __euler_env_var_spec {
+ uint64_t name_len;
+ const char *name;
+ uint64_t value_len;
+ const char *value;
+};
+
+struct [[gnu::packed]] __euler_gift_stream_spec {
+ __euler_stream_handle stream_handle_to_gifter;
+ __euler_stream_handle stream_handle_to_giftee;
+};
+
+struct [[gnu::packed]] __euler_process_start_info {
+ uint64_t file_path_length;
+ const char *file_path;
+ uint64_t env_var_count;
+ const __euler_env_var_spec *env_vars;
+ uint64_t gift_stream_count;
+ const __euler_gift_stream_spec *gift_streams;
+};
+
+extern "C" __euler_stream_result __euler_start_process(
+ const __euler_process_start_info &info, __euler_process_handle &handle_out);
+
+extern "C" __euler_stream_result __euler_get_other_end_process_handle(
+ __euler_stream_handle handle_in, __euler_process_handle &handle_out);
diff --git a/euler/include/type_traits b/euler/include/type_traits
new file mode 100644
index 0000000..fcea013
--- /dev/null
+++ b/euler/include/type_traits
@@ -0,0 +1,23 @@
+#pragma once
+
+namespace std {
+
+ template <class t>
+ struct remove_reference {
+ typedef t type;
+ };
+
+ template <class t>
+ struct remove_reference<t &> {
+ typedef t type;
+ };
+
+ template <class t>
+ struct remove_reference<t &&> {
+ typedef t type;
+ };
+
+ template <class t>
+ using remove_reference_t = typename remove_reference<t>::type;
+
+}
diff --git a/euler/include/utility b/euler/include/utility
new file mode 100644
index 0000000..23648c4
--- /dev/null
+++ b/euler/include/utility
@@ -0,0 +1,12 @@
+#pragma once
+
+#include <type_traits>
+
+namespace std {
+
+ template <class t>
+ constexpr std::remove_reference_t<t> &&move(t &&x) {
+ return static_cast<std::remove_reference_t<t> &&>(x);
+ }
+
+}
diff --git a/euler/include/vector b/euler/include/vector
new file mode 100644
index 0000000..f5083ed
--- /dev/null
+++ b/euler/include/vector
@@ -0,0 +1,62 @@
+#pragma once
+
+#include <stddef.h>
+#include <utility>
+
+namespace std {
+
+ template <class t>
+ class vector {
+
+ t *buffer;
+ size_t buffer_length;//always positive
+ size_t count;
+
+ public:
+ vector() : buffer(new t[16]), buffer_length(16), count(0) {}
+
+ ~vector() {
+ delete[] buffer;
+ }
+
+ t &operator[](size_t pos) {
+ return buffer[pos];
+ }
+
+ const t &operator[](size_t pos) const {
+ return buffer[pos];
+ }
+
+ t *data() {
+ return buffer;
+ }
+
+ const t *data() const {
+ return buffer;
+ }
+
+ size_t size() const {
+ return count;
+ }
+
+ void reserve(size_t new_length) {
+ if (new_length <= buffer_length)
+ return;
+ t *new_buffer = new t[new_length];
+ for (size_t i = 0; i < count; ++i)
+ new_buffer[i] = std::move(buffer[i]);
+ delete[] buffer;
+ buffer = new_buffer;
+ buffer_length = new_length;
+ }
+
+ void push_back(t &&value) {
+ if (count == buffer_length)
+ reserve(count * 2);
+ buffer[count++] = std::move(value);
+ }
+
+ //TODO
+ };
+
+}