Tue 27 Nov 2007 08:00:18 PM UTC, original submission:
I am compiling LWIP v1.2.0 (stable) for the Xilinx Microblaze (GCC 3.4.1).
I get errors when I compile sockets.c. The problem boils down to the following code excerpt in sockets.h:
/* FD_SET used for lwip_select */
#ifndef FD_SET
#undef FD_SETSIZE
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
#define FD_SETSIZE MEMP_NUM_NETCONN
#define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
#define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
#define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
#define FD_ZERO(p) memset((void)(p),0,sizeof((p)))
typedef struct fd_set {
unsigned char fd_bits [(FD_SETSIZE+7)/8];
} fd_set;
/*
- only define this in sockets.c so it does not interfere
- with other projects namespaces where timeval is present
*/
#ifndef LWIP_TIMEVAL_PRIVATE
#define LWIP_TIMEVAL_PRIVATE 1
#endif
#if LWIP_TIMEVAL_PRIVATE
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif /* LWIP_TIMEVAL_PRIVATE */
#endif /* FD_SET */
The problem is that FD_SET is already defined in sys/types.h for the Microblaze so this section of code is skipped. However, the struct timeval definition is used by a few lines down from here in the declaration of the function lwip_select:
int lwip_select(int maxfdp1, fd_set readset, fd_set writeset, fd_set *exceptset,
struct timeval *timeout);
The solution is to move "#endif /* FD_SET */" above the definition of struct timeval. That is,
===============
/* FD_SET used for lwip_select */
#ifndef FD_SET
#undef FD_SETSIZE
/* Make FD_SETSIZE match NUM_SOCKETS in socket.c */
#define FD_SETSIZE MEMP_NUM_NETCONN
#define FD_SET(n, p) ((p)->fd_bits[(n)/8] |= (1 << ((n) & 7)))
#define FD_CLR(n, p) ((p)->fd_bits[(n)/8] &= ~(1 << ((n) & 7)))
#define FD_ISSET(n,p) ((p)->fd_bits[(n)/8] & (1 << ((n) & 7)))
#define FD_ZERO(p) memset((void)(p),0,sizeof((p)))
typedef struct fd_set {
unsigned char fd_bits [(FD_SETSIZE+7)/8];
} fd_set;
#endif /* FD_SET */
/*
- only define this in sockets.c so it does not interfere
- with other projects namespaces where timeval is present
*/
#ifndef LWIP_TIMEVAL_PRIVATE
#define LWIP_TIMEVAL_PRIVATE 1
#endif
#if LWIP_TIMEVAL_PRIVATE
struct timeval {
long tv_sec; /* seconds */
long tv_usec; /* and microseconds */
};
#endif /* LWIP_TIMEVAL_PRIVATE */
In this solution, struct timeval is always defined in sockets.h because it is always used by the lwip_select declaration.
|