koffi 2.8.1 → 2.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,10 @@
4
4
 
5
5
  ### Koffi 2.8
6
6
 
7
+ #### Koffi 2.8.2 (2024-04-07)
8
+
9
+ - Support [loading library](functions.md#loading-options) with RTLD_GLOBAL on POSIX platforms
10
+
7
11
  #### Koffi 2.8.1 (2024-04-04)
8
12
 
9
13
  - Fix incompatibility with Node 20.12+ and 21.6+
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
package/doc/functions.md CHANGED
@@ -21,13 +21,14 @@ On some platforms (such as with the [musl C library on Linux](https://wiki.musl-
21
21
 
22
22
  ## Loading options
23
23
 
24
- *New in Koffi 2.6*
24
+ *New in Koffi 2.6 and Koffi 2.8.2*
25
25
 
26
26
  The `load` function can take an optional object argument, with the following options:
27
27
 
28
28
  ```js
29
29
  const options = {
30
- lazy: true // Use RTLD_LAZY (lazy-binding) on POSIX platforms (by default, use RTLD_NOW)
30
+ lazy: true, // Use RTLD_LAZY (lazy-binding) on POSIX platforms (by default, use RTLD_NOW)
31
+ global: true // Use RTLD_GLOBAL on POSIX platforms (by default, use RTLD_LOCAL)
31
32
  };
32
33
 
33
34
  const lib = koffi.load('/path/to/shared/library.so', options);
package/index.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.8.1",
382
- stable: "2.8.1",
381
+ version: "2.8.2",
382
+ stable: "2.8.2",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
package/indirect.js CHANGED
@@ -378,8 +378,8 @@ var require_package = __commonJS({
378
378
  "build/dist/src/koffi/package.json"(exports2, module2) {
379
379
  module2.exports = {
380
380
  name: "koffi",
381
- version: "2.8.1",
382
- stable: "2.8.1",
381
+ version: "2.8.2",
382
+ stable: "2.8.2",
383
383
  description: "Fast and simple C FFI (foreign function interface) for Node.js",
384
384
  keywords: [
385
385
  "foreign",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "koffi",
3
- "version": "2.8.1",
4
- "stable": "2.8.1",
3
+ "version": "2.8.2",
4
+ "stable": "2.8.2",
5
5
  "description": "Fast and simple C FFI (foreign function interface) for Node.js",
6
6
  "keywords": [
7
7
  "foreign",
@@ -1717,10 +1717,15 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1717
1717
  }
1718
1718
 
1719
1719
  #ifndef _WIN32
1720
- bool lazy = false;
1720
+ int flags = 0;
1721
+
1721
1722
  if (info.Length() >= 2) {
1722
1723
  Napi::Object options = info[1].As<Napi::Object>();
1723
- lazy = options.Get("lazy").ToBoolean();
1724
+
1725
+ flags |= options.Get("lazy").ToBoolean() ? RTLD_LAZY : RTLD_NOW;
1726
+ flags |= options.Get("global").ToBoolean() ? RTLD_GLOBAL : RTLD_LOCAL;
1727
+ } else {
1728
+ flags = RTLD_NOW | RTLD_LOCAL;
1724
1729
  }
1725
1730
  #endif
1726
1731
 
@@ -1744,8 +1749,6 @@ static Napi::Value LoadSharedLibrary(const Napi::CallbackInfo &info)
1744
1749
  }
1745
1750
  #else
1746
1751
  if (info[0].IsString()) {
1747
- int flags = lazy ? RTLD_LAZY : RTLD_NOW;
1748
-
1749
1752
  std::string filename = info[0].As<Napi::String>();
1750
1753
  module = dlopen(filename.c_str(), flags);
1751
1754