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

Fill in signatures for pthread_cond* #43

Merged
merged 1 commit into from
Oct 16, 2021

Conversation

jplatte
Copy link
Contributor

@jplatte jplatte commented Oct 12, 2021

This wasn't easy to figure out, but I think now I'm at a point where it wouldn't take me that long to fill in most of the remaining signatures of functions with a commented-out libc!.

The padding bytes are most likely only correct for x86_64. What would I have to do to figure out the right padding for x86?

@sunfishcode
Copy link
Owner

This wasn't easy to figure out, but I think now I'm at a point where it wouldn't take me that long to fill in most of the remaining signatures of functions with a commented-out libc!.

Very cool!

The padding bytes are most likely only correct for x86_64. What would I have to do to figure out the right padding for x86?

The libc crate has libc-compatible declarations of all the types, including the pthread_* types. Currently mustang is emulating a --linux-gnu target. I think that means pthread_cond_t etc. are defined here.

@jplatte
Copy link
Contributor Author

jplatte commented Oct 15, 2021

Is there a particular reason the padding in c-scape uses usize's rather than an array of u8?

@sunfishcode
Copy link
Owner

No particular reason; it could use either. usize ensures usize alignment, where byte arrays don't, but that's usually covered by other struct fields.

@jplatte jplatte force-pushed the condvars branch 2 times, most recently from 69cb59d to 1f7177f Compare October 15, 2021 18:39
@jplatte
Copy link
Contributor Author

jplatte commented Oct 15, 2021

I now copied sizes & alignment over from libc, adapted a bit based on the assumption that target_env = "musl" will always be false.

For SIZEOF_PTHREAD_CONDATTR_T I only copied the bits relevant for supported architectures.

@jplatte
Copy link
Contributor Author

jplatte commented Oct 15, 2021

Ah, missed riscv64 in the condattr_t cfg list. Fixed now.

@jplatte
Copy link
Contributor Author

jplatte commented Oct 15, 2021

Fixed libc-specific error. I thought I tested with that before, but maybe sth. changed when rebasing.

@sunfishcode
Copy link
Owner

Looks good!

For assumptions about target_env = "musl", I think if we do decide we want to add musl ABI support, we'd move these types into c-scape/src/data/linux/linux_gnu.rs, and then musl support could go in linux_musl.rs or so. Possibly with a factored-out linux.rs common to both. But in any case, I think what's here works for now.

@sunfishcode sunfishcode merged commit a776a00 into sunfishcode:main Oct 16, 2021
@jplatte jplatte deleted the condvars branch October 16, 2021 13:56
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

Successfully merging this pull request may close these issues.

None yet

2 participants