X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Frelocatable.c;h=581440b3c3e53ed42065912dfd86352cde27964b;hb=2f34c96410ed6ec496cd128d03e3a0026c20d104;hp=a7bbd99dca78be9628ac6a0edef175a822bcbe93;hpb=ef11bf40fdc66a337b26c40f02d0aa02faf63e38;p=gnulib.git diff --git a/lib/relocatable.c b/lib/relocatable.c index a7bbd99dc..581440b3c 100644 --- a/lib/relocatable.c +++ b/lib/relocatable.c @@ -1,21 +1,19 @@ /* Provide relocatable packages. - Copyright (C) 2003-2006, 2008-2011 Free Software Foundation, Inc. + Copyright (C) 2003-2006, 2008-2012 Free Software Foundation, Inc. Written by Bruno Haible , 2003. - This program is free software; you can redistribute it and/or modify it - under the terms of the GNU Library General Public License as published - by the Free Software Foundation; either version 2, or (at your option) - any later version. + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as published by + the Free Software Foundation; either version 2.1 of the License, or + (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. - You should have received a copy of the GNU Library General Public - License along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, - USA. */ + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . */ /* Tell glibc's to provide a prototype for getline(). @@ -72,7 +70,7 @@ IS_PATH_WITH_DIR(P) tests whether P contains a directory specification. */ #if ((defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__) || defined __EMX__ || defined __DJGPP__ - /* Win32, OS/2, DOS */ + /* Native Windows, OS/2, DOS */ # define ISSLASH(C) ((C) == '/' || (C) == '\\') # define HAS_DEVICE(P) \ ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \ @@ -87,6 +85,19 @@ # define FILE_SYSTEM_PREFIX_LEN(P) 0 #endif +/* Whether to enable the more costly support for relocatable libraries. + It allows libraries to be have been installed with a different original + prefix than the program. But it is quite costly, especially on Cygwin + platforms, see below. Therefore we enable it by default only on native + Windows platforms. */ +#ifndef ENABLE_COSTLY_RELOCATABLE +# if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ +# define ENABLE_COSTLY_RELOCATABLE 1 +# else +# define ENABLE_COSTLY_RELOCATABLE 0 +# endif +#endif + /* Original installation prefix. */ static char *orig_prefix; static size_t orig_prefix_len; @@ -156,7 +167,7 @@ set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg) #endif } -#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR) +#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE) /* Convenience function: Computes the current installation prefix, based on the original @@ -238,7 +249,7 @@ compute_curr_prefix (const char *orig_installprefix, often case-insensitive. It's better to accept the comparison if the difference is only in case, rather than to fail. */ #if defined _WIN32 || defined __WIN32__ || defined __CYGWIN__ || defined __EMX__ || defined __DJGPP__ - /* Win32, Cygwin, OS/2, DOS - case insignificant file system */ + /* Native Windows, Cygwin, OS/2, DOS - case insignificant file system */ if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi) != (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi)) break; @@ -286,16 +297,16 @@ compute_curr_prefix (const char *orig_installprefix, #endif /* !IN_LIBRARY || PIC */ -#if defined PIC && defined INSTALLDIR +#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE /* Full pathname of shared library, or NULL. */ static char *shared_library_fullname; #if (defined _WIN32 || defined __WIN32__) && !defined __CYGWIN__ -/* Native Win32 only. +/* Native Windows only. On Cygwin, it is better to use the Cygwin provided /proc interface, than - to use native Win32 API and cygwin_conv_to_posix_path, because it supports - longer file names + to use native Windows API and cygwin_conv_to_posix_path, because it + supports longer file names (see ). */ /* Determine the full pathname of the shared library when it is loaded. */ @@ -332,7 +343,9 @@ find_shared_library_fullname () #if (defined __linux__ && (__GLIBC__ >= 2 || defined __UCLIBC__)) || defined __CYGWIN__ /* Linux has /proc/self/maps. glibc 2 and uClibc have the getline() function. - Cygwin >= 1.5 has /proc/self/maps and the getline() function too. */ + Cygwin >= 1.5 has /proc/self/maps and the getline() function too. + But it is costly: ca. 0.3 ms on Linux, 3 ms on Cygwin 1.5, and 5 ms on + Cygwin 1.7. */ FILE *fp; /* Open the current process' maps file. It describes one VMA per line. */ @@ -377,11 +390,11 @@ find_shared_library_fullname () #endif } -#endif /* WIN32 / Unix */ +#endif /* Native Windows / Unix */ /* Return the full pathname of the current shared library. Return NULL if unknown. - Guaranteed to work only on Linux, Cygwin and Woe32. */ + Guaranteed to work only on Linux, Cygwin, and native Windows. */ static char * get_shared_library_fullname () { @@ -405,7 +418,7 @@ get_shared_library_fullname () const char * relocate (const char *pathname) { -#if defined PIC && defined INSTALLDIR +#if defined PIC && defined INSTALLDIR && ENABLE_COSTLY_RELOCATABLE static int initialized; /* Initialization code for a shared library. */