Use our libc_r instead of linuxthreads.

Reviewed by:	Maxim Sobolev <sobomax@altavista.net>
This commit is contained in:
Thomas Gellekum 2000-04-20 09:24:28 +00:00
parent 053726fa90
commit ab5c49f7ec
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=27779
12 changed files with 274 additions and 32 deletions

View file

@ -13,9 +13,7 @@ DISTNAME= SDL-${PORTVERSION}
MAINTAINER= sobomax@altavista.net
#This port doesn't love FreeBSD pthread :(
LIB_DEPENDS= lthread.2:${PORTSDIR}/devel/linuxthreads \
esd.2:${PORTSDIR}/audio/esound
LIB_DEPENDS= esd.2:${PORTSDIR}/audio/esound
BUILD_DEPENDS= nasm:${PORTSDIR}/devel/nasm
USE_GMAKE= yes
@ -25,12 +23,11 @@ GNU_CONFIGURE= yes
CONFIGURE_ENV= NASM="${LOCALBASE}/bin/nasm" \
LOCALBASE="${LOCALBASE}"
CFLAGS+= -I${LOCALBASE}/include/pthread/linuxthreads \
-D_THREAD_SAFE
CFLAGS+= -D_THREAD_SAFE
post-install:
@ ${MKDIR} ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
.if !defined(NOPORTDOCS)
@ ${MKDIR} ${PREFIX}/share/doc/SDL
.for file in BUGS COPYING CREDITS README WhatsNew docs.html

View file

@ -17,7 +17,7 @@
case "$target" in
*-*-freebsd*)
- pthread_lib="-lc_r"
+ pthread_lib="-L""$LOCALBASE""/lib -llthread -llgcc_r"
+ pthread_lib="-pthread"
;;
*-*-openbsd*)
pthread_lib="-lc_r"
@ -26,7 +26,7 @@
if test x$use_pthreads = xyes; then
CFLAGS="$CFLAGS -D_REENTRANT -DSDL_USE_PTHREADS"
- SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE -I""$LOCALBASE""/include/pthread/linuxthreads"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE"
SDL_LIBS="$SDL_LIBS $pthread_lib"
fi
fi

View file

@ -13,9 +13,7 @@ DISTNAME= SDL-${PORTVERSION}
MAINTAINER= sobomax@altavista.net
#This port doesn't love FreeBSD pthread :(
LIB_DEPENDS= lthread.2:${PORTSDIR}/devel/linuxthreads \
esd.2:${PORTSDIR}/audio/esound
LIB_DEPENDS= esd.2:${PORTSDIR}/audio/esound
BUILD_DEPENDS= nasm:${PORTSDIR}/devel/nasm
USE_GMAKE= yes
@ -25,12 +23,11 @@ GNU_CONFIGURE= yes
CONFIGURE_ENV= NASM="${LOCALBASE}/bin/nasm" \
LOCALBASE="${LOCALBASE}"
CFLAGS+= -I${LOCALBASE}/include/pthread/linuxthreads \
-D_THREAD_SAFE
CFLAGS+= -D_THREAD_SAFE
post-install:
@ ${MKDIR} ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
.if !defined(NOPORTDOCS)
@ ${MKDIR} ${PREFIX}/share/doc/SDL
.for file in BUGS COPYING CREDITS README WhatsNew docs.html

View file

@ -17,7 +17,7 @@
case "$target" in
*-*-freebsd*)
- pthread_lib="-lc_r"
+ pthread_lib="-L""$LOCALBASE""/lib -llthread -llgcc_r"
+ pthread_lib="-pthread"
;;
*-*-openbsd*)
pthread_lib="-lc_r"
@ -26,7 +26,7 @@
if test x$use_pthreads = xyes; then
CFLAGS="$CFLAGS -D_REENTRANT -DSDL_USE_PTHREADS"
- SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE -I""$LOCALBASE""/include/pthread/linuxthreads"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE"
SDL_LIBS="$SDL_LIBS $pthread_lib"
fi
fi

