-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from p-x9/feature/improve-key-implementation
Improve key implementation
- Loading branch information
Showing
9 changed files
with
324 additions
and
154 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
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 @@ | ||
|
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,39 @@ | ||
// | ||
// associated_object_key.h | ||
// | ||
// | ||
// Created by p-x9 on 2024/01/26. | ||
// | ||
// | ||
|
||
#ifndef associated_object_key_h | ||
#define associated_object_key_h | ||
|
||
#if defined(__wasm__) | ||
// Wasm can't access call frame for security purposes | ||
#define get_return_address() ((void*) 0) | ||
#elif __GNUC__ | ||
#define get_return_address() __builtin_return_address(0) | ||
#elif _MSC_VER | ||
#include <intrin.h> | ||
#define get_return_address() _ReturnAddress() | ||
#else | ||
#error missing implementation for get_return_address | ||
#define get_return_address() ((void*) 0) | ||
#endif | ||
|
||
#ifdef __GNUC__ | ||
#define NOINLINE __attribute__((noinline)) | ||
#elif _MSC_VER | ||
#define NOINLINE __declspec(noinline) | ||
#else | ||
#error missing implementation for `NOINLINE` | ||
#define NOINLINE | ||
#endif | ||
|
||
NOINLINE | ||
const void *_associated_object_key() { | ||
return get_return_address(); | ||
} | ||
|
||
#endif /* associated_object_key_h */ |
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
Oops, something went wrong.