Solved unknown type name 'fd_set'

balanga

Daemon

Reaction score: 100
Messages: 2,416

Can anyone suggest what is causing the error unknown type name 'fd_set' ?

This doesn't occur in FreeBSD, but I'm just wondering where it gets resolved in FreeBSD.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 6,926
Messages: 28,850

Some context would be nice. So I'm just guessing here, FD_SET(2).
 
OP
OP
B

balanga

Daemon

Reaction score: 100
Messages: 2,416

Code:
wget ftp://ftp.denx.de/pub/u-boot/u-boot-2013.10.tar.bz2
tar jxf u-boot-2013.10.tar.bz2
cd u-boot-2013.10/tools/
gcc -o kwboot kwboot.c
This is part of kwboot.c:-

Code:
static int
kwboot_tty_recv(int fd, void *buf, size_t len, int timeo)
{
        int rc, nfds;
        fd_set rfds;
        struct timeval tv;
        ssize_t n;

        rc = -1;

        FD_ZERO(&rfds);
        FD_SET(fd, &rfds);
 
        tv.tv_sec = 0;
        tv.tv_usec = timeo * 1000;
        if (tv.tv_usec > 1000000) {
                tv.tv_sec += tv.tv_usec / 1000000;
                tv.tv_usec %= 1000000;
        }
        
        do {
                nfds = select(fd + 1, &rfds, NULL, NULL, &tv);
                if (nfds < 0)
                        goto out;
                if (!nfds) {
                        errno = ETIMEDOUT;
                        goto out;
                }
                
                n = read(fd, buf, len);
                if (n < 0)
                        goto out;

                buf = (char *)buf + n;
                len -= n;
        } while (len > 0);

        rc = 0;
out:
        return rc;
}
 
Top