2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 // (This file gets included by juce_linux_NativeCode.cpp, rather than being
27 // compiled on its own).
28 #if JUCE_INCLUDED_FILE
31 //==============================================================================
32 void Logger::outputDebugString (const String
& text
)
34 std::cerr
<< text
<< std::endl
;
37 //==============================================================================
38 SystemStats::OperatingSystemType
SystemStats::getOperatingSystemType()
43 String
SystemStats::getOperatingSystemName()
48 bool SystemStats::isOperatingSystem64Bit()
53 //xxx not sure how to find this out?..
58 //==============================================================================
59 namespace LinuxStatsHelpers
61 String
getCpuInfo (const char* const key
)
64 lines
.addLines (File ("/proc/cpuinfo").loadFileAsString());
66 for (int i
= lines
.size(); --i
>= 0;) // (NB - it's important that this runs in reverse order)
67 if (lines
[i
].startsWithIgnoreCase (key
))
68 return lines
[i
].fromFirstOccurrenceOf (":", false, false).trim();
74 String
SystemStats::getCpuVendor()
76 return LinuxStatsHelpers::getCpuInfo ("vendor_id");
79 int SystemStats::getCpuSpeedInMegaherz()
81 return roundToInt (LinuxStatsHelpers::getCpuInfo ("cpu MHz").getFloatValue());
84 int SystemStats::getMemorySizeInMegabytes()
88 if (sysinfo (&sysi
) == 0)
89 return (sysi
.totalram
* sysi
.mem_unit
/ (1024 * 1024));
94 int SystemStats::getPageSize()
96 return sysconf (_SC_PAGESIZE
);
99 //==============================================================================
100 String
SystemStats::getLogonName()
102 const char* user
= getenv ("USER");
106 struct passwd
* const pw
= getpwuid (getuid());
111 return CharPointer_UTF8 (user
);
114 String
SystemStats::getFullUserName()
116 return getLogonName();
119 String
SystemStats::getComputerName()
121 char name
[256] = { 0 };
122 if (gethostname (name
, sizeof (name
) - 1) == 0)
125 return String::empty
;
128 //==============================================================================
129 SystemStats::CPUFlags::CPUFlags()
131 const String
flags (LinuxStatsHelpers::getCpuInfo ("flags"));
132 hasMMX
= flags
.contains ("mmx");
133 hasSSE
= flags
.contains ("sse");
134 hasSSE2
= flags
.contains ("sse2");
135 has3DNow
= flags
.contains ("3dnow");
137 numCpus
= LinuxStatsHelpers::getCpuInfo ("processor").getIntValue() + 1;
140 void PlatformUtilities::fpuReset()
144 //==============================================================================
145 uint32
juce_millisecondsSinceStartup() noexcept
148 clock_gettime (CLOCK_MONOTONIC
, &t
);
150 return t
.tv_sec
* 1000 + t
.tv_nsec
/ 1000000;
153 int64
Time::getHighResolutionTicks() noexcept
156 clock_gettime (CLOCK_MONOTONIC
, &t
);
158 return (t
.tv_sec
* (int64
) 1000000) + (t
.tv_nsec
/ 1000);
161 int64
Time::getHighResolutionTicksPerSecond() noexcept
163 return 1000000; // (microseconds)
166 double Time::getMillisecondCounterHiRes() noexcept
168 return getHighResolutionTicks() * 0.001;
171 bool Time::setSystemTimeToThisTime() const
174 t
.tv_sec
= millisSinceEpoch
/ 1000;
175 t
.tv_usec
= (millisSinceEpoch
- t
.tv_sec
* 1000) * 1000;
177 return settimeofday (&t
, 0) == 0;