Skip to content

Commit 2432415

Browse files
committed
Migrate code from HostFunctionXX to HostFunction
Signed-off-by: Jorge Prendes <[email protected]>
1 parent 0454d5f commit 2432415

File tree

8 files changed

+13
-33
lines changed

8 files changed

+13
-33
lines changed

src/hyperlight_host/benches/benchmarks.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::time::Duration;
1919

2020
use criterion::{criterion_group, criterion_main, Criterion};
2121
use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType};
22-
use hyperlight_host::func::HostFunction2;
22+
use hyperlight_host::func::HostFunction;
2323
use hyperlight_host::sandbox::{MultiUseSandbox, SandboxConfiguration, UninitializedSandbox};
2424
use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox;
2525
use hyperlight_host::sandbox_state::transition::Noop;

src/hyperlight_host/examples/guest-debugging/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::sync::{Arc, Mutex};
1818
use std::thread;
1919

2020
use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType};
21-
use hyperlight_host::func::HostFunction0;
21+
use hyperlight_host::func::HostFunction;
2222
#[cfg(gdb)]
2323
use hyperlight_host::sandbox::config::DebugInfo;
2424
use hyperlight_host::sandbox::SandboxConfiguration;

src/hyperlight_host/examples/hello-world/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::sync::{Arc, Mutex};
1818
use std::thread;
1919

2020
use hyperlight_common::flatbuffer_wrappers::function_types::{ParameterValue, ReturnType};
21-
use hyperlight_host::func::HostFunction0;
21+
use hyperlight_host::func::HostFunction;
2222
use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox;
2323
use hyperlight_host::sandbox_state::transition::Noop;
2424
use hyperlight_host::{MultiUseSandbox, UninitializedSandbox};

src/hyperlight_host/src/func/guest_dispatch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ mod tests {
112112

113113
use super::*;
114114
use crate::func::call_ctx::MultiUseGuestCallContext;
115-
use crate::func::host_functions::HostFunction0;
115+
use crate::func::host_functions::HostFunction;
116116
use crate::sandbox::is_hypervisor_present;
117117
use crate::sandbox::uninitialized::GuestBinary;
118118
use crate::sandbox_state::sandbox::EvolvableSandbox;

src/hyperlight_host/src/func/mod.rs

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -77,25 +77,5 @@ impl HyperlightFunction {
7777
}
7878
}
7979

80-
/// Re-export for `HostFunction0` trait
81-
pub use host_functions::HostFunction0;
82-
/// Re-export for `HostFunction1` trait
83-
pub use host_functions::HostFunction1;
84-
/// Re-export for `HostFunction10` trait
85-
pub use host_functions::HostFunction10;
86-
/// Re-export for `HostFunction2` trait
87-
pub use host_functions::HostFunction2;
88-
/// Re-export for `HostFunction3` trait
89-
pub use host_functions::HostFunction3;
90-
/// Re-export for `HostFunction4` trait
91-
pub use host_functions::HostFunction4;
92-
/// Re-export for `HostFunction5` trait
93-
pub use host_functions::HostFunction5;
94-
/// Re-export for `HostFunction6` trait
95-
pub use host_functions::HostFunction6;
96-
/// Re-export for `HostFunction7` trait
97-
pub use host_functions::HostFunction7;
98-
/// Re-export for `HostFunction8` trait
99-
pub use host_functions::HostFunction8;
100-
/// Re-export for `HostFunction9` trait
101-
pub use host_functions::HostFunction9;
80+
/// Re-export for `HostFunction` trait
81+
pub use host_functions::HostFunction;

src/hyperlight_host/src/sandbox/uninitialized.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use super::mem_mgr::MemMgrWrapper;
3030
use super::run_options::SandboxRunOptions;
3131
use super::uninitialized_evolve::evolve_impl_multi_use;
3232
use crate::error::HyperlightError::GuestBinaryShouldBeAFile;
33-
use crate::func::host_functions::HostFunction1;
33+
use crate::func::host_functions::HostFunction;
3434
use crate::mem::exe::ExeInfo;
3535
use crate::mem::mgr::{SandboxMemoryManager, STACK_COOKIE_LEN};
3636
use crate::mem::shared_mem::ExclusiveSharedMemory;
@@ -128,7 +128,7 @@ impl UninitializedSandbox {
128128
guest_binary: GuestBinary,
129129
cfg: Option<SandboxConfiguration>,
130130
sandbox_run_options: Option<SandboxRunOptions>,
131-
host_print_writer: Option<&dyn HostFunction1<String, i32>>,
131+
host_print_writer: Option<&dyn HostFunction<i32, (String,)>>,
132132
) -> Result<Self> {
133133
log_build_details();
134134

@@ -355,7 +355,7 @@ mod tests {
355355
use tracing_core::Subscriber;
356356
use uuid::Uuid;
357357

358-
use crate::func::{HostFunction1, HostFunction2};
358+
use crate::func::HostFunction;
359359
use crate::sandbox::uninitialized::GuestBinary;
360360
use crate::sandbox::SandboxConfiguration;
361361
use crate::sandbox_state::sandbox::EvolvableSandbox;

src/hyperlight_host/tests/common/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
use hyperlight_host::func::HostFunction1;
17+
use hyperlight_host::func::HostFunction;
1818
use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox;
1919
use hyperlight_host::sandbox_state::transition::Noop;
2020
use hyperlight_host::{GuestBinary, MultiUseSandbox, Result, UninitializedSandbox};
@@ -46,7 +46,7 @@ pub fn new_uninit_rust() -> Result<UninitializedSandbox> {
4646
}
4747

4848
pub fn get_simpleguest_sandboxes(
49-
writer: Option<&dyn HostFunction1<String, i32>>, // An optional writer to make sure correct info is passed to the host printer
49+
writer: Option<&dyn HostFunction<i32, (String,)>>, // An optional writer to make sure correct info is passed to the host printer
5050
) -> Vec<MultiUseSandbox> {
5151
let elf_path = get_c_or_rust_simpleguest_path();
5252
let exe_path = format!("{elf_path}.exe");
@@ -99,7 +99,7 @@ pub fn get_simpleguest_sandboxes(
9999
}
100100

101101
pub fn get_callbackguest_uninit_sandboxes(
102-
writer: Option<&dyn HostFunction1<String, i32>>, // An optional writer to make sure correct info is passed to the host printer
102+
writer: Option<&dyn HostFunction<i32, (String,)>>, // An optional writer to make sure correct info is passed to the host printer
103103
) -> Vec<UninitializedSandbox> {
104104
let elf_path = get_c_or_rust_callbackguest_path();
105105
let exe_path = format!("{elf_path}.exe");

src/hyperlight_host/tests/sandbox_host_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use core::f64;
1818
use std::sync::{Arc, Mutex};
1919

2020
use common::new_uninit;
21-
use hyperlight_host::func::{HostFunction1, ParameterValue, ReturnType, ReturnValue};
21+
use hyperlight_host::func::{HostFunction, ParameterValue, ReturnType, ReturnValue};
2222
use hyperlight_host::sandbox::SandboxConfiguration;
2323
use hyperlight_host::sandbox_state::sandbox::EvolvableSandbox;
2424
use hyperlight_host::sandbox_state::transition::Noop;

0 commit comments

Comments
 (0)