This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

CC3000HostDriver porting: Suggesting to rename FD_SET() etc to avoid conflicts

Hi,

the CC3000HostDriver offers a convenient BSD socket interface. While porting to the Atmel SAM3S platform I found that the macros and types around fd_set for select() tends to conflict quite badly with the predefined Atmel headers. This is a common problem, as for example a specific setup might also use a normal Ethernet PHY with another BSD socket interface implementation.

To avoid any conflicts it would be good to prefix all CC3000 definitions with CC3000_, or cc_ or something similar, and offer the actual BSD names as a compile time option through conditional compilation.

For some reason I just had conflicts in these symbols:

fd_set

FD_SET()

FD_CLR()

FD_ISSET()

FD_ZERO()

Renaming these macros and types manually to CC3000_ to disambiguate them solved the problem for me.

Cheers,

Johannes

  • Hi Johannes,

    There are pro's and con's for both views.
    In any case, we will take it into considiration.

    Thanks,
    Alon.S

  • Johannes

    Your Suggesting to rename FD_SET() etc to avoid conflicts posting was noted with interest, I've been working through similar issues with porting the CC3000 webserver to a Xilinx FPGA based "Microblaze" design.

    In this regard, could you perhaps share your modified socket.h,etc file(s) ?
    Which version of TI's code did you make the changes to? 

    Thanks

    Peter

  • Hi Peter,

    I am no longer using this product. I was simply renaming the macros to avoid any preprocessor symbols. I prepended CC3000_. Below is the patch I did to the v2 version and the v10 version (see host_driver_version.h):

    diff CC3000HostDriver_v2_orig/socket.h CC3000HostDriver_v2_sam3s/socket.h
    97c97
    < #define ENOBUFS 55 // No buffer space available
    ---
    > //#define ENOBUFS 55 // No buffer space available
    124c124
    < // The fd_set member is required to be an array of longs.
    ---
    > // The CC3000_fd_set member is required to be an array of longs.
    132c132
    < // fd_set for select and pselect.
    ---
    > // CC3000_fd_set for select and pselect.
    137c137
    < } fd_set;
    ---
    > } CC3000_fd_set;
    144,145c144,145
    < fd_set *__arr = (set); \
    < for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
    ---
    > CC3000_fd_set *__arr = (set); \
    > for (__i = 0; __i < sizeof (CC3000_fd_set) / sizeof (__fd_mask); ++__i) \
    152,156c152,156
    < // Access macros for 'fd_set'.
    < #define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
    < #define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
    < #define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
    < #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
    ---
    > // Access macros for 'CC3000_fd_set'.
    > #define CC3000_FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
    > #define CC3000_FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
    > #define CC3000_FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
    > #define CC3000_FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
    395,396c395,396
    < extern int select(long nfds, fd_set *readsds, fd_set *writesds,
    < fd_set *exceptsds, struct timeval *timeout);
    ---
    > extern int select(long nfds, CC3000_fd_set *readsds, CC3000_fd_set *writesds,
    > CC3000_fd_set *exceptsds, struct timeval *timeout);

    diff CC3000HostDriver_v10_orig/socket.h CC3000HostDriver_v10_sam3s/socket.h
    104c104
    < #define ENOBUFS 55 // No buffer space available
    ---
    > //#define ENOBUFS 55 // No buffer space available
    131c131
    < // The fd_set member is required to be an array of longs.
    ---
    > // The CC3000_fd_set member is required to be an array of longs.
    139c139
    < // fd_set for select and pselect.
    ---
    > // CC3000_fd_set for select and pselect.
    144c144
    < } fd_set;
    ---
    > } CC3000_fd_set;
    151,152c151,152
    < fd_set *__arr = (set); \
    < for (__i = 0; __i < sizeof (fd_set) / sizeof (__fd_mask); ++__i) \
    ---
    > CC3000_fd_set *__arr = (set); \
    > for (__i = 0; __i < sizeof (CC3000_fd_set) / sizeof (__fd_mask); ++__i) \
    159,163c159,163
    < // Access macros for 'fd_set'.
    < #define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
    < #define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
    < #define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
    < #define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
    ---
    > // Access macros for 'CC3000_fd_set'.
    > #define CC3000_FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
    > #define CC3000_FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
    > #define CC3000_FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
    > #define CC3000_FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
    412,413c412,413
    < extern int select(long nfds, fd_set *readsds, fd_set *writesds,
    < fd_set *exceptsds, struct timeval *timeout);
    ---
    > extern int select(long nfds, CC3000_fd_set *readsds, CC3000_fd_set *writesds,
    > CC3000_fd_set *exceptsds, struct timeval *timeout);

  • Johannes

    Thanks for the quick reply and for your insight on this

    Peter