sccommunity / crates-sgx

crates-sgx is a monorepo of all Rust crates ported for Teaclave SGX SDK targeting Intel SGX.
https://sccommunity.github.io/crates-sgx
Apache License 2.0
12 stars 2 forks source link

Add itoa 0.4.5 #3

Closed mssun closed 4 years ago

mssun commented 4 years ago

Adding itoa 0.4.5

Description

Add itoa 0.4.5

Crate Meta

Diff of Changes

diff --git a/Cargo.toml b/Cargo.toml
index 03fe09b..119bd41 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,9 +11,13 @@ readme = "README.md"
 exclude = ["performance.png"]

 [features]
-default = ["std"]
+default = ["std", "mesalock_sgx"]
 i128 = []
 std = []
+mesalock_sgx = ["sgx_tstd"]
+
+[dependencies]
+sgx_tstd = { git = "https://github.com/apache/incubator-teaclave-sgx-sdk", tag = "v1.1.0", optional = true }

 [badges]
 travis-ci = { repository = "dtolnay/itoa" }
diff --git a/src/lib.rs b/src/lib.rs
index 1b0f1aa..e9f7018 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -56,6 +56,15 @@
     allow(const_static_lifetime, transmute_ptr_to_ptr),
 )]

+
+#![cfg_attr(all(feature = "mesalock_sgx",
+                not(target_env = "sgx")), no_std)]
+#![cfg_attr(all(target_env = "sgx", target_vendor = "mesalock"),
+            feature(rustc_private))]
+#[cfg(all(feature = "mesalock_sgx", not(target_env = "sgx")))]
+#[macro_use]
+extern crate sgx_tstd as std;
+
 #[cfg(feature = "i128")]
 mod udiv128;

@@ -119,7 +128,7 @@ impl Buffer {
     #[allow(deprecated)]
     pub fn new() -> Buffer {
         Buffer {
-            bytes: unsafe { mem::uninitialized() },
+            bytes: unsafe { mem::MaybeUninit::zeroed().assume_init() },
         }
     }