c3c icon indicating copy to clipboard operation
c3c copied to clipboard

Adding Termios library as std::libc::termios (posix libc functions)

Open PalsFreniers opened this issue 1 year ago • 1 comments

fixed version of posix libc's termios binding, I putted it inside libc/os/posix.c3 because it is a posix only part of the libc

PalsFreniers avatar Jul 30 '24 10:07 PalsFreniers

People will look for functions using their C name, e.g. cfgetospeed, so I would do it like this:

  1. First just create the extern declarations as is, e.g. extern fn CInt tcdrain(Fd fd);
  2. Then create the abstraction variant, e.g. fn int drain(Fd fd) => tcdrain(fd); or similar, and place it outside of the libc::os as an actual stdlib feature.

Because the idea is that people should in general not need to use libc functions directly, but instead go for (preferably) cross platform functionality that is based on libc.

So I could either accept this as-is and I'll do the changes afterwards, or you do modifications. What would be the best? If you use it then you probably have a better idea of how you think the "normal" stdlib interface should look like.

lerno avatar Jul 30 '24 23:07 lerno

I made the following changes:

  • added extern functions corresponding to the c symbols;
  • added abstraction variants for all;
  • added unreachable function for all the symbols if either libc or posix is not available;

PalsFreniers avatar Jul 31 '24 11:07 PalsFreniers

Thank you for your work. Now there's just the part when not on posix/libc and it's done!

lerno avatar Jul 31 '24 11:07 lerno

Maybe some of the constants should also use the distinct types.

cbuttner avatar Jul 31 '24 12:07 cbuttner

Thank you!

lerno avatar Jul 31 '24 12:07 lerno