mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
update
This commit is contained in:
144
external/wasmi/patches/0001-xrplf-0.42.1.patch
vendored
Normal file
144
external/wasmi/patches/0001-xrplf-0.42.1.patch
vendored
Normal file
@@ -0,0 +1,144 @@
|
||||
diff --git a/crates/c_api/CMakeLists.txt b/crates/c_api/CMakeLists.txt
|
||||
index b15c787a..4e6de690 100644
|
||||
--- a/crates/c_api/CMakeLists.txt
|
||||
+++ b/crates/c_api/CMakeLists.txt
|
||||
@@ -43,6 +43,10 @@ endif()
|
||||
list(TRANSFORM WASMI_SHARED_FILES PREPEND ${WASMI_TARGET_DIR}/)
|
||||
list(TRANSFORM WASMI_STATIC_FILES PREPEND ${WASMI_TARGET_DIR}/)
|
||||
|
||||
+if(NOT BUILD_SHARED_LIBS)
|
||||
+ set(WASMI_SHARED_FILES)
|
||||
+endif()
|
||||
+
|
||||
# Instructions on how to build and install the Wasmi Rust crate.
|
||||
find_program(WASMI_CARGO_BINARY cargo REQUIRED)
|
||||
include(ExternalProject)
|
||||
@@ -112,6 +116,7 @@ install(
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
|
||||
+if(BUILD_SHARED_LIBS)
|
||||
if(WASMI_TARGET MATCHES "darwin")
|
||||
set(INSTALLED_LIB "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/libwasmi.dylib")
|
||||
install(
|
||||
@@ -131,6 +136,7 @@ if(WASMI_TARGET MATCHES "darwin")
|
||||
install(CODE "execute_process(COMMAND ${install_name_tool_cmd})")
|
||||
endif()
|
||||
endif()
|
||||
+endif()
|
||||
|
||||
# Documentation Generation via Doxygen:
|
||||
set(DOXYGEN_CONF_IN ${CMAKE_CURRENT_SOURCE_DIR}/doxygen.conf.in)
|
||||
@@ -141,19 +147,3 @@ add_custom_target(doc
|
||||
DEPENDS ${WASMI_GENERATED_CONF_H} ${DOXYGEN_CONF_OUT}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
)
|
||||
-
|
||||
-# C-Header Formatting via clang-format:
|
||||
-find_program(CLANG_FORMAT clang-format REQUIRED)
|
||||
-file(GLOB_RECURSE HEADER_FILES
|
||||
- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi.h
|
||||
- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi/*.h
|
||||
- ${CMAKE_CURRENT_SOURCE_DIR}/include/wasmi/*.hh
|
||||
-)
|
||||
-add_custom_target(check-format
|
||||
- COMMAND ${CLANG_FORMAT} -style=llvm -Werror --dry-run ${HEADER_FILES}
|
||||
- COMMENT "clang-format: Check formatting for Wasmi C-API header files"
|
||||
-)
|
||||
-add_custom_target(format
|
||||
- COMMAND ${CLANG_FORMAT} -style=llvm -i ${HEADER_FILES}
|
||||
- COMMENT "clang-format: Apply formatting rules for Wasmi C-API header files"
|
||||
-)
|
||||
diff --git a/crates/c_api/include/wasm.h b/crates/c_api/include/wasm.h
|
||||
index 5ee617ff..0199192d 100644
|
||||
--- a/crates/c_api/include/wasm.h
|
||||
+++ b/crates/c_api/include/wasm.h
|
||||
@@ -146,6 +146,13 @@ WASM_DECLARE_OWN(store)
|
||||
|
||||
WASM_API_EXTERN own wasm_store_t* wasm_store_new(wasm_engine_t*);
|
||||
|
||||
+// Store fuel functions (forward declarations)
|
||||
+struct wasmi_error;
|
||||
+
|
||||
+WASM_API_EXTERN struct wasmi_error* wasm_store_get_fuel(const wasm_store_t*, uint64_t* fuel);
|
||||
+WASM_API_EXTERN struct wasmi_error* wasm_store_set_fuel(wasm_store_t*, uint64_t fuel);
|
||||
+//WASM_API_EXTERN void *wasm_store_get_data(const wasm_store_t*);
|
||||
+//WASM_API_EXTERN void wasm_store_set_data(wasm_store_t*, void *data);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Type Representations
|
||||
diff --git a/crates/c_api/include/wasmi.h b/crates/c_api/include/wasmi.h
|
||||
index 2caffa37..0c0584ec 100644
|
||||
--- a/crates/c_api/include/wasmi.h
|
||||
+++ b/crates/c_api/include/wasmi.h
|
||||
@@ -10,7 +10,7 @@
|
||||
/**
|
||||
* \brief Wasmi version string.
|
||||
*/
|
||||
-#define WASMI_VERSION "0.35.0"
|
||||
+#define WASMI_VERSION "0.42.1"
|
||||
/**
|
||||
* \brief Wasmi major version number.
|
||||
*/
|
||||
@@ -18,10 +18,10 @@
|
||||
/**
|
||||
* \brief Wasmi minor version number.
|
||||
*/
|
||||
-#define WASMI_VERSION_MINOR 35
|
||||
+#define WASMI_VERSION_MINOR 42
|
||||
/**
|
||||
* \brief Wasmi patch version number.
|
||||
*/
|
||||
-#define WASMI_VERSION_PATCH 0
|
||||
+#define WASMI_VERSION_PATCH 1
|
||||
|
||||
#endif // WASMI_H
|
||||
diff --git a/crates/c_api/src/store.rs b/crates/c_api/src/store.rs
|
||||
index 56d4898f..543dbff8 100644
|
||||
--- a/crates/c_api/src/store.rs
|
||||
+++ b/crates/c_api/src/store.rs
|
||||
@@ -175,3 +175,44 @@ pub extern "C" fn wasmi_context_set_fuel(
|
||||
) -> Option<Box<wasmi_error_t>> {
|
||||
crate::handle_result(store.set_fuel(fuel), |()| {})
|
||||
}
|
||||
+
|
||||
+////////////////////////////////////////////////////////////////////////////////////////
|
||||
+////////////////////////////////////////////////////////////////////////////////////////
|
||||
+////////////////////////////////////////////////////////////////////////////////////////
|
||||
+////////////////////////////////////////////////////////////////////////////////////////
|
||||
+
|
||||
+/// Returns the current fuel of the wasm store context in `fuel`.
|
||||
+///
|
||||
+/// Wraps [`Store::get_fuel`].
|
||||
+///
|
||||
+/// # Errors
|
||||
+///
|
||||
+/// If [`Store::get_fuel`] errors.
|
||||
+#[no_mangle]
|
||||
+pub extern "C" fn wasm_store_get_fuel(
|
||||
+ store: &wasm_store_t,
|
||||
+ fuel: &mut u64,
|
||||
+) -> Option<Box<wasmi_error_t>> {
|
||||
+ let context = unsafe { store.inner.context() };
|
||||
+ crate::handle_result(context.get_fuel(), |amt| {
|
||||
+ *fuel = amt;
|
||||
+ })
|
||||
+}
|
||||
+
|
||||
+/// Sets the current fuel of the wasm store context to `fuel`.
|
||||
+///
|
||||
+/// Wraps [`Store::set_fuel`].
|
||||
+///
|
||||
+/// # Errors
|
||||
+///
|
||||
+/// If [`Store::set_fuel`] errors.
|
||||
+#[no_mangle]
|
||||
+pub extern "C" fn wasm_store_set_fuel(
|
||||
+ store: &mut wasm_store_t,
|
||||
+ fuel: u64,
|
||||
+) -> Option<Box<wasmi_error_t>> {
|
||||
+
|
||||
+ let mut context = unsafe { store.inner.context_mut() };
|
||||
+ crate::handle_result(context.set_fuel(fuel), |()| {})
|
||||
+}
|
||||
+
|
||||
Reference in New Issue
Block a user