Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
R
relibc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Limkilde Svendsen
relibc
Commits
7df5b16f
Commit
7df5b16f
authored
6 months ago
by
JustAnotherDev
Browse files
Options
Downloads
Patches
Plain Diff
set deny(unsafe_op_in_unsafe_fn) for
parent
6e4fdf70
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/sync/mod.rs
+5
-2
5 additions, 2 deletions
src/sync/mod.rs
src/sync/mutex.rs
+5
-5
5 additions, 5 deletions
src/sync/mutex.rs
src/sync/waitval.rs
+1
-1
1 addition, 1 deletion
src/sync/waitval.rs
with
11 additions
and
8 deletions
src/sync/mod.rs
+
5
−
2
View file @
7df5b16f
// TODO: set this for entire crate when possible
#![deny(unsafe_op_in_unsafe_fn)]
pub
mod
barrier
;
pub
mod
cond
;
// TODO: Merge with pthread_mutex
...
...
@@ -95,14 +98,14 @@ impl FutexAtomicTy for AtomicI32 {
pub
unsafe
fn
futex_wake_ptr
(
ptr
:
*
mut
impl
FutexTy
,
n
:
i32
)
->
usize
{
// TODO: unwrap_unchecked?
Sys
::
futex_wake
(
ptr
.cast
(),
n
as
u32
)
.unwrap
()
as
usize
unsafe
{
Sys
::
futex_wake
(
ptr
.cast
(),
n
as
u32
)
}
.unwrap
()
as
usize
}
pub
unsafe
fn
futex_wait_ptr
<
T
:
FutexTy
>
(
ptr
:
*
mut
T
,
value
:
T
,
deadline_opt
:
Option
<&
timespec
>
,
)
->
FutexWaitResult
{
match
Sys
::
futex_wait
(
ptr
.cast
(),
value
.conv
(),
deadline_opt
)
{
match
unsafe
{
Sys
::
futex_wait
(
ptr
.cast
(),
value
.conv
(),
deadline_opt
)
}
{
Ok
(())
=>
FutexWaitResult
::
Waited
,
Err
(
Errno
(
EAGAIN
))
=>
FutexWaitResult
::
Stale
,
Err
(
Errno
(
ETIMEDOUT
))
if
deadline_opt
.is_some
()
=>
FutexWaitResult
::
TimedOut
,
...
...
This diff is collapsed.
Click to expand it.
src/sync/mutex.rs
+
5
−
5
View file @
7df5b16f
...
...
@@ -76,8 +76,8 @@ impl<T> Mutex<T> {
/// on failure. You should probably not worry about this, it's used for
/// internal optimizations.
pub
unsafe
fn
manual_try_lock
(
&
self
)
->
Result
<&
mut
T
,
c_int
>
{
if
manual_try_lock_generic
(
&
self
.lock
)
{
Ok
(
&
mut
*
self
.content
.get
())
if
unsafe
{
manual_try_lock_generic
(
&
self
.lock
)
}
{
Ok
(
unsafe
{
&
mut
*
self
.content
.get
()
}
)
}
else
{
Err
(
0
)
}
...
...
@@ -86,12 +86,12 @@ impl<T> Mutex<T> {
/// your responsibility to unlock it after usage. Mostly useful for FFI:
/// Prefer normal .lock() where possible.
pub
unsafe
fn
manual_lock
(
&
self
)
->
&
mut
T
{
manual_lock_generic
(
&
self
.lock
);
&
mut
*
self
.content
.get
()
unsafe
{
manual_lock_generic
(
&
self
.lock
)
}
;
unsafe
{
&
mut
*
self
.content
.get
()
}
}
/// Unlock the mutex, if it's locked.
pub
unsafe
fn
manual_unlock
(
&
self
)
{
manual_unlock_generic
(
&
self
.lock
)
unsafe
{
manual_unlock_generic
(
&
self
.lock
)
}
}
pub
fn
as_ptr
(
&
self
)
->
*
mut
T
{
self
.content
.get
()
...
...
This diff is collapsed.
Click to expand it.
src/sync/waitval.rs
+
1
−
1
View file @
7df5b16f
...
...
@@ -28,7 +28,7 @@ impl<T> Waitval<T> {
// SAFETY: Caller must ensure both (1) that the value has not yet been initialized, and (2)
// that this is never run by more than one thread simultaneously.
pub
unsafe
fn
post
(
&
self
,
value
:
T
)
{
self
.value
.get
()
.write
(
MaybeUninit
::
new
(
value
));
unsafe
{
self
.value
.get
()
.write
(
MaybeUninit
::
new
(
value
))
}
;
self
.state
.store
(
1
,
Ordering
::
Release
);
crate
::
sync
::
futex_wake
(
&
self
.state
,
i32
::
MAX
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment