1 //! System bindings for the wasm/web platform
3 //! This module contains the facade (aka platform-specific) implementations of
4 //! OS level functionality for wasm. Note that this wasm is *not* the emscripten
5 //! wasm, so we have no runtime here.
7 //! This is all super highly experimental and not actually intended for
8 //! wide/production use yet, it's still all in the experimental category. This
9 //! will likely change over time.
11 //! Currently all functions here are basically stubs that immediately return
12 //! errors. The hope is that with a portability lint we can turn actually just
13 //! remove all this and just omit parts of the standard library if we're
14 //! compiling for wasm. That way it's a compile time error for something that's
15 //! guaranteed to be a runtime error!
17 use crate::os
::raw
::c_char
;
23 pub mod fast_thread_local
;
32 pub mod stack_overflow
;
38 pub use crate::sys_common
::os_str_bytes
as os_str
;
41 if #[cfg(target_feature = "atomics")] {
42 #[path = "condvar_atomics.rs"]
44 #[path = "mutex_atomics.rs"]
46 #[path = "rwlock_atomics.rs"]
58 pub fn unsupported
<T
>() -> crate::io
::Result
<T
> {
59 Err(unsupported_err())
62 pub fn unsupported_err() -> crate::io
::Error
{
63 crate::io
::Error
::new(crate::io
::ErrorKind
::Other
, "operation not supported on wasm yet")
66 pub fn decode_error_kind(_code
: i32) -> crate::io
::ErrorKind
{
67 crate::io
::ErrorKind
::Other
70 // This enum is used as the storage for a bunch of types which can't actually
72 #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Hash)]
75 pub unsafe fn strlen(mut s
: *const c_char
) -> usize {
84 pub fn abort_internal() -> ! {
85 unsafe { crate::arch::wasm32::unreachable() }
88 // We don't have randomness yet, but I totally used a random number generator to
89 // generate these numbers.
91 // More seriously though this is just for DOS protection in hash maps. It's ok
92 // if we don't do that on wasm just yet.
93 pub fn hashmap_random_keys() -> (u64, u64) {