]> xenbits.xensource.com Git - unikraft/libs/pthread-embedded.git/commitdiff
lib/pthread-embedded: Support for uksignal RELEASE-0.5
authorBernard Rizzo <b.rizzo@student.uliege.be>
Sat, 16 Jan 2021 01:52:32 +0000 (02:52 +0100)
committerSharan Santhanam <sharan.santhanam@neclab.eu>
Wed, 3 Feb 2021 17:47:35 +0000 (23:17 +0530)
This patch is an update of the original.

Signed-off-by: Mihai Pogonaru <pogonarumihai@gmail.com>
Signed-off-by: Teodora Serbanescu <teo.serbanescu16@gmail.com>
Signed-off-by: Felipe Huici <felipe.huici@neclab.eu>
Reviewed-by: ARGINT DRAGOS IULIAN <dragosargint21@gmail.com>
Config.uk
include/pte_osal.h
include/pte_types.h
patches/0012-Add_pthread_kill_when_uk_signals_are_enabled.patch [new file with mode: 0644]
pte_osal.c
pthread_sigmask.c

index 3587c5573a6b8053ab84726610e26b0de7107e73..124a23c176838b089c646118b53e89eef02a7dc4 100644 (file)
--- a/Config.uk
+++ b/Config.uk
@@ -5,6 +5,7 @@ menuconfig LIBPTHREAD_EMBEDDED
        select LIBUKDEBUG
        select LIBUKALLOC
        select LIBUKSCHED
+       select LIBUKSIGNAL
        select LIBUKLOCK
        select LIBUKLOCK_MUTEX
        select LIBUKLOCK_SEMAPHORE
index bcf537452f5b9d09eb1f72a2476f76580bb29b56..759cb1b48f04201e7ce1fcf072827b7228e4597b 100644 (file)
@@ -4,6 +4,10 @@
 #include <uk/mutex.h>
 #include <uk/semaphore.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef struct uk_thread* pte_osThreadHandle;
 typedef struct uk_semaphore *pte_osSemaphoreHandle;
 typedef struct uk_mutex *pte_osMutexHandle;
@@ -11,6 +15,11 @@ typedef struct uk_mutex *pte_osMutexHandle;
 #define OS_MAX_SIMUL_THREADS \
        CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS
 
+#ifdef __cplusplus
+}
+#endif
+
+
 #include "pte_generic_osal.h"
 
 #endif /* __PTE_OSAL_H__ */
index c9081fa0aee94a1c8f567b43629698e7807a442d..817e313613e1563d05c416113d98988092e8a404 100644 (file)
@@ -3,8 +3,16 @@
 
 #include <sys/timeb.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef unsigned int tid_t;
 
 typedef int pid_t;
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __PTE_TYPES_H__ */
diff --git a/patches/0012-Add_pthread_kill_when_uk_signals_are_enabled.patch b/patches/0012-Add_pthread_kill_when_uk_signals_are_enabled.patch
new file mode 100644 (file)
index 0000000..7b3732c
--- /dev/null
@@ -0,0 +1,24 @@
+diff --git a/pthread_kill.c b/pthread_kill.c
+index 3a6daf6..4ea7448 100644
+--- a/pthread_kill.c
++++ b/pthread_kill.c
+@@ -47,7 +47,9 @@
+ #include "pthread.h"
+ #include "implement.h"
+
+-#ifdef __hermit__
++#include <uk/config.h>
++
++#if CONFIG_LIBUKSIGNAL
+ int pte_kill(pte_osThreadHandle threadId, int sig);
+ #endif
+
+@@ -98,7 +100,7 @@ pthread_kill (pthread_t thread, int sig)
+
+   pte_osMutexUnlock(pte_thread_reuse_lock);
+
+-#ifdef __hermit__
++#if CONFIG_LIBUKSIGNAL
+   result = pte_kill(tp->threadId, sig);
+ #else
+   if (0 == result && 0 != sig)
index 640c3e4c2892c1ebf18f42bb2d5bb108433b3d9c..d884ee55043cc28c8531a06a21a49e6a5c063b51 100644 (file)
@@ -103,6 +103,19 @@ out:
        return result;
 }
 
+/***************************************************************************
+ *
+ * Signal handling
+ *
+ **************************************************************************/
+#if CONFIG_LIBUKSIGNAL
+int pte_kill(pte_osThreadHandle threadId, int sig)
+{
+       return uk_sig_thread_kill(threadId, sig);
+}
+#endif
+
+
 /****************************************************************************
  *
  * Threads
@@ -162,6 +175,12 @@ pte_osResult pte_osThreadCreate(pte_osThreadEntryPoint entry_point,
                return PTE_OS_NO_RESOURCES;
        }
 
+#if CONFIG_LIBUKSIGNAL
+       /* inherit signal mask */
+       ptd->uk_thread->signals_container.mask =
+               uk_thread_current()->signals_container.mask;
+#endif
+
        ptd->uk_thread->prv = ptd;
 
        *ph = ptd->uk_thread;
index 7e12e2b6e86cf226025607f2294804738707c486..e447f016b575b96c0d59642c74b9be17dc1f42f2 100644 (file)
@@ -21,9 +21,9 @@
 
 #include <uk/print.h>
 #include <signal.h>
+#include <uk/uk_signal.h>
 
 int pthread_sigmask(int how, const sigset_t *set, sigset_t *oldset)
 {
-       WARN_STUBBED();
-       return 0;
+       return uk_thread_sigmask(how, set, oldset);
 }