Skip to content

Commit

Permalink
Fixed bug 3478 - Patch Haiku to use dlopen instead of load_add_on
Browse files Browse the repository at this point in the history
Kai Sterker

SDL2 on Haiku so far uses Haiku-specific APIs for loading dynamic objects as add-ons, instead of using dlopen to load them as libraries. This, for example, leads to SDL_mixer not being able to load its audio backends, when compiled with standard settings.

As discussed at https://www.freelists.org/post/haikuports/SDL2-mixer-ogg-music-not-playing-and-other-stuff,2 , the best way to deal with this would be using dlopen instead of load_add_on. The following patch implements this change by dropping the Haiku-specific bits and using dlopen instead.
  • Loading branch information
slouken committed Nov 1, 2016
1 parent 98d188f commit 9a8642b
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 102 deletions.
9 changes: 1 addition & 8 deletions configure
Expand Up @@ -23490,6 +23490,7 @@ fi
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN
CheckHaikuVideo
CheckHaikuGL
CheckPTHREAD
Expand Down Expand Up @@ -23518,14 +23519,6 @@ $as_echo "#define SDL_TIMER_HAIKU 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
have_timers=yes
fi
# Set up files for the shared object loading library
if test x$enable_loadso = xyes; then

$as_echo "#define SDL_LOADSO_HAIKU 1" >>confdefs.h

SOURCES="$SOURCES $srcdir/src/loadso/haiku/*.c"
have_loadso=yes
fi
# Set up files for the system power library
if test x$enable_power = xyes; then

Expand Down
7 changes: 1 addition & 6 deletions configure.in
Expand Up @@ -3229,6 +3229,7 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
CheckDLOPEN
CheckHaikuVideo
CheckHaikuGL
CheckPTHREAD
Expand All @@ -3251,12 +3252,6 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SOURCES="$SOURCES $srcdir/src/timer/haiku/*.c"
have_timers=yes
fi
# Set up files for the shared object loading library
if test x$enable_loadso = xyes; then
AC_DEFINE(SDL_LOADSO_HAIKU, 1, [ ])
SOURCES="$SOURCES $srcdir/src/loadso/haiku/*.c"
have_loadso=yes
fi
# Set up files for the system power library
if test x$enable_power = xyes; then
AC_DEFINE(SDL_POWER_HAIKU, 1, [ ])
Expand Down
1 change: 0 additions & 1 deletion include/SDL_config.h.cmake
Expand Up @@ -252,7 +252,6 @@
#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@

/* Enable various shared object loading systems */
#cmakedefine SDL_LOADSO_HAIKU @SDL_LOADSO_HAIKU@
#cmakedefine SDL_LOADSO_DLOPEN @SDL_LOADSO_DLOPEN@
#cmakedefine SDL_LOADSO_DUMMY @SDL_LOADSO_DUMMY@
#cmakedefine SDL_LOADSO_LDG @SDL_LOADSO_LDG@
Expand Down
1 change: 0 additions & 1 deletion include/SDL_config.h.in
Expand Up @@ -253,7 +253,6 @@
#undef SDL_HAPTIC_XINPUT

/* Enable various shared object loading systems */
#undef SDL_LOADSO_HAIKU
#undef SDL_LOADSO_DLOPEN
#undef SDL_LOADSO_DUMMY
#undef SDL_LOADSO_LDG
Expand Down
16 changes: 1 addition & 15 deletions src/dynapi/SDL_dynapi.c
Expand Up @@ -216,21 +216,7 @@ static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
return retval;
}

#elif defined(__HAIKU__)
#include <os/kernel/image.h>
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
image_id lib = load_add_on(fname);
void *retval = NULL;
if (lib >= 0) {
if (get_image_symbol(lib, sym, B_SYMBOL_TYPE_TEXT, &retval) != B_NO_ERROR) {
unload_add_on(lib);
retval = NULL;
}
}
return retval;
}
#elif defined(unix) || defined(__unix__) || defined(__APPLE__)
#elif defined(unix) || defined(__unix__) || defined(__APPLE__) || defined(__HAIKU__)
#include <dlfcn.h>
static SDL_INLINE void *get_sdlapi_entry(const char *fname, const char *sym)
{
Expand Down
71 changes: 0 additions & 71 deletions src/loadso/haiku/SDL_sysloadso.c

This file was deleted.

0 comments on commit 9a8642b

Please sign in to comment.