Bite the bullet. Have to use different
binaries on 2.4 and 2.6.
This commit is contained in:
parent
b4c842f139
commit
282c88f9de
4 changed files with 21 additions and 92 deletions
8
bin/9c
8
bin/9c
|
|
@ -26,7 +26,13 @@ case "$tag" in
|
||||||
*Darwin*) usegcc
|
*Darwin*) usegcc
|
||||||
cflags="$ngflags -g3 -no-cpp-precomp" ;;
|
cflags="$ngflags -g3 -no-cpp-precomp" ;;
|
||||||
*HP-UX*) cc=cc; cflags="-g -O -c -Ae" ;;
|
*HP-UX*) cc=cc; cflags="-g -O -c -Ae" ;;
|
||||||
*Linux*) usegcc ;;
|
*Linux*) usegcc
|
||||||
|
case "`uname -r`" in
|
||||||
|
2.6*)
|
||||||
|
cflags="$cflags -D__Linux26__"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
*OSF1*) cc=cc; cflags="-g -O -c" ;;
|
*OSF1*) cc=cc; cflags="-g -O -c" ;;
|
||||||
*SunOS*-cc) cc=cc;
|
*SunOS*-cc) cc=cc;
|
||||||
cflags="-g -O -c -xCC -D__sun__"
|
cflags="-g -O -c -xCC -D__sun__"
|
||||||
|
|
|
||||||
7
bin/9l
7
bin/9l
|
|
@ -10,7 +10,12 @@ case "$tag" in
|
||||||
extralibs="$extralibs -lutil"
|
extralibs="$extralibs -lutil"
|
||||||
;;
|
;;
|
||||||
*Linux*) ld=gcc
|
*Linux*) ld=gcc
|
||||||
extralibs="$extralibs -lutil -lpthread"
|
extralibs="$extralibs -lutil"
|
||||||
|
case "`uname -r`" in
|
||||||
|
2.6.*)
|
||||||
|
extralibs="$extralibs -lpthread"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
;;
|
;;
|
||||||
*Darwin*) ld=gcc ;;
|
*Darwin*) ld=gcc ;;
|
||||||
*SunOS*) ld="${CC9:-cc} -g"
|
*SunOS*) ld="${CC9:-cc} -g"
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,5 @@
|
||||||
#define ffork ffork_clone
|
#ifdef __Linux26__
|
||||||
#define getfforkid getfforkid_clone
|
|
||||||
#include "ffork-Linux-clone.c"
|
|
||||||
#undef ffork
|
|
||||||
#undef getfforkid
|
|
||||||
|
|
||||||
#define ffork ffork_pthread
|
|
||||||
#define getfforkid getfforkid_pthread
|
|
||||||
#include "ffork-pthread.c"
|
#include "ffork-pthread.c"
|
||||||
#undef ffork
|
#else
|
||||||
#undef getfforkid
|
#include "ffork-Linux-clone.c"
|
||||||
|
#endif
|
||||||
extern int _islinuxnptl(void);
|
|
||||||
|
|
||||||
int
|
|
||||||
ffork(int flags, void (*fn)(void*), void *arg)
|
|
||||||
{
|
|
||||||
if(_islinuxnptl())
|
|
||||||
return ffork_pthread(flags, fn, arg);
|
|
||||||
else
|
|
||||||
return ffork_clone(flags, fn, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
getfforkid(void)
|
|
||||||
{
|
|
||||||
if(_islinuxnptl())
|
|
||||||
return getfforkid_pthread();
|
|
||||||
else
|
|
||||||
return getfforkid_clone();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,60 +1,5 @@
|
||||||
/*
|
#ifdef __Linux26__
|
||||||
* On Linux 2.6 and later, we can use pthreads (in fact, we must),
|
|
||||||
* but on earlier Linux, pthreads are incompatible with using our
|
|
||||||
* own coroutines in libthread. In order to make binaries that work
|
|
||||||
* on either system, we detect the pthread library in use and call
|
|
||||||
* the appropriate functions.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <u.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <pthread.h>
|
|
||||||
#include <libc.h>
|
|
||||||
|
|
||||||
#define _procsleep _procsleep_signal
|
|
||||||
#define _procwakeup _procwakeup_signal
|
|
||||||
#include "rendez-signal.c"
|
|
||||||
|
|
||||||
#undef _procsleep
|
|
||||||
#undef _procwakeup
|
|
||||||
#define _procsleep _procsleep_pthread
|
|
||||||
#define _procwakeup _procwakeup_pthread
|
|
||||||
#include "rendez-pthread.c"
|
#include "rendez-pthread.c"
|
||||||
|
#else
|
||||||
#undef _procsleep
|
#include "rendez-signal.c"
|
||||||
#undef _procwakeup
|
#endif
|
||||||
|
|
||||||
int
|
|
||||||
_islinuxnptl(void)
|
|
||||||
{
|
|
||||||
static char buf[100];
|
|
||||||
static int isnptl = -1;
|
|
||||||
|
|
||||||
if(isnptl == -1){
|
|
||||||
if(confstr(_CS_GNU_LIBPTHREAD_VERSION, buf, sizeof buf) > 0
|
|
||||||
&& strncmp(buf, "NPTL", 4) == 0)
|
|
||||||
isnptl = 1;
|
|
||||||
else
|
|
||||||
isnptl = 0;
|
|
||||||
}
|
|
||||||
return isnptl;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_procsleep(_Procrend *r)
|
|
||||||
{
|
|
||||||
if(_islinuxnptl())
|
|
||||||
return _procsleep_pthread(r);
|
|
||||||
else
|
|
||||||
return _procsleep_signal(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
_procwakeup(_Procrend *r)
|
|
||||||
{
|
|
||||||
if(_islinuxnptl())
|
|
||||||
return _procwakeup_pthread(r);
|
|
||||||
else
|
|
||||||
return _procwakeup_signal(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue