From f70f2628c478331e860a66f7e55ec2a416253797 Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 31 Jul 2024 11:14:36 -0700 Subject: [PATCH] vm: removing dlsym-raw, it's not different enough --- basis/alien/libraries/libraries.factor | 6 +----- .../image/primitives/primitives.factor | 4 ---- basis/openssl/libssl/libssl.factor | 2 +- extra/readline/readline.factor | 2 +- vm/alien.cpp | 20 ------------------- vm/code_blocks.cpp | 2 +- vm/os-unix.cpp | 6 +----- vm/os-windows.cpp | 4 ---- vm/primitives.hpp | 2 +- vm/vm.hpp | 2 -- 10 files changed, 6 insertions(+), 44 deletions(-) diff --git a/basis/alien/libraries/libraries.factor b/basis/alien/libraries/libraries.factor index 7118af18eaf..da4c319a7d4 100644 --- a/basis/alien/libraries/libraries.factor +++ b/basis/alien/libraries/libraries.factor @@ -9,14 +9,11 @@ PRIMITIVE: dll-valid? ( dll -- ? ) PRIMITIVE: (dlopen) ( path -- dll ) PRIMITIVE: (dlsym) ( name dll -- alien ) PRIMITIVE: dlclose ( dll -- ) -PRIMITIVE: (dlsym-raw) ( name dll -- alien ) : dlopen ( path -- dll ) native-string>alien (dlopen) ; : dlsym ( name dll -- alien ) [ string>symbol ] dip (dlsym) ; -: dlsym-raw ( name dll -- alien ) [ string>symbol ] dip (dlsym-raw) ; - HOOK: dlerror os ( -- message/f ) SYMBOL: libraries @@ -88,8 +85,7 @@ M: library dispose dll>> [ dispose ] when* ; lookup-library [ abi>> ] [ cdecl ] if* ; : address-of ( name library -- value ) - 2dup library-dll dlsym-raw - [ 2nip ] [ no-such-symbol ] if* ; + 2dup library-dll dlsym [ 2nip ] [ no-such-symbol ] if* ; SYMBOL: deploy-libraries diff --git a/basis/bootstrap/image/primitives/primitives.factor b/basis/bootstrap/image/primitives/primitives.factor index 96551d5b0c6..7194ba0c066 100644 --- a/basis/bootstrap/image/primitives/primitives.factor +++ b/basis/bootstrap/image/primitives/primitives.factor @@ -142,10 +142,6 @@ CONSTANT: all-primitives { { { "(dlopen)" ( path -- dll ) "dlopen" { byte-array } { dll } f } { "(dlsym)" ( name dll -- alien ) "dlsym" { byte-array object } { c-ptr } f } - { - "(dlsym-raw)" ( name dll -- alien ) "dlsym_raw" - { byte-array object } { c-ptr } f - } { "dlclose" ( dll -- ) "dlclose" { dll } { } f } { "dll-valid?" ( dll -- ? ) "dll_validp" { object } { object } f } } diff --git a/basis/openssl/libssl/libssl.factor b/basis/openssl/libssl/libssl.factor index ea3bff87217..83c23012d6b 100644 --- a/basis/openssl/libssl/libssl.factor +++ b/basis/openssl/libssl/libssl.factor @@ -592,7 +592,7 @@ FUNCTION: X509* SSL_get0_peer_certificate ( SSL* ssl ) FUNCTION: X509* SSL_get1_peer_certificate ( SSL* ssl ) : get-ssl-peer-certificate ( ssl -- x509 ) - "SSL_get1_peer_certificate" "libssl" library-dll dlsym-raw + "SSL_get1_peer_certificate" "libssl" library-dll dlsym [ SSL_get1_peer_certificate ] [ SSL_get_peer_certificate ] if ; inline FUNCTION: int SSL_set_cipher_list ( SSL* ssl, c-string str ) diff --git a/extra/readline/readline.factor b/extra/readline/readline.factor index f0a197f6ecf..5cae963b590 100644 --- a/extra/readline/readline.factor +++ b/extra/readline/readline.factor @@ -22,7 +22,7 @@ IN: readline current-line readline.ffi:rl_point head ; : has-readline? ( -- ? ) - "readline" dup library-dll dlsym-raw >boolean ; + "readline" dup library-dll dlsym >boolean ; : set-completion ( quot -- ) [ diff --git a/vm/alien.cpp b/vm/alien.cpp index 8b6cc81b765..b40925029a4 100644 --- a/vm/alien.cpp +++ b/vm/alien.cpp @@ -125,26 +125,6 @@ void factor_vm::primitive_dlsym() { ctx->replace(allot_alien(ffi_dlsym(NULL, sym))); } -// look up a symbol in a native library -// Allocates memory -void factor_vm::primitive_dlsym_raw() { - data_root library(ctx->pop(), this); - data_root name(ctx->peek(), this); - check_tagged(name); - - symbol_char* sym = name->data(); - - if (to_boolean(library.value())) { - dll* d = untag_check(library.value()); - - if (d->handle == NULL) - ctx->replace(false_object); - else - ctx->replace(allot_alien(ffi_dlsym_raw(d, sym))); - } else - ctx->replace(allot_alien(ffi_dlsym_raw(NULL, sym))); -} - // close a native library handle void factor_vm::primitive_dlclose() { dll* d = untag_check(ctx->pop()); diff --git a/vm/code_blocks.cpp b/vm/code_blocks.cpp index d9d774f9f96..394559dc6ed 100644 --- a/vm/code_blocks.cpp +++ b/vm/code_blocks.cpp @@ -149,7 +149,7 @@ cell factor_vm::compute_dlsym_address(array* parameters, FACTOR_ASSERT(TAG(symbol) == BYTE_ARRAY_TYPE); symbol_char* name = alien_offset(symbol); - cell sym = ffi_dlsym_raw(d, name); + cell sym = ffi_dlsym(d, name); sym = toc ? FUNCTION_TOC_POINTER(sym) : FUNCTION_CODE_POINTER(sym); return sym ? sym : undef; } diff --git a/vm/os-unix.cpp b/vm/os-unix.cpp index cd147dd19bd..a0ee896f29c 100644 --- a/vm/os-unix.cpp +++ b/vm/os-unix.cpp @@ -57,12 +57,8 @@ void factor_vm::ffi_dlopen(dll* dll) { dll->handle = dlopen(alien_offset(dll->path), RTLD_LAZY | RTLD_GLOBAL); } -cell factor_vm::ffi_dlsym_raw(dll* dll, symbol_char* symbol) { - return (cell)dlsym(dll ? dll->handle : null_dll, symbol); -} - cell factor_vm::ffi_dlsym(dll* dll, symbol_char* symbol) { - return FUNCTION_CODE_POINTER(ffi_dlsym_raw(dll, symbol)); + return (cell)dlsym(dll ? dll->handle : null_dll, symbol); } void factor_vm::ffi_dlclose(dll* dll) { diff --git a/vm/os-windows.cpp b/vm/os-windows.cpp index 2cab9c4e080..3c23e5b8aaa 100644 --- a/vm/os-windows.cpp +++ b/vm/os-windows.cpp @@ -38,10 +38,6 @@ cell factor_vm::ffi_dlsym(dll* dll, symbol_char* symbol) { symbol); } -cell factor_vm::ffi_dlsym_raw(dll* dll, symbol_char* symbol) { - return ffi_dlsym(dll, symbol); -} - void factor_vm::ffi_dlclose(dll* dll) { FreeLibrary((HMODULE) dll->handle); dll->handle = NULL; diff --git a/vm/primitives.hpp b/vm/primitives.hpp index ea45a3faa40..c6b68a5acb9 100644 --- a/vm/primitives.hpp +++ b/vm/primitives.hpp @@ -18,7 +18,7 @@ namespace factor { _(datastack_for) _(die) _(disable_ctrl_break) _(disable_gc_events) \ _(dispatch_stats) \ _(displaced_alien) _(dlclose) _(dll_validp) _(dlopen) _(dlsym) \ - _(dlsym_raw) _(double_bits) _(enable_ctrl_break) _(enable_gc_events) \ + _(double_bits) _(enable_ctrl_break) _(enable_gc_events) \ _(existsp) _(exit) \ _(fclose) _(fflush) _(fgetc) _(fixnum_divint) _(fixnum_divmod) \ _(fixnum_shift) _(fixnum_to_bignum) _(fixnum_to_float) _(float_add) \ diff --git a/vm/vm.hpp b/vm/vm.hpp index 4bacc4c0773..ecd256c8048 100644 --- a/vm/vm.hpp +++ b/vm/vm.hpp @@ -630,7 +630,6 @@ struct factor_vm { void* alien_pointer(); void primitive_dlopen(); void primitive_dlsym(); - void primitive_dlsym_raw(); void primitive_dlclose(); void primitive_dll_validp(); char* alien_offset(cell obj); @@ -691,7 +690,6 @@ struct factor_vm { void init_ffi(); void ffi_dlopen(dll* dll); cell ffi_dlsym(dll* dll, symbol_char* symbol); - cell ffi_dlsym_raw(dll* dll, symbol_char* symbol); void ffi_dlclose(dll* dll); void c_to_factor_toplevel(cell quot); void init_signals();