From 497f92bcb830c0a49f53ef1abc75c40d735b9e5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Mon, 29 May 2017 16:24:56 +0200 Subject: [PATCH] EVM-C: Replace evm_result payload with 24 bytes union --- examples/examplevm.c | 1 - include/evm.h | 19 +++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/examples/examplevm.c b/examples/examplevm.c index 54c059e..2a61b87 100644 --- a/examples/examplevm.c +++ b/examples/examplevm.c @@ -94,7 +94,6 @@ static struct evm_result execute(struct evm_instance* instance, ret.output_data = output_data; ret.output_size = address_size; ret.release = &free_result_output_data; - ret.payload.pointer = NULL; // We don't need another pointer. return ret; } else if (code_size == strlen(counter) && diff --git a/include/evm.h b/include/evm.h index 47c4ff5..7b2532c 100644 --- a/include/evm.h +++ b/include/evm.h @@ -170,12 +170,19 @@ struct evm_result { /// function to the result itself allows EVM composition. evm_release_result_fn release; - /// Reserved data to be optionally used by implementations. - union { - uint8_t bytes[24]; - struct evm_uint160be address; - void* pointer; - } payload; + /// Reserved data that MAY be used by a evm_result object creator. + /// + /// This reserved 24 bytes extends the size of the evm_result to 64 bytes + /// (full cache line). + /// An EVM implementation MAY use this memory to keep additional data + /// when returning result from ::evm_execute_fn. + /// The host application MAY use this memory to keep additional data + /// when returning result of performed calls from ::evm_call_fn. + union + { + void* context; ///< A pointer for storing external objects. + uint8_t data[24]; ///< 24 bytes of reserved data. + } reserved; }; /// The query callback key.