lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #21654] #ifndef FD_SET ... #endif region too large - s


From: Mark Pettigrew
Subject: [lwip-devel] [bug #21654] #ifndef FD_SET ... #endif region too large - should not include struct timeval
Date: Tue, 27 Nov 2007 20:00:19 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9

URL:
  <http://savannah.nongnu.org/bugs/?21654>

                 Summary: #ifndef FD_SET ... #endif region too large - should
not include struct timeval
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: mpettigr
            Submitted on: Tuesday 11/27/2007 at 20:00
                Category: sockets
                Severity: 3 - Normal
              Item Group: Faulty Behaviour
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: 

    _______________________________________________________

Details:

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.




    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?21654>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/





reply via email to

[Prev in Thread] Current Thread [Next in Thread]