Skip to content

Commit

Permalink
Started BeOS removal: merged BeOS thread and pthread code.
Browse files Browse the repository at this point in the history
Haiku uses most of the standard pthread API, with a few #ifdefs where we
still need to fallback onto the old BeOS APIs.

BeOS, however, does not support pthreads (or maybe doesn't support it well),
so I'm unplugging support for the platform with this changeset. Be Inc went
out of business in 2001.
  • Loading branch information
icculus committed Nov 14, 2013
1 parent b36d98b commit 7550ddc
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 408 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Expand Up @@ -1012,6 +1012,8 @@ elseif(BEOS)
set(HAVE_VIDEO_OPENGL TRUE)
endif(VIDEO_OPENGL)
endif(SDL_VIDEO)

CheckPTHREAD()
endif()

# Dummies
Expand Down
3 changes: 3 additions & 0 deletions cmake/sdlchecks.cmake
Expand Up @@ -638,6 +638,9 @@ macro(CheckPTHREAD)
elseif(HPUX)
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-L/usr/lib -pthread")
elseif(BEOS)
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "")
else()
set(PTHREAD_CFLAGS "-D_REENTRANT")
set(PTHREAD_LDFLAGS "-lpthread")
Expand Down
19 changes: 8 additions & 11 deletions configure
Expand Up @@ -21006,6 +21006,10 @@ fi
pthread_cflags="-D_REENTRANT"
pthread_lib="-L/usr/lib -lpthread"
;;
*-*-haiku*)
pthread_cflags="-D_REENTRANT"
pthread_lib=""
;;
*)
pthread_cflags="-D_REENTRANT"
pthread_lib="-lpthread"
Expand Down Expand Up @@ -22394,14 +22398,17 @@ fi
SDL_LIBS="-lcygwin $SDL_LIBS"
fi
;;
*-*-beos* | *-*-haiku*)


*-*-haiku*)
ARCH=beos
ac_default_prefix=/boot/common
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
CheckBWINDOW
CheckBeGL
CheckPTHREAD
# Set up files for the audio library
if test x$enable_audio = xyes; then

Expand All @@ -22418,16 +22425,6 @@ $as_echo "#define SDL_JOYSTICK_BEOS 1" >>confdefs.h
SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
have_joystick=yes
fi
# Set up files for the thread library
if test x$enable_threads = xyes; then

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

SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
have_threads=yes
fi
# Set up files for the timer library
if test x$enable_timers = xyes; then

Expand Down
19 changes: 10 additions & 9 deletions configure.in
Expand Up @@ -1940,6 +1940,10 @@ AC_HELP_STRING([--enable-pthread-sem], [use pthread semaphores [[default=yes]]])
pthread_cflags="-D_REENTRANT"
pthread_lib="-L/usr/lib -lpthread"
;;
*-*-haiku*)
pthread_cflags="-D_REENTRANT"
pthread_lib=""
;;
*)
pthread_cflags="-D_REENTRANT"
pthread_lib="-lpthread"
Expand Down Expand Up @@ -2613,14 +2617,19 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SDL_LIBS="-lcygwin $SDL_LIBS"
fi
;;
*-*-beos* | *-*-haiku*)

dnl BeOS support removed after SDL 2.0.1. Haiku still works. --ryan.
dnl *-*-beos*)

*-*-haiku*)
ARCH=beos
ac_default_prefix=/boot/common
CheckDummyVideo
CheckDiskAudio
CheckDummyAudio
CheckBWINDOW
CheckBeGL
CheckPTHREAD
# Set up files for the audio library
if test x$enable_audio = xyes; then
AC_DEFINE(SDL_AUDIO_DRIVER_BEOSAUDIO, 1, [ ])
Expand All @@ -2633,14 +2642,6 @@ AC_HELP_STRING([--enable-render-d3d], [enable the Direct3D render driver [[defau
SOURCES="$SOURCES $srcdir/src/joystick/beos/*.cc"
have_joystick=yes
fi
# Set up files for the thread library
if test x$enable_threads = xyes; then
AC_DEFINE(SDL_THREAD_BEOS, 1, [ ])
SOURCES="$SOURCES $srcdir/src/thread/beos/*.c"
SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_sysmutex.c"
SOURCES="$SOURCES $srcdir/src/thread/generic/SDL_syscond.c"
have_threads=yes
fi
# Set up files for the timer library
if test x$enable_timers = xyes; then
AC_DEFINE(SDL_TIMER_BEOS, 1, [ ])
Expand Down
1 change: 0 additions & 1 deletion include/SDL_config.h.cmake
Expand Up @@ -237,7 +237,6 @@
#cmakedefine SDL_LOADSO_WINDOWS @SDL_LOADSO_WINDOWS@

/* Enable various threading systems */
#cmakedefine SDL_THREAD_BEOS @SDL_THREAD_BEOS@
#cmakedefine SDL_THREAD_PTHREAD @SDL_THREAD_PTHREAD@
#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX@
#cmakedefine SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP @SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP@
Expand Down
1 change: 0 additions & 1 deletion include/SDL_config.h.in
Expand Up @@ -240,7 +240,6 @@
#undef SDL_LOADSO_WINDOWS

/* Enable various threading systems */
#undef SDL_THREAD_BEOS
#undef SDL_THREAD_PTHREAD
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX
#undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP
Expand Down
30 changes: 28 additions & 2 deletions src/audio/baudio/SDL_beaudio.cc
Expand Up @@ -25,6 +25,7 @@
/* Allow access to the audio stream on BeOS */

#include <SoundPlayer.h>
#include <signal.h>

#include "../../main/beos/SDL_BeApp.h"

Expand Down Expand Up @@ -85,6 +86,31 @@ BEOSAUDIO_CloseDevice(_THIS)
}
}


static const int sig_list[] = {
SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGWINCH, 0
};

static inline void
MaskSignals(sigset_t * omask)
{
sigset_t mask;
int i;

sigemptyset(&mask);
for (i = 0; sig_list[i]; ++i) {
sigaddset(&mask, sig_list[i]);
}
sigprocmask(SIG_BLOCK, &mask, omask);
}

static inline void
UnmaskSignals(sigset_t * omask)
{
sigprocmask(SIG_SETMASK, omask, NULL);
}


static int
BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
{
Expand Down Expand Up @@ -162,10 +188,10 @@ BEOSAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)

/* Subscribe to the audio stream (creates a new thread) */
sigset_t omask;
SDL_MaskSignals(&omask);
MaskSignals(&omask);
_this->hidden->audio_obj = new BSoundPlayer(&format, "SDL Audio",
FillSound, NULL, _this);
SDL_UnmaskSignals(&omask);
UnmaskSignals(&omask);

if (_this->hidden->audio_obj->Start() == B_NO_ERROR) {
_this->hidden->audio_obj->SetHasData(true);
Expand Down
4 changes: 0 additions & 4 deletions src/thread/SDL_thread_c.h
Expand Up @@ -28,10 +28,6 @@
/* Need the definitions of SYS_ThreadHandle */
#if SDL_THREADS_DISABLED
#include "generic/SDL_systhread_c.h"
#elif SDL_THREAD_BEOS
#include "beos/SDL_systhread_c.h"
#elif SDL_THREAD_EPOC
#include "epoc/SDL_systhread_c.h"
#elif SDL_THREAD_PTHREAD
#include "pthread/SDL_systhread_c.h"
#elif SDL_THREAD_WINDOWS
Expand Down
151 changes: 0 additions & 151 deletions src/thread/beos/SDL_syssem.c

This file was deleted.

0 comments on commit 7550ddc

Please sign in to comment.