Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate RawPOSIX constants #30

Open
rennergade opened this issue Nov 11, 2024 · 6 comments
Open

Consolidate RawPOSIX constants #30

rennergade opened this issue Nov 11, 2024 · 6 comments
Assignees

Comments

@rennergade
Copy link

Currently RawPOSIX uses a mix of libc imported constants, old rustposix constants, and now has a separate file for vmmap constants. Lets use the libc constants to be more portable, and just define them by importing, something like this:

let PROT_READ = libc::PROT_READ;
@JustinCappos
Copy link
Member

JustinCappos commented Nov 11, 2024 via email

@rennergade
Copy link
Author

If we do this, then the system you build on will have those constants loaded. So, for example, you might not be able to build parts of the codebase on a Mac (as I have been doing). I would recommend at least considering other approaches.

I'm pretty agnostic as to how we handle this as long as it's consistent. You think it's better to define them ourselves? I know @Yaxuan-w started transitioning to using the libc constants, were there some issues that led to that decision?

@JustinCappos
Copy link
Member

So, having the build system define them is making so that these (silently) change when the build system changes them (or doesn't have them defined, which occurred sometimes on my Mac). If you put references in the code to where you got them from, and define them in your code, you'll need to update these as Linux adds them, but the code will build and work everywhere. To me, the latter design is better --- so long as you always take care to note where you got the constants from...

@rennergade
Copy link
Author

That makes sense to me.

@Yaxuan-w did you need to use the libc constants when you were switching to RawPOSIX or was it just to match the syscalls we were importing? If its the latter lets go with our own defined constants like what we had in RustPOSIX, just documented better.

@Yaxuan-w
Copy link
Member

ok that makes sense to me

@rennergade
Copy link
Author

@ChinmayShringi here are the constants from RustPOSIX:

https://github.com/Lind-Project/safeposix-rust/blob/develop/src/safeposix/syscalls/fs_constants.rs

You should be able to copy these but its definitely worth doing a thorough review on all of these for correctness.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants