Who's Online |
114 user(s) are online ( 99 user(s) are browsing Forums)
Members: 1
Guests: 113
Paul,
more...
|
|
Headlines |
-
pythonssl_22.lha - library/misc
Jan 17, 2021
-
redeht_ita.lha - network/samba
Jan 17, 2021
-
aiostreams.lha - video/misc
Jan 17, 2021
-
mce.lha - game/utility
Jan 16, 2021
-
libpsem.lha - development/library/misc
Jan 15, 2021
-
a1222-mcu-watcher.lha - utility/workbench
Jan 15, 2021
-
x5000-mcu-watcher.lha - utility/workbench
Jan 15, 2021
-
earmark.lha - utility/text
Jan 14, 2021
-
jansson_library.lha - development/library/misc
Jan 11, 2021
-
flashmandelng.lha - graphics/misc
Jan 9, 2021
|
|
|
Re: Is Forbid() needed for SetMethod()? | Subject: Re: Is Forbid() needed for SetMethod()? by salass00 on 2019/4/9 13:05:59
Forbid()/Permit() would be needed if the new function acts as a wrapper for the old library function instead of replacing it entirely.
int (*oldFunc)(void);
int newFunc(void) {
IExec->DebugPrintF("SomeFunc() calledn");
return oldFunc();
}
/* ... */
/* Patch SomeFunc() in ISomeLib with newFunc() */
IExec->Forbid();
oldFunc = IExec->DoMethod((struct Interface *)ISomeLib, offsetof(struct SomeLibIFace, SomeFunc), newFunc);
IExec->Permit();
Without the Forbid() in the above example newFunc() might be called before oldFunc has been set, leading to an ISI as it tries to jump to a NULL pointer.
If the function in question is supposed to be callable from interrupts then Disable()/Enable() will need to be used instead of Forbid()/Permit().
|
|