Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address lisp kernel compiler warnings #483

Merged
merged 2 commits into from
Apr 23, 2024
Merged
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
2 changes: 1 addition & 1 deletion lisp-kernel/imports.s
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import_ptrs_start:
defimport(lisp_egc_control)
defimport(lisp_bug)
defimport(xNewThread)
defimport(cooperative_thread_startup)
defimport(do_nothing)
defimport(xDisposeThread)
defimport(xThreadCurrentStackSpace)
defimport(usage_exit)
Expand Down
70 changes: 14 additions & 56 deletions lisp-kernel/thread_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1368,9 +1368,11 @@ shutdown_thread_tcr(void *arg)
if (tcr->flags & (1<<TCR_FLAG_BIT_FOREIGN)) {
LispObj callback_macptr = nrs_FOREIGN_THREAD_CONTROL.vcell,
callback_ptr = ((macptr *)ptr_from_lispobj(untag(callback_macptr)))->address;

int (*foreign_thread_control)(int) = (int (*)(int))callback_ptr;

tsd_set(lisp_global(TCR_KEY), TCR_TO_TSD(tcr));
((void (*)())ptr_from_lispobj(callback_ptr))(1);
foreign_thread_control(1);
//((void (*)(int))ptr_from_lispobj(callback_ptr))(1);
tsd_set(lisp_global(TCR_KEY), NULL);
}
#ifdef DARWIN
Expand Down Expand Up @@ -1689,56 +1691,6 @@ lisp_thread_entry(void *param)
#endif
}

typedef
short (*suspendf)();


void
suspend_current_cooperative_thread()
{
static suspendf cooperative_suspend = NULL;
void *xFindSymbol(void*,char*);

if (cooperative_suspend == NULL) {
cooperative_suspend = (suspendf)xFindSymbol(NULL, "SetThreadState");
}
if (cooperative_suspend) {
cooperative_suspend(1 /* kCurrentThreadID */,
1 /* kStoppedThreadState */,
0 /* kAnyThreadID */);
}
}

void *
cooperative_thread_startup(void *arg)
{

TCR *tcr = get_tcr(0);
LispObj *start_vsp;

if (!tcr) {
return NULL;
}
#ifndef WINDOWS
pthread_cleanup_push(tcr_cleanup,(void *)tcr);
#endif
SET_TCR_FLAG(tcr,TCR_FLAG_BIT_AWAITING_PRESET);
start_vsp = tcr->save_vsp;
do {
SEM_RAISE(TCR_AUX(tcr)->reset_completion);
suspend_current_cooperative_thread();

start_lisp(tcr, 0);
tcr->save_vsp = start_vsp;
} while (tcr->flags & (1<<TCR_FLAG_BIT_AWAITING_PRESET));
#ifndef WINDOWS
pthread_cleanup_pop(true);
#else
tcr_cleanup(tcr);
#endif
return NULL;
}

void *
xNewThread(natural control_stack_size,
natural value_stack_size,
Expand Down Expand Up @@ -1770,6 +1722,11 @@ xNewThread(natural control_stack_size,
return TCR_TO_TSD(activation.tcr);
}

void *
do_nothing(void) {
return 0;
}

Boolean
active_tcr_p(TCR *q)
{
Expand Down Expand Up @@ -1892,6 +1849,7 @@ get_tcr(Boolean create)
if ((current == NULL) && create) {
LispObj callback_macptr = nrs_FOREIGN_THREAD_CONTROL.vcell,
callback_ptr = ((macptr *)ptr_from_lispobj(untag(callback_macptr)))->address;
int (*foreign_thread_control)(int) = (int (*)(int))callback_ptr;
int i, nbindwords = 0;
extern natural initial_stack_size;

Expand Down Expand Up @@ -1922,13 +1880,13 @@ get_tcr(Boolean create)
*(--current->save_vsp) = 0;
current->vs_area->active -= node_size;
}
nbindwords = ((int (*)())ptr_from_lispobj(callback_ptr))(-1);
nbindwords = foreign_thread_control(-1);
for (i = 0; i < nbindwords; i++) {
*(--current->save_vsp) = 0;
current->vs_area->active -= node_size;
}
TCR_AUX(current)->shutdown_count = 1;
((void (*)())ptr_from_lispobj(callback_ptr))(0);
foreign_thread_control(0);

}

Expand Down Expand Up @@ -2092,7 +2050,7 @@ create_thread_context_frame(mach_port_t, natural *, siginfo_t *, TCR*, native_th

Boolean mach_suspend_tcr(TCR *tcr)
{
thread_act_t thread = (thread_act_t)(tcr->native_thread_id);
mach_port_t thread = (mach_port_t)((intptr_t)tcr->native_thread_id);
kern_return_t kret = thread_suspend(thread);

if (kret == 0) {
Expand Down Expand Up @@ -2254,7 +2212,7 @@ resume_tcr(TCR *tcr)
Boolean mach_resume_tcr(TCR *tcr)
{
ExceptionInformation *xp = tcr->suspend_context;
mach_port_t thread = (mach_port_t)(tcr->native_thread_id);
mach_port_t thread = (mach_port_t)((intptr_t)(tcr->native_thread_id));
#if WORD_SIZE == 64
MCONTEXT_T mc = UC_MCONTEXT(xp);
#else
Expand Down
7 changes: 5 additions & 2 deletions lisp-kernel/x86-exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,6 @@ handle_alloc_trap(ExceptionInformation *xp, TCR *tcr, Boolean *notify)
return true;
}


int
callback_to_lisp (TCR * tcr, LispObj callback_macptr, ExceptionInformation *xp,
natural arg1, natural arg2, natural arg3, natural arg4, natural arg5)
Expand Down Expand Up @@ -712,8 +711,12 @@ callback_to_lisp (TCR * tcr, LispObj callback_macptr, ExceptionInformation *xp,
pointers (and at least should have called prepare_for_callback()).
*/
callback_ptr = ((macptr *)ptr_from_lispobj(untag(callback_macptr)))->address;
typedef int (*callback_fn_type)(ExceptionInformation *, natural, natural,
natural, natural, natural);
callback_fn_type callback_fn = (callback_fn_type)callback_ptr;

UNLOCK(lisp_global(EXCEPTION_LOCK), tcr);
delta = ((int (*)())callback_ptr) (xp, arg1, arg2, arg3, arg4, arg5);
delta = callback_fn(xp, arg1, arg2, arg3, arg4, arg5);
LOCK(lisp_global(EXCEPTION_LOCK), tcr);

#ifdef X8632
Expand Down