diff --git a/base-codezero/include/base/native_types.h b/base-codezero/include/base/native_types.h index 401d51db64..bb43b6c6ce 100644 --- a/base-codezero/include/base/native_types.h +++ b/base-codezero/include/base/native_types.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + 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; diff --git a/base-fiasco/include/base/native_types.h b/base-fiasco/include/base/native_types.h index 813e2663af..719d585374 100644 --- a/base-fiasco/include/base/native_types.h +++ b/base-fiasco/include/base/native_types.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + namespace Fiasco { #include @@ -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; diff --git a/base-foc/include/base/native_types.h b/base-foc/include/base/native_types.h index b20ab329d3..62cf03d504 100644 --- a/base-foc/include/base/native_types.h +++ b/base-foc/include/base/native_types.h @@ -1,6 +1,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + namespace Fiasco { #include #include @@ -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; diff --git a/base-host/include/base/native_types.h b/base-host/include/base/native_types.h index 9738ed3783..6b992420b4 100644 --- a/base-host/include/base/native_types.h +++ b/base-host/include/base/native_types.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + 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; diff --git a/base-linux/include/base/native_types.h b/base-linux/include/base/native_types.h index 31607546a5..6960bbd9d8 100644 --- a/base-linux/include/base/native_types.h +++ b/base-linux/include/base/native_types.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + /* * We cannot just include and 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 */ diff --git a/base-mb/include/base/native_types.h b/base-mb/include/base/native_types.h index 063c0234d4..e6cdefcfb0 100755 --- a/base-mb/include/base/native_types.h +++ b/base-mb/include/base/native_types.h @@ -14,6 +14,7 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include #include 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; diff --git a/base-nova/include/base/native_types.h b/base-nova/include/base/native_types.h index 506d87d768..8584709818 100644 --- a/base-nova/include/base/native_types.h +++ b/base-nova/include/base/native_types.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + 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; diff --git a/base-okl4/include/base/native_types.h b/base-okl4/include/base/native_types.h index 41135d61de..d2c0f8b4f9 100644 --- a/base-okl4/include/base/native_types.h +++ b/base-okl4/include/base/native_types.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + namespace Okl4 { extern "C" { #include } } @@ -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; diff --git a/base-pistachio/include/base/native_types.h b/base-pistachio/include/base/native_types.h index c68683efa6..6e785c7afe 100644 --- a/base-pistachio/include/base/native_types.h +++ b/base-pistachio/include/base/native_types.h @@ -14,6 +14,8 @@ #ifndef _INCLUDE__BASE__NATIVE_TYPES_H_ #define _INCLUDE__BASE__NATIVE_TYPES_H_ +#include + namespace Pistachio { #include } @@ -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; diff --git a/base/src/base/process/process.cc b/base/src/base/process/process.cc index 9167861ead..e329c8835f 100644 --- a/base/src/base/process/process.cc +++ b/base/src/base/process/process.cc @@ -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; }