Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions hal/armv7a/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@

#define GETFROMSTACK(ustack, t, v, n) \
do { \
ustack = (void *)(((addr_t)ustack + sizeof(t) - 1) & ~(sizeof(t) - 1)); \
(v) = *(t *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(t)); \
ustack = (void *)(((addr_t)ustack + sizeof(typeof(v)) - 1) & ~(sizeof(typeof(v)) - 1)); \
(v) = *(typeof(v) *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(typeof(v))); \
} while (0)

typedef struct _cpu_context_t {
Expand Down
6 changes: 3 additions & 3 deletions hal/armv7m/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@

#define GETFROMSTACK(ustack, t, v, n) \
do { \
ustack = (void *)(((ptr_t)ustack + sizeof(t) - 1) & ~(sizeof(t) - 1)); \
(v) = *(t *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(t)); \
ustack = (void *)(((ptr_t)ustack + sizeof(typeof(v)) - 1) & ~(sizeof(typeof(v)) - 1)); \
(v) = *(typeof(v) *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(typeof(v))); \
} while (0)


Expand Down
6 changes: 3 additions & 3 deletions hal/armv8m/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@

#define GETFROMSTACK(ustack, t, v, n) \
do { \
ustack = (void *)(((ptr_t)ustack + sizeof(t) - 1) & ~(sizeof(t) - 1)); \
(v) = *(t *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(t)); \
ustack = (void *)(((ptr_t)ustack + sizeof(typeof(v)) - 1) & ~(sizeof(typeof(v)) - 1)); \
(v) = *(typeof(v) *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(typeof(v))); \
} while (0)


Expand Down
6 changes: 3 additions & 3 deletions hal/armv8r/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@

#define GETFROMSTACK(ustack, t, v, n) \
do { \
ustack = (void *)(((addr_t)ustack + sizeof(t) - 1) & ~(sizeof(t) - 1)); \
(v) = *(t *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(t)); \
ustack = (void *)(((addr_t)ustack + sizeof(typeof(v)) - 1) & ~(sizeof(typeof(v)) - 1)); \
(v) = *(typeof(v) *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(typeof(v))); \
} while (0)

typedef struct _cpu_context_t {
Expand Down
5 changes: 2 additions & 3 deletions hal/ia32/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,11 @@
do { \
if (n == 0) \
ustack += 4; \
v = *(t *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(t)); \
v = *(typeof(v) *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(typeof(v))); \
} while (0)



#pragma pack(push, 1)

typedef struct {
Expand Down
6 changes: 3 additions & 3 deletions hal/riscv64/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@

#define GETFROMSTACK(ustack, t, v, n) \
do { \
ustack = (void *)(((addr_t)ustack + sizeof(t) - 1) & ~(sizeof(t) - 1)); \
(v) = *(t *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(t)); \
ustack = (void *)(((addr_t)ustack + sizeof(typeof(v)) - 1) & ~(sizeof(typeof(v)) - 1)); \
(v) = *(typeof(v) *)ustack; \
ustack += SIZE_STACK_ARG(sizeof(typeof(v))); \
} while (0)


Expand Down
8 changes: 4 additions & 4 deletions hal/sparcv8leon3/arch/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,10 @@
do { \
/* 8-byte values might have been put on stack unaligned */ \
/* clang-format off */ \
if (sizeof(t) == 8 && ((ptr_t)(ustack) & 0x7) != 0) { \
if (sizeof(typeof(v)) == 8 && ((ptr_t)(ustack) & 0x7) != 0) { \
/* clang-format on */ \
union { \
t val; \
typeof(v) val; \
struct { \
u32 lo; \
u32 hi; \
Expand All @@ -164,9 +164,9 @@
v = data##n.val; \
} \
else { \
(v) = *(t *)ustack; \
(v) = *(typeof(v) *)ustack; \
} \
ustack += SIZE_STACK_ARG(sizeof(t)); \
ustack += SIZE_STACK_ARG(sizeof(typeof(v))); \
} while (0)


Expand Down
2 changes: 1 addition & 1 deletion proc/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ typedef struct _process_t {

unsigned sigpend;
unsigned sigmask;
void *sighandler;
void (*sighandler)(void);

void *got;
hal_tls_t tls;
Expand Down
4 changes: 2 additions & 2 deletions proc/threads.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,7 +1486,7 @@ void threads_setupUserReturn(void *retval)
{
spinlock_ctx_t sc;
cpu_context_t *ctx, *signalCtx;
void *f;
void (*f)(void);
void *kstackTop;
thread_t *thread;

Expand All @@ -1501,7 +1501,7 @@ void threads_setupUserReturn(void *retval)
if (_threads_checkSignal(thread, thread->process, signalCtx, SIG_SRC_SCALL) == 0) {
f = thread->process->sighandler;
hal_spinlockClear(&threads_common.spinlock, &sc);
hal_jmp(f, kstackTop, hal_cpuGetUserSP(signalCtx), 0, NULL);
hal_jmp((void *)f, kstackTop, hal_cpuGetUserSP(signalCtx), 0, NULL);
/* no return */
}

Expand Down
10 changes: 5 additions & 5 deletions syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int syscalls_beginthreadex(void *ustack)
int *id;
int err;

GETFROMSTACK(ustack, void *, start, 0);
GETFROMSTACK(ustack, void (*)(void *), start, 0);
GETFROMSTACK(ustack, unsigned int, priority, 1);
GETFROMSTACK(ustack, void *, stack, 2);
GETFROMSTACK(ustack, unsigned int, stacksz, 3);
Expand Down Expand Up @@ -659,14 +659,14 @@ int syscalls_interrupt(void *ustack)
{
process_t *proc = proc_current()->process;
unsigned int n;
void *f;
int (*f)(unsigned int, void *);
void *data;
handle_t cond;
handle_t *handle;
int res;

GETFROMSTACK(ustack, unsigned int, n, 0);
GETFROMSTACK(ustack, void *, f, 1);
GETFROMSTACK(ustack, int (*)(unsigned int, void *), f, 1);
GETFROMSTACK(ustack, void *, data, 2);
GETFROMSTACK(ustack, handle_t, cond, 3);
GETFROMSTACK(ustack, handle_t *, handle, 4);
Expand Down Expand Up @@ -941,11 +941,11 @@ addr_t syscalls_va2pa(void *ustack)

int syscalls_signalHandle(void *ustack)
{
void *handler;
void (*handler)(void);
unsigned mask, mmask;
thread_t *thread;

GETFROMSTACK(ustack, void *, handler, 0);
GETFROMSTACK(ustack, void (*)(void), handler, 0);
GETFROMSTACK(ustack, unsigned, mask, 1);
GETFROMSTACK(ustack, unsigned, mmask, 2);

Expand Down