95
100
#elif defined(__APPLE__)
96
#if defined(__x86_64__)
97
add_platform("x86_64-apple-darwin");
100
102
#if defined(__i386__) || defined(__x86_64__)
101
// Supported on both Mac Intel architectures
103
OSStatus err = noErr;
107
size_t len = sizeof(response);
109
err = Gestalt(gestaltSystemVersion, &version);
110
retval = sysctlbyname("hw.optional.x86_64", &response, &len, NULL, 0);
111
if ((err == noErr) && (version >= 0x1050) && response && (!retval)) {
112
HOSTTYPE = "x86_64-apple-darwin";
113
add_platform("x86_64-apple-darwin");
115
HOSTTYPE = "i686-apple-darwin";
118
// Supported on both Mac Intel architectures
102
119
add_platform("i686-apple-darwin");
104
121
// Supported on all 3 Mac architectures
105
122
add_platform("powerpc-apple-darwin");
124
#elif defined(__linux__) && ( defined(__i386__) || defined(__x86_64__) )
125
// Let's try to support both 32 and 64 bit applications in one client
126
// regardless of whether it is a 32 or 64 bit client
127
const char *uname[]={"/bin/uname","/usr/bin/uname",0};
128
int eno=0, support64=0, support32=0;
133
// find the 'uname' executable
135
if (boinc_file_exists(uname[eno])) break;
136
} while (uname[++eno] != 0);
138
// run it and check the kernel machine architecture.
139
if ( uname[eno] != 0 ) {
140
strlcpy(cmdline,uname[eno],256);
141
strlcat(cmdline," -m",256);
142
if ((f=popen(cmdline,"r"))) {
143
while (!std::feof(f)) {
144
fgets(cmdline,256,f);
145
if (strstr(cmdline,"x86_64")) support64=1;
151
// we're running on a 32 bit kernel, so we will assume
152
// we are i686-pc-linux-gnu only.
155
// we're running on a 64 bit kernel.
156
// Now comes the hard part. How to tell whether we can run
158
#if defined(__i386__) && !defined(__x86_64__)
159
// If we're a 32 bit binary, then we obviously can.
162
// If we're a 64 bit binary, the check is a bit harder.
163
// We'll use the file command to check installation of
164
// 32 bit libraries or executables.
165
const char *file[]={"/usr/bin/file","/bin/file",0};
166
const char *libdir[]={"/lib","/lib32","/lib/32","/usr/lib","/usr/lib32","/usr/lib/32"};
167
const int nlibdirs=sizeof(libdir)/sizeof(char *);
172
if (boinc_file_exists(file[eno])) break;
173
} while (file[++eno] != 0);
175
// now try to find a 32-bit C library.
176
if (file[eno] != 0) {
178
for (i=0; i < nlibdirs; i++) {
179
struct dirent *entry;
180
DIR *a = opendir(libdir[i]);
181
// if dir doesn't exist, do to the next one
182
if (a == 0) continue;
183
// dir exists. read each entry until you find a 32bit lib
184
while ((support32 == 0) && ((entry=readdir(a)) != 0)) {
185
strlcpy(cmdline, file[eno], 256);
186
strlcat(cmdline, " -L ", 256);
187
strlcat(cmdline, libdir[i], 256);
188
strlcat(cmdline, "/", 256);
189
strlcat(cmdline, entry->d_name, 256);
190
f = popen(cmdline, "r");
192
while (!std::feof(f)) {
193
fgets(cmdline,256,f);
194
// If the library is 32-bit ELF, then we're
196
if (strstr(cmdline, "ELF") && strstr(cmdline, "32-bit")) support32=1;
202
if (support32) break;
210
add_platform("x86_64-pc-linux-gnu");
213
add_platform("i686-pc-linux-gnu");
216
if (!(support64 || support32)) {
217
// Something went wrong. Assume HOSTTYPE and HOSTTYPEALT
219
add_platform(HOSTTYPE);
221
add_platform(HOSTTYPEALT);
106
225
#elif defined(sun)
107
// Check if we can run 64 bit binaries...
226
// Check if we can run 64-bit binaries...
227
// this assumes there isn't a 64-bit only solaris. (Every 64-bit solaris can run 32 bit binaries)
109
229
#if defined(__sparc) || defined(sparc)
110
FILE *f=fopen("/usr/bin/sparcv9/ls","r");
230
char *exe64=const_cast<char *>("/usr/bin/sparcv9/ls");
231
char *platform64=const_cast<char *>("sparc64-sun-solaris");
232
char *platform32=const_cast<char *>("sparc-sun-solaris");
233
#elif defined(__i386) || defined(i386) || defined(__amd64) || defined(__x86_64__)
234
char *exe64=const_cast<char *>("/usr/bin/amd64/ls");
235
char *platform64=const_cast<char *>("x86_64-pc-solaris");
236
char *platform32=const_cast<char *>("i686-pc-solaris");
238
#define UNKNOWN_SOLARIS_PROCESSOR
241
#ifndef UNKNOWN_SOLARIS_PROCESSOR
242
FILE *f=fopen(exe64,"r");
114
argv[0]="/usr/bin/sparcv9/ls";