1// vi:set ft=cpp: -*- Mode: C++ -*-
2/*
3 * Copyright (C) 2015 Kernkonzept GmbH.
4 * Author(s): Sarah Hoffmann <sarah.hoffmann@kernkonzept.com>
5 *
6 * This file is distributed under the terms of the GNU General Public
7 * License, version 2.  Please see the COPYING-GPL-2 file for details.
8 */
9#pragma once
10
11#include <thread>
12#include <pthread-l4.h>
13
14namespace std { namespace L4 {
15
16/**
17 * Return the L4 thread capability for a given std::thread.
18 *
19 * If the std::thread is not joinable, the invalid capability (#L4_INVALID_CAP)
20 * is returned.
21 */
22inline ::L4::Cap< ::L4::Thread> thread_cap(std::thread &t)
23{
24  if (t.joinable())
25    return Pthread::L4::cap(t.native_handle());
26  return ::L4::Cap< ::L4::Thread>();
27}
28
29/// Return a pointer to the UTCB of this thread.
30inline l4_utcb_t * thread_utcb(std::thread &t)
31{ return Pthread::L4::utcb(t.native_handle()); }
32
33}} // namespace L4, namespace std
34