FD_ZERO problem description changes in EGCS FAQ.

Vladimir Makarov vmakarov@cygnus.com
Thu Mar 18 14:23:00 GMT 1999


Hello, Gerald.

Jeff Law wrote me that you are maintainer EGCS FAQ.  I would change the
following entry
---------------------------------------------------------------------------

FD_ZERO macro

The FD_ZERO macro in (e.g.) libc-5.4.46 is incorrect. It uses invalid
asm clobbers. The following rewrite by Ulrich Drepper
<drepper@cygnus.com> should fix this for glibc 2.0:

  # define __FD_ZERO(fdsetp) \
    do { \
      int __d0, __d1; \
    __asm__ __volatile__ ("cld; rep; stosl" \
                          : "=m" (((__fd_mask *) \
                                   (fdsetp))[__FDELT (__FD_SETSIZE)]), \

                            "=&c" (__d0), "=&D" (__d1) \
                          : "a" (0), "1" (sizeof (__fd_set) \
                                          / sizeof (__fd_mask)), \
                            "2" ((__fd_mask *) (fdsetp)) \
                          : "memory"); \
    } while (0)
---------------------------------------------------------------------------

onto
---------------------------------------------------------------------------

FD_ZERO macro

The FD_ZERO macro in (e.g.) libc-5.4.46 is incorrect. It uses invalid
asm clobbers. The following rewrite by Ulrich Drepper
<drepper@cygnus.com> should fix this for glibc 2.0:

  # define __FD_ZERO(fdsetp) \
    do { \
      int __d0, __d1; \
    __asm__ __volatile__ ("cld; rep; stosl" \
                          : "=m" (((__fd_mask *) \
                                   (fdsetp))[__FDELT (__FD_SETSIZE)]), \

                            "=&c" (__d0), "=&D" (__d1) \
                          : "a" (0), "1" (sizeof (__fd_set) \
                                          / sizeof (__fd_mask)), \
                            "2" ((__fd_mask *) (fdsetp)) \
                          : "memory"); \
    } while (0)

Currently egcs has a wrap solution of the problem for all version of
libc.  The solution will also work if you install a new version of libc
or an older one even without reinstalling egcs after that.  Egcs use the
correct FD_ZERO macro instead of incorrect one.  You can see details how
egcs makes this in file gcc/fixinc.x86-linux-gnu.
-------------------------------------------------------------------------

You may want to change something in my addition.  Please, feel free.
English is not my native language.

Best reagrds,
Vladimir Makarov




More information about the Gcc-patches mailing list