mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-28 08:26:14 +01:00
Merge branch 'remove-gmodule-dyld' into 'master'
gmodule: remove macOS dyld implementation See merge request GNOME/glib!1093
This commit is contained in:
commit
f944049869
@ -1,152 +0,0 @@
|
||||
/* GMODULE - GLIB wrapper code for dynamic module loading
|
||||
* Copyright (C) 1998, 2000 Tim Janik
|
||||
*
|
||||
* dyld (Darwin) GMODULE implementation
|
||||
* Copyright (C) 2001 Dan Winship
|
||||
*
|
||||
* This library 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 library 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
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
static gpointer self_module = GINT_TO_POINTER (1);
|
||||
|
||||
static gpointer
|
||||
_g_module_open (const gchar *file_name,
|
||||
gboolean bind_lazy,
|
||||
gboolean bind_local)
|
||||
{
|
||||
NSObjectFileImage image;
|
||||
NSObjectFileImageReturnCode ret;
|
||||
NSModule module;
|
||||
unsigned long options;
|
||||
char *msg;
|
||||
|
||||
ret = NSCreateObjectFileImageFromFile (file_name, &image);
|
||||
if (ret != NSObjectFileImageSuccess)
|
||||
{
|
||||
switch (ret)
|
||||
{
|
||||
case NSObjectFileImageInappropriateFile:
|
||||
case NSObjectFileImageFormat:
|
||||
msg = g_strdup_printf ("%s is not a loadable module", file_name);
|
||||
break;
|
||||
|
||||
case NSObjectFileImageArch:
|
||||
msg = g_strdup_printf ("%s is not built for this architecture",
|
||||
file_name);
|
||||
break;
|
||||
|
||||
case NSObjectFileImageAccess:
|
||||
if (access (file_name, F_OK) == 0)
|
||||
msg = g_strdup_printf ("%s: permission denied", file_name);
|
||||
else
|
||||
msg = g_strdup_printf ("%s: no such file or directory", file_name);
|
||||
break;
|
||||
|
||||
default:
|
||||
msg = g_strdup_printf ("unknown error for %s", file_name);
|
||||
break;
|
||||
}
|
||||
|
||||
g_module_set_error (msg);
|
||||
g_free (msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
options = NSLINKMODULE_OPTION_RETURN_ON_ERROR;
|
||||
if (bind_local)
|
||||
options |= NSLINKMODULE_OPTION_PRIVATE;
|
||||
if (!bind_lazy)
|
||||
options |= NSLINKMODULE_OPTION_BINDNOW;
|
||||
module = NSLinkModule (image, file_name, options);
|
||||
NSDestroyObjectFileImage (image);
|
||||
if (!module)
|
||||
{
|
||||
NSLinkEditErrors c;
|
||||
int error_number;
|
||||
const char *file, *error;
|
||||
|
||||
NSLinkEditError (&c, &error_number, &file, &error);
|
||||
msg = g_strdup_printf ("could not link %s: %s", file_name, error);
|
||||
g_module_set_error (msg);
|
||||
g_free (msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return module;
|
||||
}
|
||||
|
||||
static gpointer
|
||||
_g_module_self (void)
|
||||
{
|
||||
return &self_module;
|
||||
}
|
||||
|
||||
static void
|
||||
_g_module_close (gpointer handle,
|
||||
gboolean is_unref)
|
||||
{
|
||||
if (handle == &self_module)
|
||||
return;
|
||||
|
||||
if (!NSUnLinkModule (handle, 0))
|
||||
g_module_set_error ("could not unlink module");
|
||||
}
|
||||
|
||||
static gpointer
|
||||
_g_module_symbol (gpointer handle,
|
||||
const gchar *symbol_name)
|
||||
{
|
||||
NSSymbol sym;
|
||||
char *msg;
|
||||
|
||||
if (handle == &self_module)
|
||||
{
|
||||
if (NSIsSymbolNameDefined (symbol_name))
|
||||
sym = NSLookupAndBindSymbol (symbol_name);
|
||||
else
|
||||
sym = NULL;
|
||||
}
|
||||
else
|
||||
sym = NSLookupSymbolInModule (handle, symbol_name);
|
||||
|
||||
if (!sym)
|
||||
{
|
||||
msg = g_strdup_printf ("no such symbol %s", symbol_name);
|
||||
g_module_set_error (msg);
|
||||
g_free (msg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return NSAddressOfSymbol (sym);
|
||||
}
|
||||
|
||||
static gchar*
|
||||
_g_module_build_path (const gchar *directory,
|
||||
const gchar *module_name)
|
||||
{
|
||||
if (directory && *directory)
|
||||
{
|
||||
if (strncmp (module_name, "lib", 3) == 0)
|
||||
return g_strconcat (directory, "/", module_name, NULL);
|
||||
else
|
||||
return g_strconcat (directory, "/lib", module_name, "." G_MODULE_SUFFIX, NULL);
|
||||
}
|
||||
else if (strncmp (module_name, "lib", 3) == 0)
|
||||
return g_strdup (module_name);
|
||||
else
|
||||
return g_strconcat ("lib", module_name, "." G_MODULE_SUFFIX, NULL);
|
||||
}
|
@ -283,8 +283,6 @@ g_module_set_error (const gchar *error)
|
||||
#include "gmodule-dl.c"
|
||||
#elif (G_MODULE_IMPL == G_MODULE_IMPL_WIN32)
|
||||
#include "gmodule-win32.c"
|
||||
#elif (G_MODULE_IMPL == G_MODULE_IMPL_DYLD)
|
||||
#include "gmodule-dyld.c"
|
||||
#elif (G_MODULE_IMPL == G_MODULE_IMPL_AR)
|
||||
#include "gmodule-ar.c"
|
||||
#else
|
||||
|
@ -26,7 +26,6 @@ extern "C" {
|
||||
#define G_MODULE_IMPL_NONE 0
|
||||
#define G_MODULE_IMPL_DL 1
|
||||
#define G_MODULE_IMPL_WIN32 3
|
||||
#define G_MODULE_IMPL_DYLD 6
|
||||
#define G_MODULE_IMPL_AR 7
|
||||
|
||||
#define G_MODULE_IMPL @G_MODULE_IMPL@
|
||||
|
@ -15,10 +15,6 @@ elif host_system == 'aix'
|
||||
g_module_impl = 'G_MODULE_IMPL_AR'
|
||||
elif have_dlopen_dlsym
|
||||
g_module_impl = 'G_MODULE_IMPL_DL'
|
||||
# NSLinkModule (dyld) in system libraries (Darwin)
|
||||
elif cc.has_function('NSLinkModule')
|
||||
g_module_impl = 'G_MODULE_IMPL_DYLD'
|
||||
g_module_need_uscore = 1
|
||||
endif
|
||||
|
||||
# additional checks for G_MODULE_IMPL_DL
|
||||
|
Loading…
Reference in New Issue
Block a user