-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more examples of temporal safety (#279)
Following the recent thread with Murali on sub objects I though it would be useful to add some more use cases to the temporal_safety example to illustrate sub objects and also claims
- Loading branch information
1 parent
9baefdb
commit 64d8460
Showing
5 changed files
with
207 additions
and
10 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
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
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,34 @@ | ||
#include <compartment.h> | ||
#include <cstdlib> | ||
#include <debug.hh> | ||
#include <fail-simulator-on-error.h> | ||
|
||
/// Expose debugging features unconditionally for this compartment. | ||
using Debug = ConditionalDebug<true, "Claimant compartment">; | ||
|
||
void *x; | ||
|
||
int __cheri_compartment("claimant") make_claim(void *ptr) | ||
{ | ||
Debug::log("Initial quota: {}", heap_quota_remaining(MALLOC_CAPABILITY)); | ||
|
||
if (x != nullptr) | ||
{ | ||
free(x); | ||
} | ||
|
||
Timeout t{10}; | ||
heap_claim(MALLOC_CAPABILITY, ptr); | ||
x = ptr; | ||
|
||
Debug::log("Make Claim : {}", x); | ||
Debug::log("heap quota: {}", heap_quota_remaining(MALLOC_CAPABILITY)); | ||
return 0; | ||
}; | ||
|
||
int __cheri_compartment("claimant") show_claim() | ||
{ | ||
Debug::log("Show Claim : {}", x); | ||
|
||
return 0; | ||
} |
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,5 @@ | ||
#include "compartment-macros.h" | ||
|
||
int __cheri_compartment("claimant") make_claim(void *ptr); | ||
|
||
int __cheri_compartment("claimant") show_claim(); |
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