/* OS dependent Open. */ int sslOpenOsdep(void) { tickspersec = sysClkRateGet(); psOpenMalloc(MAX_MEMORY_USAGE); return 0; }
int32 sslOpenOsdep() { int32 rc; if ((rc = psOpenMalloc(MAX_MEMORY_USAGE)) < 0) { return rc; } /* Hires time init */ QueryPerformanceFrequency(&hiresFreq); QueryPerformanceCounter(&hiresStart); if (!CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) { return -1; } return 0; }
int32 sslOpenOsdep(void) { FILE *cpuInfo; double mhz; char line[80] = ""; char *tmpstr; int32 c; /* Open /dev/random access non-blocking. */ if ((randfd = open("/dev/random", O_RDONLY | O_NONBLOCK)) < 0) { return -1; } if ((urandfd = open("/dev/urandom", O_RDONLY)) < 0) { close(randfd); return -1; } /* Initialize times */ #if defined(USE_RDTSCLL_TIME) || defined(RDTSC) if ((cpuInfo = fopen ("/proc/cpuinfo","r")) == NULL) { matrixStrDebugMsg("Error opening /proc/cpuinfo\n", NULL); return -2; } while ((!feof(cpuInfo)) && (strncasecmp(line,"cpu MHz",7) != 0)){ fgets(line,79,cpuInfo); } if (strncasecmp(line,"cpu MHz",7) == 0){ tmpstr = strchr(line,':'); tmpstr++; c = strspn(tmpstr, " \t"); tmpstr +=c; c = strcspn(tmpstr, " \t\n\r"); tmpstr[c] = '\0'; mhz = 1000000 * atof(tmpstr); hiresFreq = (sslTime_t)mhz; fclose (cpuInfo); } else { fclose (cpuInfo); hiresStart = 0; return -3; } rdtscll(hiresStart); #endif /* USE_RDTSCLL_TIME */ /* FUTURE - Solaris doesn't support recursive mutexes! We don't use them internally anyway, so this is not an issue, but we like to set this if we can because it's silly for a thread to lock itself, rather than error or recursive lock */ #ifdef USE_MULTITHREADING pthread_mutexattr_init(&attr); #ifndef OSX pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE_NP); #endif /* !OSX */ #endif /* USE_MULTITHREADING */ return psOpenMalloc(MAX_MEMORY_USAGE); }