[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[UNIKRAFT/LIBPTHREAD-EMBEDDED PATCH] Add support for the uksignal Unikraft internal library.



From: Mihai Pogonaru <pogonarumihai@xxxxxxxxx>

Signed-off-by: Mihai Pogonaru <pogonarumihai@xxxxxxxxx>
Signed-off-by: Teodora Serbanescu <teo.serbanescu16@xxxxxxxxx>
Signed-off-by: Felipe Huici <felipe.huici@xxxxxxxxx>
---
 Makefile.uk                                   |  2 ++
 include/pte_osal.h                            |  8 +++++++
 include/pte_types.h                           |  8 +++++++
 ...ead_kill_when_uk_signals_are_enabled.patch | 24 +++++++++++++++++++
 pte_osal.c                                    | 20 ++++++++++++++++
 5 files changed, 62 insertions(+)
 create mode 100644 
patches/0010-Add_pthread_kill_when_uk_signals_are_enabled.patch

diff --git a/Makefile.uk b/Makefile.uk
index b9b7456..2087641 100644
--- a/Makefile.uk
+++ b/Makefile.uk
@@ -67,7 +67,9 @@ LIBPTHREAD-EMBEDDED_EXPORTS = 
$(LIBPTHREAD-EMBEDDED_BASE)/exportsyms.uk
 LIBPTHREAD-EMBEDDED_SRCS-y += $(LIBPTHREAD-EMBEDDED_BASE)/pte_osal.c|glue
 LIBPTHREAD-EMBEDDED_SRCS-y += $(LIBPTHREAD-EMBEDDED_BASE)/attributes.c|glue
 LIBPTHREAD-EMBEDDED_SRCS-y += $(LIBPTHREAD-EMBEDDED_BASE)/pthread_atfork.c|glue
+ifneq ($(CONFIG_LIBUKSIGNAL),y)
 LIBPTHREAD-EMBEDDED_SRCS-y += 
$(LIBPTHREAD-EMBEDDED_BASE)/pthread_sigmask.c|glue
+endif
 LIBPTHREAD-EMBEDDED_SRCS-y += 
$(LIBPTHREAD-EMBEDDED_BASE)/pthread_condattr.c|glue
 
 
################################################################################
diff --git a/include/pte_osal.h b/include/pte_osal.h
index bcf5374..34122ea 100644
--- a/include/pte_osal.h
+++ b/include/pte_osal.h
@@ -4,10 +4,18 @@
 #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;
 
+#ifdef __cplusplus
+}
+#endif
+
 #define OS_MAX_SIMUL_THREADS \
        CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS
 
diff --git a/include/pte_types.h b/include/pte_types.h
index c9081fa..817e313 100644
--- a/include/pte_types.h
+++ b/include/pte_types.h
@@ -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/0010-Add_pthread_kill_when_uk_signals_are_enabled.patch 
b/patches/0010-Add_pthread_kill_when_uk_signals_are_enabled.patch
new file mode 100644
index 0000000..cf30aca
--- /dev/null
+++ b/patches/0010-Add_pthread_kill_when_uk_signals_are_enabled.patch
@@ -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)
diff --git a/pte_osal.c b/pte_osal.c
index cfd5b3b..4bd9bf0 100644
--- a/pte_osal.c
+++ b/pte_osal.c
@@ -29,6 +29,9 @@
 #include <uk/arch/time.h>
 #include <uk/arch/atomic.h>
 #include <uk/print.h>
+#if CONFIG_LIBUKSIGNAL
+#include <uk/uk_signal.h>
+#endif
 #include <uk/thread.h>
 #include "pte_osal.h"
 #include "pthread.h"
@@ -102,6 +105,18 @@ 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
@@ -161,6 +176,11 @@ 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;
-- 
2.20.1




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.