fwide.c 222 B

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