fwide.c 251 B

1234567891011121314
  1. #include <wchar.h>
  2. #include "stdio_impl.h"
  3. #define SH (8*sizeof(int)-1)
  4. #define NORMALIZE(x) ((x)>>SH | -((-(x))>>SH))
  5. int fwide(FILE *f, int mode)
  6. {
  7. FLOCK(f);
  8. if (!f->mode) f->mode = NORMALIZE(mode);
  9. mode = f->mode;
  10. FUNLOCK(f);
  11. return mode;
  12. }