src/sys/pm/name/main.c
/**
 * @brief Register a process name.
 *
 * @param nodenum Target NoC node.
 * @param name    Name of the process to register.
 *
 * @returns Upon successful registration the number of name registered
 * is returned. Upon failure, a negative error code is returned instead.
 */
@brief Register a process name.
@param nodenum Target NoC node.
@param name    Name of the process to register.

@returns Upon successful registration the number of name registered
is returned. Upon failure, a negative error code is returned instead.
@brief Register a process name . @param nodenum Target NoC node . @param name Name of the process to register . @returns Upon successful registration the number of name registered is returned . Upon failure a negative error code is returned instead .
static int do_name_link(int nodenum, char *name)
{
	int index;          
	name_debug("link nodenum=%d name=%s", nodenum, name);
	if (nr_registration >= NANVIX_NODES_NUM)
		return (-EINVAL);
	for (int i = 0; i < NANVIX_NODES_NUM; i++)
	{
		if (ustrcmp(names[i].name, name) == 0)
			return (-EINVAL);
	}
	for (int i = 0; i < NANVIX_NODES_NUM; i++)
	{
		if (names[i].nodenum == nodenum)
		{
			index = i;
			goto found;
		}
	}
	return (-EINVAL);
found:
	if (ustrcmp(names[index].name, ""))
		return (-EINVAL);
	ustrcpy(names[index].name, name);
	return (++nr_registration);
}
static int do_name_link ( int nodenum , char * name ) { int index ; name_debug ( " " , nodenum , name ) ; if ( nr_registration >= NANVIX_NODES_NUM ) return ( - EINVAL ) ; for ( int i = 0 ; i < NANVIX_NODES_NUM ; i ++ ) { if ( ustrcmp ( names [ i ] . name , name ) == 0 ) return ( - EINVAL ) ; } for ( int i = 0 ; i < NANVIX_NODES_NUM ; i ++ ) { if ( names [ i ] . nodenum == nodenum ) { index = i ; goto found ; } } return ( - EINVAL ) ; found : if ( ustrcmp ( names [ index ] . name , " " ) ) return ( - EINVAL ) ; ustrcpy ( names [ index ] . name , name ) ; return ( ++ nr_registration ) ; }
@brief Register a process name.
@brief Register a process name .
/* Index where the process will be stored. */ /* No entry available. */ /* Check that the name is not already used */ /* Find index. */ /* Found. */ /* Entry not available */