use of __builtin_memset

Mumit Khan khan@NanoTech.Wisc.EDU
Fri Jan 7 11:08:00 GMT 2000


I see that the use of __builtin_memset has been turned on in the
last winsup snapshot, which breaks building under gcc-2.95.x, which 
doesn't really support it. Interestingly enough, gcc-2.95.2 seems to 
have __builtin_memset in its code, but c++ front-end rejects the code 
unless properly prototyped.

A good way to handle this is to use autoconf.

Here's how you can do this in configure.in:

  # Test for builtin mem* functions.
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS
  AC_TRY_COMPILE([
  #include <string.h>
  void foo (char *s, int c, size_t n)
  {  
      __builtin_memset(s, c, n);
  }
  ], [ ],
  use_builtin_memset=yes, use_builtin_memset=no)
  if test "$use_builtin_memset" = "yes"; then
    AC_DEFINE(WINSUP_HAS_BUILTIN_MEMSET)
  fi
  AC_LANG_RESTORE

and so on for all the other builtin's that are "new". If there are going
to be more, then we should consider the use of config.h{.in} and using
that instead of passing cpp macros flags on the command line.

I can work up a patch if interested. 

Regards,
Mumit




More information about the Cygwin-developers mailing list