• source navigation  • diff markup  • identifier search  • freetext search  • 

Sources/ucode/lib/ffi/ATTRIBUTION.md

  1 # Attribution and License
  2 
  3 ## Original Work
  4 
  5 This project is based on **LuaJIT**, created by Mike Pall. The FFI
  6 (Foreign Function Interface) implementation in LuaJIT is a sophisticated
  7 system for calling C functions and working with C data types from Lua
  8 code.
  9 
 10 ## License
 11 
 12 LuaJIT is released under the MIT license. The original LuaJIT license text:
 13 
 14 ```
 15 Copyright (C) 2005-2025 Mike Pall
 16 
 17 Permission is hereby granted, free of charge, to any person obtaining a copy
 18 of this software and associated documentation files (the "Software"), to deal
 19 in the Software without restriction, including without limitation the rights
 20 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 21 copies of the Software, and to permit persons to whom the Software is
 22 furnished to do so, subject to the following conditions:
 23 
 24 The above copyright notice and this permission notice shall be included in all
 25 copies or substantial portions of the Software.
 26 
 27 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 28 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 29 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 30 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 31 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 32 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 33 SOFTWARE.
 34 ```
 35 
 36 ## Implementation
 37 
 38 The ucode FFI module (currently called `ffi`) is **heavily inspired**
 39 by LuaJIT's FFI implementation. In many cases, the code structure,
 40 algorithms, and even specific implementations have been taken
 41 **verbatim** from LuaJIT's source code, with necessary adaptations
 42 to work with the ucode virtual machine.
 43 
 44 ### What Has Been Taken from LuaJIT
 45 
 46 - **C Parser** (`lj_cparse.c`): The frontend for parsing C declarations
 47 - **Type System** (`lj_ctype.c`): The CTState registry and
 48   CType representations
 49 - **Value Conversions** (`lj_cconv.c`): The machinery for converting
 50   between ucode and C values
 51 - **C Data Objects** (`lj_cdata.c`): Allocation and access
 52   to C data objects
 53 
 54 ### What Has Been Changed
 55 
 56 - LuaJIT's own call infrastructure (`lj_ccall.c`, `lj_ccallback.c`)
 57   has been replaced with **libffi** exclusively
 58 - LuaJIT's arithmetic operations (`lj_carith.c`) have been removed
 59 - Library loading logic has been consolidated into the main FFI module
 60 - All VM interactions have been adapted to use ucode's API
 61   (`uc_vm_t *`, `uc_vm_raise_exception()`, etc.)
 62 - JIT-specific code and dependencies have been removed
 63 
 64 ## Acknowledgment
 65 
 66 Mike Pall and the LuaJIT community created the FFI implementation that
 67 inspired this work. The LuaJIT FFI provided the C parser concept and
 68 code structure that was adapted for ucode.
 69 
 70 This project does not aim to provide native machine code generation or
 71 JIT compilation. It is essentially libffi with the C parser functionality
 72 bolted on top, providing a seamless usage experience similar to LuaJIT's
 73 FFI interface.
 74 
 75 ## Transparency
 76 
 77 This project maintains this attribution file to be completely
 78 transparent about its origins. Any code that resembles LuaJIT's
 79 implementation is either:
 80 
 81 1. Directly adapted from LuaJIT's source code (with proper attribution
 82    in comments where applicable)
 83 2. Reimplemented based on the same design principles and algorithms
 84 
 85 All modifications are intended to integrate with ucode and remove
 86 dependencies on LuaJIT-specific infrastructure.
 87 
 88 ---
 89 
 90 **Last updated:** 2026-04-06

This page was automatically generated by LXR 0.3.1.  •  OpenWrt