diff options
author | Elias Sjögreen <eliassjogreen1@gmail.com> | 2021-12-15 15:41:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-15 15:41:49 +0100 |
commit | ee49cce726c27cdcb372b9dba7f2deab840d9e6b (patch) | |
tree | d1a9a843eb5fba782a7cff5e50cb973ee3806225 /test_ffi/src/lib.rs | |
parent | 4d176b7b7c11aabc584bee45423f108ea47faefe (diff) |
feat(ext/ffi): implement UnsafePointer and UnsafePointerView (#12828)
Diffstat (limited to 'test_ffi/src/lib.rs')
-rw-r--r-- | test_ffi/src/lib.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test_ffi/src/lib.rs b/test_ffi/src/lib.rs index 38275e547..b0206276a 100644 --- a/test_ffi/src/lib.rs +++ b/test_ffi/src/lib.rs @@ -3,6 +3,8 @@ use std::thread::sleep; use std::time::Duration; +static BUFFER: [u8; 8] = [1, 2, 3, 4, 5, 6, 7, 8]; + #[no_mangle] pub extern "C" fn print_something() { println!("something"); @@ -29,6 +31,16 @@ pub extern "C" fn print_buffer2( } #[no_mangle] +pub extern "C" fn return_buffer() -> *const u8 { + BUFFER.as_ptr() +} + +#[no_mangle] +pub extern "C" fn is_null_ptr(ptr: *const u8) -> u8 { + ptr.is_null() as u8 +} + +#[no_mangle] pub extern "C" fn add_u32(a: u32, b: u32) -> u32 { a + b } |