Hacker News new | past | comments | ask | show | jobs | submit login

To be fair, that is how most of linux tends to work. With glib wrappers around syscalls. It's just that the numbers are considered part of the stable interface. Hence people can write their own wrappers.

It's part of linux saying 'we don't break userspace' and the syscall numbers being how userspace talks to kernelspace.




Nitpick:

glibc is the GNU C library and wraps syscalls, among other things.

glib is a bunch of cross platform interfaces and data structures that grew out of Gtk+.


Given glibc isn't part of the OS, and that hence you can statically link to it, it can't be part of the stable interface. glibc isn't a thing as far as the OS is concerned.

It seems to me this also means Linux is more limited in what it can do in breaking syscalls too. On Windows, if you load any shared library (including ntdll) and an exported function isn't there, the loader can produce an error for you telling you that a function you need isn't there. On Linux... you're calling the syscall directly, so there's nothing that can stand between you and the syscalls to perform a check or anything. Overall it seems to me like coding against direct syscall numbers is a disadvantage on almost every front.


So where this affects things is when you want to take advantage of a newly-added syscall, or a newly-added feature of an existing syscall.

In the second case, both systems behave the same - if your program runs on an older kernel, the function entry point exists (either the syscall or ntdll symbol) but when you call the function to request the new feature, it returns a runtime error.

In the first case, Linux behaves identically to the first case - you get a runtime error (ENOSYS) - whereas Windows will produce an error at load time.

Typically what is done is that whatever is wrapping the syscall falls back to an alternate implementation for older kernels, if that's possible. If it's not, the program can either continue without that feature if it wants, or fail with a message that a newer kernel is required.

I don't feel that there's really a significant difference in the two approaches - wherever you draw the backwards-compatibility line you're going to have to do the same sort of work to maintain it.


> Given glibc isn't part of the OS, and that hence you can statically link to it

Unless you want to use any other library on the OS, for example 3D graphics drivers which tend to have hardware-specific parts in userspace.

> Overall it seems to me like coding against direct syscall numbers is a disadvantage on almost every front.

Which is why noone does it unless they have a very good reason.


> Unless you want to use any other library on the OS, for example 3D graphics drivers which tend to have hardware-specific parts in userspace.

Not sure what you mean regarding this and glibc.

> Which is why noone does it unless they have a very good reason.

I think you changed the meaning of my sentence to be able to make this reply. I was referring to what Linux does re: syscalls vs. library exports, not hard-coding syscall numbers in the source code.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: