Beispiel #1
0
void
runtime·selectrecv2(Select *sel, Hchan *c, void *elem, bool *received, bool selected)
{
	selected = false;
	FLUSH(&selected);

	// nil cases do not compete
	if(c == nil)
		return;

	selectrecv(sel, c, runtime·getcallerpc(&sel), elem, received, (byte*)&selected - (byte*)&sel);
}
Beispiel #2
0
void
runtime·selectrecv2(Select* sel, Hchan* c, byte* elem, bool* received, bool selected)
{
	selected = 0;
	FLUSH(&selected);
#line 521 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"

	selected = false;

	// nil cases do not compete
	if(c != nil)
		selectrecv(sel, c, runtime·getcallerpc(&sel), elem, received, (byte*)&selected - (byte*)&sel);
	FLUSH(&selected);
}
Beispiel #3
0
void
runtime·selectrecv2(Select* sel, Hchan* c, byte* elem, bool* received, bool selected)
{
	selected = 0;
	FLUSH(&selected);
#line 523 "/home/14/ren/source/golang/go/src/pkg/runtime/chan.goc"

	selected = false;

	// nil cases do not compete
	if(c != nil)
		selectrecv(sel, c, runtime·getcallerpc(&sel), elem, received, (byte*)&selected - (byte*)&sel);
	FLUSH(&selected);
}
Beispiel #4
0
void
reflect·rselect(Slice cases, intgo chosen, bool recvOK)
{
	chosen = 0;
	FLUSH(&chosen);
	recvOK = 0;
	FLUSH(&recvOK);
#line 990 "/tmp/makerelease402042453/go/src/pkg/runtime/chan.goc"

	int32 i;
	Select *sel;
	runtimeSelect* rcase, *rc;

	chosen = -1;
	recvOK = false;

	rcase = (runtimeSelect*)cases.array;

	sel = newselect(cases.len);
	for(i=0; i<cases.len; i++) {
		rc = &rcase[i];
		switch(rc->dir) {
		case SelectDefault:
			selectdefault(sel, (void*)i, 0);
			break;
		case SelectSend:
			if(rc->ch == nil)
				break;
			selectsend(sel, rc->ch, (void*)i, rc->val, 0);
			break;
		case SelectRecv:
			if(rc->ch == nil)
				break;
			selectrecv(sel, rc->ch, (void*)i, rc->val, &recvOK, 0);
			break;
		}
	}

	chosen = (intgo)(uintptr)selectgo(&sel);
	FLUSH(&chosen);
	FLUSH(&recvOK);
}
Beispiel #5
0
// func rselect(cases []runtimeSelect) (chosen int, word uintptr, recvOK bool)
void
reflect·rselect(Slice cases, intgo chosen, uintptr word, bool recvOK)
{
	int32 i;
	Select *sel;
	runtimeSelect* rcase, *rc;
	void *elem;
	void *recvptr;
	uintptr maxsize;

	chosen = -1;
	word = 0;
	recvOK = false;

	maxsize = 0;
	rcase = (runtimeSelect*)cases.array;
	for(i=0; i<cases.len; i++) {
		rc = &rcase[i];
		if(rc->dir == SelectRecv && rc->ch != nil && maxsize < rc->typ->elem->size)
			maxsize = rc->typ->elem->size;
	}

	recvptr = nil;
	if(maxsize > sizeof(void*))
		recvptr = runtime·mal(maxsize);

	newselect(cases.len, &sel);
	for(i=0; i<cases.len; i++) {
		rc = &rcase[i];
		switch(rc->dir) {
		case SelectDefault:
			selectdefault(sel, (void*)i, 0);
			break;
		case SelectSend:
			if(rc->ch == nil)
				break;
			if(rc->typ->elem->size > sizeof(void*))
				elem = (void*)rc->val;
			else
				elem = (void*)&rc->val;
			selectsend(sel, rc->ch, (void*)i, elem, 0);
			break;
		case SelectRecv:
			if(rc->ch == nil)
				break;
			if(rc->typ->elem->size > sizeof(void*))
				elem = recvptr;
			else
				elem = &word;
			selectrecv(sel, rc->ch, (void*)i, elem, &recvOK, 0);
			break;
		}
	}

	chosen = (intgo)(uintptr)selectgo(&sel);
	if(rcase[chosen].dir == SelectRecv && rcase[chosen].typ->elem->size > sizeof(void*))
		word = (uintptr)recvptr;

	FLUSH(&chosen);
	FLUSH(&word);
	FLUSH(&recvOK);
}