(0011874)
bernhardf
09-24-08 07:10
|
Works for me on current trunk:
$ cat setlinebuf.c
#include <stdio.h>
#include <errno.h>
#ifdef __UCLIBC__
#define foo __modeflags
#else
#define foo _IO_file_flags
#define __FLAG_LBF _IO_LINE_BUF
#define __FLAG_NBF _IO_UNBUFFERED
#endif
#define bar(x) ((fla & x) == x)
static void print_flags(int fla) {
printf("%d & __FLAG_LBF = %d\n", fla, bar(__FLAG_LBF));
printf("%d & __FLAG_NBF = %d\n", fla, bar(__FLAG_NBF));
}
int main(void) {
int err;
FILE *fp = fopen("/tmp/filp","w");
if (!fp)
return 1;
print_flags(fp->foo);
setlinebuf (fp);
err = errno;
print_flags(fp->foo);
printf("errno=%d\n", err);
return 0;
}
$ gcc -o setlinebuf setlinebuf.c && ./setlinebuf
-72539004 & __FLAG_LBF = 0
-72539004 & __FLAG_NBF = 0
-72538492 & __FLAG_LBF = 1
-72538492 & __FLAG_NBF = 0
errno=0
$ /scratch/src/buildroot.git.pentium4/build_i386/staging_dir/usr/bin/i386-linux-uclibc-gcc -Os -o setlinebuf_ setlinebuf.c -static && ./setlinebuf_
24592 & __FLAG_LBF = 0
24592 & __FLAG_NBF = 0
8464 & __FLAG_LBF = 1
8464 & __FLAG_NBF = 0
errno=0 |