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

Use Scalar consistently in foreign item emulation #3776

Merged
merged 1 commit into from
Jul 30, 2024

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 30, 2024

Step 0 of #3772

This just makes the code consistent. While we could also go for consistency the other way, that would only allow us to use integers in some cases where we use Scalar right now, because Scalar can also hold pointers where applicable.

There's also no danger in messing up (even though we do lose some compile-time checks), as Scalar knows the size of the integer stored within, so it will check that against the destination when it is written. In fact, this makes the checks much stronger compared with write_int, which just checks that the integer fits into the destination size.

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 30, 2024

@bors r+

@bors
Copy link
Contributor

bors commented Jul 30, 2024

📌 Commit 04e46e1 has been approved by oli-obk

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 30, 2024

⌛ Testing commit 04e46e1 with merge 759b1b0...

@bors
Copy link
Contributor

bors commented Jul 30, 2024

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 759b1b0 to master...

@bors bors merged commit 759b1b0 into rust-lang:master Jul 30, 2024
8 checks passed
let result = this.pthread_cond_broadcast(cond)?;
this.write_scalar(Scalar::from_i32(result), dest)?;
this.pthread_cond_broadcast(cond)?;
this.write_null(dest)?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it nicer to have the knowledge that these always return null inside pthread_cond_broadcast rather than here?

I feel like ideally, there's as little function-specific knowledge in this file as possible. (In fact ideally we'd have a macro generate the match in perfect uniformity... if someone is motivated enough to write such a macro, one day.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this would be resolved by always passing in the dest and handling it inside entirely

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's also an option, yes.

@oli-obk oli-obk deleted the duplicator branch July 30, 2024 21:06
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.

3 participants