dl: always use dl.get_shared_library_extension() for dl.dl_ext

pull/7351/head
Delyan Angelov 2020-12-15 18:53:27 +02:00
parent 3e85c759aa
commit 50c09e074a
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 12 additions and 13 deletions

View File

@ -2,4 +2,16 @@ module dl
pub const ( pub const (
version = 1 version = 1
dl_ext = get_shared_library_extension()
) )
pub fn get_shared_library_extension() string {
mut res := '.so'
$if macos {
res = '.dylib'
}
$if windows {
res = '.dll'
}
return res
}

View File

@ -4,7 +4,6 @@ module dl
pub const ( pub const (
rtld_now = C.RTLD_NOW rtld_now = C.RTLD_NOW
rtld_lazy = C.RTLD_LAZY rtld_lazy = C.RTLD_LAZY
dl_ext = get_shared_library_extension()
) )
fn C.dlopen(filename charptr, flags int) voidptr fn C.dlopen(filename charptr, flags int) voidptr
@ -27,14 +26,3 @@ pub fn close(handle voidptr) bool {
pub fn sym(handle voidptr, symbol string) voidptr { pub fn sym(handle voidptr, symbol string) voidptr {
return C.dlsym(handle, symbol.str) return C.dlsym(handle, symbol.str)
} }
pub fn get_shared_library_extension() string {
mut res := '.so'
$if macos {
res = '.dylib'
}
$if windows {
res = '.dll'
}
return res
}

View File

@ -3,7 +3,6 @@ module dl
pub const ( pub const (
rtld_now = 0 rtld_now = 0
rtld_lazy = 0 rtld_lazy = 0
dl_ext = '.dll'
) )
fn C.LoadLibrary(libfilename C.LPCWSTR) voidptr fn C.LoadLibrary(libfilename C.LPCWSTR) voidptr