Example #1
0
void
_threadnote(void *v, char *s)
{
	Proc *p;
	Note *n;

	_threaddebug(DBGNOTE, "Got note %s", s);
//	if(strncmp(s, "sys:", 4) == 0)
//		noted(NDFLT);

//	if(_threadexitsallstatus){
//		_threaddebug(DBGNOTE, "Threadexitsallstatus = '%s'\n", _threadexitsallstatus);
//		_exits(_threadexitsallstatus);
//	}

	if(strcmp(s, "threadint")==0)
		noted(NCONT);

	p = _threadgetproc();
	if(p == nil)
		noted(NDFLT);

	for(n=notes; n<enotes; n++)
		if(canlock(&n->inuse))
			break;
	if(n==enotes)
		sysfatal("libthread: too many delayed notes");
	utfecpy(n->s, n->s+ERRMAX, s);
	n->proc = p;
	p->pending = 1;
	if(!p->splhi)
		delayednotes(p, v);
	noted(NCONT);
}
Example #2
0
static void
winerror(int e, char *buf, uint nerr)
{
	int r;
	char buf2[ERRMAX], *p, *q;
	
	r = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
		0, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
		buf2, sizeof(buf2), 0);

	if(r == 0)
		snprint(buf2, ERRMAX, "windows error %d", e);

	q = buf2;
	for(p = buf2; *p; p++) {
		if(*p == '\r')
			continue;
		if(*p == '\n')
			*q++ = ' ';
		else
			*q++ = *p;
	}
	*q = '\0';
	utfecpy(buf, buf+nerr, buf2);
}
Example #3
0
static void
syserrstr(void)
{
	char buf[ERRMAX], *srct;
	u32int src, len;
	int copied;
	
	src = arg(0);
	len = arg(1);
	srct = copyifnec(src, len, &copied);
	strcpy(buf, P->errbuf);
	utfecpy(P->errbuf, P->errbuf + ERRMAX, srct);
	utfecpy(srct, srct + len, buf);
	if(copied)
		copyback(src, len, srct);
	P->R[0] = 0;
}
Example #4
0
void
rerrstr(char *buf, uint nbuf)
{
	char tmp[ERRMAX];

	tmp[0] = 0;
	errstr(tmp, sizeof tmp);
	utfecpy(buf, buf+nbuf, tmp);
	errstr(tmp, sizeof tmp);
}
Example #5
0
int
errstr(char *buf, uint nerr)
{
	DWORD le;

	le = GetLastError();
	if(le == Magic)
		utfecpy(buf, buf+nerr, errstring);
	else
		winerror(le, buf, nerr);
	return 1;
}
Example #6
0
void
threadexits(char *exitstr)
{
	Proc *p;
	Thread *t;

	p = _threadgetproc();
	t = p->thread;
	t->moribund = 1;
	if(exitstr==nil)
		exitstr="";
	utfecpy(p->exitstr, p->exitstr+ERRMAX, exitstr);
	_sched();
}
Example #7
0
static char*
unmask(Pair * list, uint val)
{
	Pair  *p;
	char *s, *end;
	int n;

	buffer[0] = '\0';
	end = buffer + sizeof buffer;
	s = buffer;

	n = 0;
	s = utfecpy(s, end, "(");
	for (p = list; p->val; p++)
		if (val & p->key) {
			if(n++)
				s = utfecpy(s, end, "|");
			s = utfecpy(s, end, p->val);
		}
	utfecpy(s, end, ")");

	return buffer;
}
Example #8
0
File: main.c Project: npe9/harvey
void
_schedexit(Proc *p)
{
	char ex[ERRMAX];
	Proc **l;

	lock(&_threadpq.lock);
	for(l=&_threadpq.head; *l; l=&(*l)->next){
		if(*l == p){
			*l = p->next;
			if(*l == nil)
				_threadpq.tail = l;
			break;
		}
	}
	unlock(&_threadpq.lock);

	utfecpy(ex, ex+sizeof ex, p->exitstr);
	free(p);
	_exits(ex);
}