// -*- Mode: C++ -*-
// vim:ft=cpp
/**
 * \file
 * \brief  Capability utility functions
 */
/*
 * (c) 2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
 *     economic rights: Technische Universität Dresden (Germany)
 *
 * License: see LICENSE.spdx (in this directory or the directories above)
 */

#pragma once

#include <l4/sys/task>

namespace L4Re { namespace Util {

/**
 * \brief Release a capability from a task (unmap).
 * \ingroup api_l4re_util
 *
 * Note that the given capability does not need to be handled by the
 * capability allocator in any way.
 */
L4_CV static inline l4_msgtag_t cap_release(L4::Cap<void> cap)
{
  return l4_task_unmap(L4_BASE_TASK_CAP,
                       l4_obj_fpage(cap.cap(), 0, L4_FPAGE_RWX),
		       L4_FP_ALL_SPACES);
}

}}
