aboutsummaryrefslogtreecommitdiff
path: root/ctr-std/src/io/print.rs
diff options
context:
space:
mode:
authorRonald Kinard <[email protected]>2017-02-25 21:19:47 -0600
committerGitHub <[email protected]>2017-02-25 21:19:47 -0600
commit4ecade8af14dff869c4d41dcd60040b69f06b64e (patch)
tree0bfc16fd5a5e1b5698e0fe9b786caf9a0c4062ae /ctr-std/src/io/print.rs
parentMerge pull request #23 from panicbit/unmarked_api (diff)
parentimplement buffered stdio (diff)
downloadarchived-ctru-rs-4ecade8af14dff869c4d41dcd60040b69f06b64e.tar.xz
archived-ctru-rs-4ecade8af14dff869c4d41dcd60040b69f06b64e.zip
Merge pull request #22 from FenrirWolf/stdio
Implement synchronized stdio
Diffstat (limited to 'ctr-std/src/io/print.rs')
-rw-r--r--ctr-std/src/io/print.rs33
1 files changed, 0 insertions, 33 deletions
diff --git a/ctr-std/src/io/print.rs b/ctr-std/src/io/print.rs
deleted file mode 100644
index 8a5851b..0000000
--- a/ctr-std/src/io/print.rs
+++ /dev/null
@@ -1,33 +0,0 @@
-use fmt;
-use io::{self, Write};
-
-// NOTE: We're just gonna use the spin mutex until we figure out how to properly
-// implement mutexes with ctrulib functions
-use spin::Mutex;
-use libc;
-
-pub static STDOUT: Mutex<StdoutRaw> = Mutex::new(StdoutRaw(()));
-
-pub struct StdoutRaw(());
-
-#[stable(feature = "3ds", since = "1.0.0")]
-impl Write for StdoutRaw {
- fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
- unsafe {
- // devkitPro's version of write(2) fails if zero bytes are written,
- // so let's just exit if the buffer size is zero
- if buf.is_empty() {
- return Ok(buf.len())
- }
- libc::write(libc::STDOUT_FILENO, buf.as_ptr() as *const _, buf.len());
- Ok(buf.len())
- }
- }
-
- fn flush(&mut self) -> io::Result<()> { Ok(()) }
-}
-
-#[doc(hidden)]
-pub fn _print(args: fmt::Arguments) {
- STDOUT.lock().write_fmt(args).unwrap();
-}