Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added a new header file: SDL_loadso.h
It contains the following functions:
	SDL_LoadObject(), SDL_LoadFunction(), SDL_UnloadObject()
The UNIX esd and arts audio code use these to dynamically load
their respective audio libraries.
  • Loading branch information
slouken committed Mar 6, 2002
1 parent c7813bb commit 09a5305
Show file tree
Hide file tree
Showing 13 changed files with 516 additions and 24 deletions.
6 changes: 6 additions & 0 deletions WhatsNew
Expand Up @@ -4,6 +4,12 @@ This is a list of API changes in SDL's version history.
Version 1.0:

1.2.4:
Added a new header file: SDL_loadso.h
It contains the following functions:
SDL_LoadObject(), SDL_LoadFunction(), SDL_UnloadObject()
The UNIX esd and arts audio code use these to dynamically load
their respective audio libraries.

Added SDL_LockRect() and SDL_UnlockRect() to lock a portion of a
surface. This may be more efficient than a full lock if you are
using a hardware surface and plan to make a few changes to small
Expand Down
74 changes: 68 additions & 6 deletions configure.in
Expand Up @@ -324,12 +324,26 @@ CheckESD()
[ --enable-esd support the Enlightened Sound Daemon [default=yes]],
, enable_esd=yes)
if test x$enable_audio = xyes -a x$enable_esd = xyes; then
AM_PATH_ESD(0.2.8, [
CFLAGS="$CFLAGS -DESD_SUPPORT $ESD_CFLAGS"
SYSTEM_LIBS="$SYSTEM_LIBS $ESD_LIBS"
use_esd=no
AM_PATH_ESD(0.2.8, use_esd=yes)
if test x$use_esd = xyes; then
AC_ARG_ENABLE(esd-shared,
[ --enable-esd-shared dynamically load ESD support [default=yes]],
, enable_esd_shared=yes)
esd_lib_spec=`echo $ESD_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libesd.so.*/'`
esd_lib=`ls $esd_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'`
echo "-- $esd_lib_spec -> $esd_lib"
if test x$enable_dlopen = xyes && \
test x$enable_esd_shared = xyes && test x$esd_lib != x; then
CFLAGS="$CFLAGS -DESD_SUPPORT -DESD_DYNAMIC=\$(esd_lib) $ESD_CFLAGS"
AC_SUBST(esd_lib)
else
CFLAGS="$CFLAGS -DESD_SUPPORT $ESD_CFLAGS"
SYSTEM_LIBS="$SYSTEM_LIBS $ESD_LIBS"
fi
AUDIO_SUBDIRS="$AUDIO_SUBDIRS esd"
AUDIO_DRIVERS="$AUDIO_DRIVERS esd/libaudio_esd.la"
])
fi
fi
}

Expand Down Expand Up @@ -359,8 +373,20 @@ CheckARTSC()
CFLAGS="$save_CFLAGS"
AC_MSG_RESULT($audio_arts)
if test x$audio_arts = xyes; then
CFLAGS="$CFLAGS -DARTSC_SUPPORT $ARTSC_CFLAGS"
SYSTEM_LIBS="$SYSTEM_LIBS $ARTSC_LIBS"
AC_ARG_ENABLE(arts-shared,
[ --enable-arts-shared dynamically load ESD support [default=yes]],
, enable_arts_shared=yes)
arts_lib_spec=`echo $ARTSC_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libarts.so.*/'`
arts_lib=`ls $arts_lib_spec | head -1 | sed 's/.*\/\(.*\)/\1/'`
echo "-- $arts_lib_spec -> $arts_lib"
if test x$enable_dlopen = xyes && \
test x$enable_arts_shared = xyes && test x$arts_lib != x; then
CFLAGS="$CFLAGS -DARTSC_SUPPORT -DARTSC_DYNAMIC=\$(arts_lib) $ARTSC_CFLAGS"
AC_SUBST(arts_lib)
else
CFLAGS="$CFLAGS -DARTSC_SUPPORT $ARTSC_CFLAGS"
SYSTEM_LIBS="$SYSTEM_LIBS $ARTSC_LIBS"
fi
AUDIO_SUBDIRS="$AUDIO_SUBDIRS arts"
AUDIO_DRIVERS="$AUDIO_DRIVERS arts/libaudio_arts.la"
fi
Expand Down Expand Up @@ -1353,11 +1379,36 @@ CheckQUARTZ()
VIDEO_DRIVERS="$VIDEO_DRIVERS quartz/libvideo_quartz.la"
}

dnl Check for the dlfcn.h interface for dynamically loading objects
CheckDLOPEN()
{
AC_ARG_ENABLE(dlopen,
[ --enable-dlopen use dlopen for shared object loading [default=yes]],
, enable_dlopen=yes)
if test x$enable_dlopen = xyes; then
AC_MSG_CHECKING(for dlopen)
use_dlopen=no
AC_TRY_COMPILE([
#include <dlfcn.h>
],[
],[
use_dlopen=yes
])
AC_MSG_RESULT($use_dlopen)

if test x$use_dlopen = xyes; then
CFLAGS="$CFLAGS -DUSE_DLOPEN"
SYSTEM_LIBS="$SYSTEM_LIBS -ldl"
fi
fi
}

