-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
add teeos std impl #116565
add teeos std impl #116565
Conversation
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
All the changes are under |
Failed to set assignee to
|
r? rust-lang/libs-impl |
Team or group rust-lang team names can be found at https://github.com/rust-lang/team/tree/master/teams. |
some code merged after 0.2.149, so I need to wait 0.2.150 |
library/std/src/sys/teeos/time.rs
Outdated
@@ -0,0 +1,348 @@ | |||
//! copy from unix 100%, version 1.65 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this is an exact copy of unix/time.rs, it might be better to just import that file directly from mod.rs:
#[path = "../unix/time.rs"]
pub mod time;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(And similar for thread_local_key.rs
and perhaps more.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some code under unix is not allowed to be imported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
time.rs can not be imported, thread_local_key.rs is optimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the issue is due to pub(in crate::sys::unix)
in the unix implementation. Maybe it would be better to just change that to pub(crate)
to allow the code to be reused (timespec is very widespread outside "unix" targets).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I imported unix timespec from the beginning, if it could be a pub(crate) I would be more than happy to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, please just change the Unix code to use pub(crate)
to avoid the code duplication.
library/std/src/sys/mod.rs
Outdated
} else if #[cfg(target_os = "teeos")] { | ||
mod teeos; | ||
pub use self::teeos::*; | ||
use teeos as unsupported; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this line for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
accepted
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be removed
☔ The latest upstream changes (presumably #117617) made this pull request unmergeable. Please resolve the merge conflicts. |
6a7448c
to
68b54c1
Compare
These commits modify compiler targets. |
Is there any more questions? |
library/std/src/sys/teeos/rwlock.rs
Outdated
@@ -0,0 +1,43 @@ | |||
pub struct RwLock {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is better to implement this as a Mutex
than not supporting RwLock
at all. Even though it won't allow concurrent reads, it will still allow the type to work correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I can use Cell for rwlock like unsupported/locks/rwlock.rs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the Cell implementation is only correct for systems without thread support. You need to implement it using a mutex.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I prefer not to support rwlock and tell users in the manual that we do not support rwlock, for it's really different from mutex and rwlock interfaces. And a little hard :-) , I will try.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I overestimated the problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you change the code to wrap Mutex
instead of duplicating all the logic around pthread_mutex_t
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I originally thought I needed to do it through libc's interface. Is this the effect you expected?
use crate::sys::locks::mutex::Mutex;
/// we do not supported rwlock, so use mutex to simulate rwlock.
/// it's useful because so many code in std will use rwlock.
pub struct RwLock {
inner: Mutex,
}
impl RwLock {
#[inline]
pub const fn new() -> RwLock {
RwLock { inner: Mutex::new() }
}
#[inline]
pub fn read(&self) {
unsafe { self.inner.lock() };
}
#[inline]
pub fn try_read(&self) -> bool {
unsafe { self.inner.try_lock() }
}
#[inline]
pub fn write(&self) {
unsafe { self.inner.lock() };
}
#[inline]
pub unsafe fn try_write(&self) -> bool {
unsafe { self.inner.try_lock() }
}
#[inline]
pub unsafe fn read_unlock(&self) {
unsafe { self.inner.unlock() };
}
#[inline]
pub unsafe fn write_unlock(&self) {
unsafe { self.inner.unlock() };
}
}
library/std/src/sys/teeos/time.rs
Outdated
@@ -0,0 +1,348 @@ | |||
//! copy from unix 100%, version 1.65 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the issue is due to pub(in crate::sys::unix)
in the unix implementation. Maybe it would be better to just change that to pub(crate)
to allow the code to be reused (timespec is very widespread outside "unix" targets).
☔ The latest upstream changes (presumably #118547) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
c6eaa91
to
7566d14
Compare
Signed-off-by: 袁浩 <yuanhao34@huawei.com>
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (568f6a8): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 675.253s -> 675.831s (0.09%) |
add teeos std library implement.
this MR is draft untill the libc update to 0.2.150
this MR is the final step for suppot rust in teeos.
first step(add target): #113480
second step(add teeos libc): rust-lang/libc#3333