X-Git-Url: http://winboard.nl/cgi-bin?p=polyglot.git;a=blobdiff_plain;f=util.cpp;h=a7a733cf1088f662a1add4f7ab661ef31e3bf152;hp=3ec89b790aac833d183a1190414baf2fb68cc350;hb=5cd5185613348b13625e257efcd7b2f11ca85276;hpb=ad2265d4fc54fc9ba99fc606e6174df34bfb4a0f diff --git a/util.cpp b/util.cpp index 3ec89b7..a7a733c 100644 --- a/util.cpp +++ b/util.cpp @@ -16,9 +16,14 @@ #include "posix.h" #include "util.h" +// + +const int ErrorBufferSize=4096; + // variables static bool Error; +static char ErrorBuffer[ErrorBufferSize]; FILE * LogFile=NULL; @@ -366,3 +371,22 @@ double my_timer_elapsed_real(const my_timer_t * timer) { return elapsed; } + +// my_timer() + +char * my_error(){ +#ifdef _WIN32 + FormatMessage( + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, + GetLastError(), + LANG_USER_DEFAULT, + ErrorBuffer, + ErrorBufferSize, + NULL); + return ErrorBuffer; +#else + return strerror(errno); +#endif +} +