bug-gnulib
[Top][All Lists]
Advanced

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

FYI: strndup portability fix [was Re: coreutils 6.2


From: Jim Meyering
Subject: FYI: strndup portability fix [was Re: coreutils 6.2
Date: Thu, 28 Sep 2006 13:21:14 +0200

Jim Meyering <address@hidden> wrote:
> "Gabor Z. Papp" <address@hidden> wrote:
> ...
>> gcc -std=gnu99  -g -O2  -Wl,--as-needed -o cp  cp.o copy.o cp-hash.o 
>> ../lib/libcoreutils.a  ../lib/libcoreutils.a
>> ../lib/libcoreutils.a(xstrndup.o): In function `xstrndup':
>> /home/gzp/src/coreutils-6.2/lib/xstrndup.c:37: undefined reference to 
>> `rpl_strndup'
>> collect2: ld returned 1 exit status
>> make[2]: *** [cp] Error 1
>> make[2]: Leaving directory `/home/gzp/src/coreutils-6.2/src'
>> make[1]: *** [all] Error 2
>> make[1]: Leaving directory `/home/gzp/src/coreutils-6.2/src'
>> make: *** [all-recursive] Error 1
>
> Thanks for reporting that.
>
> The above makes me think your tools have incomplete "weak_alias" support,
> so that lib/strndup.o ends up with a definition for a function
> named __strndup, rather than rpl_strndup.
>
> Gabor, would you please tell us what compiler and libc/OS you're using?
>
> --------------
> ...
> #ifndef weak_alias
> # define __strndup strndup
> #endif
>
> char *
> __strndup (s, n)
>      const char *s;
>      size_t n;
> {
> ...
> }
> #ifdef weak_alias
> weak_alias (__strndup, strndup)
> #endif
> -------------------
>
> If one person (Paul?) signs off on this, I'll check it in
> and use it for coreutils-6.3.  I've tested it on systems
> without strndup.  Running one more test, now...
>
>       [lib/ChangeLog]
>       This function could end up with a definition for a function
>       named __strndup, rather than rpl_strndup on a system with
>       incomplete weak_alias support.
>       * strndup.c (strndup): Rename from __strndup.
>       Remove #defines that used to map __strndup to strndup.
>       Don't use K&R prototypes.
>       Remove LIBC-related code, since this file is not sync'd with glibc.
>       * strndup.h: Revamp, accordingly.
>       [m4/ChangeLog]
>       * strndup.m4: Modernize.

No one signed off, but it works everywhere I've tested,
so I've checked it in.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]