refactor: simplify the Plan 9 runtime loop
This commit is contained in:
2
Makefile
2
Makefile
@@ -14,7 +14,7 @@ OBJS = $(SRCS:.c=.o)
|
|||||||
all: $(PROG) xim gtk
|
all: $(PROG) xim gtk
|
||||||
|
|
||||||
$(PROG): $(OBJS)
|
$(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
|
$(OBJS): dat.h fn.h ipc.h
|
||||||
# Avoid Arch's GLIBC_2.43 sqrtf optimization for older glibc runtimes.
|
# Avoid Arch's GLIBC_2.43 sqrtf optimization for older glibc runtimes.
|
||||||
|
|||||||
2
dict.c
2
dict.c
@@ -44,7 +44,7 @@ void
|
|||||||
dictthread(void*)
|
dictthread(void*)
|
||||||
{
|
{
|
||||||
Dictreq req;
|
Dictreq req;
|
||||||
Dictres res;
|
static Dictres res;
|
||||||
|
|
||||||
threadsetname("dict");
|
threadsetname("dict");
|
||||||
for(;;){
|
for(;;){
|
||||||
|
|||||||
20
main.c
20
main.c
@@ -7,13 +7,6 @@ Channel *dictreqc;
|
|||||||
Channel *dictresc;
|
Channel *dictresc;
|
||||||
char *fontdir;
|
char *fontdir;
|
||||||
|
|
||||||
int
|
|
||||||
threadmaybackground(void)
|
|
||||||
{
|
|
||||||
/* Keep the launcher PID stable so supervisors can own this daemon. */
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
@@ -39,10 +32,9 @@ emalloc(ulong n)
|
|||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
p = malloc(n);
|
p = mallocz(n, 1);
|
||||||
if(p == nil)
|
if(p == nil)
|
||||||
die("out of memory");
|
die("out of memory");
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,9 +50,6 @@ erealloc(void *p, ulong n)
|
|||||||
void
|
void
|
||||||
threadmain(int argc, char **argv)
|
threadmain(int argc, char **argv)
|
||||||
{
|
{
|
||||||
Channel *waitc;
|
|
||||||
uchar stop;
|
|
||||||
|
|
||||||
if(argc != 3)
|
if(argc != 3)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
@@ -81,10 +70,5 @@ threadmain(int argc, char **argv)
|
|||||||
die("can't create Wayland worker");
|
die("can't create Wayland worker");
|
||||||
if(threadcreate(dictthread, nil, 16384) < 0)
|
if(threadcreate(dictthread, nil, 16384) < 0)
|
||||||
die("can't create dictionary worker");
|
die("can't create dictionary worker");
|
||||||
if(threadcreate(imthread, nil, 16384) < 0)
|
imthread(nil);
|
||||||
die("can't create input worker");
|
|
||||||
|
|
||||||
/* Keep the supervising process and its externally visible PID alive. */
|
|
||||||
waitc = chancreate(sizeof stop, 0);
|
|
||||||
chanrecv(waitc, &stop);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,10 +27,9 @@ emalloc(ulong n)
|
|||||||
{
|
{
|
||||||
void *p;
|
void *p;
|
||||||
|
|
||||||
p = malloc(n);
|
p = mallocz(n, 1);
|
||||||
if(p == nil)
|
if(p == nil)
|
||||||
die("out of memory");
|
die("out of memory");
|
||||||
memset(p, 0, n);
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user