Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc
Commits
103b4129
Commit
103b4129
authored
May 12, 2011
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split Win32 and POSIX dynamic linker backends
parent
bdc46e27
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
216 additions
and
18 deletions
+216
-18
configure.ac
configure.ac
+0
-15
src/Makefile.am
src/Makefile.am
+5
-1
src/modules/modules.h
src/modules/modules.h
+0
-2
src/posix/plugin.c
src/posix/plugin.c
+106
-0
src/win32/plugin.c
src/win32/plugin.c
+105
-0
No files found.
configure.ac
View file @
103b4129
...
...
@@ -691,21 +691,6 @@ AC_CHECK_LIB(m,lrintf, [
dnl Check for dynamic plugins
ac_cv_have_plugins=no
# HP-UX style
if test "${ac_cv_have_plugins}" = "no"; then
AC_CHECK_HEADERS(dl.h)
ac_cv_my_have_shl_load=no
AC_CHECK_FUNC(shl_load,
[ac_cv_my_have_shl_load=yes,
AC_CHECK_LIB(dld, shl_load,
[ac_cv_my_have_shl_load=yes
VLC_ADD_LIBS([libvlccore],[-ldld])])])
if test "${ac_cv_my_have_shl_load}" = "yes"; then
AC_DEFINE(HAVE_DL_SHL_LOAD, 1, [Define if you have the shl_load API])
ac_cv_have_plugins=yes
fi
fi
# Win32 style
if test "${ac_cv_have_plugins}" = "no"; then
if test "${SYS}" = "mingw32" ; then
...
...
src/Makefile.am
View file @
103b4129
...
...
@@ -278,6 +278,7 @@ SOURCES_libvlc_darwin = \
posix/darwin_dirs.c
\
misc/atomic.c
\
posix/filesystem.c
\
posix/plugin.c
\
posix/thread.c
\
posix/darwin_specific.c
\
$(NULL)
...
...
@@ -286,6 +287,7 @@ SOURCES_libvlc_linux = \
posix/dirs.c
\
misc/atomic.c
\
posix/filesystem.c
\
posix/plugin.c
\
posix/thread.c
\
posix/linux_specific.c
\
$(NULL)
...
...
@@ -294,6 +296,7 @@ SOURCES_libvlc_win32 = \
win32/dirs.c
\
win32/atomic.c
\
win32/filesystem.c
\
win32/plugin.c
\
win32/thread.c
\
win32/specific.c
\
win32/winsock.c
\
...
...
@@ -303,6 +306,7 @@ SOURCES_libvlc_symbian = \
symbian/path.cpp
\
symbian/dirs.c
\
misc/atomic.c
\
win32/plugin.c
\
$(NULL)
SOURCES_libvlc_other
=
\
...
...
@@ -310,6 +314,7 @@ SOURCES_libvlc_other = \
misc/atomic.c
\
posix/filesystem.c
\
posix/thread.c
\
posix/thread.c
\
posix/specific.c
\
$(NULL)
...
...
@@ -436,7 +441,6 @@ SOURCES_libvlc_common = \
modules/modules.c
\
modules/cache.c
\
modules/entry.c
\
modules/os.c
\
modules/textdomain.c
\
misc/threads.c
\
misc/stats.c
\
...
...
src/modules/modules.h
View file @
103b4129
...
...
@@ -74,8 +74,6 @@ typedef int module_handle_t;
typedef
void
*
module_handle_t
;
#elif defined(HAVE_DL_DLOPEN)
typedef
void
*
module_handle_t
;
#elif defined(HAVE_DL_SHL_LOAD)
typedef
shl_t
module_handle_t
;
#endif
/**
...
...
src/
modules/os
.c
→
src/
posix/plugin
.c
View file @
103b4129
...
...
@@ -29,47 +29,16 @@
#endif
#include <vlc_common.h>
#include <vlc_plugin.h>
/* MODULE_SUFFIX */
#include <vlc_charset.h>
#include "libvlc.h"
#include "modules.h"
#include <stdlib.h>
/* free(), strtol() */
#include <stdio.h>
/* sprintf() */
#include <string.h>
/* strdup() */
#include "modules/modules.h"
#include <sys/types.h>
#include <dlfcn.h>
#if !defined(HAVE_DYNAMIC_PLUGINS)
/* no support for plugins */
#elif defined(__APPLE__)
# include <dlfcn.h>
#elif defined(HAVE_DL_WINDOWS)
# include <windows.h>
#elif defined(HAVE_DL_DLOPEN)
# if defined(HAVE_DLFCN_H)
/* Linux, BSD, Hurd */
# include <dlfcn.h>
# endif
# if defined(HAVE_SYS_DL_H)
# include <sys/dl.h>
# endif
#elif defined(HAVE_DL_SHL_LOAD)
# if defined(HAVE_DL_H)
# include <dl.h>
# endif
#endif
#ifdef HAVE_VALGRIND_VALGRIND_H
# include <valgrind/valgrind.h>
#endif
/*****************************************************************************
* Local prototypes
*****************************************************************************/
#ifdef HAVE_DYNAMIC_PLUGINS
#if defined(HAVE_DL_WINDOWS)
static
char
*
GetWindowsError
(
void
);
#endif
/**
* Load a dynamically linked library using a system dependent method.
*
...
...
@@ -81,44 +50,16 @@ static char * GetWindowsError ( void );
int
module_Load
(
vlc_object_t
*
p_this
,
const
char
*
psz_file
,
module_handle_t
*
p_handle
)
{
module_handle_t
handle
;
#if defined(HAVE_DL_WINDOWS)
wchar_t
psz_wfile
[
MAX_PATH
];
MultiByteToWideChar
(
CP_UTF8
,
0
,
psz_file
,
-
1
,
psz_wfile
,
MAX_PATH
);
#ifndef UNDER_CE
/* FIXME: this is not thread-safe -- Courmisch */
UINT
mode
=
SetErrorMode
(
SEM_FAILCRITICALERRORS
);
SetErrorMode
(
mode
|
SEM_FAILCRITICALERRORS
);
#endif
handle
=
LoadLibraryW
(
psz_wfile
);
#ifndef UNDER_CE
SetErrorMode
(
mode
);
#endif
if
(
handle
==
NULL
)
{
char
*
psz_err
=
GetWindowsError
();
msg_Warn
(
p_this
,
"cannot load module `%s' (%s)"
,
psz_file
,
psz_err
);
free
(
psz_err
);
return
-
1
;
}
#elif defined(HAVE_DL_DLOPEN)
# if defined (RTLD_NOW)
#if defined (RTLD_NOW)
const
int
flags
=
RTLD_NOW
;
#
elif defined (DL_LAZY)
#elif defined (DL_LAZY)
const
int
flags
=
DL_LAZY
;
#
else
#else
const
int
flags
=
0
;
#
endif
#endif
char
*
path
=
ToLocale
(
psz_file
);
handle
=
dlopen
(
path
,
flags
);
module_handle_t
handle
=
dlopen
(
path
,
flags
);
if
(
handle
==
NULL
)
{
msg_Warn
(
p_this
,
"cannot load module `%s' (%s)"
,
path
,
dlerror
()
);
...
...
@@ -126,20 +67,6 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
return
-
1
;
}
LocaleFree
(
path
);
#elif defined(HAVE_DL_SHL_LOAD)
handle
=
shl_load
(
psz_file
,
BIND_IMMEDIATE
|
BIND_NONFATAL
,
NULL
);
if
(
handle
==
NULL
)
{
msg_Warn
(
p_this
,
"cannot load module `%s' (%m)"
,
psz_file
);
return
-
1
;
}
#else
# error "Something is wrong in modules.c"
#endif
*
p_handle
=
handle
;
return
0
;
}
...
...
@@ -155,21 +82,11 @@ int module_Load( vlc_object_t *p_this, const char *psz_file,
*/
void
module_Unload
(
module_handle_t
handle
)
{
#if defined(HAVE_DL_WINDOWS)
FreeLibrary
(
handle
);
#elif defined(HAVE_DL_DLOPEN)
# ifdef HAVE_VALGRIND_VALGRIND_H
#ifdef HAVE_VALGRIND_VALGRIND_H
if
(
RUNNING_ON_VALGRIND
>
0
)
return
;
/* do not dlclose() so that we get proper stack traces */
# endif
dlclose
(
handle
);
#elif defined(HAVE_DL_SHL_LOAD)
shl_unload
(
handle
);
#endif
return
;
dlclose
(
handle
)
;
}
/**
...
...
@@ -185,47 +102,5 @@ void module_Unload( module_handle_t handle )
*/
void
*
module_Lookup
(
module_handle_t
handle
,
const
char
*
psz_function
)
{
#if defined(HAVE_DL_WINDOWS) && defined(UNDER_CE)
wchar_t
wide
[
strlen
(
psz_function
)
+
1
];
size_t
i
=
0
;
do
wide
[
i
]
=
psz_function
[
i
];
/* UTF-16 <- ASCII */
while
(
psz_function
[
i
++
]
);
return
(
void
*
)
GetProcAddress
(
handle
,
wide
);
#elif defined(HAVE_DL_WINDOWS) && defined(WIN32)
return
(
void
*
)
GetProcAddress
(
handle
,
(
char
*
)
psz_function
);
#elif defined(HAVE_DL_DLOPEN)
return
dlsym
(
handle
,
psz_function
);
#elif defined(HAVE_DL_SHL_LOAD)
void
*
p_sym
;
shl_findsym
(
&
handle
,
psz_function
,
TYPE_UNDEFINED
,
&
p_sym
);
return
p_sym
;
#endif
}
#if defined(HAVE_DL_WINDOWS)
# include <wchar.h>
static
char
*
GetWindowsError
(
void
)
{
wchar_t
wmsg
[
256
];
int
i
=
0
,
i_error
=
GetLastError
();
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
i_error
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
wmsg
,
256
,
NULL
);
/* Go to the end of the string */
while
(
!
wmemchr
(
L"
\r\n\0
"
,
wmsg
[
i
],
3
)
)
i
++
;
snwprintf
(
wmsg
+
i
,
256
-
i
,
L" (error %i)"
,
i_error
);
return
FromWide
(
wmsg
);
}
#endif
/* HAVE_DL_WINDOWS */
#endif
/* HAVE_DYNAMIC_PLUGINS */
src/win32/plugin.c
0 → 100644
View file @
103b4129
/*****************************************************************************
* plugin.c : Low-level dynamic library handling
*****************************************************************************
* Copyright (C) 2001-2011 the VideoLAN team
*
* Authors: Sam Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
* Hans-Peter Jansen <hpj@urpla.net>
* Gildas Bazin <gbazin@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_charset.h>
#include "modules/modules.h"
#include <windows.h>
#include <wchar.h>
static
char
*
GetWindowsError
(
void
)
{
wchar_t
wmsg
[
256
];
int
i
=
0
,
i_error
=
GetLastError
();
FormatMessageW
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
i_error
,
MAKELANGID
(
LANG_NEUTRAL
,
SUBLANG_DEFAULT
),
wmsg
,
256
,
NULL
);
/* Go to the end of the string */
while
(
!
wmemchr
(
L"
\r\n\0
"
,
wmsg
[
i
],
3
)
)
i
++
;
snwprintf
(
wmsg
+
i
,
256
-
i
,
L" (error %i)"
,
i_error
);
return
FromWide
(
wmsg
);
}
int
module_Load
(
vlc_object_t
*
p_this
,
const
char
*
psz_file
,
module_handle_t
*
p_handle
)
{
module_handle_t
handle
;
wchar_t
psz_wfile
[
MAX_PATH
];
MultiByteToWideChar
(
CP_UTF8
,
0
,
psz_file
,
-
1
,
psz_wfile
,
MAX_PATH
);
#ifndef UNDER_CE
/* FIXME: this is not thread-safe -- Courmisch */
UINT
mode
=
SetErrorMode
(
SEM_FAILCRITICALERRORS
);
SetErrorMode
(
mode
|
SEM_FAILCRITICALERRORS
);
#endif
handle
=
LoadLibraryW
(
psz_wfile
);
#ifndef UNDER_CE
SetErrorMode
(
mode
);
#endif
if
(
handle
==
NULL
)
{
char
*
psz_err
=
GetWindowsError
();
msg_Warn
(
p_this
,
"cannot load module `%s' (%s)"
,
psz_file
,
psz_err
);
free
(
psz_err
);
return
-
1
;
}
*
p_handle
=
handle
;
return
0
;
}
void
module_Unload
(
module_handle_t
handle
)
{
FreeLibrary
(
handle
);
}
void
*
module_Lookup
(
module_handle_t
handle
,
const
char
*
psz_function
)
{
#ifdef UNDER_CE
wchar_t
wide
[
strlen
(
psz_function
)
+
1
];
size_t
i
=
0
;
do
wide
[
i
]
=
psz_function
[
i
];
/* UTF-16 <- ASCII */
while
(
psz_function
[
i
++
]
);
return
(
void
*
)
GetProcAddress
(
handle
,
wide
);
#else
return
(
void
*
)
GetProcAddress
(
handle
,
(
char
*
)
psz_function
);
#endif
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment