refactor: simplify the Plan 9 runtime loop

This commit is contained in:
2026-08-12 17:26:55 +09:00
parent 211a6917b2
commit 91931196e2
4 changed files with 5 additions and 22 deletions

View File

@@ -14,7 +14,7 @@ OBJS = $(SRCS:.c=.o)
all: $(PROG) xim gtk
$(PROG): $(OBJS)
$(LD) -o $@ $(OBJS) -lthread -lString -lbio -lxcb -lm $(PKG_LIBS)
$(LD) -o $@ $(OBJS) -lthread -lbio -lxcb -lm $(PKG_LIBS)
$(OBJS): dat.h fn.h ipc.h
# Avoid Arch's GLIBC_2.43 sqrtf optimization for older glibc runtimes.

2
dict.c
View File

@@ -44,7 +44,7 @@ void
dictthread(void*)
{
Dictreq req;
Dictres res;
static Dictres res;
threadsetname("dict");
for(;;){

20
main.c
View File

@@ -7,13 +7,6 @@ Channel *dictreqc;
Channel *dictresc;
char *fontdir;
int
threadmaybackground(void)
{
/* Keep the launcher PID stable so supervisors can own this daemon. */
return 0;
}
void
usage(void)
{
@@ -39,10 +32,9 @@ emalloc(ulong n)
{
void *p;
p = malloc(n);
p = mallocz(n, 1);
if(p == nil)
die("out of memory");
memset(p, 0, n);
return p;
}
@@ -58,9 +50,6 @@ erealloc(void *p, ulong n)
void
threadmain(int argc, char **argv)
{
Channel *waitc;
uchar stop;
if(argc != 3)
usage();
@@ -81,10 +70,5 @@ threadmain(int argc, char **argv)
die("can't create Wayland worker");
if(threadcreate(dictthread, nil, 16384) < 0)
die("can't create dictionary worker");
if(threadcreate(imthread, nil, 16384) < 0)
die("can't create input worker");
/* Keep the supervising process and its externally visible PID alive. */
waitc = chancreate(sizeof stop, 0);
chanrecv(waitc, &stop);
imthread(nil);
}

View File

@@ -27,10 +27,9 @@ emalloc(ulong n)
{
void *p;
p = malloc(n);
p = mallocz(n, 1);
if(p == nil)
die("out of memory");
memset(p, 0, n);
return p;
}