Commit bae5c76d authored by Alexandre Julliard's avatar Alexandre Julliard

Moved dlopen wrappers to loader.c.

parent a9bedef3
...@@ -405,3 +405,98 @@ void *wine_dll_load_main_exe( const char *name, char *error, int errorsize, int ...@@ -405,3 +405,98 @@ void *wine_dll_load_main_exe( const char *name, char *error, int errorsize, int
{ {
return dlopen_dll( name, error, errorsize, test_only ); return dlopen_dll( name, error, errorsize, test_only );
} }
/*
* These functions provide wrappers around dlopen() and associated
* functions. They work around a bug in glibc 2.1.x where calling
* a dl*() function after a previous dl*() function has failed
* without a dlerror() call between the two will cause a crash.
* They all take a pointer to a buffer that
* will receive the error description (from dlerror()). This
* parameter may be NULL if the error description is not required.
*/
/***********************************************************************
* wine_dlopen
*/
void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
{
#ifdef HAVE_DLOPEN
void *ret;
const char *s;
dlerror(); dlerror();
ret = dlopen( filename, flag );
s = dlerror();
if (error)
{
strncpy( error, s ? s : "", errorsize );
error[errorsize - 1] = '\0';
}
dlerror();
return ret;
#else
if (error)
{
strncpy( error, "dlopen interface not detected by configure", errorsize );
error[errorsize - 1] = '\0';
}
return NULL;
#endif
}
/***********************************************************************
* wine_dlsym
*/
void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
{
#ifdef HAVE_DLOPEN
void *ret;
const char *s;
dlerror(); dlerror();
ret = dlsym( handle, symbol );
s = dlerror();
if (error)
{
strncpy( error, s ? s : "", errorsize );
error[errorsize - 1] = '\0';
}
dlerror();
return ret;
#else
if (error)
{
strncpy( error, "dlopen interface not detected by configure", errorsize );
error[errorsize - 1] = '\0';
}
return NULL;
#endif
}
/***********************************************************************
* wine_dlclose
*/
int wine_dlclose( void *handle, char *error, int errorsize )
{
#ifdef HAVE_DLOPEN
int ret;
const char *s;
dlerror(); dlerror();
ret = dlclose( handle );
s = dlerror();
if (error)
{
strncpy( error, s ? s : "", errorsize );
error[errorsize - 1] = '\0';
}
dlerror();
return ret;
#else
if (error)
{
strncpy( error, "dlopen interface not detected by configure", errorsize );
error[errorsize - 1] = '\0';
}
return 1;
#endif
}
...@@ -248,100 +248,6 @@ void *wine_anon_mmap( void *start, size_t size, int prot, int flags ) ...@@ -248,100 +248,6 @@ void *wine_anon_mmap( void *start, size_t size, int prot, int flags )
} }
/*
* These functions provide wrappers around dlopen() and associated
* functions. They work around a bug in glibc 2.1.x where calling
* a dl*() function after a previous dl*() function has failed
* without a dlerror() call between the two will cause a crash.
* They all take a pointer to a buffer that
* will receive the error description (from dlerror()). This
* parameter may be NULL if the error description is not required.
*/
/***********************************************************************
* wine_dlopen
*/
void *wine_dlopen( const char *filename, int flag, char *error, int errorsize )
{
#ifdef HAVE_DLOPEN
void *ret;
const char *s;
dlerror(); dlerror();
ret = dlopen( filename, flag );
s = dlerror();
if (error)
{
strncpy( error, s ? s : "", errorsize );
error[errorsize - 1] = '\0';
}
dlerror();
return ret;
#else
if (error)
{
strncpy( error, "dlopen interface not detected by configure", errorsize );
error[errorsize - 1] = '\0';
}
return NULL;
#endif
}
/***********************************************************************
* wine_dlsym
*/
void *wine_dlsym( void *handle, const char *symbol, char *error, int errorsize )
{
#ifdef HAVE_DLOPEN
void *ret;
const char *s;
dlerror(); dlerror();
ret = dlsym( handle, symbol );
s = dlerror();
if (error)
{
strncpy( error, s ? s : "", errorsize );
error[errorsize - 1] = '\0';
}
dlerror();
return ret;
#else
if (error)
{
strncpy( error, "dlopen interface not detected by configure", errorsize );
error[errorsize - 1] = '\0';
}
return NULL;
#endif
}
/***********************************************************************
* wine_dlclose
*/
int wine_dlclose( void *handle, char *error, int errorsize )
{
#ifdef HAVE_DLOPEN
int ret;
const char *s;
dlerror(); dlerror();
ret = dlclose( handle );
s = dlerror();
if (error)
{
strncpy( error, s ? s : "", errorsize );
error[errorsize - 1] = '\0';
}
dlerror();
return ret;
#else
if (error)
{
strncpy( error, "dlopen interface not detected by configure", errorsize );
error[errorsize - 1] = '\0';
}
return 1;
#endif
}
#ifndef HAVE_ECVT #ifndef HAVE_ECVT
/*********************************************************************** /***********************************************************************
* ecvt * ecvt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment