1//===- System.inc ---------------------------------------------------------===// 2// 3// The MCLinker Project 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9#include <string> 10 11#include <cstdlib> 12#include <cstring> 13#include <fcntl.h> 14#include <sys/types.h> 15#include <sys/stat.h> 16#include <windows.h> 17 18namespace mcld { 19namespace sys { 20 21char* strerror(int errnum) { 22 return std::strerror(errnum); 23} 24 25std::string getDefaultTargetTriple() { 26 return MCLD_DEFAULT_TARGET_TRIPLE; 27} 28 29int GetPageSize() { 30 static int _pagesize = 0; 31 if (!_pagesize) { 32 SYSTEM_INFO sysinfo; 33 GetSystemInfo(&sysinfo); 34 _pagesize = sysinfo.dwPageSize; 35 } 36 return _pagesize; 37} 38 39/// random - generate a random number. 40long GetRandomNum() { 41 return ::rand(); 42} 43 44/// srandom - set the initial seed value for future calls to random(). 45void SetRandomSeed(unsigned pSeed) { 46 ::srand(pSeed); 47} 48 49} // namespace sys 50} // namespace mcld 51