int ProbePointerBits(int *sure) { int iret = 32; char *uname; char cmnd[1024], res[1024]; /* * Note this is a weak probe, archinfo_x86 much better . . . */ *sure = 0; uname = FindUname(NULL); sprintf(cmnd, "%s -a", uname); /* * This probe should be running on backend; if its ptr length is 8, we've * definitely got a 64 bit machine * NOTE: getting 4 could be a result of compiler flags on a 64-bit arch, * so reverse is not dispositive */ if (sizeof(void*) == 8) { iret = 64; *sure = 1; } else if (!CmndOneLine(NULL, cmnd, res)) { /* * If uname is a known 64-bit platform, we're sure we've got OS support * for 64bits (may not have compiler support, but that's not our fault) */ if (strstr(res, "x86_64") || strstr(res, "ppc64") || strstr(res, "ia64")) { iret = 64; *sure = 1; } } return(iret); }
enum OSTYPE ProbeOS(int verb, char *targ) { int i, ierr=0; char ln[1024], ln2[1024]; char *cmnd, *res; enum OSTYPE OS; char *unam; if (verb) printf("Probing to make operating system determination:\n"); unam = FindUname(targ); i = strlen(unam) + 4; cmnd = malloc(sizeof(char)*i); assert(cmnd); sprintf(cmnd, "%s -s", unam); res = atlsys_1L(targ, cmnd, verb, 0); if (res) { /* * Accept GNU (HURD) as Linux, since they seem to use same stuff; * This is patch from Sylvestre Ledru; I have no direct experience wt HURD */ if(strstr(res, "Linux") || strstr(res, "GNU")) OS = OSLinux; else if(strstr(res, "FreeBSD")) OS = OSFreeBSD; else if (strstr(res, "Darwin")) OS = OSOSX; else if(strstr(res, "SunOS")) { sprintf(cmnd, "%s -r", unam); free(res); res = atlsys_1L(targ, cmnd, verb, 0); if (res[0] == '4') OS = OSSunOS4; else OS = OSSunOS; } else if(strstr(res, "OSF1")) OS = OSOSF1; else if(strstr(res, "IRIX")) OS = OSIRIX; else if(strstr(res, "AIX")) OS = OSAIX; else if(strstr(res, "WIN")) { if (strstr(res, "95") || strstr(res, "98") || strstr(res, "_ME")) OS = OSWin9x; /* * Need to confirm what is returned under cygwin for XP, etc. */ else if (strstr(res, "WOW64")) OS =OSWin64; else if (strstr(res, "NT")) OS = OSWinNT; else ierr = 1; } else if (strstr(res, "HP-UX")) OS = OSHPUX; else ierr = 1; free(res); } free(cmnd); if (ierr) { printf("\n\nUnable to determine OS, quitting\n\n"); exit(-1); } if (verb) printf("Operating system configured as %s\n\n", osnam[OS]); return(OS); }