src/sys/mm/rmem/main.c
/**
 * @brief Handles remote memory free.
 *
 * @param blknum Number of the target block.
 *
 * @returns Upon successful completion, zero is returned. Upon
 * failure, a negative error code is returned instead.
 */
@brief Handles remote memory free.
@param blknum Number of the target block.

@returns Upon successful completion, zero is returned. Upon
failure, a negative error code is returned instead.
@brief Handles remote memory free . @param blknum Number of the target block . @returns Upon successful completion zero is returned . Upon failure a negative error code is returned instead .
static inline int do_rmem_free(rpage_t blknum)
{
	rpage_t _blknum;
	_blknum = RMEM_BLOCK_NUM(blknum);
	if ((_blknum == RMEM_NULL) || (_blknum >= RMEM_NUM_BLOCKS))
	{
		uprintf("[nanvix][rmem] invalid block number");
		return (-EINVAL);
	}
	if (stats.nblocks == 1)
	{
		uprintf("[nanvix][rmem] remote memory is empty");
		return (-EFAULT);
	}
	if (!bitmap_check_bit(blocks, _blknum))
	{
		uprintf("[nanvix][rmem] bad free block");
		return (-EFAULT);
	}
	umemset(&rmem[_blknum][0], 0, RMEM_BLOCK_SIZE);
	stats.nblocks--;
	bitmap_clear(blocks, _blknum);
	rmem_debug("rmem_free() blknum=%d nblocks=%d/%d",
		_blknum, stats.nblocks, RMEM_NUM_BLOCKS
	);
	return (0);
}
static inline int do_rmem_free ( rpage_t blknum ) { rpage_t _blknum ; _blknum = RMEM_BLOCK_NUM ( blknum ) ; if ( ( _blknum == RMEM_NULL ) || ( _blknum >= RMEM_NUM_BLOCKS ) ) { uprintf ( " " ) ; return ( - EINVAL ) ; } if ( stats . nblocks == 1 ) { uprintf ( " " ) ; return ( - EFAULT ) ; } if ( ! bitmap_check_bit ( blocks , _blknum ) ) { uprintf ( " " ) ; return ( - EFAULT ) ; } umemset ( & rmem [ _blknum ] [ 0 ] , 0 , RMEM_BLOCK_SIZE ) ; stats . nblocks -- ; bitmap_clear ( blocks , _blknum ) ; rmem_debug ( " " , _blknum , stats . nblocks , RMEM_NUM_BLOCKS ) ; return ( 0 ) ; }
@brief Handles remote memory free.
@brief Handles remote memory free .
/* Invalid block number. */ /* Remote memory is empty. */ /* Bad block number. */ /* Clean block. */ /* Free block. */