On 28 Nov 2001 at 18:08, Hrvoje Niksic wrote:

> Daniel Stenberg <[EMAIL PROTECTED]> writes:
> 
> > On Wed, 28 Nov 2001, zefiro wrote:
> > 
> >> ld: Undefined symbol
> >>    _memmove
> >>
> >> Do you have any suggestion ?
> > 
> > SunOS 4 is known to not have memmove.
> > 
> > May I suggest adding the following (or similiar) to a relevant wget source
> > file:
> [...]
> 
> Thanks for the suggestion and the code example.  Two points, though:
> 
> * Isn't it weird that the undefined symbol is _memmove, not memmove?
>   It looks as if a header file is translating the symbol, thinking
>   that _memmove exists.

Not really. UNIX C compilers of old prefix C external symbols with '_'. GCC doesn't do 
that unless targetted for a system that uses the prefix in its standard system library 
symbols.

> * As a BSD offshoot, SunOS almost certainly has bcopy.  Could we make
>   use of it?  I seem to remember reading that BSD bcopy is supposed to
>   handle overlapping blocks, but I cannot find a confirmation right
>   now.  If that were the case, we could simply use this:
> 
> #ifndef HAVE_MEMMOVE
> # define memmove(to, from, len) bcopy(from, to, len)
> #endif

That ought to work as the SunOS and BSD man pages say that the strings can overlap.

However, the Linux man page for bcopy(3) do not say the strings can overlap and in 
fact 
suggest that it be replaced with memcpy in new programs! Linux has memmove so that 
does 
not matter, but perhaps rolling our own memmove as Daniel suggested would be the 
safest 
option. Another difference between bcopy() and memmove() is that bcopy() returns void 
whereas memmove returns a pointer, but in the one place in the Wget source where 
memmove() is called, the return value is not used.

Reply via email to