Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Plugin] initial support of the zlib plugin (WasmEdge#2562)
* Include wasmedge_zlib in plugins/CMakeLists.txt . Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Add Zlib Plugin as an option in root CMakeLists.txt . Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Add zlib-ng dependency through FetchContent. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib build target for job 'build_ubuntu' in build-extensions.yml . Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib build target for job 'build_manylinux' in build-extensions.yml . Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Init env & base headers, struct Wasm_z_stream & ZStreamMap Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added basic zlib function declarations. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib env implementation & PluginDescriptor. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib module implementation, and added Host Functions. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib plugin WasmEdgeZlibDeflateInit_ implementation. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib plugin WasmEdgeZlibInflateInit_ implementation. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib plugin WasmEdgeZlibDeflate implementation. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib plugin WasmEdgeZlibInflate implementation. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib plugin WasmEdgeZlibDeflateEnd implementation. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added zlib plugin WasmEdgeZlibInflateEnd implementation. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Populated plugins/wasmedge_zlib/CMakeLists.txt to build & link the zlib plugin source. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fix: Added ZLIB as link dep to wasmedge_zlib plugin. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added basic test for zlib plugin; WIP/TODO. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added test/plugins/wasmedge_zlib/CMakeLists.txt to build and create zlib test executable. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Include zlib plugin test sub directory in test/plugins/CMakeLists.txt. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fixed naming convention by omitting namespace prefix from function name. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fix case sensitivity in CMake of zlib library. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Refactor build-extensions.yml to be in-line with upstream master. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fix typo in build-extensions.yml on zlib cmake option Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Minor type changes to better reflect the Zlib API. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added Deflate Inflate Integration Test Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Removed unnecessary nulling of wasm module's z_stream allocators | The host ignores them. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added static_assert on Wasm_z_stream struct size. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Start writing to the wasm heap from address 1 onwards, to nto collide with the semantic meaning of address/offset 0 as nullptr. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fix: Correct Version Check and Stream Size Check Error code, and API behaviour, along with relevant test case changes. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added in-code documentation/pointer/reason on why we just compare only the first character of zlib version strings. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Remove unsafe usage of wasm MemStart(pointer from base{0}). Converted to offset based pointer calculation, based on pointer increment after zlib operation.. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added in-code documentation to every field in Wasm_z_stream. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Honor LLVM Naming Convention: Change 'Wasm_z_stream' struct name to 'WasmZStream'. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Honor LLVM Naming Convention: Change 'Wasm_z_stream' struct name to 'WasmZStream'. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Changed c style cast to static_cast. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Updated a few variable name to reflect LLVM standards. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Updated a few more variable name to reflect LLVM standards. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added a more comprehensive Host and Wasm ZStream Syncronization Func, and wrapped all zlib calls with it. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Change few comments. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Add Condition to only add ZStream to internal registry, if init succeeded. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Remove unnecessary zlib version check in wasmedge, delegated it to the zlib implementation. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added WasmEdgeZlibDeflateSetDictionary and WasmEdgeZlibDeflateGetDictionary. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added WasmEdgeZlibDeflateCopy with a comment on impl. ref. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added deflateReset Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added deflateParams Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added deflateTune & deflateBound. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added deflatePending & deflatePrime. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Defined the Wasm gz_header struct. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added few function impl of zlib. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added most of non gz functions. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added adler32, adler32_z, crc32, crc32_z. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Remove _v2 postfix Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Remove duplicate impl. of WasmEdgeZlibInflateSetDictionary. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Remove unused parameter 'Frame' from WasmEdgeZlibZlibCompilerFlags & WasmEdgeZlibCompressBound. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Correct few pointer value usage. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added GZFile support Env & implemented WasmEdgeZlibGZDOpen. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Implemented gzbuffer, gzsetparams & gzread. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzfread, gzwrite & gzfwrite. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzputs, gzgets, gzputc, gzgetc. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzflush & gzrewind Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Remove unused parameter 'Frame'. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzeof, gzdirect, gzclose, gzclose_r, gzclose_w. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzclearerr. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Change void* to unsigned char* Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzgetc & gzungetc. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fix name Spell mistake. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fixed no-return on a Expect<void>. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fix move semantics related to unique_ptr. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added deflateInit2 & inflateInit2 & inflateBackInit2 & Refactor Part 1. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzopen | gzseek | gztell | gzoffset | adler32_combine | crc32_combine & Refactor Part 2 Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added deflateInit2_ | inflateInit2_ | inflateBackInit_. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added gzgetc_ Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added inflateSyncPoint | inflateUndermine | inflateValidate | inflateCodesUsed | inflateResetKeep | deflateResetKeep. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added draft WasmEdgeZlibGZVPrintf. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Removed unused Frame parameter. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Change all remaining naming convention to LLVM style. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added Host Func registration & Refactor Part 3. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Update function presence check to validate al 74 functions. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Update release.yml to include zlib. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added deflatesetheader & inflategetheader. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Change return type of SyncRun. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * SyncRun Func Design & Params Overhaul. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Remove access to moved unique_ptr. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added GZHeader Sync steps in SyncRun. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Registered deflateSetHeader | inflateGetHeader. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Updated Test to check for deflateSetHeader & inflateGetHeader. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Updated function count test to check for 76 functions. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Check if SyncRun fails even with no call to zlib API. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Removed old unused comments, revert usage of named fields & naming convention fixes. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added extensive error logging to Zlib Plugin. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added Function Instance Name, to SyncRun Error messages for better debug experience. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added a space between error msg tag & message. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Added info to error msg if the error is caught inside SyncRun. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Removed usage of a temporary ZRes variable wherever not absolutely necessary. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Fix Bug: Properly return a placeholder number to Module to act as a pointer to Host gzFile_s. We don't need to pass the raw pointer to Module, since gzFile_s is an opaque structure & the zlib app shouldn't try to access any of it's fields. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * [Style Change] Remove trailing _s from GZFile_s. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> * Removed usage of decltype, due to gcc [error: type qualifiers ignored on cast result type]. Using remove_cv to supress, would create code bloat. Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> --------- Signed-off-by: Saikat Dey <saikatdey2100@gmail.com> Signed-off-by: Sarrah Bastawala <sarrah.basta@gmail.com>
- Loading branch information