apps/odroid_vm/components/helloworld/linux_userlevel/build/vchan_code/sel4_vchan_testsuite.c
int vchantests_prod_cons(libvchan_t *ctrl) {
	int x, i, t, ret;
	int chunk[PROD_CONS_CHUNK];

	TDPRINTF(2, "prodcons: start\n");
	for(x = 0; x < PROD_CONS_NUM; x++) {
		for(i = 0; i < PROD_CONS_CHUNK; i++) {
			chunk[i] = x + i;
		}
		ret = libvchan_send(ctrl, chunk, PROD_CONS_CHUNK * sizeof(int));
		if(ret != PROD_CONS_CHUNK * sizeof(int)) {
			TERROR("prodcons: failed to write chunk")
			return -1;
		}

		t = libvchan_buffer_space(ctrl);
		TDPRINTF(4, "prodcons: has buffer space left: %d\n", t);
	}

	TDPRINTF(4, "prodcons: wait for ack\n");
	ret = libvchan_recv(ctrl, &x, sizeof(int));
	if(x != 1 || ret != sizeof(int)) {
		TERROR("prodcons: bad ack\n");
		return -1;
	}
	TDPRINTF(2, "prodcons: concluded\n");

	return 0;
}
/*
    vchantests_prod_cons:
        Simple buffer reading and writing test, similar to packet test
*/
Simple buffer reading and writing test, similar to packet test
Simple buffer reading and writing test similar to packet test
int vchantests_prod_cons(libvchan_t *ctrl) {
	int x, i, t, ret;
	int chunk[PROD_CONS_CHUNK];
	TDPRINTF(2, "prodcons: start\n");
	for(x = 0; x < PROD_CONS_NUM; x++) {
		for(i = 0; i < PROD_CONS_CHUNK; i++) {
			chunk[i] = x + i;
		}
		ret = libvchan_send(ctrl, chunk, PROD_CONS_CHUNK * sizeof(int));
		if(ret != PROD_CONS_CHUNK * sizeof(int)) {
			TERROR("prodcons: failed to write chunk")
			return -1;
		}
		t = libvchan_buffer_space(ctrl);
		TDPRINTF(4, "prodcons: has buffer space left: %d\n", t);
	}
	TDPRINTF(4, "prodcons: wait for ack\n");
	ret = libvchan_recv(ctrl, &x, sizeof(int));
	if(x != 1 || ret != sizeof(int)) {
		TERROR("prodcons: bad ack\n");
		return -1;
	}
	TDPRINTF(2, "prodcons: concluded\n");
	return 0;
}
int vchantests_prod_cons ( libvchan_t * ctrl ) { int x , i , t , ret ; int chunk [ PROD_CONS_CHUNK ] ; TDPRINTF ( 2 , " \n " ) ; for ( x = 0 ; x < PROD_CONS_NUM ; x ++ ) { for ( i = 0 ; i < PROD_CONS_CHUNK ; i ++ ) { chunk [ i ] = x + i ; } ret = libvchan_send ( ctrl , chunk , PROD_CONS_CHUNK * sizeof ( int ) ) ; if ( ret != PROD_CONS_CHUNK * sizeof ( int ) ) { TERROR ( " " ) return -1 ; } t = libvchan_buffer_space ( ctrl ) ; TDPRINTF ( 4 , " \n " , t ) ; } TDPRINTF ( 4 , " \n " ) ; ret = libvchan_recv ( ctrl , & x , sizeof ( int ) ) ; if ( x != 1 || ret != sizeof ( int ) ) { TERROR ( " \n " ) ; return -1 ; } TDPRINTF ( 2 , " \n " ) ; return 0 ; }
vchantests_prod_cons:
Simple buffer reading and writing test, similar to packet test
vchantests_prod_cons : Simple buffer reading and writing test similar to packet test