From 746a86a267a7e958382308016af02d3db0ad716f Mon Sep 17 00:00:00 2001
From: Wren Turkal <wt@penguintechs.org>
Date: Wed, 8 Jul 2020 02:17:00 -0700
Subject: [PATCH] Add unlocked variation of fwide function.

Signed-off-by: Wren Turkal <wt@penguintechs.org>
---
 src/header/stdio/mod.rs | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/header/stdio/mod.rs b/src/header/stdio/mod.rs
index 73f1bba3..8a370261 100644
--- a/src/header/stdio/mod.rs
+++ b/src/header/stdio/mod.rs
@@ -174,15 +174,19 @@ impl FILE {
     }
 
     pub fn try_set_orientation(&mut self, mode: c_int) -> c_int {
-        let mut stream = self.lock();
-        if stream.0.orientation == 0 {
-            stream.0.orientation = match mode {
+        let stream = self.lock();
+        stream.0.try_set_orientation_unlocked(mode)
+    }
+
+    pub fn try_set_orientation_unlocked(&mut self, mode: c_int) -> c_int {
+        if self.orientation == 0 {
+            self.orientation = match mode {
                 1..=i32::MAX => 1,
                 i32::MIN..=-1 => -1,
-                0 => stream.0.orientation,
+                0 => self.orientation,
             };
         }
-        stream.0.orientation
+        self.orientation
     }
 }
 
-- 
GitLab