/string-wasm

A simple implementation of some string functions from libc in WebAssembly.

Primary LanguageWebAssemblyMIT LicenseMIT

A simple implementation of some string functions from libc in WebAssembly.

Modules

Contains a simple implementation of strcat, strcmp, strcpy and strlen functions from libc.

For now, contains only an optimized version of strlen function, that reads four bytes per iteration.

Building and Testing

Prerequisites:

  • wat2wasm (from WebAssembly Binary Toolkit)
  • Node.js (only for running tests)

Build .wasm files

To build string.wasm:

$ wat2wasm -o build/string.wasm src/string.wat

To build string_opt.wasm:

$ wat2wasm -o build/string_opt.wasm src/string_opt.wat

Or build the two using Makefile:

$ make all

Test the .wasm modules

First, build the tests.wasm module:

$ wat2wasm -o tests/tests.wasm tests/tests.wat

Then, run the tests with Node.js:

$ node tests/tests.js

Note: For now, only string.wasm is tested.

Build .wasm files and run tests (using Makefile)

$ make tests