Skip to content

Commit

Permalink
expose RTLD_LAZY
Browse files Browse the repository at this point in the history
  • Loading branch information
xan105 committed Oct 5, 2023
1 parent 3949e5a commit a9b3d6a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lib/ffi-napi/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ function load(path, option = {}){
const options = {
ignoreLoadingFail: asBoolean(option.ignoreLoadingFail) ?? false,
ignoreMissingSymbol: asBoolean(option.ignoreMissingSymbol) ?? false,
lazy: asBoolean(option.lazy) ?? false,
abi: conventions.includes(option.abi) ? option.abi : "default_abi"
};

Expand All @@ -45,7 +46,7 @@ function load(path, option = {}){
if (path.indexOf(ext) === -1) path += ext;
const [ dylib, err ] = attempt(ffi.DynamicLibrary, [
path,
ffi.DynamicLibrary.FLAGS.RTLD_NOW,
options.lazy ? ffi.DynamicLibrary.FLAGS.RTLD_LAZY : ffi.DynamicLibrary.FLAGS.RTLD_NOW,
ffi["FFI_" + options.abi.toUpperCase()]
]);

Expand Down
3 changes: 2 additions & 1 deletion lib/koffi/open.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function load(path, option = {}){
const options = {
ignoreLoadingFail: asBoolean(option.ignoreLoadingFail) ?? false,
ignoreMissingSymbol: asBoolean(option.ignoreMissingSymbol) ?? false,
lazy: asBoolean(option.lazy) ?? false,
abi: conventions.includes(option.abi) ? option.abi : "func"
};

Expand All @@ -40,7 +41,7 @@ function load(path, option = {}){
}[platform] ?? ".so";

if (path.indexOf(ext) === -1) path += ext;
const [dylib, err] = attemptify(koffi.load)(path, { lazy: false });
const [dylib, err] = attemptify(koffi.load)(path, { lazy: options.lazy });

if(err && !options.ignoreLoadingFail){
throw new Failure(err.message, {
Expand Down

0 comments on commit a9b3d6a

Please sign in to comment.