Dear list,
The attached patch is meant to fix problems with the libltdl.dll
under Windows. It attaches LT_SCOPE to each exported/imported symbol.
Furthermore it changes
#ifdef DLL_EXPORT
# define LT_SCOPE __declspec(dllexport)
#endif
#ifdef LIBLTDL_DLL_IMPORT
# define LT_SCOPE extern __declspec(dllimport)
#endif
into
#ifdef LIBLTDL_DLL_IMPORT
# define LT_SCOPE __declspec(dllimport) extern
#elif defined (DLL_EXPORT)
# define LT_SCOPE __declspec(dllexport) extern
#endif
This fixes the following problem: With the above order you *cannot* use
the libltdl.dll from another dll, because the dll would define DLL_EXPORT
and LIBLTDL_DLL_IMPORT concurrently.
Do you agree? And will you apply the patch?
Thanks in advance,
[EMAIL PROTECTED]
? patch.diff
Index: libltdl/ltdl.c
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.c,v
retrieving revision 1.162
diff -u -r1.162 ltdl.c
--- libltdl/ltdl.c 11 Jan 2002 00:25:18 -0000 1.162
+++ libltdl/ltdl.c 29 Jan 2002 10:59:01 -0000
@@ -65,7 +65,13 @@
# include <errno.h>
#endif
-#if HAVE_DIRENT_H
+#if defined (_MSC_VER) || defined (__BORLANDC__)
+# include <io.h>
+# ifndef R_OK
+# define R_OK 4
+# endif
+# define LT_D_NAMLEN(dirent) (strlen((dirent)->d_name))
+#elif HAVE_DIRENT_H
# include <dirent.h>
# define LT_D_NAMLEN(dirent) (strlen((dirent)->d_name))
#else
@@ -1981,8 +1987,9 @@
assert (strchr (dirname, LT_DIRSEP_CHAR) == 0);
#endif
- if (dirname[dirname_len -1] == '/')
- --dirname_len;
+ if (dirname_len > 0)
+ if (dirname[dirname_len -1] == '/')
+ --dirname_len;
filename_len = dirname_len + 1 + LT_STRLEN (dlname);
/* Allocate memory, and combine DIRNAME and MODULENAME into it.
Index: libltdl/ltdl.h
===================================================================
RCS file: /cvsroot/libtool/libtool/libltdl/ltdl.h,v
retrieving revision 1.57
diff -u -r1.57 ltdl.h
--- libltdl/ltdl.h 13 Aug 2001 17:25:49 -0000 1.57
+++ libltdl/ltdl.h 29 Jan 2002 10:59:02 -0000
@@ -127,11 +127,10 @@
ridiculous implementation of data symbol exporting. */
#ifndef LT_SCOPE
# ifdef __WINDOWS__
-# ifdef DLL_EXPORT /* defined by libtool (if required) */
-# define LT_SCOPE __declspec(dllexport)
-# endif
# ifdef LIBLTDL_DLL_IMPORT /* define if linking with this dll */
-# define LT_SCOPE extern __declspec(dllimport)
+# define LT_SCOPE __declspec(dllimport) extern
+# elif defined (DLL_EXPORT) /* defined by libtool (if required) */
+# define LT_SCOPE __declspec(dllexport) extern
# endif
# endif
# ifndef LT_SCOPE /* static linking or !__WINDOWS__ */
@@ -148,31 +147,31 @@
typedef struct lt_dlhandle_struct *lt_dlhandle; /* A loaded module. */
/* Initialisation and finalisation functions for libltdl. */
-extern int lt_dlinit LT_PARAMS((void));
-extern int lt_dlexit LT_PARAMS((void));
+LT_SCOPE int lt_dlinit LT_PARAMS((void));
+LT_SCOPE int lt_dlexit LT_PARAMS((void));
/* Module search path manipulation. */
-extern int lt_dladdsearchdir LT_PARAMS((const char *search_dir));
-extern int lt_dlinsertsearchdir LT_PARAMS((const char *before,
+LT_SCOPE int lt_dladdsearchdir LT_PARAMS((const char *search_dir));
+LT_SCOPE int lt_dlinsertsearchdir LT_PARAMS((const char *before,
const char *search_dir));
-extern int lt_dlsetsearchpath LT_PARAMS((const char *search_path));
-extern const char *lt_dlgetsearchpath LT_PARAMS((void));
-extern int lt_dlforeachfile LT_PARAMS((
+LT_SCOPE int lt_dlsetsearchpath LT_PARAMS((const char *search_path));
+LT_SCOPE const char *lt_dlgetsearchpath LT_PARAMS((void));
+LT_SCOPE int lt_dlforeachfile LT_PARAMS((
const char *search_path,
int (*func) (const char *filename, lt_ptr data),
lt_ptr data));
/* Portable libltdl versions of the system dlopen() API. */
-extern lt_dlhandle lt_dlopen LT_PARAMS((const char *filename));
-extern lt_dlhandle lt_dlopenext LT_PARAMS((const char *filename));
-extern lt_ptr lt_dlsym LT_PARAMS((lt_dlhandle handle,
+LT_SCOPE lt_dlhandle lt_dlopen LT_PARAMS((const char *filename));
+LT_SCOPE lt_dlhandle lt_dlopenext LT_PARAMS((const char *filename));
+LT_SCOPE lt_ptr lt_dlsym LT_PARAMS((lt_dlhandle handle,
const char *name));
-extern const char *lt_dlerror LT_PARAMS((void));
-extern int lt_dlclose LT_PARAMS((lt_dlhandle handle));
+LT_SCOPE const char *lt_dlerror LT_PARAMS((void));
+LT_SCOPE int lt_dlclose LT_PARAMS((lt_dlhandle handle));
/* Module residency management. */
-extern int lt_dlmakeresident LT_PARAMS((lt_dlhandle handle));
-extern int lt_dlisresident LT_PARAMS((lt_dlhandle handle));
+LT_SCOPE int lt_dlmakeresident LT_PARAMS((lt_dlhandle handle));
+LT_SCOPE int lt_dlisresident LT_PARAMS((lt_dlhandle handle));
@@ -185,7 +184,7 @@
typedef void lt_dlmutex_seterror LT_PARAMS((const char *errmsg));
typedef const char *lt_dlmutex_geterror LT_PARAMS((void));
-extern int lt_dlmutex_register LT_PARAMS((lt_dlmutex_lock *lock,
+LT_SCOPE int lt_dlmutex_register LT_PARAMS((lt_dlmutex_lock *lock,
lt_dlmutex_unlock *unlock,
lt_dlmutex_seterror *seterror,
lt_dlmutex_geterror *geterror));
@@ -201,9 +200,9 @@
libltdl relies on a featureful realloc, but if you are sure yours
has the right semantics then you can assign it directly. Generally,
it is safe to assign just a malloc() and a free() function. */
-LT_SCOPE lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size));
-LT_SCOPE lt_ptr (*lt_dlrealloc) LT_PARAMS((lt_ptr ptr, size_t size));
-LT_SCOPE void (*lt_dlfree) LT_PARAMS((lt_ptr ptr));
+LT_SCOPE lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size));
+LT_SCOPE lt_ptr (*lt_dlrealloc) LT_PARAMS((lt_ptr ptr, size_t size));
+LT_SCOPE void (*lt_dlfree) LT_PARAMS((lt_ptr ptr));
@@ -218,8 +217,8 @@
lt_ptr address;
} lt_dlsymlist;
-extern int lt_dlpreload LT_PARAMS((const lt_dlsymlist *preloaded));
-extern int lt_dlpreload_default
+LT_SCOPE int lt_dlpreload LT_PARAMS((const lt_dlsymlist *preloaded));
+LT_SCOPE int lt_dlpreload_default
LT_PARAMS((const lt_dlsymlist *preloaded));
#define LTDL_SET_PRELOADED_SYMBOLS() LT_STMT_START{ \
@@ -241,20 +240,20 @@
number of times lt_dlclosed. */
} lt_dlinfo;
-extern const lt_dlinfo *lt_dlgetinfo LT_PARAMS((lt_dlhandle handle));
-extern lt_dlhandle lt_dlhandle_next LT_PARAMS((lt_dlhandle place));
-extern int lt_dlforeach LT_PARAMS((
+LT_SCOPE const lt_dlinfo *lt_dlgetinfo LT_PARAMS((lt_dlhandle handle));
+LT_SCOPE lt_dlhandle lt_dlhandle_next LT_PARAMS((lt_dlhandle place));
+LT_SCOPE int lt_dlforeach LT_PARAMS((
int (*func) (lt_dlhandle handle, lt_ptr data),
lt_ptr data));
/* Associating user data with loaded modules. */
typedef unsigned lt_dlcaller_id;
-extern lt_dlcaller_id lt_dlcaller_register LT_PARAMS((void));
-extern lt_ptr lt_dlcaller_set_data LT_PARAMS((lt_dlcaller_id key,
+LT_SCOPE lt_dlcaller_id lt_dlcaller_register LT_PARAMS((void));
+LT_SCOPE lt_ptr lt_dlcaller_set_data LT_PARAMS((lt_dlcaller_id key,
lt_dlhandle handle,
lt_ptr data));
-extern lt_ptr lt_dlcaller_get_data LT_PARAMS((lt_dlcaller_id key,
+LT_SCOPE lt_ptr lt_dlcaller_get_data LT_PARAMS((lt_dlcaller_id key,
lt_dlhandle handle));
@@ -285,15 +284,15 @@
lt_user_data dlloader_data;
};
-extern lt_dlloader *lt_dlloader_next LT_PARAMS((lt_dlloader *place));
-extern lt_dlloader *lt_dlloader_find LT_PARAMS((
+LT_SCOPE lt_dlloader *lt_dlloader_next LT_PARAMS((lt_dlloader *place));
+LT_SCOPE lt_dlloader *lt_dlloader_find LT_PARAMS((
const char *loader_name));
-extern const char *lt_dlloader_name LT_PARAMS((lt_dlloader *place));
-extern lt_user_data *lt_dlloader_data LT_PARAMS((lt_dlloader *place));
-extern int lt_dlloader_add LT_PARAMS((lt_dlloader *place,
+LT_SCOPE const char *lt_dlloader_name LT_PARAMS((lt_dlloader *place));
+LT_SCOPE lt_user_data *lt_dlloader_data LT_PARAMS((lt_dlloader *place));
+LT_SCOPE int lt_dlloader_add LT_PARAMS((lt_dlloader *place,
const struct lt_user_dlloader *dlloader,
const char *loader_name));
-extern int lt_dlloader_remove LT_PARAMS((
+LT_SCOPE int lt_dlloader_remove LT_PARAMS((
const char *loader_name));
@@ -336,8 +335,8 @@
};
/* These functions are only useful from inside custom module loaders. */
-extern int lt_dladderror LT_PARAMS((const char *diagnostic));
-extern int lt_dlseterror LT_PARAMS((int errorcode));
+LT_SCOPE int lt_dladderror LT_PARAMS((const char *diagnostic));
+LT_SCOPE int lt_dlseterror LT_PARAMS((int errorcode));