82
devel/sdl/files/patch-ae Normal file
View file

@ -0,0 +1,82 @@
--- src/thread/SDL_thread.c.orig Fri Mar 3 01:24:35 2000
+++ src/thread/SDL_thread.c Mon Apr 17 21:05:52 2000
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "SDL_error.h"
#include "SDL_mutex.h"
@@ -175,7 +176,7 @@
int (*func)(void *);
void *data;
SDL_Thread *info;
- SDL_mutex *wait;
+ int wait;
} thread_args;
void SDL_RunThread(void *data)
@@ -199,8 +200,8 @@
userdata = args->data;
statusloc = &args->info->status;
/* Wake up the parent thread */
- SDL_mutexV(args->wait);
+ args->wait = 1;
/* Run the function */
*statusloc = userfunc(userdata);
@@ -213,16 +214,16 @@
int ret;
/* Allocate memory for the thread info structure */
- thread = (SDL_Thread *)malloc(sizeof(*thread));
+ thread = (SDL_Thread *)malloc(sizeof(thread));
if ( thread == NULL ) {
SDL_OutOfMemory();
return(NULL);
}
- memset(thread, 0, (sizeof *thread));
+ memset(thread, 0, (sizeof thread));
thread->status = -1;
/* Set up the arguments for the thread */
- args = (thread_args *)malloc(sizeof(*args));
+ args = (thread_args *)malloc(sizeof(args));
if ( args == NULL ) {
SDL_OutOfMemory();
free(thread);
@@ -231,14 +232,7 @@
args->func = fn;
args->data = data;
args->info = thread;
- args->wait = SDL_CreateMutex();
- if ( args->wait == NULL ) {
- free(thread);
- free(args);
- SDL_OutOfMemory();
- return(NULL);
- }
- SDL_mutexP(args->wait); /* We will block later */
+ args->wait = 0;
/* Add the thread to the list of available threads */
SDL_AddThread(thread);
@@ -247,14 +241,14 @@
ret = SDL_SYS_CreateThread(thread, args);
if ( ret >= 0 ) {
/* Wait for the thread function to use arguments */
- SDL_mutexP(args->wait);
+ while (args->wait == 0)
+ usleep(20000);
} else {
/* Oops, failed. Gotta free everything */
SDL_DelThread(thread);
free(thread);
thread = NULL;
}
- SDL_DestroyMutex(args->wait);
free(args);
/* Everything is running now */

45
devel/sdl/files/patch-af Normal file
View file

@ -0,0 +1,45 @@
--- src/thread/linux/SDL_mutex.c.orig Tue Nov 23 20:01:41 1999
+++ src/thread/linux/SDL_mutex.c Mon Apr 17 21:08:57 2000
@@ -42,6 +42,7 @@
#ifdef SDL_USE_PTHREADS
+#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
@@ -60,14 +61,14 @@
SDL_mutex *mutex;
/* Allocate the structure */
- mutex = (SDL_mutex *)malloc(sizeof(*mutex));
+ mutex = (SDL_mutex *)malloc(sizeof(mutex));
if ( mutex == NULL ) {
SDL_OutOfMemory();
return(NULL);
}
if ( pthread_mutex_init(&mutex->id, NULL) != 0 ) {
- SDL_SetError("Couldn't create mutex");
+ SDL_SetError("Couldn't create mutex; reason: %d", errno);
free(mutex);
return(NULL);
}
@@ -82,7 +83,7 @@
return(-1);
}
if ( pthread_mutex_lock(&mutex->id) != 0 ) {
- SDL_SetError("Couldn't lock mutex");
+ SDL_SetError("Couldn't lock mutex; reason: %d", errno);
return(-1);
}
return(0);
@@ -96,7 +97,7 @@
return(-1);
}
if ( pthread_mutex_unlock(&mutex->id) != 0 ) {
- SDL_SetError("Couldn't unlock mutex");
+ SDL_SetError("Couldn't unlock mutex; reason: %d", errno);
return(-1);
}
return(0);

View file

@ -13,9 +13,7 @@ DISTNAME= SDL-${PORTVERSION}
MAINTAINER= sobomax@altavista.net
#This port doesn't love FreeBSD pthread :(
LIB_DEPENDS= lthread.2:${PORTSDIR}/devel/linuxthreads \
esd.2:${PORTSDIR}/audio/esound
LIB_DEPENDS= esd.2:${PORTSDIR}/audio/esound
BUILD_DEPENDS= nasm:${PORTSDIR}/devel/nasm
USE_GMAKE= yes
@ -25,12 +23,11 @@ GNU_CONFIGURE= yes
CONFIGURE_ENV= NASM="${LOCALBASE}/bin/nasm" \
LOCALBASE="${LOCALBASE}"
CFLAGS+= -I${LOCALBASE}/include/pthread/linuxthreads \
-D_THREAD_SAFE
CFLAGS+= -D_THREAD_SAFE
post-install:
@ ${MKDIR} ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
.if !defined(NOPORTDOCS)
@ ${MKDIR} ${PREFIX}/share/doc/SDL
.for file in BUGS COPYING CREDITS README WhatsNew docs.html

View file

@ -17,7 +17,7 @@
case "$target" in
*-*-freebsd*)
- pthread_lib="-lc_r"
+ pthread_lib="-L""$LOCALBASE""/lib -llthread -llgcc_r"
+ pthread_lib="-pthread"
;;
*-*-openbsd*)
pthread_lib="-lc_r"
@ -26,7 +26,7 @@
if test x$use_pthreads = xyes; then
CFLAGS="$CFLAGS -D_REENTRANT -DSDL_USE_PTHREADS"
- SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE -I""$LOCALBASE""/include/pthread/linuxthreads"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE"
SDL_LIBS="$SDL_LIBS $pthread_lib"
fi
fi

View file

@ -0,0 +1,82 @@
--- src/thread/SDL_thread.c.orig Fri Mar 3 01:24:35 2000
+++ src/thread/SDL_thread.c Mon Apr 17 21:05:52 2000
@@ -30,6 +30,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <unistd.h>
#include "SDL_error.h"
#include "SDL_mutex.h"
@@ -175,7 +176,7 @@
int (*func)(void *);
void *data;
SDL_Thread *info;
- SDL_mutex *wait;
+ int wait;
} thread_args;
void SDL_RunThread(void *data)
@@ -199,8 +200,8 @@
userdata = args->data;
statusloc = &args->info->status;
/* Wake up the parent thread */
- SDL_mutexV(args->wait);
+ args->wait = 1;
/* Run the function */
*statusloc = userfunc(userdata);
@@ -213,16 +214,16 @@
int ret;
/* Allocate memory for the thread info structure */
- thread = (SDL_Thread *)malloc(sizeof(*thread));
+ thread = (SDL_Thread *)malloc(sizeof(thread));
if ( thread == NULL ) {
SDL_OutOfMemory();
return(NULL);
}
- memset(thread, 0, (sizeof *thread));
+ memset(thread, 0, (sizeof thread));
thread->status = -1;
/* Set up the arguments for the thread */
- args = (thread_args *)malloc(sizeof(*args));
+ args = (thread_args *)malloc(sizeof(args));
if ( args == NULL ) {
SDL_OutOfMemory();
free(thread);
@@ -231,14 +232,7 @@
args->func = fn;
args->data = data;
args->info = thread;
- args->wait = SDL_CreateMutex();
- if ( args->wait == NULL ) {
- free(thread);
- free(args);
- SDL_OutOfMemory();
- return(NULL);
- }
- SDL_mutexP(args->wait); /* We will block later */
+ args->wait = 0;
/* Add the thread to the list of available threads */
SDL_AddThread(thread);
@@ -247,14 +241,14 @@
ret = SDL_SYS_CreateThread(thread, args);
if ( ret >= 0 ) {
/* Wait for the thread function to use arguments */
- SDL_mutexP(args->wait);
+ while (args->wait == 0)
+ usleep(20000);
} else {
/* Oops, failed. Gotta free everything */
SDL_DelThread(thread);
free(thread);
thread = NULL;
}
- SDL_DestroyMutex(args->wait);
free(args);
/* Everything is running now */

View file

@ -0,0 +1,45 @@
--- src/thread/linux/SDL_mutex.c.orig Tue Nov 23 20:01:41 1999
+++ src/thread/linux/SDL_mutex.c Mon Apr 17 21:08:57 2000
@@ -42,6 +42,7 @@
#ifdef SDL_USE_PTHREADS
+#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <pthread.h>
@@ -60,14 +61,14 @@
SDL_mutex *mutex;
/* Allocate the structure */
- mutex = (SDL_mutex *)malloc(sizeof(*mutex));
+ mutex = (SDL_mutex *)malloc(sizeof(mutex));
if ( mutex == NULL ) {
SDL_OutOfMemory();
return(NULL);
}
if ( pthread_mutex_init(&mutex->id, NULL) != 0 ) {
- SDL_SetError("Couldn't create mutex");
+ SDL_SetError("Couldn't create mutex; reason: %d", errno);
free(mutex);
return(NULL);
}
@@ -82,7 +83,7 @@
return(-1);
}
if ( pthread_mutex_lock(&mutex->id) != 0 ) {
- SDL_SetError("Couldn't lock mutex");
+ SDL_SetError("Couldn't lock mutex; reason: %d", errno);
return(-1);
}
return(0);
@@ -96,7 +97,7 @@
return(-1);
}
if ( pthread_mutex_unlock(&mutex->id) != 0 ) {
- SDL_SetError("Couldn't unlock mutex");
+ SDL_SetError("Couldn't unlock mutex; reason: %d", errno);
return(-1);
}
return(0);

View file

@ -13,9 +13,7 @@ DISTNAME= SDL-${PORTVERSION}
MAINTAINER= sobomax@altavista.net
#This port doesn't love FreeBSD pthread :(
LIB_DEPENDS= lthread.2:${PORTSDIR}/devel/linuxthreads \
esd.2:${PORTSDIR}/audio/esound
LIB_DEPENDS= esd.2:${PORTSDIR}/audio/esound
BUILD_DEPENDS= nasm:${PORTSDIR}/devel/nasm
USE_GMAKE= yes
@ -25,12 +23,11 @@ GNU_CONFIGURE= yes
CONFIGURE_ENV= NASM="${LOCALBASE}/bin/nasm" \
LOCALBASE="${LOCALBASE}"
CFLAGS+= -I${LOCALBASE}/include/pthread/linuxthreads \
-D_THREAD_SAFE
CFLAGS+= -D_THREAD_SAFE
post-install:
@ ${MKDIR} ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
@ ${INSTALL_DATA} ${WRKSRC}/test/* ${PREFIX}/share/examples/SDL
.if !defined(NOPORTDOCS)
@ ${MKDIR} ${PREFIX}/share/doc/SDL
.for file in BUGS COPYING CREDITS README WhatsNew docs.html

View file

@ -17,7 +17,7 @@
case "$target" in
*-*-freebsd*)
- pthread_lib="-lc_r"
+ pthread_lib="-L""$LOCALBASE""/lib -llthread -llgcc_r"
+ pthread_lib="-pthread"
;;
*-*-openbsd*)
pthread_lib="-lc_r"
@ -26,7 +26,7 @@
if test x$use_pthreads = xyes; then
CFLAGS="$CFLAGS -D_REENTRANT -DSDL_USE_PTHREADS"
- SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE -I""$LOCALBASE""/include/pthread/linuxthreads"
+ SDL_CFLAGS="$SDL_CFLAGS -D_REENTRANT -D_THREAD_SAFE"
SDL_LIBS="$SDL_LIBS $pthread_lib"
fi
fi