forked from unikraft/lib-pthread-embedded
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
patches: Add patch for making pte_handle a C++ structure
The CXX library requires pthe_handle to be defined as a C++ structure. This patch also adds the overloaded operators needed by the CXX library. Signed-off-by: Teodora Serbanescu <[email protected]> Reviewed-by: Felipe Huici <[email protected]>
- Loading branch information
1 parent
6eb1154
commit 71258f9
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
From 1465fc0bcb52860d6077ae72a8e2364890485fd1 Mon Sep 17 00:00:00 2001 | ||
From: Teodora Serbanescu <[email protected]> | ||
Date: Wed, 5 Jun 2019 10:45:36 +0300 | ||
Subject: [UNIKRAFT/PTHREAD-EMBEDDED] Make pte_handle a C++ structure | ||
|
||
This patch changes the pte_handle structure to a C++ structure, also adding the | ||
overloaded operators needed by the cxx library. | ||
|
||
Signed-off-by: Teodora Serbanescu <[email protected]> | ||
--- | ||
pthread.h | 28 ++++++++++++++++++++++++++++ | ||
1 file changed, 28 insertions(+) | ||
|
||
diff --git a/pthread.h b/pthread.h | ||
index 33df446..48625a4 100644 | ||
--- a/pthread.h | ||
+++ b/pthread.h | ||
@@ -388,10 +388,25 @@ enum | ||
* that available with a simple pointer. It should scale for either | ||
* IA-32 or IA-64. | ||
*/ | ||
+ | ||
+#ifdef __cplusplus | ||
+ typedef struct pte_handle | ||
+#else | ||
typedef struct | ||
+#endif | ||
{ | ||
void * p; /* Pointer to actual object */ | ||
unsigned int x; /* Extra information - reuse count etc */ | ||
+ | ||
+#ifdef __cplusplus | ||
+ pte_handle() {}; | ||
+ pte_handle(int ptr_value) | ||
+ { | ||
+ this->p = reinterpret_cast <void *>(ptr_value); | ||
+ } | ||
+ inline struct pte_handle& operator=(unsigned int ptr_value); | ||
+ inline bool operator==(int ptr_value); | ||
+#endif | ||
} pte_handle_t; | ||
|
||
typedef pte_handle_t pthread_t; | ||
@@ -994,6 +1009,19 @@ enum | ||
{ | ||
return ((size_t) l.p) == ((size_t) r.p); | ||
} | ||
+ | ||
+ /* Operator to compare the thread pointer with a given value */ | ||
+ bool pte_handle_t::operator==(int ptr_value) | ||
+ { | ||
+ return ((size_t) this->p) == ((size_t) (reinterpret_cast <void *>(ptr_value))); | ||
+ } | ||
+ | ||
+ /* Operator to assign a given value to the thread pointer */ | ||
+ pte_handle_t& pte_handle_t::operator=(unsigned int ptr_value) | ||
+ { | ||
+ this->p = reinterpret_cast <void *>(ptr_value); | ||
+ return *this; | ||
+ } | ||
#endif | ||
|
||
|
||
-- | ||
2.20.1 | ||
|