diff options
| author | 2014-04-08 19:25:03 -0400 | |
|---|---|---|
| committer | 2014-04-08 19:25:03 -0400 | |
| commit | 63e46abdb8764bc97e91bae862c8d461e61b1965 (patch) | |
| tree | e73f4aa25d7b4015a265e7bbfb6004dab7561027 /src/common/misc.cpp | |
| parent | fixed some license headers that I missed (diff) | |
| download | yuzu-63e46abdb8764bc97e91bae862c8d461e61b1965.tar.gz yuzu-63e46abdb8764bc97e91bae862c8d461e61b1965.tar.xz yuzu-63e46abdb8764bc97e91bae862c8d461e61b1965.zip | |
got rid of 'src' folders in each sub-project
Diffstat (limited to 'src/common/misc.cpp')
| -rw-r--r-- | src/common/misc.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/common/misc.cpp b/src/common/misc.cpp new file mode 100644 index 000000000..935805478 --- /dev/null +++ b/src/common/misc.cpp | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | // Copyright 2013 Dolphin Emulator Project | ||
| 2 | // Licensed under GPLv2 | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common.h" | ||
| 6 | |||
| 7 | #ifdef _WIN32 | ||
| 8 | #include <windows.h> | ||
| 9 | #endif | ||
| 10 | |||
| 11 | // Neither Android nor OS X support TLS | ||
| 12 | #if defined(__APPLE__) || (ANDROID && __clang__) | ||
| 13 | #define __thread | ||
| 14 | #endif | ||
| 15 | |||
| 16 | // Generic function to get last error message. | ||
| 17 | // Call directly after the command or use the error num. | ||
| 18 | // This function might change the error code. | ||
| 19 | const char* GetLastErrorMsg() | ||
| 20 | { | ||
| 21 | static const size_t buff_size = 255; | ||
| 22 | |||
| 23 | #ifdef _WIN32 | ||
| 24 | static __declspec(thread) char err_str[buff_size] = {}; | ||
| 25 | |||
| 26 | FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), | ||
| 27 | MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), | ||
| 28 | err_str, buff_size, NULL); | ||
| 29 | #else | ||
| 30 | static __thread char err_str[buff_size] = {}; | ||
| 31 | |||
| 32 | // Thread safe (XSI-compliant) | ||
| 33 | strerror_r(errno, err_str, buff_size); | ||
| 34 | #endif | ||
| 35 | |||
| 36 | return err_str; | ||
| 37 | } | ||