sparc-solaris: detect_platforms() now checks if it is possible to run 64-bit

apps.

svn path=/trunk/boinc/; revision=15573
This commit is contained in:
Eric J. Korpela 2008-07-08 23:51:54 +00:00
parent 0dbb698403
commit cbde755a32
2 changed files with 70 additions and 0 deletions

View File

@ -5580,3 +5580,11 @@ David 8 July 2008
html/inc/
boinc_db.inc
util.inc
Eric K 8 July 2008
- sparc-solaris: detect_platforms()
test if it is possible to run 64-bit apps.
client/
cs_platforms.C

View File

@ -29,6 +29,18 @@
#ifndef _WIN32
#include "config.h"
#include <stdio.h>
#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#endif
#include "client_types.h"
@ -88,6 +100,56 @@ void CLIENT_STATE::detect_platforms() {
// Supported on all 3 Mac architectures
add_platform("powerpc-apple-darwin");
#elif defined(sun)
// Check if we can run 64 bit binaries...
#if defined(__sparc) || defined(sparc)
FILE *f=fopen("/usr/bin/sparcv9/ls","r");
char *argv[3];
pid_t pid;
int rv=0;
argv[0]="/usr/bin/sparcv9/ls";
argv[1]=argv[0];
argv[2]=NULL;
if (f) {
fclose(f);
if (0==(pid=fork())) {
// we are in child process
freopen("/dev/null","a",stderr);
freopen("/dev/null","a",stdout);
rv=execv(argv[0],argv);
exit(rv);
} else {
// we are in the parent process.
time_t start=time(0);
int done;
// wait 5 seconds or until the process exits.
do {
done=waitpid(pid,&rv,WNOHANG);
sleep(1);
} while (!done && ((time(0)-start)<5));
// if we timed out, kill the process
if ((time(0)-start)>=5) {
kill(pid,SIGKILL);
done=-1;
}
// if we exited with success add the 64 bit platform
if ((done == pid) && (rv == 0)) {
add_platform("sparc64-sun-solaris");
}
}
}
add_platform("sparc-sun-solaris");
// the following platform is obsolete, but we'll add it anyway.
add_platform("sparc-sun-solaris2.7");
#else // defined sparc
add_platform(HOSTTYPE);
#ifdef HOSTTYPEALT
add_platform(HOSTTYPEALT);
#endif
#endif // else defined sparc
#else
// Any other platform, fall back to the previous method