summaryrefslogtreecommitdiff
path: root/LibC
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-03-25 13:03:49 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-03-25 13:03:49 +0100
commit500df578fe5b24d14062d030c5628cbb4b69d3a6 (patch)
treee484af9a08e7463e95e947f8e8af3b94fb3d6645 /LibC
parent108b663618e893c804c150205a21f2e8d95088c2 (diff)
downloadserenity-500df578fe5b24d14062d030c5628cbb4b69d3a6.zip
LibGUI+Kernel: Add a GLock class (userspace mutex.)
It's basically a userspace port of the kernel's Lock class. Added gettid() and donate() syscalls to support the timeslice donation feature we already enjoyed in the kernel.
Diffstat (limited to 'LibC')
-rw-r--r--LibC/errno_numbers.h3
-rw-r--r--LibC/string.cpp1
-rw-r--r--LibC/unistd.cpp12
-rw-r--r--LibC/unistd.h2
4 files changed, 17 insertions, 1 deletions
diff --git a/LibC/errno_numbers.h b/LibC/errno_numbers.h
index 710982f205..2527d44e97 100644
--- a/LibC/errno_numbers.h
+++ b/LibC/errno_numbers.h
@@ -70,4 +70,5 @@
#define ETIMEDOUT 67
#define EPROTOTYPE 68
#define EINPROGRESS 69
-#define EMAXERRNO 70
+#define ENOTHREAD 70
+#define EMAXERRNO 71
diff --git a/LibC/string.cpp b/LibC/string.cpp
index 02a5dba3f5..eed302db5f 100644
--- a/LibC/string.cpp
+++ b/LibC/string.cpp
@@ -312,6 +312,7 @@ const char* sys_errlist[] = {
"Timed out",
"Wrong protocol type",
"Operation in progress",
+ "No such thread",
"The highest errno +1 :^)",
};
diff --git a/LibC/unistd.cpp b/LibC/unistd.cpp
index 9082d5d92a..6d820d6646 100644
--- a/LibC/unistd.cpp
+++ b/LibC/unistd.cpp
@@ -421,4 +421,16 @@ int ftruncate(int fd, off_t length)
ASSERT_NOT_REACHED();
}
+int gettid()
+{
+ int rc = syscall(SC_gettid);
+ __RETURN_WITH_ERRNO(rc, rc, -1);
+}
+
+int donate(int tid)
+{
+ int rc = syscall(SC_donate, tid);
+ __RETURN_WITH_ERRNO(rc, rc, -1);
+}
+
}
diff --git a/LibC/unistd.h b/LibC/unistd.h
index 5f38e15b63..9114572fdc 100644
--- a/LibC/unistd.h
+++ b/LibC/unistd.h
@@ -14,6 +14,8 @@ __BEGIN_DECLS
extern char** environ;
+int gettid();
+int donate(int tid);
int create_thread(int(*)(void*), void*);
int create_shared_buffer(pid_t peer_pid, int, void** buffer);
void* get_shared_buffer(int shared_buffer_id);