Add 'socket' member to 'Native_capability::Dst'

In the final version, the 'socket' will be the only member to remain in
the 'Dst' time. In the transition phase, we store both the old 'tid' and
the 'socket'.
This commit is contained in:
Norman Feske
2012-07-18 14:07:13 +02:00
parent c09cd2d1a7
commit 1c3b9a6f68
5 changed files with 25 additions and 11 deletions

View File

@ -56,7 +56,7 @@ namespace Genode {
static IF *deref(Capability<IF> cap)
{
/* check if this is a pseudo capability */
if (cap.dst() != 0 || !cap.local_name())
if (cap.dst().tid != 0 || !cap.local_name())
throw Non_local_capability();
/*
@ -81,7 +81,8 @@ namespace Genode {
template <typename IF>
static Capability<IF> capability(IF *interface)
{
return reinterpret_cap_cast<IF>(Native_capability(0, (long)interface));
typedef Native_capability::Dst Dst;
return reinterpret_cap_cast<IF>(Native_capability(Dst(), (long)interface));
};
};
}

View File

@ -95,9 +95,20 @@ namespace Genode {
return (t1.tid != t2.tid) || (t1.pid != t2.pid); }
struct Cap_dst_policy {
typedef long Dst;
static bool valid(Dst id) { return id != 0; }
static Dst invalid() { return 0; }
struct Dst
{
long tid; /* XXX to be removed once the transition to SCM rights
is completed */
int socket;
Dst() : tid(0), socket(-1) { }
Dst(long tid, int socket) : tid(tid), socket(socket) { }
};
static bool valid(Dst id) { return id.tid != 0; }
static Dst invalid() { return Dst(); }
static void copy(void* dst, Native_capability_tpl<Cap_dst_policy>* src);
};

View File

@ -327,7 +327,9 @@ namespace Genode {
long local_name = _get_env_ulong("parent_local_name");
/* produce typed capability manually */
return reinterpret_cap_cast<Parent>(Native_capability(tid, local_name));
typedef Native_capability::Dst Dst;
return reinterpret_cap_cast<Parent>(Native_capability(Dst(tid, -1),
local_name));
}