Debian Codegraph @

Source/Core/Common/CommonFuncs.h

raw symbols SCIP
1 // Copyright 2009 Dolphin Emulator Project
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 #pragma once
5
6 #ifdef _WIN32
7 #include <optional>
8 #endif
9 #include <string>
10
11 #ifdef __APPLE__
12 #include "Common/CommonTypes.h"
13 #endif
14
15 #ifndef _WIN32
16
17 // go to debugger mode
18 #define Crash() \
19 { \
20 __builtin_trap(); \
21 }
22
23 #else // WIN32
24 // Function Cross-Compatibility
25 #define strcasecmp _stricmp
26 #define strncasecmp _strnicmp
27 #define unlink _unlink
28 #define vscprintf _vscprintf
29
30 // 64 bit offsets for Windows
31 #define fseeko _fseeki64
32 #define ftello _ftelli64
33 #define atoll _atoi64
34 #define stat _stat64
35 #define fstat _fstat64
36 #define fileno _fileno
37
38 extern "C" {
39 __declspec(dllimport) void __stdcall DebugBreak(void);
40 }
41 #define Crash() \
42 { \
43 DebugBreak(); \
44 }
45 #endif // _WIN32
46
47 namespace Common
48 {
49 // strerror_r wrapper to handle XSI and GNU versions.
50 const char* StrErrorWrapper(int error, char* buffer, std::size_t length);
51
52 // Wrapper functions to get strerror(errno) string, which itself is not threadsafe.
53 // These functions might change the error code.
54 std::string StrerrorString(int error);
55 std::string LastStrerrorString();
56
57 #ifdef _WIN32
58 // Wrapper function to get GetLastError() string.
59 // This function might change the error code.
60 std::string GetLastErrorString();
61
62 // Like GetLastErrorString() but if you have already queried the error code.
63 std::string GetWin32ErrorString(unsigned long error_code);
64
65 // Obtains a full path to the specified module.
66 std::optional<std::wstring> GetModuleName(void* hInstance);
67 #endif
68
69 #ifdef __APPLE__
70 struct MacOSVersion // NSOperatingSystemVersion
71 {
72 s64 major; // NSInteger majorVersion
73 s64 minor; // NSInteger minorVersion
74 s64 patch; // NSInteger patchVersion
75 };
76
77 // Helper function to get the current macOS version, which is easy to do with
78 // from Objective-C code, but a little harder from C++.
79 MacOSVersion GetMacOSVersion();
80 #endif
81 } // namespace Common