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#include <sys/types.h>
11#include <sys/stat.h>
12#include <fcntl.h>
13#include <cstdlib>
14#include <cstring>
15#include <windows.h>
16
17namespace mcld{
18namespace sys{
19
20char* strerror(int errnum)
21{
22  return std::strerror(errnum);
23}
24
25std::string getDefaultTargetTriple()
26{
27  return MCLD_DEFAULT_TARGET_TRIPLE;
28}
29
30int GetPageSize()
31{
32  static int _pagesize = 0;
33  if (! _pagesize) {
34    SYSTEM_INFO sysinfo;
35    GetSystemInfo (&sysinfo);
36    _pagesize = sysinfo.dwPageSize;
37  }
38  return _pagesize;
39}
40
41/// random - generate a random number.
42long GetRandomNum()
43{
44  return ::rand();
45}
46
47/// srandom - set the initial seed value for future calls to random().
48void SetRandomSeed(unsigned pSeed)
49{
50  ::srand(pSeed);
51}
52
53} // namespace of sys
54} // namespace of mcld
55
56