case "$target" in
*-*-linux*)
ARCH=linux
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckNASM
CheckOSS
CheckALSA
Expand Down Expand Up @@ -1429,6 +1480,7 @@ case "$target" in
ARCH=bsdi
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckNASM
CheckOSS
CheckARTSC
Expand Down Expand Up @@ -1480,6 +1532,7 @@ case "$target" in
ARCH=freebsd
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckVGL
CheckNASM
CheckOSS
Expand Down Expand Up @@ -1535,6 +1588,7 @@ case "$target" in
ARCH=netbsd
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckNASM
CheckOSS
CheckARTSC
Expand Down Expand Up @@ -1588,6 +1642,7 @@ case "$target" in
ARCH=openbsd
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckOPENBSDAUDIO
CheckNASM
CheckOSS
Expand Down Expand Up @@ -1647,6 +1702,7 @@ case "$target" in
ARCH=sysv5
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckNASM
CheckOSS
CheckARTSC
Expand Down Expand Up @@ -1696,6 +1752,7 @@ case "$target" in
CFLAGS="$CFLAGS -D__ELF__" # Fix for nasm on Solaris x86
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckNASM
CheckOSS
CheckARTSC
Expand Down Expand Up @@ -1744,6 +1801,7 @@ case "$target" in
ARCH=irix
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckDMEDIA
CheckESD
CheckNAS
Expand Down Expand Up @@ -1806,6 +1864,7 @@ case "$target" in
ARCH=hpux
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckOSS
CheckNAS
CheckX11
Expand Down Expand Up @@ -1853,6 +1912,7 @@ case "$target" in
ARCH=aix
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckOSS
CheckNAS
CheckX11
Expand Down Expand Up @@ -1898,6 +1958,7 @@ case "$target" in
ARCH=osf
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckNAS
CheckX11
CheckGGI
Expand Down Expand Up @@ -1944,6 +2005,7 @@ case "$target" in
ARCH=qnx
CheckDummyVideo
CheckDiskAudio
CheckDLOPEN
CheckNAS
CheckPHOTON
CheckX11
Expand Down
1 change: 1 addition & 0 deletions docs.html
Expand Up @@ -16,6 +16,7 @@ <H2>
Major changes since SDL 1.0.0:
</H2>
<UL>
<LI> 1.2.4: Added shared object loading functions in SDL_loadso.h
<LI> 1.2.4: Added SDL_LockRect() and SDL_UnlockRect()
<LI> 1.2.4: Incorporated XFree86 extension libraries into the source
<LI> 1.2.4: Added initial support for Atari (thanks Patrice!)
Expand Down
1 change: 1 addition & 0 deletions include/Makefile.am
Expand Up @@ -18,6 +18,7 @@ libSDLinclude_HEADERS = \
SDL_joystick.h \
SDL_keyboard.h \
SDL_keysym.h \
SDL_loadso.h \
SDL_main.h \
SDL_mouse.h \
SDL_mutex.h \
Expand Down
1 change: 1 addition & 0 deletions include/SDL.h
Expand Up @@ -34,6 +34,7 @@ static char rcsid =
#include "SDL_types.h"
#include "SDL_getenv.h"
#include "SDL_error.h"
#include "SDL_loadso.h"
#include "SDL_rwops.h"
#include "SDL_timer.h"
#include "SDL_audio.h"
Expand Down
61 changes: 61 additions & 0 deletions include/SDL_loadso.h
@@ -0,0 +1,61 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 Sam Lantinga
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 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
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Sam Lantinga
slouken@libsdl.org
*/

#ifdef SAVE_RCSID
static char rcsid =
"@(#) $Id$";
#endif

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/* System dependent library loading routines */

#ifndef _SDL_loadso_h
#define _SDL_loadso_h

#include "begin_code.h"
/* Set up for C function definitions, even when using C++ */
#ifdef __cplusplus
extern "C" {
#endif

/* This function dynamically loads a shared object and returns a pointer
* to the object handle (or NULL if there was an error).
* The 'sofile' parameter is a system dependent name of the object file.
*/
extern DECLSPEC void *SDL_LoadObject(const char *sofile);

/* Given an object handle, this function looks up the address of the
* named function in the shared object and returns it. This address
* is no longer valid after calling SDL_UnloadObject().
*/
extern DECLSPEC void *SDL_LoadFunction(void *handle, const char *name);

/* Unload a shared object from memory */
extern DECLSPEC void SDL_UnloadObject(void *handle);

/* Ends C function definitions when using C++ */
#ifdef __cplusplus
}
#endif
#include "close_code.h"

#endif /* _SDL_loadso_h */
2 changes: 0 additions & 2 deletions include/SDL_name.h
Expand Up @@ -6,8 +6,6 @@
#define NeedFunctionPrototypes 1
#endif

#ifndef SDL_NAME
#define SDL_NAME(X) SDL_##X
#endif

#endif /* _SDLname_h_ */
3 changes: 2 additions & 1 deletion src/Makefile.am
Expand Up @@ -37,5 +37,6 @@ GENERAL_SRCS = \
SDL_error_c.h \
SDL_fatal.c \
SDL_fatal.h \
SDL_getenv.c
SDL_getenv.c \
SDL_loadso.c

0 comments on commit 09a5305

Please sign in to comment.