src/libruntime/portal.c
/**
 * @brief Closes a portal.
 *
 * @param id ID of the target portal.
 *
 * @returns Upon successful completion, zero is returned. Upon
 * failure, a negative error code is returned instead.
 *
 * @note This function is @b NOT thread safe.
 */
@brief Closes a portal.
@param id ID of the target portal.

@returns Upon successful completion, zero is returned. Upon
failure, a negative error code is returned instead.

@note This function is @b NOT thread safe.
@brief Closes a portal . @param id ID of the target portal . @returns Upon successful completion zero is returned . Upon failure a negative error code is returned instead . @note This function is @b NOT thread safe .
int nanvix_portal_close(int id)
{
	int err;
	if (!nanvix_portal_is_valid(id))
		return (-EINVAL);
	if (!nanvix_portal_is_used(id))
		return (-EINVAL);
	if (!nanvix_portal_is_wronly(id))
		return (-EINVAL);
	if (portals[id].owner != knode_get_num())
		return (-EINVAL);
	if ((err = kportal_close(portals[id].portalid)) != 0)
		return (err);
	nanvix_portal_free(id);
	return (0);
}
int nanvix_portal_close ( int id ) { int err ; if ( ! nanvix_portal_is_valid ( id ) ) return ( - EINVAL ) ; if ( ! nanvix_portal_is_used ( id ) ) return ( - EINVAL ) ; if ( ! nanvix_portal_is_wronly ( id ) ) return ( - EINVAL ) ; if ( portals [ id ] . owner != knode_get_num ( ) ) return ( - EINVAL ) ; if ( ( err = kportal_close ( portals [ id ] . portalid ) ) != 0 ) return ( err ) ; nanvix_portal_free ( id ) ; return ( 0 ) ; }
@brief Closes a portal.
@brief Closes a portal .
/* Invalid portal ID.*/ /* Bad portal. */ /*  Invalid portal. */ /* Not the owner. */ /* Close underlying unnamed portal. */