30 static_assert (
sizeof (pointer_sized_int) ==
sizeof (
void*),
"Basic sanity test failed: please report!");
31 static_assert (
sizeof (int8) == 1,
"Basic sanity test failed: please report!");
32 static_assert (
sizeof (uint8) == 1,
"Basic sanity test failed: please report!");
33 static_assert (
sizeof (int16) == 2,
"Basic sanity test failed: please report!");
34 static_assert (
sizeof (uint16) == 2,
"Basic sanity test failed: please report!");
35 static_assert (
sizeof (int32) == 4,
"Basic sanity test failed: please report!");
36 static_assert (
sizeof (uint32) == 4,
"Basic sanity test failed: please report!");
37 static_assert (
sizeof (int64) == 8,
"Basic sanity test failed: please report!");
38 static_assert (
sizeof (uint64) == 8,
"Basic sanity test failed: please report!");
40 return "JUCE v" JUCE_STRINGIFY (JUCE_MAJOR_VERSION)
41 "." JUCE_STRINGIFY (JUCE_MINOR_VERSION)
42 "." JUCE_STRINGIFY (JUCE_BUILDNUMBER);
45#if JUCE_ANDROID && ! defined (JUCE_DISABLE_JUCE_VERSION_PRINTING)
46 #define JUCE_DISABLE_JUCE_VERSION_PRINTING 1
49#if JUCE_DEBUG && ! JUCE_DISABLE_JUCE_VERSION_PRINTING
50 struct JuceVersionPrinter
54 DBG (SystemStats::getJUCEVersion());
58 static JuceVersionPrinter juceVersionPrinter;
71String getLegacyUniqueDeviceID();
78 arr.add (mac.toString());
92 auto legacyIdProvider = [] ([[maybe_unused]]
StringArray& arr)
95 arr.add (getLegacyUniqueDeviceID());
105 static const Provider providers[] =
115 for (
const auto& provider : providers)
117 if (hasBitValueSet (flags, provider.flag))
127 CPUInformation() noexcept { initialise(); }
129 void initialise() noexcept;
131 int numLogicalCPUs = 0, numPhysicalCPUs = 0;
133 bool hasMMX = false, hasSSE = false, hasSSE2 = false, hasSSE3 = false,
134 has3DNow = false, hasFMA3 = false, hasFMA4 = false, hasSSSE3 = false,
135 hasSSE41 = false, hasSSE42 = false, hasAVX = false, hasAVX2 = false,
136 hasAVX512F = false, hasAVX512BW = false, hasAVX512CD = false,
137 hasAVX512DQ = false, hasAVX512ER = false, hasAVX512IFMA = false,
138 hasAVX512PF = false, hasAVX512VBMI = false, hasAVX512VL = false,
139 hasAVX512VPOPCNTDQ = false,
143static const CPUInformation& getCPUInformation() noexcept
145 static CPUInformation info;
181 #if JUCE_ANDROID || JUCE_MINGW || JUCE_WASM
185 HANDLE process = GetCurrentProcess();
186 SymInitialize (process,
nullptr, TRUE);
189 int frames = (int) CaptureStackBackTrace (0, numElementsInArray (stack), stack,
nullptr);
192 symbol.
calloc (
sizeof (SYMBOL_INFO) + 256, 1);
193 symbol->MaxNameLen = 255;
194 symbol->SizeOfStruct =
sizeof (SYMBOL_INFO);
196 for (
int i = 0; i < frames; ++i)
198 DWORD64 displacement = 0;
200 if (SymFromAddr (process, (DWORD64) stack[i], &displacement, symbol))
204 IMAGEHLP_MODULE64 moduleInfo;
205 zerostruct (moduleInfo);
206 moduleInfo.SizeOfStruct =
sizeof (moduleInfo);
208 if (::SymGetModuleInfo64 (process, symbol->ModBase, &moduleInfo))
209 result << moduleInfo.ModuleName <<
": ";
211 result << symbol->Name <<
" + 0x" <<
String::toHexString ((int64) displacement) << newLine;
217 auto frames = backtrace (stack, numElementsInArray (stack));
218 char** frameStrings = backtrace_symbols (stack, frames);
220 for (
auto i = (
decltype (frames)) 0; i < frames; ++i)
221 result << frameStrings[i] << newLine;
223 ::free (frameStrings);
235static LONG WINAPI handleCrash (LPEXCEPTION_POINTERS ep)
237 globalCrashHandler (ep);
238 return EXCEPTION_EXECUTE_HANDLER;
241static void handleCrash (
int signum)
243 globalCrashHandler ((
void*) (pointer_sized_int) signum);
244 ::kill (getpid(), SIGKILL);
247int juce_siginterrupt (
int sig,
int flag);
252 jassert (handler !=
nullptr);
253 globalCrashHandler = handler;
256 SetUnhandledExceptionFilter (handleCrash);
258 const int signals[] = { SIGFPE, SIGILL, SIGSEGV, SIGBUS, SIGABRT, SIGSYS };
260 for (
int i = 0; i < numElementsInArray (signals); ++i)
262 ::signal (signals[i], handleCrash);
263 juce_siginterrupt (signals[i], 1);
272 #if JUCE_MAC || JUCE_IOS
273 static bool isRunningInAppSandbox = [&]
287 return isRunningInAppSandbox;
295class UniqueHardwareIDTest final :
public UnitTest
299 UniqueHardwareIDTest() :
UnitTest (
"UniqueHardwareID", UnitTestCategories::analytics) {}
301 void runTest()
override
303 beginTest (
"getUniqueDeviceID returns usable data.");
305 expect (SystemStats::getUniqueDeviceID().isNotEmpty());
310static UniqueHardwareIDTest uniqueHardwareIDTest;
String getFileExtension() const
static File JUCE_CALLTYPE getSpecialLocation(const SpecialLocationType type)
File getParentDirectory() const
uint64 getFileIdentifier() const
void calloc(SizeType newNumElements, const size_t elementSize=sizeof(ElementType))
static Array< MACAddress > getAllAddresses()
bool isEmpty() const noexcept
static String toHexString(IntegerType number)
static bool hasAVX512CD() noexcept
static String getStackBacktrace()
static bool hasMMX() noexcept
static void setApplicationCrashHandler(CrashHandlerFunction)
static int getNumPhysicalCpus() noexcept
static bool hasAVX512ER() noexcept
static bool has3DNow() noexcept
static bool hasAVX2() noexcept
static bool hasAVX512VPOPCNTDQ() noexcept
static bool hasSSE() noexcept
static bool hasAVX512DQ() noexcept
static bool isRunningInAppExtensionSandbox() noexcept
static bool hasNeon() noexcept
static bool hasAVX512F() noexcept
static bool hasSSE3() noexcept
static bool hasSSE2() noexcept
static bool hasAVX() noexcept
void(*)(void *) CrashHandlerFunction
static bool hasAVX512VBMI() noexcept
static String getUniqueDeviceID()
@ legacyUniqueId
Only implemented on Windows. A hash of the full smbios table, may be unstable on certain machines.
@ uniqueId
The most stable kind of machine identifier. A good default to use.
@ fileSystemId
The filesystem id of the user's home directory (or system directory on Windows).
@ macAddresses
All Mac addresses of the machine.
static bool hasSSSE3() noexcept
static bool hasAVX512VL() noexcept
static bool hasAVX512PF() noexcept
static bool hasSSE41() noexcept
static StringArray getDeviceIdentifiers()
static bool hasFMA4() noexcept
static String getJUCEVersion()
static bool hasSSE42() noexcept
static StringArray getMachineIdentifiers(MachineIdFlags flags)
static bool hasFMA3() noexcept
static bool hasAVX512IFMA() noexcept
static bool hasAVX512BW() noexcept
static int getNumCpus() noexcept