mirror of
https://github.com/genodelabs/genode.git
synced 2025-04-07 19:34:56 +00:00
Don't memcpy the parent capability. Fix #144.
To give the platform developer more freedom in how the Native_capability class is internally implemented (e.g. turning it into a smart-pointer), this patch removes the memcpy operation, when transfering the parent-capability to a new process from the generic code, and let the implementation of the platform-specific Native_capability decide how the transfer has to be done. Please refer to issue #144.
This commit is contained in:
parent
fa377f0df5
commit
9992efed03
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Codezero {
|
||||
|
||||
struct l4_mutex;
|
||||
@ -140,6 +142,12 @@ namespace Genode {
|
||||
int dst() const { return _tid.tid; }
|
||||
|
||||
Native_thread_id tid() const { return _tid; }
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef int Native_connection_state;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/types.h>
|
||||
|
||||
@ -114,6 +116,12 @@ namespace Genode {
|
||||
* Access raw capability data
|
||||
*/
|
||||
Fiasco::l4_threadid_t tid() const { return _tid; }
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef Fiasco::l4_threadid_t Native_connection_state;
|
||||
|
@ -1,6 +1,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Fiasco {
|
||||
#include <l4/sys/consts.h>
|
||||
#include <l4/sys/types.h>
|
||||
@ -84,6 +86,11 @@ namespace Genode {
|
||||
|
||||
bool valid() const { return _cap_sel.valid() && _unique_id != 0; }
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef int Native_connection_state;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
typedef volatile int Native_lock;
|
||||
@ -42,6 +44,12 @@ namespace Genode {
|
||||
void* local() const { return (void*)_local_name; }
|
||||
int dst() const { return 0; }
|
||||
Native_thread_id tid() const { return 0; }
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef int Native_connection_state;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
/*
|
||||
* We cannot just include <semaphore.h> and <pthread.h> here
|
||||
* because this would impy the nested inclusion of a myriad
|
||||
@ -145,6 +147,12 @@ namespace Genode {
|
||||
*/
|
||||
long dst() const { return _tid; }
|
||||
long tid() const { return _tid; }
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef int Native_connection_state; /* socket descriptor */
|
||||
|
@ -14,6 +14,7 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
#include <kernel/types.h>
|
||||
|
||||
namespace Genode {
|
||||
@ -56,6 +57,12 @@ namespace Genode {
|
||||
int dst() const { return (int)_tid; }
|
||||
|
||||
Native_thread_id tid() const { return _tid; }
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef int Native_connection_state;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Genode {
|
||||
|
||||
typedef volatile int Native_lock;
|
||||
@ -85,6 +87,12 @@ namespace Genode {
|
||||
|
||||
int unique_id() const { return _unique_id; }
|
||||
int pt_sel() const { return _pt_sel; }
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef int Native_connection_state;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Okl4 { extern "C" {
|
||||
#include <l4/types.h>
|
||||
} }
|
||||
@ -125,6 +127,12 @@ namespace Genode {
|
||||
* Access raw capability data
|
||||
*/
|
||||
Okl4::L4_ThreadId_t tid() const { return _tid; };
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef Okl4::L4_ThreadId_t Native_connection_state;
|
||||
|
@ -14,6 +14,8 @@
|
||||
#ifndef _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
#define _INCLUDE__BASE__NATIVE_TYPES_H_
|
||||
|
||||
#include <util/string.h>
|
||||
|
||||
namespace Pistachio {
|
||||
#include <l4/types.h>
|
||||
}
|
||||
@ -109,6 +111,12 @@ namespace Genode {
|
||||
* Access raw capability data
|
||||
*/
|
||||
Pistachio::L4_ThreadId_t tid() const { return _tid; };
|
||||
|
||||
/**
|
||||
* Copy this capability to another pd.
|
||||
*/
|
||||
void copy_to(void* dst) {
|
||||
memcpy(dst, this, sizeof(Native_capability)); }
|
||||
};
|
||||
|
||||
typedef Pistachio::L4_ThreadId_t Native_connection_state;
|
||||
|
@ -122,7 +122,7 @@ static addr_t _setup_elf(Parent_capability parent_cap,
|
||||
* data segment
|
||||
*/
|
||||
if (!parent_info) {
|
||||
memcpy(ptr, &parent_cap, sizeof(parent_cap));
|
||||
parent_cap.copy_to(ptr);
|
||||
parent_info = true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user