summaryrefslogtreecommitdiff
path: root/sys/src/libthread/threadimpl.h
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2021-10-13 17:08:26 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2021-10-13 17:08:26 +0000
commit5a807265a819206f8342ab3a23b940a0c75049fc (patch)
treea84effb4eb8852b1346259b98772c5c269f91e09 /sys/src/libthread/threadimpl.h
parent3fe3e370e3bcad21b61aec6cbf5d11a9398e805b (diff)
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.
Diffstat (limited to 'sys/src/libthread/threadimpl.h')
-rw-r--r--sys/src/libthread/threadimpl.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/sys/src/libthread/threadimpl.h b/sys/src/libthread/threadimpl.h
index 6574a6201..b5006f914 100644
--- a/sys/src/libthread/threadimpl.h
+++ b/sys/src/libthread/threadimpl.h
@@ -157,15 +157,12 @@ int _schedexec(Execargs*);
void _schedexecwait(void);
void _schedexit(Proc*);
int _schedfork(Proc*);
-void _schedinit(void*);
-void _systhreadinit(void);
+void _schedinit(void);
void _threadassert(char*);
void _threadbreakrendez(void);
-void _threaddebug(ulong, char*, ...);
+void _threadprint(char*, ...);
void _threadexitsall(char*);
void _threadflagrendez(Thread*);
-Proc* _threadgetproc(void);
-void _threadsetproc(Proc*);
void _threadinitstack(Thread*, void(*)(void*), void*);
void* _threadmalloc(long, int);
void _threadnote(void*, char*);
@@ -173,6 +170,10 @@ void _threadready(Thread*);
void* _threadrendezvous(void*, void*);
void _threadsysfatal(char*, va_list);
+Proc **_threadprocp;
+#define _threadgetproc() (*_threadprocp)
+#define _threadsetproc(p) (*_threadprocp = (p))
+
extern int _threaddebuglevel;
extern char* _threadexitsallstatus;
extern Pqueue _threadpq;
@@ -187,4 +188,7 @@ extern Rgrp _threadrgrp;
#define DBGNOTE (1 << 20)
#define DBGEXEC (1 << 21)
+#pragma varargck argpos _threadprint 1
+#define _threaddebug(flag, ...) if((_threaddebuglevel&(flag))==0){}else _threadprint(__VA_ARGS__)
+
#define ioproc_arg(io, type) (va_arg((io)->arg, type))