From db7614726184b8e50c4713b8087eea83a21e3a42 Mon Sep 17 00:00:00 2001 From: Takahiro Ishikawa Date: Thu, 5 Dec 2024 21:01:23 +0900 Subject: [PATCH] delete unnecessary dlopen Signed-off-by: Takahiro Ishikawa --- src/agnocast_heaphook/src/lib.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/agnocast_heaphook/src/lib.rs b/src/agnocast_heaphook/src/lib.rs index a8821d44..d8648955 100644 --- a/src/agnocast_heaphook/src/lib.rs +++ b/src/agnocast_heaphook/src/lib.rs @@ -82,6 +82,10 @@ static ORIGINAL_MEMALIGN: LazyLock = LazyLock::new(|| { static MEMPOOL_START: AtomicUsize = AtomicUsize::new(0); static MEMPOOL_END: AtomicUsize = AtomicUsize::new(0); +extern "C" { + fn initialize_agnocast(size: usize) -> *mut c_void; +} + const FLLEN: usize = 28; // The maximum block size is (32 << 28) - 1 = 8_589_934_591 (nearly 8GiB) const SLLEN: usize = 64; // The worst-case internal fragmentation is ((32 << 28) / 64 - 2) = 134_217_726 (nearly 128MiB) type FLBitmap = u32; // FLBitmap should contain at least FLLEN bits @@ -99,26 +103,6 @@ static TLSF: LazyLock> = LazyLock::new(|| { let page_size: usize = unsafe { libc::sysconf(libc::_SC_PAGESIZE) as usize }; let aligned_size: usize = (mempool_size + page_size - 1) & !(page_size - 1); - let agnocast_lib: *mut c_void = unsafe { - libc::dlopen( - b"libagnocast.so\0".as_ptr() as *const c_char, - libc::RTLD_NOW, - ) - }; - if agnocast_lib.is_null() { - panic!("[ERROR] [Agnocast] Failed to load libagnocast.so"); - } - - let symbol: &CStr = CStr::from_bytes_with_nul(b"initialize_agnocast\0").unwrap(); - let initialize_agnocast_ptr: *mut c_void = - unsafe { libc::dlsym(agnocast_lib, symbol.as_ptr()) }; - if initialize_agnocast_ptr.is_null() { - panic!("[ERROR] [Agnocast] Failed to find initialize_agnocast() function"); - } - - let initialize_agnocast: InitializeAgnocastType = - unsafe { std::mem::transmute(initialize_agnocast_ptr) }; - let mempool_ptr: *mut c_void = unsafe { initialize_agnocast(aligned_size) }; let pool: &mut [MaybeUninit] = unsafe {