Skip to main content

Crate libbsd_sys

Crate libbsd_sys 

Source
Expand description

Raw FFI bindings to libbsd.

This crate provides extern "C" declarations for the functions and types exported by libbsd, a library that provides commonly-used BSD functions on GNU/Linux systems.

§Platform support

On macOS, FreeBSD, OpenBSD, and NetBSD, most of these functions are already part of the system C library, so no additional library is needed.

On Linux, the crate uses pkg-config at build time to locate libbsd. On Debian/Ubuntu, install the development headers with:

apt install libbsd-dev

On Windows and other unsupported platforms, this crate is empty.

§Conditional compilation

Functions that only exist in libbsd (not on any BSD natively) are gated behind #[cfg(target_os = "linux")]. Functions available on the BSDs but not macOS are gated behind #[cfg(not(target_os = "macos"))].

The strnvis and strnunvis functions have different parameter orders depending on whether the platform follows the NetBSD convention (macOS, NetBSD, OpenBSD) or the FreeBSD convention (FreeBSD, Linux/libbsd).