mirror of https://github.com/status-im/evmc.git
EVM-C: return by explicit output param
In evm_query_fn, return result by explicit output parameter to avoid C ABI issues and inrease portability. C compiler would do the same implicitly.
This commit is contained in:
parent
575337b449
commit
66b2ae9663
|
@ -16,25 +16,27 @@ struct evm_uint160be address(struct evm_env* env)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static union evm_variant query(struct evm_env* env,
|
||||
enum evm_query_key key,
|
||||
const union evm_variant* arg) {
|
||||
union evm_variant result;
|
||||
static void query(union evm_variant* result,
|
||||
struct evm_env* env,
|
||||
enum evm_query_key key,
|
||||
const union evm_variant* arg) {
|
||||
printf("EVM-C: QUERY %d\n", key);
|
||||
switch (key) {
|
||||
case EVM_GAS_LIMIT: result.int64 = 314; break;
|
||||
case EVM_GAS_LIMIT:
|
||||
result->int64 = 314;
|
||||
break;
|
||||
|
||||
case EVM_BALANCE:
|
||||
result.uint256be = balance(env, arg->address);
|
||||
result->uint256be = balance(env, arg->address);
|
||||
break;
|
||||
|
||||
case EVM_ADDRESS:
|
||||
result.address = address(env);
|
||||
result->address = address(env);
|
||||
break;
|
||||
|
||||
default: result.int64 = 0; break;
|
||||
default:
|
||||
result->int64 = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static void update(struct evm_env* env,
|
||||
|
|
|
@ -229,9 +229,10 @@ union evm_variant {
|
|||
/// @param arg evm_variant::uint256be The index of the storage entry.
|
||||
/// @result evm_variant::uint256be The current value of the storage entry.
|
||||
///
|
||||
typedef union evm_variant (*evm_query_fn)(struct evm_env* env,
|
||||
enum evm_query_key key,
|
||||
const union evm_variant* arg);
|
||||
typedef void (*evm_query_fn)(union evm_variant* result,
|
||||
struct evm_env* env,
|
||||
enum evm_query_key key,
|
||||
const union evm_variant* arg);
|
||||
|
||||
/// The update callback key.
|
||||
enum evm_update_key {
|
||||
|
|
Loading…
Reference in New Issue