aboutsummaryrefslogtreecommitdiff
path: root/libc/inc/sys.h
diff options
context:
space:
mode:
Diffstat (limited to 'libc/inc/sys.h')
-rw-r--r--libc/inc/sys.h38
1 files changed, 22 insertions, 16 deletions
diff --git a/libc/inc/sys.h b/libc/inc/sys.h
index 3145432..14f83dd 100644
--- a/libc/inc/sys.h
+++ b/libc/inc/sys.h
@@ -20,11 +20,6 @@ enum sys {
SYS_EXIT, // Exit current process // TODO: Free all memory of process
SYS_YIELD, // Switch to next process
SYS_TIME, // Get kernel time
- SYS_REGISTER, // Register for event
- SYS_UNREGISTER, // Unregister event
- SYS_SEND, // Send message to process
- SYS_RECEIVE, // Receive message (non-blocking/sync)
- SYS_GETPID, // Get the process ID
SYS_NET_OPEN, // Open network socket
SYS_NET_CLOSE, // Close network socket
SYS_NET_CONNECT, // Connect to destination
@@ -94,22 +89,33 @@ int sysv(enum sys num, ...);
#define yield() (int)sys0(SYS_YIELD)
#define time() (u32) sys0(SYS_TIME)
-#define event_register(id) sys1(SYS_REGISTER, (int)(id))
-#define event_unregister(id) sys1(SYS_UNREGISTER, (int)(id))
+static inline u32 getpid()
+{
+ u32 buf = 0;
+ read("/proc/self/pid", &buf, 0, sizeof(buf));
+ return buf;
+}
-#define msg_send(pid, type, msg) sys3(SYS_SEND, (int)(pid), (int)(type), (int)(msg))
-#define msg_receive() (struct message *)sys0(SYS_RECEIVE)
-#define getpid() (int)sys0(SYS_GETPID)
-static inline struct message *msg_receive_loop()
+// Hacky one-digit solution - TODO!
+#include <mem.h>
+#include <str.h>
+static inline u32 pidof(const char *name)
{
- struct message *msg;
- while (!(msg = msg_receive()))
- yield();
- return msg;
+ u32 curr = 1;
+ char buf[32] = { 0 };
+ char *path = (char *)"/proc/1/name"; // AAH
+ while (read(path, buf, 0, 32)) {
+ if (!strcmp(name, buf))
+ return curr;
+
+ curr++;
+ path[7]++;
+ }
+
+ return 0;
}
// Simple read wrapper
-#include <mem.h>
static inline void *sread(const char *path)
{
struct stat s = { 0 };