~registry/dolphin-emu/triforce

« back to all changes in this revision

Viewing changes to Source/Core/Common/Src/Misc.cpp

  • Committer: Sérgio Benjamim
  • Date: 2015-02-13 05:54:40 UTC
  • Revision ID: sergio_br2@yahoo.com.br-20150213055440-ey2rt3sjpy27km78
Dolphin Triforce branch from code.google, commit b957980 (4.0-315).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
// Neither Android nor OS X support TLS
 
8
#if  defined(__APPLE__) || (ANDROID && __clang__)
 
9
#define __thread
 
10
#endif
 
11
 
 
12
// Generic function to get last error message.
 
13
// Call directly after the command or use the error num.
 
14
// This function might change the error code.
 
15
const char* GetLastErrorMsg()
 
16
{
 
17
        static const size_t buff_size = 255;
 
18
 
 
19
#ifdef _WIN32
 
20
        static __declspec(thread) char err_str[buff_size] = {};
 
21
 
 
22
        FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(),
 
23
                MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
 
24
                err_str, buff_size, NULL);
 
25
#else
 
26
        static __thread char err_str[buff_size] = {};
 
27
 
 
28
        // Thread safe (XSI-compliant)
 
29
        strerror_r(errno, err_str, buff_size);
 
30
#endif
 
31
 
 
32
        return err_str;
 
33
}