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

Create bindings for native mutexes #9105

Closed
brson opened this issue Sep 10, 2013 · 4 comments
Closed

Create bindings for native mutexes #9105

brson opened this issue Sep 10, 2013 · 4 comments
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Sep 10, 2013

The LittleLock type currently works by allocating a C++ lock_and_signal type. This makes it unsuitable for creating static mutexes. Create new bindings to the native mutex types, along with static initializers, port LittleLock, then delete lock_and_signal.

@emberian
Copy link
Member

@brson would this use pthreads or the uv_mutex stuff?

@alexcrichton
Copy link
Member

Blocked by #9243, locks have the Drop trait implemented.

@brson
Copy link
Contributor Author

brson commented Sep 27, 2013

@cmr pthreads

@alexcrichton I don't know that this needs to be blocked on that. Certainly LittleLock itself couldn't be initialized statically, but we could have a yet-more-primitive mutex that could still be initialized statically. Also, from a casual glance, LittleLock's destructor is just for deallocating the lock, which would not be necessary if we had the types defined in Rust.

@brson
Copy link
Contributor Author

brson commented Oct 29, 2013

Here are some comments I left in IRC

15:48 <brson> All of the mutexes in Rust are based on a C++ type defined in src/rt/sync/lock_and_signal.h
15:48 <brson> The Rust bindings for this is called LittleLock, in std::unstable::sync
15:49 <brson> the problem is that LittleLock must call into C++ to allocate the lock_and_signal type
15:50 <brson> but many mutexs need to be globally-allocated as `statics`, initialized statically to the unlocked state
15:50 <brson> so none of our locks can be declared `static`
15:51 <brson> this bug is about creating completely new mutex bindings for Rust
15:51 <brson> it will involve creating a correct declaration of the unix pthread_mutex_t as well as the equivalent type on windows
15:52 <brson> meaning, define `struct pthread_muxet_t` so that it has the same definition as in C
15:52 <brson> then creating bindings to all the appropriate pthreads functions that operate on mutexes
15:52 <brson> pthread_mutex_t may have a platform-specific definitions, so you'll need to look up how it is defined in the header files for OS X, FreeBSD, and Linux
15:53 <brson> then, once you have bindings for the unix mutex type and the Windows mutex type, create some abstraction called e.g. `NativeMutex` that delegates to them
15:54 <brson> then start replacing uses of LittleLock with NativeMutex

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 18, 2022
Add `invalid_utf8_in_unchecked`

changelog: Add [`invalid_utf8_in_unchecked`]
closes: rust-lang#629

Don't know how useful of a lint this is, just saw this was a really old issue 😄.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-runtime Area: std's runtime and "pre-main" init for handling backtraces, unwinds, stack overflows E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

No branches or pull requests

3 participants