long arg; ioctl(fd, FIONREAD, (char *) &arg);
BytesReadable_t arg = 0; ioctl(fd, FIONREAD, (BytesReadable_t *) &arg);
GetBytesAvailable(int fd){#if defined(FIONREAD)    long arg;    ioctl(fd, FIONREAD, (char *) &arg);    return (int) arg;#elif defined(__CYGWIN__)    fd_set set;    struct timeval timeout =    {0, 0};    FD_ZERO(&set);    FD_SET(fd, &set);    if (select(fd + 1, &set, NULL, NULL, &timeout) > 0)	return 1;    else	return 0;#elif defined(FIORDCK)    return (ioctl(fd, FIORDCHK, NULL));#else /* !FIORDCK */    struct pollfd pollfds[1];    pollfds[0].fd = fd;    pollfds[0].events = POLLIN;    return poll(pollfds, 1, 0);#endif}