Skip to content

Commit

Permalink
lib/pthread-embedded: Support for uksignal
Browse files Browse the repository at this point in the history
This patch is an update of the original.

Signed-off-by: Mihai Pogonaru <[email protected]>
Signed-off-by: Teodora Serbanescu <[email protected]>
Signed-off-by: Felipe Huici <[email protected]>
Reviewed-by: ARGINT DRAGOS IULIAN <[email protected]>
  • Loading branch information
Bernard Rizzo authored and Sharan Santhanam committed Feb 3, 2021
1 parent 49a2433 commit 2dd7129
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions Config.uk
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ menuconfig LIBPTHREAD_EMBEDDED
select LIBUKDEBUG
select LIBUKALLOC
select LIBUKSCHED
select LIBUKSIGNAL
select LIBUKLOCK
select LIBUKLOCK_MUTEX
select LIBUKLOCK_SEMAPHORE
Expand Down
9 changes: 9 additions & 0 deletions include/pte_osal.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,22 @@
#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;

#define OS_MAX_SIMUL_THREADS \
CONFIG_LIBPTHREAD_EMBEDDED_MAX_SIMUL_THREADS

#ifdef __cplusplus
}
#endif


#include "pte_generic_osal.h"

#endif /* __PTE_OSAL_H__ */
8 changes: 8 additions & 0 deletions include/pte_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -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__ */
24 changes: 24 additions & 0 deletions patches/0012-Add_pthread_kill_when_uk_signals_are_enabled.patch
Original file line number Diff line number Diff line change
@@ -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)
19 changes: 19 additions & 0 deletions pte_osal.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,19 @@ pte_osResult pte_osInit(void)
return result;
}

/***************************************************************************
*
* Signal handling
*
**************************************************************************/
#if CONFIG_LIBUKSIGNAL
int pte_kill(pte_osThreadHandle threadId, int sig)
{
return uk_sig_thread_kill(threadId, sig);
}
#endif


/****************************************************************************
*
* Threads
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions pthread_sigmask.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 2dd7129

Please sign in to comment.