[vlc-devel] commit: macosx at core: removed the usage of dyld's 'Library Functions' completely ( Felix Paul Kühne )

git version control git at videolan.org
Mon Jun 22 20:32:19 CEST 2009


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Mon Jun 22 20:32:03 2009 +0200| [27953d60c99bc0e46d6f0d77a7e3f2f3b36ccf9e] | committer: Felix Paul Kühne 

macosx at core: removed the usage of dyld's 'Library Functions' completely

these are automagically 'replaced by the more efficient 'Dynamic Loader Compatibility Functions.'' as suggested by Apple's documentation. IMO, this should be ported to the 1.0-bugfix branch as it cleanly fixes some 64bit crashes and should improve the performance slightly

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=27953d60c99bc0e46d6f0d77a7e3f2f3b36ccf9e
---

 configure.ac               |    6 ----
 src/misc/darwin_specific.c |    4 +--
 src/modules/os.c           |   55 ++++---------------------------------------
 3 files changed, 7 insertions(+), 58 deletions(-)

diff --git a/configure.ac b/configure.ac
index 34ed30b..7d25e70 100644
--- a/configure.ac
+++ b/configure.ac
@@ -740,12 +740,6 @@ fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"
 dnl Check for dynamic plugins
 ac_cv_have_plugins=no
 
-# OS X style
-AC_CHECK_HEADERS(mach-o/dyld.h,
-  [AC_CHECK_FUNCS(NSLinkModule,
-    [AC_DEFINE(HAVE_DL_DYLD, 1, [Define if you have the Darwin dyld API])
-     ac_cv_have_plugins=yes])])
-
 # HP-UX style
 if test "${ac_cv_have_plugins}" = "no"; then
   AC_CHECK_HEADERS(dl.h)
diff --git a/src/misc/darwin_specific.c b/src/misc/darwin_specific.c
index 23ef2ff..a156718 100644
--- a/src/misc/darwin_specific.c
+++ b/src/misc/darwin_specific.c
@@ -32,13 +32,11 @@
 #include <dirent.h>                                                /* *dir() */
 
 #include <CoreFoundation/CoreFoundation.h>
+#include <mach-o/dyld.h>
 
 #ifdef HAVE_LOCALE_H
 #   include <locale.h>
 #endif
-#ifdef HAVE_MACH_O_DYLD_H
-#   include <mach-o/dyld.h>
-#endif
 
 #ifndef MAXPATHLEN
 # define MAXPATHLEN 1024
diff --git a/src/modules/os.c b/src/modules/os.c
index 58fef51..c77cc74 100644
--- a/src/modules/os.c
+++ b/src/modules/os.c
@@ -43,14 +43,12 @@
 
 #if !defined(HAVE_DYNAMIC_PLUGINS)
     /* no support for plugins */
-#elif defined(HAVE_DL_DYLD)
-#   if defined(HAVE_MACH_O_DYLD_H)
-#       include <mach-o/dyld.h>
-#   endif
 #elif defined(HAVE_DL_BEOS)
 #   if defined(HAVE_IMAGE_H)
 #       include <image.h>
 #   endif
+#elif defined(__APPLE__)
+#   include <dlfcn.h>
 #elif defined(HAVE_DL_WINDOWS)
 #   include <windows.h>
 #elif defined(HAVE_DL_DLOPEN)
@@ -98,7 +96,7 @@ int module_Call( vlc_object_t *obj, module_t *p_module )
 
     if( pf_symbol == NULL )
     {
-#if defined(HAVE_DL_DYLD) || defined(HAVE_DL_BEOS)
+#if defined(HAVE_DL_BEOS)
         msg_Warn( obj, "cannot find symbol \"%s\" in file `%s'",
                   psz_name, p_module->psz_filename );
 #elif defined(HAVE_DL_WINDOWS)
@@ -145,37 +143,7 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
 {
     module_handle_t handle;
 
-#if defined(HAVE_DL_DYLD)
-    NSObjectFileImage image;
-    NSObjectFileImageReturnCode ret;
-
-    ret = NSCreateObjectFileImageFromFile( psz_file, &image );
-
-    if( ret != NSObjectFileImageSuccess )
-    {
-        msg_Warn( p_this, "cannot create image from `%s'", psz_file );
-        return -1;
-    }
-
-    /* Open the dynamic module */
-    handle = NSLinkModule( image, psz_file,
-                           NSLINKMODULE_OPTION_RETURN_ON_ERROR );
-
-    if( !handle )
-    {
-        NSLinkEditErrors errors;
-        const char *psz_file, *psz_err;
-        int i_errnum;
-        NSLinkEditError( &errors, &i_errnum, &psz_file, &psz_err );
-        msg_Warn( p_this, "cannot link module `%s' (%s)", psz_file, psz_err );
-        NSDestroyObjectFileImage( image );
-        return -1;
-    }
-
-    /* Destroy our image, we won't need it */
-    NSDestroyObjectFileImage( image );
-
-#elif defined(HAVE_DL_BEOS)
+#if defined(HAVE_DL_BEOS)
     handle = load_add_on( psz_file );
     if( handle < 0 )
     {
@@ -253,10 +221,7 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
  */
 void module_Unload( module_handle_t handle )
 {
-#if defined(HAVE_DL_DYLD)
-    NSUnLinkModule( handle, FALSE );
-
-#elif defined(HAVE_DL_BEOS)
+#if defined(HAVE_DL_BEOS)
     unload_add_on( handle );
 
 #elif defined(HAVE_DL_WINDOWS)
@@ -289,15 +254,7 @@ void module_Unload( module_handle_t handle )
  */
 static void *module_Lookup( module_handle_t handle, const char *psz_function )
 {
-#if defined(HAVE_DL_DYLD)
-    char psz_call[strlen( psz_function ) + 2];
-    psz_call[0] = '_';
-    memcpy( psz_call + 1, psz_function, sizeof( psz_call ) - 1 );
-
-    NSSymbol sym = NSLookupSymbolInModule( handle, psz_call );
-    return NSAddressOfSymbol( sym );
-
-#elif defined(HAVE_DL_BEOS)
+#if defined(HAVE_DL_BEOS)
     void * p_symbol;
     if( B_OK == get_image_symbol( handle, psz_function,
                                   B_SYMBOL_TYPE_TEXT, &p_symbol ) )




More information about the vlc-devel mailing list