From cbde755a32c8489b75bfa8e36f85e321243e7602 Mon Sep 17 00:00:00 2001 From: "Eric J. Korpela" Date: Tue, 8 Jul 2008 23:51:54 +0000 Subject: [PATCH] sparc-solaris: detect_platforms() now checks if it is possible to run 64-bit apps. svn path=/trunk/boinc/; revision=15573 --- checkin_notes | 8 ++++++ client/cs_platforms.C | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/checkin_notes b/checkin_notes index 129f91682a..1b8d18ecf4 100644 --- a/checkin_notes +++ b/checkin_notes @@ -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 + diff --git a/client/cs_platforms.C b/client/cs_platforms.C index a90dece364..abf710279e 100644 --- a/client/cs_platforms.C +++ b/client/cs_platforms.C @@ -29,6 +29,18 @@ #ifndef _WIN32 #include "config.h" #include +#ifdef HAVE_SIGNAL_H +#include +#endif +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_WAIT_H +#include +#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