libthread: fix debug prints, simplify

Do the debuglevel check before calling the print
function for _threaddebug, by making it a macro.
Do not waste cycles passing arguments.

Generalize the _threaddebug function into _threadprint()
and add a varargcheck pragma. This function can
also be used from _threadassert().

Fix missing arguments in one case, fix trailing
newlines in _threaddebug().

Make _threadgetproc()/_threadsetproc() a macro,
just dereferencing Proc**_threadprocp.

Simplify the mainjump, just call _threadsetproc()
directly without that mainp dance. Remove the
_schedinit() argument, it uses _threadgetproc() now.
Get rid of Mainarg struct, just have a global variable
for argc.
This commit is contained in:
cinap_lenrek 2021-10-13 17:08:26 +00:00
parent 3fe3e370e3
commit 5a807265a8
6 changed files with 35 additions and 91 deletions

View file

@ -72,7 +72,7 @@ delayednotes(Proc *p, void *v)
break;
}
if(i==NFN){
_threaddebug(DBGNOTE, "Unhandled note %s, proc %p\n", n->s, p);
_threaddebug(DBGNOTE, "Unhandled note %s, proc %p", n->s, p);
if(v != nil)
noted(NDFLT);
else if(strncmp(n->s, "sys:", 4)==0)
@ -94,7 +94,7 @@ _threadnote(void *v, char *s)
noted(NDFLT);
if(_threadexitsallstatus){
_threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'\n", _threadexitsallstatus);
_threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'", _threadexitsallstatus);
_exits(_threadexitsallstatus);
}