Code Monkey home page Code Monkey logo

wasix's Introduction

WASIX

This library provides stubs for POSIX compatibility when compiling sources using the WASI SDK. The WASI SDK and the accomanying wasi-libc do provide some POSIX functionality, but many functions that are not currently supported or do not make sense in the context of WASM are missing. This can make it difficult to compile sources to WASI that expect POSIX compatibility.

The library in this project aims to fill the gaps between POSIX and WASI. In many cases, the implementation of functions will simply return an error code, but it will allow many 3rd party sources to compile using WASI and access any functionality that doesn't require the stubbed out functions.

Some functions (e.g., getpid, getuid, getgid) are implemented to return a static value given at compile time or an environment variable specified at runtime. This allows you to more closely emulate some POSIX functions in your environment as needed.

Build

The build requirements for WASIX are the same as for WASI SDK. The Makefile may need to be changed to reflect the installation path of WASI SDK and wasi-libc.

To build libwasix.a, simply run the Makefile:

make all

Abort on Error

The default behavior for WASIX is to return an error code if a function is not implemented. Depending on how the library is used, it may be preferable to have the process abort when an unimplemented function is called. To enable this behavior use the following build command:

make all_abort

Use

To use libwasix.a, add the following options to your compilation step:

-isystem ${WASIX_DIR}/include

Then add the following options to your link step:

-L${WASIX_DIR} -lwasix

Static Return Value Functions

Some functions in WASIX can be configured to return a static value rather than an error. The following functions can be configured in the specified ways.

Function Environment Variable Compile-Time Definition Default
getpid WASIX_PID -D_WASIX_PID=value 66600
getppid WASIX_PPID -D_WASIX_PPID=value 55500
getuid WASIX_UID -D_WASIX_UID=value 1
geteuid WASIX_EUID -D_WASIX_EUID=value 1
getgid WASIX_GID -D_WASIX_GID=value 100
getegid WASIX_EGID -D_WASIX_EGID=value 100

Ignored Functions

Some functions in WASIX do nothing and return a successful return value. These include chmod, fchmod, chown, fchown, and umask (returns 0755).

ToDo

Threads

Currently, threads are stubbed out and do not allow new threads to be created. We are planning on doing a thread implementation based on async which will enable threads to be created although only one thread will actually be working at any time.

Credits

Some of the structure definitions in the header and source files were taken from the WASI SDK sources and modified to include additions to assist in the compilation of various libraries. The WASI SDK uses the same license as this project.

Resources

WASM

WASI SDK

wasix's People

Contributors

kesmit13 avatar tiran avatar adamreese avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.