2011-03-30 05:46:40 -07:00
|
|
|
#include <u.h>
|
|
|
|
#include <libc.h>
|
|
|
|
#include <thread.h>
|
|
|
|
#include "threadimpl.h"
|
|
|
|
|
|
|
|
long
|
|
|
|
iocall(Ioproc *io, long (*op)(va_list*), ...)
|
|
|
|
{
|
2011-08-21 18:03:27 -07:00
|
|
|
Iocall r;
|
2011-03-30 05:46:40 -07:00
|
|
|
|
2011-08-21 18:03:27 -07:00
|
|
|
r.op = op;
|
|
|
|
va_start(r.arg, op);
|
|
|
|
if(sendp(io->c, &r) < 0){
|
2011-03-30 05:46:40 -07:00
|
|
|
werrstr("interrupted");
|
|
|
|
return -1;
|
|
|
|
}
|
2011-08-21 18:03:27 -07:00
|
|
|
while(recv(io->creply, nil) < 0){
|
2012-04-03 13:10:19 -07:00
|
|
|
if(io->ctl < 0)
|
|
|
|
continue;
|
2011-08-21 18:03:27 -07:00
|
|
|
if(canqlock(io)){
|
|
|
|
if(++io->intr == 1)
|
|
|
|
write(io->ctl, "interrupt", 9);
|
|
|
|
qunlock(io);
|
|
|
|
}
|
2011-03-30 05:46:40 -07:00
|
|
|
}
|
2011-08-21 18:03:27 -07:00
|
|
|
va_end(r.arg);
|
|
|
|
if(r.ret < 0)
|
|
|
|
errstr(r.err, sizeof r.err);
|
|
|
|
return r.ret;
|
2011-03-30 05:46:40 -07:00
|
|
|
}
|