From: Gary V. Vaughan Date: Thu, 8 Apr 2004 13:06:16 +0000 (+0000) Subject: Keywords: X-Git-Tag: release-1-9b~104 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b61dada32237a41cf0f639e194e87663a75fc977;p=thirdparty%2Flibtool.git Keywords: Factor out the bottom portability layer from ltdl. Code in this layer has global symbols renamed by lt__pre89.h, and may not refer to any symbols except those provided by the system libraries or other code in the portability layer: * libltdl/lt__pre89.h: New file. Rename all the symbols from LTLIBOBJS into the lt__ namespace so that they don't clash with other libraries. * libltdl/ltdl.c (rpl_memcpy, rpl_memmove, rpl_strchr, rpl_strcmp) (rpl_strrchr): Moved from here... * libltdl/memcpy.c (memcpy): ...to here, and fixed void * dereference bug... * libltdl/memmove.c (memmove): ...to here, and fixed void * dereference bug... * libltdl/strchr.c (strchr): ...to here... * libltdl/strcmp.c (strcmp): ...here... * libltdl/strrchr.c (strrchr): ...and here. * libltdl/Makefile.am (libltdl_la_SOURCES): Add lt__pre89.h. (libltdl_la_LIBADD, libltdlc_la_LIBADD): Add $(LTLIBOBJS). (ltdldata_DATA): Add replacement sources files. * m4/ltdl.m4 (AC_LIB_LTDL): Do careful config.h and LTLIBOBJ setting for missing pre89 functions. $Revision: 1.1470 $ $Date: 2004/04/08 12:01:57 $ --- diff --git a/ChangeLog b/ChangeLog index 662e0510d..351edeae8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2004-04-08 Gary V. Vaughan + + Factor out the bottom portability layer from ltdl. Code in this + layer has global symbols renamed by lt__pre89.h, and may not + refer to any symbols except those provided by the system libraries + or other code in the portability layer: + + * libltdl/lt__pre89.h: New file. Rename all the symbols from + LTLIBOBJS into the lt__ namespace so that they don't clash with + other libraries. + * libltdl/ltdl.c (rpl_memcpy, rpl_memmove, rpl_strchr, rpl_strcmp) + (rpl_strrchr): Moved from here... + * libltdl/memcpy.c (memcpy): ...to here, and fixed void * + dereference bug... + * libltdl/memmove.c (memmove): ...to here, and fixed void * + dereference bug... + * libltdl/strchr.c (strchr): ...to here... + * libltdl/strcmp.c (strcmp): ...here... + * libltdl/strrchr.c (strrchr): ...and here. + * libltdl/Makefile.am (libltdl_la_SOURCES): Add lt__pre89.h. + (libltdl_la_LIBADD, libltdlc_la_LIBADD): Add $(LTLIBOBJS). + (ltdldata_DATA): Add replacement sources files. + * m4/ltdl.m4 (AC_LIB_LTDL): Do careful config.h and LTLIBOBJ + setting for missing pre89 functions. + 2004-04-08 Gary V. Vaughan * libltdl/ltdl.h (LT_PARAMS): Removed. Changed all users to diff --git a/libltdl/Makefile.am b/libltdl/Makefile.am index 89857f5f4..a5096df59 100644 --- a/libltdl/Makefile.am +++ b/libltdl/Makefile.am @@ -38,14 +38,16 @@ endif ## default. CLEANFILES = libltdl.la libltdlc.la -libltdl_la_SOURCES = lt__alloc.c lt__alloc.h lt_system.h ltdl.c ltdl.h +libltdl_la_SOURCES = lt__alloc.c lt__alloc.h lt__pre89.h lt_system.h \ + ltdl.c ltdl.h libltdl_la_LDFLAGS = -no-undefined -version-info 5:0:2 -libltdl_la_LIBADD = $(LIBADD_DL) +libltdl_la_LIBADD = $(LIBADD_DL) $(LTLIBOBJS) libltdlc_la_SOURCES = $(libltdl_la_SOURCES) -libltdlc_la_LIBADD = $(LIBADD_DL) +libltdlc_la_LIBADD = $(LIBADD_DL) $(LTLIBOBJS) ## These are installed as a subdirectory of pkgdatadir so that ## libtoolize --ltdl can find them later: ltdldatadir = $(pkgdatadir)/libltdl -ltdldata_DATA = COPYING.LIB Makefile.am README $(libltdl_la_SOURCES) +ltdldata_DATA = COPYING.LIB Makefile.am README $(libltdl_la_SOURCES) \ + memcpy.c memmove.c strchr.c strcmp.c strrchr.c diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 41224cebb..620a281aa 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -71,6 +71,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA #include "ltdl.h" #include "lt__alloc.h" +#include "lt__pre89.h" #if defined(HAVE_CLOSEDIR) && defined(HAVE_OPENDIR) && defined(HAVE_READDIR) && defined(HAVE_DIRENT_H) /* We have a fully operational dirent subsystem. */ @@ -141,134 +142,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - -/* --- REPLACEMENT FUNCTIONS --- */ - - -#if ! HAVE_STRCMP - -#undef strcmp -#define strcmp rpl_strcmp - -static int -strcmp (const char *str1, const char *str2) -{ - if (str1 == str2) - return 0; - if (str1 == 0) - return -1; - if (str2 == 0) - return 1; - - for (;*str1 && *str2; ++str1, ++str2) - { - if (*str1 != *str2) - break; - } - - return (int)(*str1 - *str2); -} -#endif - - -#if ! HAVE_STRCHR - -# if HAVE_INDEX -# define strchr index -# else -# define strchr rpl_strchr - -static const char * -strchr (const char *str, int ch) -{ - const char *p; - - for (p = str; *p != (char)ch && *p != LT_EOS_CHAR; ++p) - /*NOWORK*/; - - return (*p == (char)ch) ? p : 0; -} - -# endif -#endif /* !HAVE_STRCHR */ - - -#if ! HAVE_STRRCHR - -# if HAVE_RINDEX -# define strrchr rindex -# else -# define strrchr rpl_strrchr - -static const char * -strrchr (const char *str, int ch) -{ - const char *p, *q = 0; - - for (p = str; *p != LT_EOS_CHAR; ++p) - { - if (*p == (char) ch) - { - q = p; - } - } - - return q; -} - -# endif -#endif - -/* NOTE: Neither bcopy nor the memcpy implementation below can - reliably handle copying in overlapping areas of memory. Use - memmove (for which there is a fallback implmentation below) - if you need that behaviour. */ -#if ! HAVE_MEMCPY - -# if HAVE_BCOPY -# define memcpy(dest, src, size) bcopy (src, dest, size) -# else -# define memcpy rpl_memcpy - -static void * -memcpy (void *dest, const void *src, size_t size) -{ - size_t i = 0; - - for (i = 0; i < size; ++i) - { - dest[i] = src[i]; - } - - return dest; -} - -# endif /* !HAVE_BCOPY */ -#endif /* !HAVE_MEMCPY */ - -#if ! HAVE_MEMMOVE -# define memmove rpl_memmove - -static void * -memmove (void *dest, const void *src, size_t size) -{ - size_t i; - - if (dest < src) - for (i = 0; i < size; ++i) - { - dest[i] = src[i]; - } - else if (dest > src) - for (i = size -1; i >= 0; --i) - { - dest[i] = src[i]; - } - - return dest; -} - -#endif /* !HAVE_MEMMOVE */ # if LT_USE_WINDOWS_DIRENT_EMULATION diff --git a/m4/ltdl.m4 b/m4/ltdl.m4 index 57cb062f9..fc9cfb5a9 100644 --- a/m4/ltdl.m4 +++ b/m4/ltdl.m4 @@ -110,10 +110,23 @@ AC_CHECK_HEADERS([assert.h ctype.h errno.h malloc.h memory.h stdlib.h \ [], [], [AC_INCLUDES_DEFAULT]) AC_CHECK_HEADERS([string.h strings.h], [break], [], [AC_INCLUDES_DEFAULT]) -AC_CHECK_FUNCS([strchr index], [break]) -AC_CHECK_FUNCS([strrchr rindex], [break]) -AC_CHECK_FUNCS([memcpy bcopy], [break]) -AC_CHECK_FUNCS([memmove strcmp]) +AC_FOREACH([LTDL_Func], [strchr index strrchr rindex memcpy bcopy], + [AH_TEMPLATE(AS_TR_CPP(HAVE_[]LTDL_Func), + [Define to 1 if you have the `]LTDL_Func[' function.])]) + +AC_CHECK_FUNC([strchr], [AC_DEFINE([HAVE_STRCHR])], + [AC_CHECK_FUNC([index], [AC_DEFINE([HAVE_INDEX])], + [AC_LIBOBJ([strchr])])]) + +AC_CHECK_FUNC([strrchr], [AC_DEFINE([HAVE_STRRCHR])], + [AC_CHECK_FUNC([rindex], [AC_DEFINE([HAVE_RINDEX])], + [AC_LIBOBJ([strrchr])])]) + +AC_CHECK_FUNC([memcpy], [AC_DEFINE([HAVE_MEMCPY])], + [AC_CHECK_FUNC([bcopy], [AC_DEFINE([HAVE_BCOPY])], + [AC_LIBOBJ([memcpy])])]) + +AC_REPLACE_FUNCS([memmove strcmp]) AC_CHECK_FUNCS([closedir opendir readdir]) ])# AC_LIB_LTDL