Exemplo n.º 1
0
int main(int argc, char *argv[]) {
	PRd(SZ_A_ST);
	PRd(SZ_B_ST);
	PRd(sizeof(Twig_s));
	PRd(sizeof(Head_s));
	return 0;
}
Exemplo n.º 2
0
int send_tcp (msgbuf_s *mb)
{
	int	sock;		// Socket descriptor
	int	rc;

		/* Create a reliable, stream socket using TCP */
	sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
	if (sock< 0) fatal("socket():");

		/* Establish the connection to the echo server */
	rc = connect(sock, (struct sockaddr *)&TcpServAddr, sizeof(TcpServAddr));
	if (rc < 0) fatal("connect():");

		/* Send the msgbuf to the server */
	mb->mb_type = SEND_MSGTCP;
	uuid_copy(mb->mb_pr_id, Me.pr_id);
PRd(sizeof(*mb));
	rc = send(sock, mb, sizeof(*mb), 0);
	if (rc != sizeof(*mb)) {
		fatal("send() sent a different number of bytes than expected:");
	}
PROMPT;
	close(sock);
	return 0;
}
Exemplo n.º 3
0
int receive_tcp (msgbuf_s *mb)
{
	int	sock;				// Socket descriptor
	int	bytesRcvd;
	int	remainder;
	int	rc;
	u8	*buf = (u8 *)mb;

PROMPT;
		/* Create a reliable, stream socket using TCP */
	sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
	if (sock< 0) fatal("socket():");

		/* Establish the connection to the echo server */
	rc = connect(sock, (struct sockaddr *)&TcpServAddr, sizeof(TcpServAddr));
	if (rc < 0) fatal("connect():");

	mb->mb_type = SEND_MSGTCP;
	uuid_copy(mb->mb_pr_id, Me.pr_id);	// Don't need to send it all
	rc = send(sock, mb, sizeof(*mb), 0);
	if (rc != sizeof(*mb)) {
		fatal("send() sent a different number of bytes than expected:");
	}
	for (remainder = sizeof(*mb); remainder; remainder -= bytesRcvd) {
			/* Receive up to the buffer size bytes from the sender */
		bytesRcvd = recv(sock, buf, remainder, 0);
PRd(bytesRcvd);
		if (bytesRcvd <= 0) {
			fatal("recv() failed of connection closed prematurely:");
		}
		buf += bytesRcvd;
	}
	close(sock);
	return 0;
}
Exemplo n.º 4
0
Arquivo: mtree.c Projeto: wtaysom/tau
static int insert_branch (
	tree_s		*tree,
	branch_s	*parent,
	u64		key,
	void		*rec,
	unint		size)
{
	void		*child;
	s64		k;	/* Critical that this be signed */
FN;
	for (;;) {
		do {
			k = binary_search_branch(key, parent->br_key,
							parent->br_num);
PRd(k);
			child = parent->br_key[k].k_node;
PRp(child);
			if (!child) {
				return qERR_NOT_FOUND;
			}
		} while (split_node(tree, parent, child, k, size));
		if (magic(child) != BRANCH) {
			return insert_node(tree, child, key, rec, size);
		}
		parent = child;
	}
}
Exemplo n.º 5
0
Arquivo: json.c Projeto: taysom/tau
static Tree_s *value (void)
{
FN;
	Token_s	t;
	Tree_s	*tree;
	
	t = get_token();
	switch (t.type) {
	case T_STRING:
	case T_NUMBER:
	case T_TRUE:
	case T_FALSE:
	case T_NULL:
		tree = new_tree();
		tree->token = t;
		return tree;
	case '[':
		return array();
	case '{':
		unget_token(t);
		return object();
	default:
PRd(t.type);
		return NULL;
	}
}
Exemplo n.º 6
0
Arquivo: buf.c Projeto: taysom/tau
void buf_put (Buf_s **bp)
{
	Buf_s *b = *bp;

	*bp = NULL;
	aver(b->blknum == ((Node_s *)b->d)->blknum);
	aver(0 < b->inuse);
	++Cache.stat.puts;
	--b->inuse;
	if (!b->inuse) {
		u64 crc = crc64(b->d, BLOCK_SIZE);
		if (b->dirty) {
			if (crc == b->crc) {
				printf("Didn't change %lld\n", b->blknum);
			}
			//XXX: this can be true. aver(crc != b->crc);
			b->crc = crc;
			dev_flush(b);
			b->dirty = FALSE;
		} else {
			if (crc != b->crc) {
				PRd(b->blknum);
			}
			aver(crc == b->crc);
		}
	}
}
Exemplo n.º 7
0
Arquivo: main.c Projeto: taysom/tau
void err_jmp (char *msg)
{
	PRd(errno);
	if (errno) {
		perror(msg);
	} else {
		fprintf(stderr, "Error: %s\n", msg);
	}
	longjmp(Err_jmp, 1);
}
Exemplo n.º 8
0
Arquivo: inode.c Projeto: taysom/tau
info_s *get_info (u64 ino)
{
    info_s	*info;
    FN;
    PRd(ino);
    info = find_info(ino);
    if (info) return info;

    info = find_inode(ino);
    if (!info) return NULL;

    add_info(ino, info);
    return info;
}
Exemplo n.º 9
0
Arquivo: bag.c Projeto: taysom/tau
struct bag *new_bag(size_t size)
{
	struct bag *bag;

if (0) PRd(size);
	bag = ezalloc(sizeof(*bag));
	bag->nkeys = size / 20 + 1;
	bag->nextkey = 0;
	bag->keys = ezalloc(bag->nkeys * sizeof(*bag->keys));
	bag->size = size;
	bag->next = 0;
	bag->data = ezalloc(size);
	return bag;
}
Exemplo n.º 10
0
Arquivo: inode.c Projeto: taysom/tau
buf_s *alloc_block (dev_s *dev)
{
    super_s	*super;
    buf_s	*buf;
    u64	blkno;
    FN;
    buf = bget(dev, SUPER_BLOCK);
    super = buf->b_data;

    if (super->sp_magic != SUPER_MAGIC) {
        eprintf("no super block");
    }
    blkno = super->sp_next++;
    PRd(blkno);
    bdirty(buf);
    bput(buf);

    buf = bnew(dev, blkno);
    bdirty(buf);
    return buf;
}