src/libruntime/mailbox.c
/**
 * @todo TODO: provide a detailed description for this function.
*/
@todo TODO: provide a detailed description for this function.
@todo TODO : provide a detailed description for this function .
int nanvix_mailbox_create(const char *name)
{
	int fd;      
	int nodenum; 
	int mbxid;   
	if (name == NULL)
		return (-EINVAL);
	if (ustrlen(name) > MAILBOX_MSG_SIZE)
		return (-EINVAL);
	if ((fd = stdinbox_get()) < 0)
		return (-EAGAIN);
	if ((mbxid = nanvix_mailbox_alloc()) < 0)
		return (-EAGAIN);
	nodenum = knode_get_num();
	if (name_link(nodenum, name) != 0)
		goto error0;
	mailboxes[mbxid].fd = fd;
	mailboxes[mbxid].owner = nodenum;
	ustrcpy(mailboxes[mbxid].name, name);
	named_inboxes[core_get_id()] = mbxid;
	return (mbxid);
error0:
	nanvix_mailbox_free(mbxid);
	return (-EAGAIN);
}
int nanvix_mailbox_create ( const char * name ) { int fd ; int nodenum ; int mbxid ; if ( name == NULL ) return ( - EINVAL ) ; if ( ustrlen ( name ) > MAILBOX_MSG_SIZE ) return ( - EINVAL ) ; if ( ( fd = stdinbox_get ( ) ) < 0 ) return ( - EAGAIN ) ; if ( ( mbxid = nanvix_mailbox_alloc ( ) ) < 0 ) return ( - EAGAIN ) ; nodenum = knode_get_num ( ) ; if ( name_link ( nodenum , name ) != 0 ) goto error0 ; mailboxes [ mbxid ] . fd = fd ; mailboxes [ mbxid ] . owner = nodenum ; ustrcpy ( mailboxes [ mbxid ] . name , name ) ; named_inboxes [ core_get_id ( ) ] = mbxid ; return ( mbxid ) ; error0 : nanvix_mailbox_free ( mbxid ) ; return ( - EAGAIN ) ; }
@todo TODO: provide a detailed description for this function.
@todo TODO : provide a detailed description for this function .
/* NoC connector. */ /* NoC node.      */ /* ID of mailbix. */ /* Invalid name. */ /* Check name length. */ /* Runtime not initialized. */ /* Allocate mailbox. */ /* Link name. */ /* Initialize mailbox. */ /* Initialize named inbox. */