Skip to content
This repository was archived by the owner on Apr 8, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ jobs:
- run:
name: "Test documentation"
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
printf '\n\nDoxygen warnings:\n\n'
cat doxygen.warnings
exit 1
fi
cat doxygen.log
- store_artifacts:
path: ~/docs
destination: docs

upload-docs:
docker:
Expand Down
34 changes: 0 additions & 34 deletions include/evmc/evmc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down
49 changes: 49 additions & 0 deletions include/evmc/helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,53 @@ static inline void evmc_release_result(struct evmc_result* 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;
}

/** @} */

/** @} */
4 changes: 3 additions & 1 deletion test/vmtester/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "vmtester.hpp"

#include <evmc/helpers.h>

#include <cstring>

// Compile time checks:
Expand All @@ -22,7 +24,7 @@ static_assert(sizeof(evmc_revision) == sizeof(int), "Enum `evmc_revision` is not

static constexpr size_t optionalDataSize =
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)
{
Expand Down