Skip to content

Deduplicate libc bindings #16505

@straight-shoota

Description

@straight-shoota

While working with libc bindings recently, I noticed that there's a lot of duplication there.

For example, we have four different bindings for glibc on linux for four different platforms:

But the original headers for glibc are largely identical across all platforms with only some details being target-specific.
Those are usually collected in sysdeps/.

Looking at the Crystal bindings, out of 45 files with 1000 loc in each lib_c/aarch64-linux-gnu and lib_c/x86_64-linux-gnu there are only 25 different lines. Some of the differences might even be unintentional omissions. Around 98% of the bindings are identical between both targets.

The situation is similar with musl and probably darwin. And more when we gain support for additional platforms (say aarch64-freebsd).

It seems silly to have this kind of duplication in the Crystal bindings, when the original headers are mostly shared between targets.

We could simplify the bindings a lot by avoiding this duplication. That would help to make the bindings more manageable.


Add a 👍 reaction to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions