defs: allow NULL callbacks in gint_call()

This commit is contained in:
Lephe 2023-01-29 21:40:50 +01:00
parent 18e0db3886
commit 6f758cd36c
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495
7 changed files with 16 additions and 24 deletions

View file

@ -153,7 +153,8 @@ static GINLINE int gint_call(gint_call_t cb)
int (*f)(int r4, int r5, int r6, int r7) = cb.function;
#endif
return f(cb.args[0].i, cb.args[1].i, cb.args[2].i, cb.args[3].i);
gint_call_arg_t *args = cb.args;
return f ? f(args[0].i, args[1].i, args[2].i, args[3].i) : -1;
}
//---

View file

@ -160,11 +160,8 @@ static void dma_interrupt_transfer_ended(int channel)
if(dma_wait_ics[channel])
cpu_csleep_cancel(dma_wait_ics[channel]);
if(dma_callbacks[channel].function)
{
gint_call(dma_callbacks[channel]);
dma_callbacks[channel] = GINT_CALL_NULL;
}
gint_call(dma_callbacks[channel]);
dma_callbacks[channel] = GINT_CALL_NULL;
}
/* dma_channel_wait(): Wait for a particular channel's transfer to finish

View file

@ -149,7 +149,7 @@ int gint_world_switch(gint_call_t call)
if(canary)
*canary = 0xb7c0ffee;
int rc = call.function ? gint_call(call) : 0;
int rc = gint_call(call);
/* The canary check needs to occur before switching in the gint world;
otherwise we just crash due to the overflow. gint_panic() isn't

View file

@ -12,8 +12,7 @@ void dupdate(void)
r61524_display(gint_vram, 0, 224, method);
gint_call_t hook = dupdate_get_hook();
if(hook.function) gint_call(hook);
gint_call(dupdate_get_hook());
/* Switch buffers if triple buffering is enabled */
dvram_switch();

View file

@ -28,8 +28,7 @@ void dupdate(void)
t6k11_display(gint_vram, 0, 64, 16);
}
gint_call_t hook = dupdate_get_hook();
if(hook.function) gint_call(hook);
gint_call(dupdate_get_hook());
}
__attribute__((alias("dupdate")))
void _WEAK_dupdate(void);

View file

@ -263,10 +263,10 @@ static void finish_transfer(struct transfer volatile *t, int pipe)
t->used = 0;
/* Disable the interrupt */
if(pipe) USB.BEMPENB &= ~(1 << pipe);
if(t->callback.function) gint_call(t->callback);
if(pipe != 0)
USB.BEMPENB &= ~(1 << pipe);
gint_call(t->callback);
USB_TRACE("finish_transfer()");
}
@ -287,14 +287,14 @@ static void finish_round(struct transfer volatile *t, int pipe)
t->flying = 0;
/* Account for auto-transfers */
if(t->used == pipe_bufsize(pipe)) t->used = 0;
if(t->used == pipe_bufsize(pipe))
t->used = 0;
/* At the end, free the FIFO and invoke the callback. Hold the
controller until the pipe is committed */
if(t->size == 0)
{
if(t->size == 0) {
t->data = NULL;
if(t->callback.function) gint_call(t->callback);
gint_call(t->callback);
}
USB_TRACE("finish_round()");

View file

@ -266,13 +266,9 @@ static void usb_interrupt_handler(void)
if(USB.INTSTS0.DVSQ == 3)
{
usb_configure_clear_pipes();
usb_open_status = true;
if(usb_open_callback.function)
{
gint_call(usb_open_callback);
usb_open_callback = GINT_CALL_NULL;
}
gint_call(usb_open_callback);
usb_open_callback = GINT_CALL_NULL;
}
}
else if(USB.INTSTS0.BEMP)