Code Monkey home page Code Monkey logo

posish's Introduction

posish

Safe Rust bindings to POSIX-ish libc APIs and syscalls

A Bytecode Alliance project

Github Actions CI Status crates.io page docs.rs docs

posish provides efficient memory-safe and I/O-safe wrappers to "POSIX-ish" libc APIs and syscalls, with configurable backends. It uses Rust references, slices, and return values instead of raw pointers, and io-lifetimes instead of raw file descriptors, providing memory safety and I/O safety. It uses Results for reporting errors, bitflags instead of bare integer flags, an Arg trait with optimizations to efficiently accept any Rust string type, and several other efficient conveniences.

posish is low-level and does not support Windows; for higher-level and more portable APIs built on this functionality, see the system-interface, cap-std, and fs-set-times crates, for example.

Posish currently has two backends available: libc and linux_raw.

The linux_raw backend is enabled by default on Linux on x86-64, x86, and aarch64, and uses raw Linux system calls and vDSO calls. It supports stable as well as nightly Rust.

  • By being implemented entirely in Rust, avoiding libc, errno, and pthread cancellation, and employing some specialized optimizations, most functions compile down to very efficient code. On nightly Rust, they can often be fully inlined into user code.
  • Most functions in linux_raw preserve memory and I/O safety all the way down to the syscalls.
  • linux_raw uses a 64-bit time_t type on all platforms, avoiding the y2038 bug.

The libc backend is enabled by default on all other platforms, and can be explicitly for any target by setting RUSTFLAGS to --cfg posish_use_libc. It uses the libc crate which provides bindings to native libc libraries and is portable to many OS's.

posish's People

Contributors

sunfishcode avatar pchickey avatar cfallin avatar

Watchers

 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.