libaio

What is libaio?

libaio is a library for doing event-driven programming, mostly focusing on I/O. (The name comes from "asynchronous I/O", which is not really accurate. True asynchronous I/O requires kernel support (or auxiliary processes). But the coding paradigms libaio leads to feel rather like asynchronous I/O.)

libaio focuses heavily on callbacks. It leads to programs made up of many small functions, called when they're relevant, rather than fewer larger functions which implement the traditional sequential-imperative design. (Since libaio is for C, it necessarily is sequential-imperative at some level. But the mindset that results is more "do this when it's relevant" rather than "do these in this order".)

It's similar in some respects to libevent, found in (some of?) the BSDs. I could, maybe, just use libevent instead; my reasons for not doing so are:

Where does libaio work?

At this writing (2025-11-12), the only places I know it works are machines I've set it up on. Its native home is NetBSD; I've found the changes needed to make it work on at least one Linux distro to be relatively minor.

I expect it to be relatively easy to make it work on anything with poll(2) and a Unix-style I/O subsystem (read(2), write(2), etc).

At this point, there are probably issues. Once I get some testers on a wider variety of systems I expect to fix them.

So what does libaio-using code look like?

I wrote a small plain-text tutorial for libaio. It will not teach you how to use every facility it has, but it should be able to give you an idea of the general flavour and get you started. It's available here.

How do I get libaio?

My primary distribution mechanism is a world-clonable git repo: git://git.rodents-montreal.org/libaio is the thing to clone.

Mouse, reachable @rodents-montreal.org with the obvious local-part (mouse).

Almost all these pages—all, I think—are 100% hand-coded.