Beispiel #1
0
static gpointer
_g_module_symbol (gpointer     handle,
		  const gchar *symbol_name)
{
  gpointer p;
  gchar *msg;

  fetch_dlerror (FALSE);
  p = dlsym (handle, symbol_name);
  msg = fetch_dlerror (FALSE);
  if (msg)
    g_module_set_error (msg);
  
  return p;
}
Beispiel #2
0
static gpointer
_g_module_open (const gchar *file_name,
                gboolean     bind_lazy,
                gboolean     bind_local)
{
    gpointer handle;
    gchar* member;
    gchar* full_name;

    /* extract name of first member of archive */

    member = _g_module_get_member (file_name);
    if (member != NULL)
    {
        full_name = g_strconcat (file_name, "(", member, ")", NULL);
        g_free (member);
    }
    else
        full_name = g_strdup (file_name);

    handle = dlopen (full_name,
                     (bind_local ? RTLD_LOCAL : RTLD_GLOBAL) | RTLD_MEMBER | (bind_lazy ? RTLD_LAZY : RTLD_NOW));

    g_free (full_name);

    if (!handle)
        g_module_set_error (fetch_dlerror (TRUE));

    return handle;
}
Beispiel #3
0
static gpointer
_g_module_self (void)
{
    gpointer handle;

    handle = dlopen (NULL, RTLD_GLOBAL | RTLD_LAZY);
    if (!handle)
        g_module_set_error (fetch_dlerror (TRUE));

    return handle;
}
static gpointer
_g_module_open (const gchar *file_name,
		gboolean     bind_lazy)
{
  gpointer handle;
  
  handle = dlopen (file_name, RTLD_GLOBAL | (bind_lazy ? RTLD_LAZY : RTLD_NOW));
  if (!handle)
    g_module_set_error (fetch_dlerror ());
  
  return handle;
}
static gpointer
_g_module_symbol (gpointer     handle,
		  const gchar *symbol_name)
{
  gpointer p;
  
  p = dlsym (handle, symbol_name);
  if (!p)
    g_module_set_error (fetch_dlerror ());
  
  return p;
}
static gpointer
_g_module_self (void)
{
  gpointer handle;
  
  /* to query symbols from the program itself, special link options
   * are required on some systems.
   */
  
  handle = dlopen (NULL, RTLD_GLOBAL | RTLD_LAZY);
  if (!handle)
    g_module_set_error (fetch_dlerror ());
  
  return handle;
}
static void
_g_module_close (gpointer handle,
		 gboolean is_unref)
{
  /* are there any systems out there that have dlopen()/dlclose()
   * without a reference count implementation?
   */
  is_unref |= 1;
  
  if (is_unref)
    {
      if (dlclose (handle) != 0)
	g_module_set_error (fetch_dlerror ());
    }
}