CINXE.COM
Changelog | Koffi
<!DOCTYPE html> <html lang="en" class="nojs"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Changelog | Koffi</title> <meta name="author" content="Niels Martign猫ne"> <meta name="description" content="List of Koffi versions"> <link rel="icon" href="/favicon.png?6F4A78C161971E68"> <meta name="theme-color" content="#6aa051"> <link rel="stylesheet" href="/static/site.min.css?62721D34F757222F"> <script type="text/javascript" src="/static/site.min.js?1D8A2E636120C2D4" async></script> </head> <body> <div id="deploy"></div> <nav id="top"> <menu> <a id="logo" href="/"><img src="/static/logo.webp?FE8FFC069ADF0F5B" alt="Logo Koffi" /></a> <li><a href="/" style="margin-left: 0em;">Overview</a></li> <li><a href="#" class="category" style="margin-left: 0em;">Documentation</a><div> <a href="/platforms" style="margin-left: 0em;">Requirements</a> <a href="/start" style="margin-left: 0em;">Get started</a> <a href="/functions" style="margin-left: 0em;">Function calls</a> <a href="/input" style="margin-left: 0em;">Input parameters</a> <a href="/pointers" style="margin-left: 0em;">Data pointers</a> <a href="/output" style="margin-left: 0em;">Output parameters</a> <a href="/unions" style="margin-left: 0em;">Union values</a> <a href="/variables" style="margin-left: 0em;">Exported variables</a> <a href="/callbacks" style="margin-left: 0em;">Javascript callbacks</a> <a href="/misc" style="margin-left: 0em;">Miscellaneous</a> <a href="/packaging" style="margin-left: 0em;">Bundlers and Koffi</a> <a href="/migration" style="margin-left: 0em;">Migration guide</a> </div></li> <li><a href="/benchmarks" style="margin-left: 0em;">Benchmarks</a></li> <li><a href="/contribute" style="margin-left: 0em;">Contribute</a></li> <li><a href="/changelog" class="active" style="margin-left: 0em;">Changelog</a></li> <div style="flex: 1;"></div> <li><a href="https://www.npmjs.com/package/koffi" style="border-bottom-color: transparent; margin-top: 8px;"><img src="https://img.shields.io/npm/v/koffi?color=brightgreen&cacheSeconds=7200" alt="NPM"/></a></li> <li><a href="https://github.com/Koromix/koffi" style="border-bottom-color: transparent; margin-top: 8px;"><img src="https://img.shields.io/badge/GitHub-Koffi-ff6600" alt="GitHub"/></a></li> </menu> </nav> <nav id="side"><menu> <li><a href="#version-history" class="lv1">Version history</a></li> <li><a href="#koffi-2" class="lv2">Koffi 2</a></li> <li><a href="#koffi-1" class="lv2">Koffi 1</a></li> <li><a href="#todo-list" class="lv1">Todo list</a></li> </menu></nav> <main> <h1><a id="version-history"></a><a id="version_history"></a>Version history</h1> <div class="alert note"> <div class="title"></div> <p> Consult the <a href="migration">migration guide</a> to migrate between major Koffi versions.</p> </div> <h2><a id="koffi-2"></a><a id="koffi_2"></a>Koffi 2</h2> <h3>Koffi 2.10</h3> <h4>Koffi 2.10.1 (2025-01-24)</h4> <ul> <li>Fix detection of ARM32 in build script in some cases</li> <li>Fix wrong path for ARM32 prebuild</li> </ul> <h4>Koffi 2.10.0 (2024-12-22)</h4> <ul> <li>Allow <a href="misc#circular-references">redefinition of opaque types</a> to concrete struct or union</li> <li>Clear out executable stack bit from ELF targets (<code>-z noexecstack</code>)</li> <li>Update documentation style</li> </ul> <h3>Koffi 2.9</h3> <h4>Koffi 2.9.2 (2024-11-08)</h4> <ul> <li>Fix non-aligned pointers when pushing UTF-16 and UTF-32 string parameters</li> <li>Various documentation fixes and improvements</li> </ul> <h4>Koffi 2.9.1 (2024-09-23)</h4> <ul> <li>Fix x86 32-bit support regression in 2.9.0</li> <li>Add missing TS definition for <code>koffi.alloc()</code></li> <li>Support <code>koffi.load(null)</code> in TS definition file</li> </ul> <h4>Koffi 2.9.0 (2024-07-22)</h4> <ul> <li>Add support for char32_t and wchar_t (wide) strings</li> <li>Include Linux/musl x64 prebuild (based on Alpine)</li> </ul> <h3>Koffi 2.8</h3> <h4>Koffi 2.8.11 (2024-06-19)</h4> <ul> <li>Work around MSVC compiler bug introduced in Visual Studio 17.10</li> </ul> <div class="alert warning"> <div class="title"></div> <p> Use on platforms without pre-built binaries is broken in Koffi 2.8.10, skip this version.</p> </div> <h4>Koffi 2.8.9 (2024-05-17)</h4> <ul> <li>Fix ABI issue regarding bool return values on x86_64 (and possibly other platforms)</li> </ul> <h4>Koffi 2.8.8 (2024-04-26)</h4> <ul> <li>Support use of buffers with mismatched size (truncation or zero-filling)</li> </ul> <h4>Koffi 2.8.7 (2024-04-23)</h4> <ul> <li>Improve compatibility with SEHOP on Windows (<a href="https://github.com/longhun12346">@longhun12346</a>)</li> </ul> <h4>Koffi 2.8.6 (2024-04-12)</h4> <ul> <li>Support <a href="functions#loading-options">loading library</a> with RTLD_DEEPBIND where supported</li> </ul> <h4>Koffi 2.8.5 (2024-04-11)</h4> <ul> <li>Prevent obviously invalid type and member names</li> <li>Fix possible infinite loop / UB for <code>koffi.load()</code> errors on POSIX systems</li> <li>Fix null return value instead of exception for some errors in <code>koffi.load()</code> on Windows</li> </ul> <h4>Koffi 2.8.4 (2024-04-09)</h4> <ul> <li>Use simpler workaround for Node 20.12+ and 21.6+ to avoid excessive memory use</li> </ul> <div class="alert warning"> <div class="title"></div> <p> Some pre-built binaries are missing in Koffi 2.8.3, skip this version.</p> </div> <h4>Koffi 2.8.2 (2024-04-07)</h4> <ul> <li>Support <a href="functions#loading-options">loading library</a> with RTLD_GLOBAL on POSIX platforms</li> </ul> <h4>Koffi 2.8.1 (2024-04-04)</h4> <ul> <li>Fix incompatibility with Node 20.12+ and 21.6+</li> </ul> <h4>Koffi 2.8.0 (2024-02-12)</h4> <ul> <li>Support pushing pointers for string arguments</li> <li>Add <code>koffi.alloc()</code> for <a href="output#stable-pointers">stable pointers</a></li> </ul> <h3>Koffi 2.7</h3> <h4>Koffi 2.7.4 (2024-02-04)</h4> <ul> <li>Support callbacks happening on main thread but outside JS call (such as during event loop)</li> <li>Improve stability after <code>koffi.reset()</code></li> <li>Expose internal Node/NAPI <code>env</code> pointer</li> <li>Name main Koffi API functions</li> </ul> <h4>Koffi 2.7.3 (2024-01-26)</h4> <ul> <li>Support decoding NULL terminated arrays</li> </ul> <h4>Koffi 2.7.2 (2024-01-15)</h4> <ul> <li>Add missing TypeScript declaration for <code>koffi.free()</code></li> <li>Fix TypeScript declaration of <code>koffi.encode()</code></li> <li>Try to improve compatibility with webpack</li> </ul> <h4>Koffi 2.7.1 (2024-01-02)</h4> <ul> <li>Support C-like <code>int[3]</code> syntax for <a href="input#fixed-size-c-arrays">fixed array types</a></li> <li>Refuse type specifiers with invalid tokens at the end (previously ignored)</li> </ul> <h4>Koffi 2.7.0 (2023-12-21)</h4> <ul> <li>Support alternative <a href="callbacks#callback-types">callback calling convention</a> in classic syntax</li> <li>Change syntax for <a href="functions#calling-conventions">calling conventions</a> with classic syntax</li> <li>Drop unused "internal" property from Koffi</li> </ul> <h3>Koffi 2.6</h3> <h4>Koffi 2.6.12 (2023-12-11)</h4> <ul> <li>Fix possible crash introduced in Koffi 2.6.11</li> </ul> <h4>Koffi 2.6.11 (2023-12-05)</h4> <ul> <li>Speed up resolving simple and often used type names</li> <li>Fix use of optional length argument with <a href="variables#encode-to-c-memory">koffi.encode()</a></li> </ul> <h4>Koffi 2.6.10 (2023-11-29)</h4> <ul> <li>Protect GetLastError() value from Node.js and V8 on Windows</li> </ul> <h4>Koffi 2.6.9 (2023-11-25)</h4> <ul> <li>Search in DLL directory for additional dependencies on Windows</li> <li>Ignore prototype properties when making structs or unions</li> <li>Show detected version of Node when not adequate</li> <li>Minor documentation fixes</li> </ul> <div class="alert warning"> <div class="title"></div> <p> Loading Win32 system libraries can fail in Koffi 2.6.8, skip this version.</p> </div> <h4>Koffi 2.6.6 (2023-10-28)</h4> <ul> <li>Better handle errors while making struct or union types</li> </ul> <h4>Koffi 2.6.5 (2023-10-28)</h4> <ul> <li>Allow self-referential structs and unions</li> <li>Fix rare Node.js "FATAL ERROR" with some invalid type specifiers</li> </ul> <h4>Koffi 2.6.4 (2023-10-26)</h4> <ul> <li>Fix build issue with recent Visual Studio versions</li> </ul> <h4>Koffi 2.6.3 (2023-10-17)</h4> <ul> <li>Add indirect loading script to help some bundlers</li> </ul> <div class="alert warning"> <div class="title"></div> <p> Pre-built binaries don't work correctly in Koffi 2.6.2, skip this version.</p> </div> <h4>Koffi 2.6.1 (2023-09-18)</h4> <ul> <li>Support string direction qualifiers in classic function definitions</li> <li>Fix possible off-by-one array access when parsing type name</li> </ul> <h4>Koffi 2.6.0 (2023-09-13)</h4> <p><strong>New features:</strong></p> <ul> <li>Use <a href="variables#variable-definitions">koffi.symbol()</a> to make pointers to exported variables (or other symbols)</li> <li>Use <a href="variables#encode-to-c-memory">koffi.encode()</a> to explictly encode data from JS to C memory</li> <li>Use shared library <a href="functions#loading-options">lazy-loading</a> (RTLD_LAZY) on POSIX platforms</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Print more helpful error for Win32/Win64 DLL mismatches</li> <li>Add missing 'Union' primitive value in TS definition file</li> </ul> <h3>Koffi 2.5</h3> <h4>Koffi 2.5.20 (2023-08-31)</h4> <ul> <li>Fix possible crash with async registered callbacks introduced in Koffi 2.5.19</li> <li>Various documentation fixes and improvements</li> </ul> <h4>Koffi 2.5.19 (2023-08-29)</h4> <ul> <li>Create thread-safe function broker lazily</li> <li>Add <a href="misc#reset-internal-state">koffi.reset()</a> for type names and async broker</li> </ul> <h4>Koffi 2.5.18 (2023-08-27)</h4> <ul> <li>Fix compatibility with Electron</li> </ul> <h4>Koffi 2.5.16 (2023-08-25)</h4> <ul> <li>Run Koffi tests through usual index.js entry point</li> <li>Fix DLL error when using Koffi from NW.js on Windows</li> <li>Simplify NW.js Koffi example</li> </ul> <div class="alert warning"> <div class="title"></div> <p> Pre-built binaries don't work correctly in Koffi 2.5.13 to 2.5.15, skip those versions.</p> </div> <h4>Koffi 2.5.12 (2023-08-21)</h4> <ul> <li>Fix native module bundling for FreeBSD ARM64 and Linux RISC-V 64</li> <li>Increase maximum number of parameters to 64</li> </ul> <h4>Koffi 2.5.11 (2023-08-03)</h4> <ul> <li>Support casting function pointers with <a href="pointers#handling-void-pointers">koffi.as()</a></li> <li>Build in C++20 mode</li> </ul> <h4>Koffi 2.5.10 (2023-08-01)</h4> <ul> <li>Fix CMake regression when client has to build Koffi</li> </ul> <h4>Koffi 2.5.9 (2023-07-28)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Use bundler-friendly static require calls in Koffi</li> <li>Add packaging examples to documentation</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Add missing unload() export to TS file</li> <li>Add export for koffi.types in TS file</li> </ul> <h4>Koffi 2.5.8 (2023-07-26)</h4> <ul> <li>Add more search paths for native Koffi modules</li> <li>Add section <a href="start#bundling-koffi">about bundling</a> to documentation</li> </ul> <h4>Koffi 2.5.7 (2023-07-19)</h4> <ul> <li>Point package to new repository</li> </ul> <h4>Koffi 2.5.6 (2023-07-19)</h4> <ul> <li>Increase limit of output parameters from 16 to 32</li> </ul> <h4>Koffi 2.5.5 (2023-07-17)</h4> <ul> <li>Support decoding non-char null-terminated arrays</li> </ul> <h4>Koffi 2.5.4 (2023-07-14)</h4> <ul> <li>Fix <code>koffi.pointer()</code> not accepting disposable types</li> <li>Fix potential issues when making pointers to anonymous types</li> </ul> <h4>Koffi 2.5.3 (2023-07-05)</h4> <ul> <li>Add missing union exports in TS definition file</li> <li>Fix some parameter names in TS definition file</li> </ul> <h4>Koffi 2.5.2 (2023-07-04)</h4> <ul> <li>Default initialize unset object/struct members</li> </ul> <h4>Koffi 2.5.1 (2023-06-20)</h4> <ul> <li>Fix crash with some struct types in System V 64 ABI</li> <li>Always use direct passthrough for buffer arguments</li> </ul> <h4>Koffi 2.5.0 (2023-06-20)</h4> <p><strong>New features:</strong></p> <ul> <li>Support <a href="unions">union types</a></li> </ul> <p><strong>Other fixes:</strong></p> <ul> <li>Fix ABI for single-float aggregate return on i386 BSD systems</li> <li>Don't mess with Node.js signal handling on POSIX systems</li> </ul> <h3>Koffi 2.4</h3> <h4>Koffi 2.4.2 (2023-06-04)</h4> <ul> <li>Support calling variadic function pointers</li> <li>Add documentation for function pointers</li> </ul> <h4>Koffi 2.4.1 (2023-06-03)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Support <a href="functions#decode-pointer-to-function">decoding function pointers</a> to callable functions</li> <li>Support calling function pointers with <a href="functions#call-pointer-directly">koffi.call()</a></li> <li>Deprecate <code>koffi.callback</code> in favor of <code>koffi.proto</code></li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Increase maximum number of callbacks to 8192</li> <li>Build Koffi with static CRT on Windows</li> <li>Reorganize Koffi data conversion documentation</li> <li>Add deprecated <code>koffi.handle</code> to TS file</li> </ul> <h3>Koffi 2.3</h3> <h4>Koffi 2.3.20 (2023-05-15)</h4> <ul> <li>Support explicit library unloading with <code>lib.unload()</code></li> </ul> <h4>Koffi 2.3.19 (2023-04-21)</h4> <ul> <li>Actually allow non-ambiguous [string] values for <code>void *</code> arguments</li> </ul> <h4>Koffi 2.3.18 (2023-04-21)</h4> <ul> <li>Fix possible crash on exit caused by unregistered callbacks</li> </ul> <h4>Koffi 2.3.17 (2023-04-20)</h4> <ul> <li>Allow strings for input <code>void *</code>, <code>int8_t *</code> and <code>int16_t *</code> pointer arguments</li> <li>Support using <code>[string]</code> (single-element string arrays) for polymorphic input/output arguments</li> </ul> <h4>Koffi 2.3.16 (2023-04-11)</h4> <ul> <li>Fix Windows ARM64 build to work with official Node.js version</li> <li>Compile Windows builds with Visual Studio 2022 17.5.3</li> <li>Support null in <code>koffi.free()</code> and <code>koffi.address()</code></li> </ul> <h4>Koffi 2.3.15 (2023-04-10)</h4> <ul> <li>Improve manual decoding of 0-terminated strings</li> <li>Add checks around array conversion hints</li> </ul> <h4>Koffi 2.3.14 (2023-04-05)</h4> <ul> <li>Add <code>koffi.errno()</code> function to get and set current errno value</li> <li>Add <code>koffi.os.errno</code> object with valid errno codes</li> </ul> <h4>Koffi 2.3.13 (2023-03-30)</h4> <ul> <li>Add <code>koffi.address()</code> to get the raw value of a wrapper pointer</li> </ul> <h4>Koffi 2.3.12 (2023-03-30)</h4> <ul> <li>Fix broken syntax in TS definition file</li> <li>Add missing exported properties in TS file</li> </ul> <h4>Koffi 2.3.11 (2023-03-30)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Allow numbers and BigInts to be used for pointer arguments</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Use SQLITE_TRANSIENT in SQLite test code</li> <li>Avoid using <code>statx()</code> to allow compilation with glibc < 2.28</li> <li>Reorganize NPM package files to be less convoluted</li> </ul> <h4>Koffi 2.3.9 (2023-03-10)</h4> <ul> <li>Relicense under MIT license</li> </ul> <h4>Koffi 2.3.8 (2023-02-28)</h4> <ul> <li>Disable non-ready union support</li> <li>Simplify Windows stack allocation and drop NOACCESS and GUARD pages</li> <li>Adjust Windows TEB SEH chain and GuaranteedStackBytes for Koffi calls</li> </ul> <h4>Koffi 2.3.7 (2023-02-27)</h4> <ul> <li>Fix missing require in index.js (<a href="https://github.com/gastonFrecceroNapse">@gastonFrecceroNapse</a>)</li> <li>Reduce NPM package bloat (from 65 MB to 20 MB) caused by changes in 2.3.6</li> </ul> <h4>Koffi 2.3.6 (2023-02-26)</h4> <ul> <li>Fix broken TS definition file</li> <li>Keep all prebuilt binaries and load correct one at runtime</li> </ul> <h4>Koffi 2.3.5 (2023-02-24)</h4> <p><strong>Main fixes:</strong></p> <ul> <li>Fix rare random crashes with async callbacks</li> <li>Fix some bugs with RISC-V 64 ABI</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Expose array type hint in <code>koffi.introspect()</code></li> <li>Add missing <code>koffi.array()</code> export in TS definition</li> <li>Make KoffiFunction more flexible in TS definition (<a href="https://github.com/insraq">@insraq</a>)</li> <li>Add a KoffiFunc<T> helper type in TS typing (<a href="https://github.com/insraq">@insraq</a>)</li> <li>Mark optional properties in TS TypeInfo class</li> <li>Minor performance improvements</li> </ul> <h4>Koffi 2.3.4 (2023-01-31)</h4> <ul> <li>Fix error when installing Koffi on Windows (2.3.2)</li> </ul> <h4>Koffi 2.3.2 (2023-01-30)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Fix type parser issues (such as ignoring some <a href="pointers#disposable-types">disposable qualifiers</a>)</li> <li>Fix crash when using disposable types in output parameters</li> <li>Add basic <a href="misc#usage-statistics">koffi.stats()</a> interface</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Avoid CNoke dependency</li> <li>Clear out development dependencies from package.json</li> </ul> <h4>Koffi 2.3.1 (2023-01-30)</h4> <ul> <li>Error out when trying to use ambiguous <code>void *</code> arguments (input and/or output)</li> <li>Adjust TypeScript definitions (<a href="https://github.com/insraq">@insraq</a>)</li> <li>Fix possible crash when parsing invalid prototype</li> </ul> <h4>Koffi 2.3.0 (2023-01-25)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Allow buffers (TypedArray or ArrayBuffer) values for input and/or output pointer arguments (for polymorphic arguments)</li> <li>Support opaque buffers (TypedArray or ArrayBuffer) values in <code>koffi.decode()</code> to <a href="output#output-buffers">decode output buffers</a></li> <li>Decode non-string types as arrays when an <a href="callbacks#decoding-pointer-arguments">explicit length is passed to koffi.decode()</a></li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Drop TypedArray type check for array and pointer values (only the size matters)</li> <li>Allow ArrayBuffer everywhere TypedArray is supported</li> <li>Add TypeScript definition for Koffi (<a href="https://github.com/insraq">@insraq</a>)</li> <li>Improve documentation about opaque and polymorphic structs</li> <li>Improve documentation for <code>koffi.decode()</code></li> <li>Reduce NPM package size (from 100 MB to 25 MB) by removing test code and dependencies</li> </ul> <h3>Koffi 2.2</h3> <h4>Koffi 2.2.5 (2023-01-23)</h4> <ul> <li>Relicense Koffi under LGPL 3.0</li> </ul> <h4>Koffi 2.2.4 (2023-01-19)</h4> <ul> <li>Fix memory leak on Windows (in Koffi 2.2.3) when running many async calls</li> <li>Reorganize documentation pages</li> </ul> <h4>Koffi 2.2.3 (2023-01-17)</h4> <ul> <li>Support native code that uses <a href="https://learn.microsoft.com/en-us/cpp/cpp/structured-exception-handling-c-cpp">Structured Exception Handling (SEH)</a> on Windows (x86, x64 and ARM64)</li> <li>Try to use ebp/rbp as frame pointer in x86/x64 ASM code</li> </ul> <h4>Koffi 2.2.2 (2023-01-14)</h4> <p><strong>Main fixes:</strong></p> <ul> <li>Support transparent <a href="callbacks#asynchronous-callbacks">asynchronous callbacks</a></li> <li>Expand from a maximum of 16+16 to 1024 callbacks running in parallel</li> </ul> <p><strong>Other fixes:</strong></p> <ul> <li>Fix bundler support by removing shebang from index.js</li> <li>Fix bugs when loading Koffi multiples times in same process (context aware module)</li> <li>Check N-API version when module is loaded</li> <li>Optimize callback unregistration</li> </ul> <h4>Koffi 2.2.1 (2022-12-21)</h4> <ul> <li>Fix crash when <a href="https://github.com/Koromix/rygel/issues/15">calling callback again after FFI call inside previous callback</a></li> </ul> <h4>Koffi 2.2.0 (2022-12-20)</h4> <p><strong>New features:</strong></p> <ul> <li>Add <a href="callbacks#decoding-pointer-arguments">koffi.decode()</a> for callback pointer arguments</li> <li>Support transparent <a href="output#string-buffer-example">output string parameters</a></li> <li>Add <code>koffi.offsetof()</code> utility function</li> <li>Support optional <em>this</em> binding in <code>koffi.register()</code></li> </ul> <p><strong>Other fixes:</strong></p> <ul> <li>Correctly validate output parameter types</li> <li>Fix assertion with <code>void *</code> parameters</li> </ul> <h3>Koffi 2.1</h3> <h4>Koffi 2.1.5 (2022-11-27)</h4> <ul> <li>Add missing README file to NPM package</li> </ul> <h4>Koffi 2.1.4 (2022-11-25)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Increase maximum type size from 32 kiB to 64 MiB</li> <li>Add configurable option for maximum type size</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Moved Koffi to a new repository: <a href="https://github.com/Koromix/rygel/">https://github.com/Koromix/rygel/</a></li> </ul> <h4>Koffi 2.1.3 (2022-10-31)</h4> <ul> <li>Support up to 16 output parameters (instead of 8)</li> </ul> <h4>Koffi 2.1.2 (2022-10-31)</h4> <ul> <li>Support up to 8 output parameters (instead of 4)</li> </ul> <h4>Koffi 2.1.1 (2022-08-16)</h4> <ul> <li>Fix potential memory allocation bugs</li> </ul> <h4>Koffi 2.1.0 (2022-08-13)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Add <a href="pointers#handling-void-pointers">koffi.as()</a> to support polymorphic APIs based on <code>void *</code> parameters</li> <li>Add <a href="input#endian-sensitive-integers">endian-sensitive integer types</a>: <code>intX_le_t</code>, <code>intX_be_t</code>, <code>uintX_le_t</code>, <code>uintX_be_t</code></li> <li>Accept typed arrays for <code>void *</code> parameters</li> <li>Introduce <code>koffi.opaque()</code> to replace <code>koffi.handle()</code> (which remains supported until Koffi 3.0)</li> <li>Support JS Array and TypedArray to fill struct and array pointer members</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Improve global performance with inlining and unity builds</li> <li>Add <code>size_t</code> primitive type</li> <li>Support member-specific alignement values in structs</li> <li>Detect impossible parameter and return types (such as non-pointer opaque types)</li> <li>Various documentation fixes and improvements</li> </ul> <h3>Koffi 2.0</h3> <h4>Koffi 2.0.1 (2022-07-30)</h4> <ul> <li>Return <code>undefined</code> (instead of null) for <code>void</code> functions</li> </ul> <h4>Koffi 2.0.0 (2022-07-29)</h4> <p><strong>Major new features:</strong></p> <ul> <li>Add <a href="pointers#disposable-types">disposable types</a> for automatic disposal of C values (such as heap-allocated strings)</li> <li>Add support for <a href="callbacks#registered-callbacks">registered callbacks</a>, that can be called after the initial FFI call</li> <li>Support named pointer types</li> <li>Support complex type specifications outside of prototype parser</li> </ul> <p><strong>Minor new features:</strong></p> <ul> <li>Support type aliases with <code>koffi.alias()</code></li> <li>Add <code>koffi.resolve()</code> to resolve type strings</li> <li>Expose all primitive type aliases in <code>koffi.types</code></li> <li>Correctly pass exceptions thrown in JS callbacks</li> </ul> <p><strong>Breaking API changes:</strong></p> <ul> <li>Change handling of callback types, which must be used through pointers</li> <li>Change handling of opaque handles, which must be used through pointers</li> <li>Support all types in <code>koffi.introspect(type)</code></li> </ul> <p>Consult the <a href="migration">migration guide</a> for more information.</p> <h2><a id="koffi-1"></a><a id="koffi_1"></a>Koffi 1</h2> <h3>Koffi 1.3</h3> <h4>Koffi 1.3.12 (2022-07-27)</h4> <ul> <li>Fix support for Yarn package manager</li> </ul> <h4>Koffi 1.3.11 (2022-07-26)</h4> <ul> <li>Fix broken parsing of <code>void *</code> when used for first parameter</li> </ul> <h4>Koffi 1.3.10 (2022-07-25)</h4> <p><strong>Main fixes:</strong></p> <ul> <li>Fix support for callbacks with more than 4 parameters on Windows x64</li> <li>Fix support for callbacks with multiple floating-point arguments on ARM32 platforms</li> <li>Fix possibly incorrect conversion for uint32_t callback parameters</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Various documentation fixes and improvements</li> </ul> <h4>Koffi 1.3.9 (2022-07-15)</h4> <ul> <li>Fix prebuild compatibility with Electron on Windows x64</li> </ul> <h4>Koffi 1.3.8 (2022-07-12)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Prevent callback reuse beyond FFI call</li> <li>Add BTI support for AAarch64 platforms (except Windows)</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Fix and harmonize a few error messages</li> </ul> <h4>Koffi 1.3.7 (2022-07-07)</h4> <p><strong>Main fixes:</strong></p> <ul> <li>Fix crash when using callbacks inside structs</li> <li>Support for null strings in record members</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Add intptr_t and uintptr_t primitive types</li> <li>Add str/str16 type aliases for string/string16</li> <li>Various documentation fixes and improvements</li> </ul> <h4>Koffi 1.3.6 (2022-07-01)</h4> <p><strong>Main fixes:</strong></p> <ul> <li>Fix install error with Node < 15 on Windows (build system bug)</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Detect incompatible Node.js versions when installing Koffi</li> <li>Prebuild with Clang for Windows x64 and Linux x64 binaries</li> <li>Various documentation improvements</li> </ul> <h4>Koffi 1.3.5 (2022-06-25)</h4> <p><strong>Main changes:</strong></p> <ul> <li>Fix memory leak when many async calls are running</li> <li>Add configurable limit for maximum number of async calls (max_async_calls)</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Reduce default async memory stack and heap size</li> <li>Various documentation improvements</li> </ul> <h4>Koffi 1.3.4 (2022-06-24)</h4> <ul> <li>Fix possible OpenBSD i386 crash with <code>(void)</code> functions</li> </ul> <h4>Koffi 1.3.3 (2022-06-24)</h4> <p><strong>Main fixes:</strong></p> <ul> <li>Fix misconversion of signed integer return value as unsigned</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Support <code>(void)</code> (empty) function signatures</li> <li>Disable unsafe compiler optimizations</li> <li>Various documentation improvements</li> </ul> <h4>Koffi 1.3.2 (2022-06-23)</h4> <ul> <li>Support compilation in C++14 mode (graceful degradation)</li> <li>Support older toolchains on Linux (tested on Debian 9)</li> </ul> <h4>Koffi 1.3.1 (2022-06-22)</h4> <ul> <li>The prebuilt binary is tested when Koffi is installed, and a rebuild happens if it fails to load</li> </ul> <h4>Koffi 1.3.0 (2022-06-22)</h4> <p><strong>Major changes:</strong></p> <ul> <li>Expand and move documentation to <a href="https://koffi.dev/">https://koffi.dev/</a></li> <li>Support JS arrays and TypedArrays for pointer arguments (input, output and mixed)</li> </ul> <p><strong>Other changes:</strong></p> <ul> <li>Convert NULL string pointers to null instead of crashing (return values, struct and array members, callbacks)</li> <li>Default to 'string' array hint for char, char16 and char16_t arrays</li> <li>Fix definition of long types on Windows x64 (LLP64 model)</li> <li>Restrict automatic string conversion to signed char types</li> <li>Detect floating-point ABI before using prebuilt binaries (ARM32, RISC-V)</li> <li>Forbid duplicate member names in struct types</li> </ul> <h3>Koffi 1.2</h3> <h4>Koffi 1.2.4 (2022-06-12)</h4> <ul> <li>Windows ARM64 is now supported</li> </ul> <h4>Koffi 1.2.3 (2022-06-11)</h4> <ul> <li>A prebuilt binary for macOS ARM64 (M1) is now included</li> </ul> <h4>Koffi 1.2.1 (2022-06-11)</h4> <p>This entry documents changes since version 1.1.0.</p> <p><strong>New features:</strong></p> <ul> <li>JS functions can be used as C callbacks (cdecl, stdcall) on all platforms</li> <li>RISC-V 64 LP64D ABI is supported (LP64 is untested)</li> <li>Expose settings for memory usage of synchronous and asynchronous calls</li> <li>Transparent conversion between C buffers and strings</li> <li>Tentative support for Windows ARM64 (untested)</li> </ul> <p><strong>Main fixes:</strong></p> <ul> <li>Fix excessive stack alignment of structs on x86 platforms</li> <li>Fix potential problems with big int64_t/uint64_t values</li> <li>Fix possible struct layout errors in push/pop code</li> <li>Fix alignment issues in ARM32 push code</li> <li>Fix incomplete/buggy support for HFA structs on ARM32 and ARM64</li> <li>Fix crashes on OpenBSD caused by missing MAP_STACK flag</li> <li>Fix non-sense "duplicate array type" errors</li> <li>Fix value <code>koffi.internal</code> to false in module (normal) builds</li> <li>Make sure we have a redzone below the stack for all architectures</li> <li>Use slower allocation for big objects instead of failing</li> </ul> <h1><a id="todo-list"></a><a id="todo_list"></a>Todo list</h1> <p>The following features and improvements are planned, not necessarily in that order:</p> <ul> <li>Port Koffi to Loong64 ISA and ABI</li> <li>Port Koffi to PowerPC (POWER9+) ISA and ABI</li> <li>Optimize passing of structs and arrays (with auto-generated JS)</li> <li>Automate Windows/AArch64 (qemu) and macOS/AArch64 (how? ... thanks Apple) tests</li> <li>Create a real-world example, using several libraries (Raylib, SQLite, libsodium) to illustrate various C API styles</li> <li>Add simple struct type parser</li> <li>Fix assembly unwind and CFI directives for better debugging experience</li> </ul> </main> <footer> <div>Koffi 漏 2024</div> <div style="font-size: 0.8em;"> Niels Martign猫ne (<a href="https://github.com/Koromix/" target="_blank">Koromix</a>)<br> <a href="mailto:niels.martignene@protonmail.com" style="font-weight: bold; color: inherit;">niels.martignene@protonmail.com</a> </div> </footer> </body> </html>