reduce code duplication in dynamic linker error paths
[oweals/musl.git] / src / stdio / fwide.c
1 #include <wchar.h>
2 #include "stdio_impl.h"
3
4 #define SH (8*sizeof(int)-1)
5 #define NORMALIZE(x) ((x)>>SH | -((-(x))>>SH))
6
7 int fwide(FILE *f, int mode)
8 {
9         FLOCK(f);
10         if (!f->mode) mode = f->mode = NORMALIZE(mode);
11         FUNLOCK(f);
12         return mode;
13 }