lib/thread: hide low-level details from applications

evl_get_current() contains implementation details which are definitely
not part of the API and the way this works should not be exposed.

Signed-off-by: Philippe Gerum <rpm@xenomai.org>
This commit is contained in:
Philippe Gerum 2020-12-13 12:29:25 +01:00
parent 6c7838c862
commit 04db253a39
6 changed files with 23 additions and 20 deletions

View File

@ -12,6 +12,9 @@
#include <pthread.h>
#include <stdio.h>
/* Enable dlopen() on libeshi.so. */
#define EVL_TLS_MODEL "global-dynamic"
static inline
void timespec_add(struct timespec *r, const struct timespec *t)
{

View File

@ -10,6 +10,7 @@
#include <stdio.h>
#include <evl/thread.h>
#include <evl/proxy.h>
#include "internal.h"
static __thread __attribute__ ((tls_model (EVL_TLS_MODEL)))
char fmt_buf[1024];

View File

@ -12,9 +12,6 @@
#include <stdbool.h>
#include <evl/syscall.h>
/* Enable dlopen() on libeshi.so. */
#define EVL_TLS_MODEL "global-dynamic"
#define EVL_STACK_DEFAULT \
({ \
int __ret = PTHREAD_STACK_MIN; \

View File

@ -17,9 +17,6 @@
#include <uapi/evl/sched.h>
#include <uapi/evl/factory.h>
/* Enable dlopen() on libevl.so. */
#define EVL_TLS_MODEL "global-dynamic"
#define EVL_STACK_DEFAULT \
({ \
int __ret = PTHREAD_STACK_MIN; \
@ -35,20 +32,6 @@
extern "C" {
#endif
extern __thread __attribute__ ((tls_model (EVL_TLS_MODEL)))
struct evl_user_window *evl_current_window;
static inline int evl_get_current_mode(void)
{
return evl_current_window ?
evl_current_window->state : T_INBAND;
}
static inline bool evl_is_inband(void)
{
return !!(evl_get_current_mode() & T_INBAND);
}
int evl_attach_thread(int flags, const char *fmt, ...);
int evl_detach_thread(int flags);
@ -64,6 +47,8 @@ int evl_switch_oob(void);
int evl_switch_inband(void);
bool evl_is_inband(void);
int evl_get_state(int efd, struct evl_thread_state *statebuf);
int evl_unblock_thread(int efd);

View File

@ -84,12 +84,24 @@
__ret ? -errno : 0; \
})
/* Enable dlopen() on libevl.so. */
#define EVL_TLS_MODEL "global-dynamic"
extern __thread __attribute__ ((tls_model (EVL_TLS_MODEL)))
fundle_t evl_current;
extern __thread __attribute__ ((tls_model (EVL_TLS_MODEL)))
int evl_efd;
extern __thread __attribute__ ((tls_model (EVL_TLS_MODEL)))
struct evl_user_window *evl_current_window;
static inline int evl_get_current_mode(void)
{
return evl_current_window ?
evl_current_window->state : T_INBAND;
}
static inline fundle_t evl_get_current(void)
{
return evl_current;

View File

@ -169,6 +169,11 @@ int evl_get_self(void)
return evl_efd;
}
bool evl_is_inband(void)
{
return !!(evl_get_current_mode() & T_INBAND);
}
int evl_switch_oob(void)
{
int ret;