mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-23 18:52:09 +01:00
Made it MT safe, the g_module_error() is now thread specific.
1998-12-10 Sebastian Wilhelmi <wilhelmi@ira.uka.de> * gmodule.c: Made it MT safe, the g_module_error() is now thread specific.
This commit is contained in:
parent
df942a0c9e
commit
c3ba51da2c
@ -1,3 +1,8 @@
|
|||||||
|
1998-12-10 Sebastian Wilhelmi <wilhelmi@ira.uka.de>
|
||||||
|
|
||||||
|
* gmodule.c: Made it MT safe, the g_module_error() is now thread
|
||||||
|
specific.
|
||||||
|
|
||||||
Fri Nov 20 14:43:44 1998 Tim Janik <timj@gtk.org>
|
Fri Nov 20 14:43:44 1998 Tim Janik <timj@gtk.org>
|
||||||
|
|
||||||
* gmodule.c (_g_module_build_path): added empty default imlementation
|
* gmodule.c (_g_module_build_path): added empty default imlementation
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MT safe
|
||||||
|
*/
|
||||||
|
|
||||||
#include <dlfcn.h>
|
#include <dlfcn.h>
|
||||||
|
|
||||||
/* Perl includes <nlist.h> and <link.h> instead of <dlfcn.h> on some systmes? */
|
/* Perl includes <nlist.h> and <link.h> instead of <dlfcn.h> on some systmes? */
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MT safe
|
||||||
|
*/
|
||||||
|
|
||||||
#include <dl.h>
|
#include <dl.h>
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,6 +17,11 @@
|
|||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MT safe
|
||||||
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
* Boston, MA 02111-1307, USA.
|
* Boston, MA 02111-1307, USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* MT safe
|
||||||
|
*/
|
||||||
|
|
||||||
#include "gmodule.h"
|
#include "gmodule.h"
|
||||||
#include "gmoduleconf.h"
|
#include "gmoduleconf.h"
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
@ -59,10 +64,11 @@ static inline GModule* g_module_find_by_name (const gchar *name);
|
|||||||
|
|
||||||
|
|
||||||
/* --- variables --- */
|
/* --- variables --- */
|
||||||
const char *g_log_domain_gmodule = "GModule";
|
static G_LOCK_DEFINE (g_module_global);
|
||||||
static GModule *modules = NULL;
|
const char *g_log_domain_gmodule = "GModule";
|
||||||
static GModule *main_module = NULL;
|
static GModule *modules = NULL;
|
||||||
static gchar *module_error = NULL;
|
static GModule *main_module = NULL;
|
||||||
|
static GStaticPrivate module_error_private = G_STATIC_PRIVATE_INIT;
|
||||||
|
|
||||||
|
|
||||||
/* --- inline functions --- */
|
/* --- inline functions --- */
|
||||||
@ -70,30 +76,45 @@ static inline GModule*
|
|||||||
g_module_find_by_handle (gpointer handle)
|
g_module_find_by_handle (gpointer handle)
|
||||||
{
|
{
|
||||||
GModule *module;
|
GModule *module;
|
||||||
|
GModule *retval = NULL;
|
||||||
|
|
||||||
|
g_lock (g_module_global);
|
||||||
if (main_module && main_module->handle == handle)
|
if (main_module && main_module->handle == handle)
|
||||||
return main_module;
|
retval = main_module;
|
||||||
|
else
|
||||||
for (module = modules; module; module = module->next)
|
for (module = modules; module; module = module->next)
|
||||||
if (handle == module->handle)
|
if (handle == module->handle)
|
||||||
return module;
|
{
|
||||||
return NULL;
|
retval = module;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_unlock (g_module_global);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline GModule*
|
static inline GModule*
|
||||||
g_module_find_by_name (const gchar *name)
|
g_module_find_by_name (const gchar *name)
|
||||||
{
|
{
|
||||||
GModule *module;
|
GModule *module;
|
||||||
|
GModule *retval = NULL;
|
||||||
|
|
||||||
|
g_lock (g_module_global);
|
||||||
for (module = modules; module; module = module->next)
|
for (module = modules; module; module = module->next)
|
||||||
if (strcmp (name, module->file_name) == 0)
|
if (strcmp (name, module->file_name) == 0)
|
||||||
return module;
|
{
|
||||||
return NULL;
|
retval = module;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
g_unlock (g_module_global);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
g_module_set_error (const gchar *error)
|
g_module_set_error (const gchar *error)
|
||||||
{
|
{
|
||||||
|
gchar* module_error = g_static_private_get (&module_error_private);
|
||||||
if (module_error)
|
if (module_error)
|
||||||
g_free (module_error);
|
g_free (module_error);
|
||||||
if (error)
|
if (error)
|
||||||
@ -101,6 +122,7 @@ g_module_set_error (const gchar *error)
|
|||||||
else
|
else
|
||||||
module_error = NULL;
|
module_error = NULL;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
g_static_private_set (&module_error_private, module_error, g_free);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -175,7 +197,8 @@ g_module_open (const gchar *file_name,
|
|||||||
CHECK_ERROR (NULL);
|
CHECK_ERROR (NULL);
|
||||||
|
|
||||||
if (!file_name)
|
if (!file_name)
|
||||||
{
|
{
|
||||||
|
g_lock (g_module_global);
|
||||||
if (!main_module)
|
if (!main_module)
|
||||||
{
|
{
|
||||||
handle = _g_module_self ();
|
handle = _g_module_self ();
|
||||||
@ -190,7 +213,8 @@ g_module_open (const gchar *file_name,
|
|||||||
main_module->next = NULL;
|
main_module->next = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
g_unlock (g_module_global);
|
||||||
|
|
||||||
return main_module;
|
return main_module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -222,8 +246,8 @@ g_module_open (const gchar *file_name,
|
|||||||
return module;
|
return module;
|
||||||
}
|
}
|
||||||
|
|
||||||
saved_error = module_error;
|
saved_error = g_module_error();
|
||||||
module_error = NULL;
|
g_static_private_set (&module_error_private, NULL, NULL);
|
||||||
g_module_set_error (NULL);
|
g_module_set_error (NULL);
|
||||||
|
|
||||||
module = g_new (GModule, 1);
|
module = g_new (GModule, 1);
|
||||||
@ -232,8 +256,10 @@ g_module_open (const gchar *file_name,
|
|||||||
module->ref_count = 1;
|
module->ref_count = 1;
|
||||||
module->is_resident = FALSE;
|
module->is_resident = FALSE;
|
||||||
module->unload = NULL;
|
module->unload = NULL;
|
||||||
|
g_lock (g_module_global);
|
||||||
module->next = modules;
|
module->next = modules;
|
||||||
modules = module;
|
modules = module;
|
||||||
|
g_unlock (g_module_global);
|
||||||
|
|
||||||
/* check initialization */
|
/* check initialization */
|
||||||
if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init))
|
if (g_module_symbol (module, "g_module_check_init", (gpointer) &check_init))
|
||||||
@ -286,6 +312,8 @@ g_module_close (GModule *module)
|
|||||||
GModule *node;
|
GModule *node;
|
||||||
|
|
||||||
last = NULL;
|
last = NULL;
|
||||||
|
|
||||||
|
g_lock (g_module_global);
|
||||||
node = modules;
|
node = modules;
|
||||||
while (node)
|
while (node)
|
||||||
{
|
{
|
||||||
@ -301,6 +329,7 @@ g_module_close (GModule *module)
|
|||||||
node = last->next;
|
node = last->next;
|
||||||
}
|
}
|
||||||
module->next = NULL;
|
module->next = NULL;
|
||||||
|
g_unlock (g_module_global);
|
||||||
|
|
||||||
_g_module_close (module->handle, FALSE);
|
_g_module_close (module->handle, FALSE);
|
||||||
g_free (module->file_name);
|
g_free (module->file_name);
|
||||||
@ -308,7 +337,7 @@ g_module_close (GModule *module)
|
|||||||
g_free (module);
|
g_free (module);
|
||||||
}
|
}
|
||||||
|
|
||||||
return module_error == NULL;
|
return g_module_error() == NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -322,7 +351,7 @@ g_module_make_resident (GModule *module)
|
|||||||
gchar*
|
gchar*
|
||||||
g_module_error (void)
|
g_module_error (void)
|
||||||
{
|
{
|
||||||
return module_error;
|
return g_static_private_get (&module_error_private);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
@ -330,6 +359,7 @@ g_module_symbol (GModule *module,
|
|||||||
const gchar *symbol_name,
|
const gchar *symbol_name,
|
||||||
gpointer *symbol)
|
gpointer *symbol)
|
||||||
{
|
{
|
||||||
|
gchar *module_error;
|
||||||
if (symbol)
|
if (symbol)
|
||||||
*symbol = NULL;
|
*symbol = NULL;
|
||||||
CHECK_ERROR (FALSE);
|
CHECK_ERROR (FALSE);
|
||||||
@ -350,7 +380,7 @@ g_module_symbol (GModule *module,
|
|||||||
*symbol = _g_module_symbol (module->handle, symbol_name);
|
*symbol = _g_module_symbol (module->handle, symbol_name);
|
||||||
#endif /* !G_MODULE_NEED_USCORE */
|
#endif /* !G_MODULE_NEED_USCORE */
|
||||||
|
|
||||||
if (module_error)
|
if ((module_error = g_module_error()))
|
||||||
{
|
{
|
||||||
gchar *error;
|
gchar *error;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user