Andy-Python-Programmer / aero

Aero is a new modern, experimental, UNIX-like operating system following the monolithic kernel design. Supporting modern PC features such as long mode, 5-level paging, and SMP (multicore), to name a few.
https://aero.andypy.dev
GNU General Public License v3.0
1.17k stars 50 forks source link

Extern some driver things out to C #44

Closed ghost closed 2 years ago

ghost commented 2 years ago

This externs some driver interfaces to C for portability.

Andy-Python-Programmer commented 2 years ago

no this is not how extern "C" works. Even if you extern the function, you still wont be able to access it from C since rust mangles the name of the functions. Looks like in the pr that you extern the functions in struct impl aswell which is useless since if you even add no_mangle on top of it, they will still be mangled for obvious reasons if you know how the compiler works. I dont think so doing this is worth the effort anyways. Also https://andy-python-programmer.github.io/opinions/c.md ftw

Andy-Python-Programmer commented 2 years ago

If you really want to do this you will have to make your own bindings in a separate crate that basically internally calls these functions. The rust does somewhere explain this, take a look at them. For now closing the pull request.

ghost commented 2 years ago

no this is not how extern "C" works. Even if you extern the function, you still wont be able to access it from C since rust mangles the name of the functions. Looks like in the pr that you extern the functions in struct impl aswell which is useless since if you even add no_mangle on top of it, they will still be mangled for obvious reasons if you know how the compiler works. I dont think so doing this is worth the effort anyways. Also https://andy-python-programmer.github.io/opinions/c.md ftw

Ok, Ill just not modify the kernel.