aboutsummaryrefslogtreecommitdiff
path: root/src/stdio/fwide.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stdio/fwide.c')
-rw-r--r--src/stdio/fwide.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/stdio/fwide.c b/src/stdio/fwide.c
new file mode 100644
index 0000000..f4da47f
--- /dev/null
+++ b/src/stdio/fwide.c
@@ -0,0 +1,10 @@
+#include "stdio_impl.h"
+
+#define SH (8*sizeof(int)-1)
+#define NORMALIZE(x) ((x)>>SH | -((-(x))>>SH))
+
+int fwide(FILE *f, int mode)
+{
+ if (!f->mode) f->mode = NORMALIZE(mode);
+ return f->mode;
+}