| @@ -48,14 +48,13 @@ const DEFAULT_HEAP_SIZE: usize = 32 * 1024; | |||||||
| pub fn register_helpers<'a>( | pub fn register_helpers<'a>( | ||||||
|     vm: &mut EbpfVm<'a, BPFError>, |     vm: &mut EbpfVm<'a, BPFError>, | ||||||
| ) -> Result<MemoryRegion, EbpfError<BPFError>> { | ) -> Result<MemoryRegion, EbpfError<BPFError>> { | ||||||
|  |     // Helper function common across languages | ||||||
|     vm.register_helper_ex("abort", helper_abort)?; |     vm.register_helper_ex("abort", helper_abort)?; | ||||||
|     vm.register_helper_ex("sol_panic", helper_sol_panic)?; |  | ||||||
|     vm.register_helper_ex("sol_panic_", helper_sol_panic)?; |     vm.register_helper_ex("sol_panic_", helper_sol_panic)?; | ||||||
|     vm.register_helper_ex("sol_log", helper_sol_log)?; |  | ||||||
|     vm.register_helper_ex("sol_log_", helper_sol_log)?; |     vm.register_helper_ex("sol_log_", helper_sol_log)?; | ||||||
|     vm.register_helper_ex("sol_log_64", helper_sol_log_u64)?; |  | ||||||
|     vm.register_helper_ex("sol_log_64_", helper_sol_log_u64)?; |     vm.register_helper_ex("sol_log_64_", helper_sol_log_u64)?; | ||||||
|  |  | ||||||
|  |     // Memory allocator | ||||||
|     let heap = vec![0_u8; DEFAULT_HEAP_SIZE]; |     let heap = vec![0_u8; DEFAULT_HEAP_SIZE]; | ||||||
|     let heap_region = MemoryRegion::new_from_slice(&heap, MM_HEAP_START); |     let heap_region = MemoryRegion::new_from_slice(&heap, MM_HEAP_START); | ||||||
|     vm.register_helper_with_context_ex( |     vm.register_helper_with_context_ex( | ||||||
| @@ -142,8 +141,9 @@ fn translate_string_and_do( | |||||||
| } | } | ||||||
|  |  | ||||||
| /// Abort helper functions, called when the BPF program calls `abort()` | /// Abort helper functions, called when the BPF program calls `abort()` | ||||||
| /// The verify function returns an error which will cause the BPF program | /// LLVM will insert calls to `abort()` if it detects an untenable situation, | ||||||
| /// to be halted immediately | /// `abort()` is not intended to be called explicitly by the program. | ||||||
|  | /// Causes the BPF program to be halted immediately | ||||||
| pub fn helper_abort( | pub fn helper_abort( | ||||||
|     _arg1: u64, |     _arg1: u64, | ||||||
|     _arg2: u64, |     _arg2: u64, | ||||||
| @@ -156,9 +156,8 @@ pub fn helper_abort( | |||||||
|     Err(HelperError::Abort.into()) |     Err(HelperError::Abort.into()) | ||||||
| } | } | ||||||
|  |  | ||||||
| /// Panic helper functions, called when the BPF program calls 'sol_panic_()` | /// Panic helper function, called when the BPF program calls 'sol_panic_()` | ||||||
| /// The verify function returns an error which will cause the BPF program | /// Causes the BPF program to be halted immediately | ||||||
| /// to be halted immediately |  | ||||||
| pub fn helper_sol_panic( | pub fn helper_sol_panic( | ||||||
|     file: u64, |     file: u64, | ||||||
|     len: u64, |     len: u64, | ||||||
| @@ -192,7 +191,7 @@ pub fn helper_sol_log( | |||||||
|     Ok(0) |     Ok(0) | ||||||
| } | } | ||||||
|  |  | ||||||
| /// Log 5 u64 values | /// Log 5 64-bit values | ||||||
| pub fn helper_sol_log_u64( | pub fn helper_sol_log_u64( | ||||||
|     arg1: u64, |     arg1: u64, | ||||||
|     arg2: u64, |     arg2: u64, | ||||||
|   | |||||||
| @@ -135,7 +135,9 @@ void sol_log_(const char *, uint64_t); | |||||||
|  * Helper function that prints a 64 bit values represented in hexadecimal |  * Helper function that prints a 64 bit values represented in hexadecimal | ||||||
|  * to stdout |  * to stdout | ||||||
|  */ |  */ | ||||||
| void sol_log_64(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); | void sol_log_64_(uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); | ||||||
|  | #define sol_log_64 sol_log_64_ | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * Size of Public key in bytes |  * Size of Public key in bytes | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user