Incorrect usage of __mempcpy () in regex.c ?


I'm about to prepare a new update for the Cygwin package of MC. During the 
link stage of the build process I've encountered an error - the linker 
complains about undefined symbol ___mempcpy. Here is the code snippet from
regerror() which is defined in regex.c:

   if (errbuf_size != 0)
       if (msg_size > errbuf_size)
 #if defined HAVE_MEMPCPY || defined _LIBC
           *((char *) __mempcpy (errbuf, msg, errbuf_size - 1)) = 
           memcpy (errbuf, msg, errbuf_size - 1);
           errbuf[errbuf_size - 1] = 0;

In the past Cygwin missed mempcpy, but it was recently included into
the library. The configure script properly detects that *mempcpy* is 
present and sets HAVE_MEMPCPY, but the source uses __mempcpy which is not
present on Cygwin. Now, I red the info manual about using double 
underscores in symbol names an it has to say the following about that:

   In addition to the names documented in this manual, reserved names
include all external identifiers (global functions and variables) that
begin with an underscore (`_') and all identifiers regardless of use
that begin with either two underscores or an underscore followed by a
capital letter are reserved names.  This is so that the library and
header files can define functions, variables, and macros for internal
purposes without risk of conflict with names in user programs.

So, my question is isn't it better to replace the __mempcpy with mempcpy ?
It seems that __mempcpy is too glibc specific and there are other systems 
that do not rely on glibc i.e. Cygwin (Newlib), Solaris, all BSDs, etc.


Pavel Tsekov

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