My solution: wrap FILE* and all functions which use FILE*
typedef struct __darwin_sFILE { unsigned char *_p; /* current position in (some) buffer */ int _r; /* read space left for getc() */ int _w; /* write space left for putc() */ // TODO(hamaji): we need to modify this value with ferror and feof... short _flags; /* flags, below; this FILE is free if 0 */ short _file; /* fileno, if Unix descriptor, else -1 */ FILE* linux_fp; } int __darwin_fputs(const char* s, __darwin_FILE* fp) { return fputs(s, fp->linux_fp); }
My emulation layer doesn't handle _flags field properly
feof and ferror should be broken