Merge pull request #59 from ethereum/optional_storage

Result Optional Storage
This commit is contained in:
Paweł Bylica 2018-08-20 11:19:13 +02:00 committed by GitHub
commit c18463bb70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 36 deletions

View File

@ -54,13 +54,16 @@ jobs:
- run: - run:
name: "Test documentation" name: "Test documentation"
command: | command: |
doxygen Doxyfile > doxygen.log 2> doxygen.warnings cat Doxyfile | sed 's/HTML_OUTPUT = ./HTML_OUTPUT = ..\/docs/' | doxygen - > doxygen.log 2> doxygen.warnings
if [ -s doxygen.warnings ]; then if [ -s doxygen.warnings ]; then
printf '\n\nDoxygen warnings:\n\n' printf '\n\nDoxygen warnings:\n\n'
cat doxygen.warnings cat doxygen.warnings
exit 1 exit 1
fi fi
cat doxygen.log cat doxygen.log
- store_artifacts:
path: ~/docs
destination: docs
upload-docs: upload-docs:
docker: docker:

View File

@ -393,40 +393,6 @@ struct evmc_result
}; };
/**
* The union representing evmc_result "optional data".
*
* The evmc_result struct contains 24 bytes of optional data that can be
* reused by the object creator if the object does not contain
* evmc_result::create_address.
*
* An EVM implementation MAY use this memory to keep additional data
* when returning result from ::evmc_execute_fn.
* The host application MAY use this memory to keep additional data
* when returning result of performed calls from ::evmc_call_fn.
*
* @see evmc_get_optional_data(), evmc_get_const_optional_data().
*/
union evmc_result_optional_data
{
uint8_t bytes[24]; /**< 24 bytes of optional data. */
void* pointer; /**< Optional pointer. */
};
/** Provides read-write access to evmc_result "optional data". */
static inline union evmc_result_optional_data* evmc_get_optional_data(struct evmc_result* result)
{
return (union evmc_result_optional_data*)&result->create_address;
}
/** Provides read-only access to evmc_result "optional data". */
static inline const union evmc_result_optional_data* evmc_get_const_optional_data(
const struct evmc_result* result)
{
return (const union evmc_result_optional_data*)&result->create_address;
}
/** /**
* Check account existence callback function * Check account existence callback function
* *

View File

@ -51,4 +51,53 @@ static inline void evmc_release_result(struct evmc_result* result)
result->release(result); result->release(result);
} }
/**
* Helpers for optional storage of evmc_result.
*
* In some contexts (i.e. evmc_result::create_address is unused) objects of
* type evmc_result contains a memory storage that MAY be used by the object
* owner. This group defines helper types and functions for accessing
* the optional storage.
*
* @defgroup result_optional_storage Result Optional Storage
* @{
*/
/**
* The union representing evmc_result "optional storage".
*
* The evmc_result struct contains 24 bytes of optional storage that can be
* reused by the object creator if the object does not contain
* evmc_result::create_address.
*
* A VM implementation MAY use this memory to keep additional data
* when returning result from evmc_execute_fn().
* The host application MAY use this memory to keep additional data
* when returning result of performed calls from evmc_call_fn().
*
* @see evmc_get_optional_storage(), evmc_get_const_optional_storage().
*/
union evmc_result_optional_storage
{
uint8_t bytes[24]; /**< 24 bytes of optional storage. */
void* pointer; /**< Optional pointer. */
};
/** Provides read-write access to evmc_result "optional storage". */
static inline union evmc_result_optional_storage* evmc_get_optional_storage(
struct evmc_result* result)
{
return (union evmc_result_optional_storage*)&result->create_address;
}
/** Provides read-only access to evmc_result "optional storage". */
static inline const union evmc_result_optional_storage* evmc_get_const_optional_storage(
const struct evmc_result* result)
{
return (const union evmc_result_optional_storage*)&result->create_address;
}
/** @} */
/** @} */ /** @} */

View File

@ -4,6 +4,8 @@
#include "vmtester.hpp" #include "vmtester.hpp"
#include <evmc/helpers.h>
#include <cstring> #include <cstring>
// Compile time checks: // Compile time checks:
@ -22,7 +24,7 @@ static_assert(sizeof(evmc_revision) == sizeof(int), "Enum `evmc_revision` is not
static constexpr size_t optionalDataSize = static constexpr size_t optionalDataSize =
sizeof(evmc_result) - offsetof(evmc_result, create_address); sizeof(evmc_result) - offsetof(evmc_result, create_address);
static_assert(optionalDataSize == sizeof(evmc_result_optional_data), ""); static_assert(optionalDataSize == sizeof(evmc_result_optional_storage), "");
TEST_F(evmc_vm_test, abi_version_match) TEST_F(evmc_vm_test, abi_version_match)
{ {