comparison Core/Toolbox.cpp @ 892:517e28b420af plugins

integration mainline -> plugins
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Jun 2014 15:41:13 +0200
parents 0570a8c859cb 816dccaeb7cf
children 3fb427ac3f53
comparison
equal deleted inserted replaced
891:d0a08d8881b7 892:517e28b420af
52 #if defined(__APPLE__) && defined(__MACH__) 52 #if defined(__APPLE__) && defined(__MACH__)
53 #include <mach-o/dyld.h> /* _NSGetExecutablePath */ 53 #include <mach-o/dyld.h> /* _NSGetExecutablePath */
54 #include <limits.h> /* PATH_MAX */ 54 #include <limits.h> /* PATH_MAX */
55 #endif 55 #endif
56 56
57 #if defined(__linux) 57 #if defined(__linux) || defined(__FreeBSD_kernel__)
58 #include <limits.h> /* PATH_MAX */ 58 #include <limits.h> /* PATH_MAX */
59 #include <signal.h> 59 #include <signal.h>
60 #include <unistd.h> 60 #include <unistd.h>
61 #endif 61 #endif
62 62
160 160
161 void Toolbox::USleep(uint64_t microSeconds) 161 void Toolbox::USleep(uint64_t microSeconds)
162 { 162 {
163 #if defined(_WIN32) 163 #if defined(_WIN32)
164 ::Sleep(static_cast<DWORD>(microSeconds / static_cast<uint64_t>(1000))); 164 ::Sleep(static_cast<DWORD>(microSeconds / static_cast<uint64_t>(1000)));
165 #elif defined(__linux) 165 #elif defined(__linux) || defined(__FreeBSD_kernel__)
166 usleep(microSeconds); 166 usleep(microSeconds);
167 #else 167 #else
168 #error Support your platform here 168 #error Support your platform here
169 #endif 169 #endif
170 } 170 }
513 std::vector<char> buffer(32768); 513 std::vector<char> buffer(32768);
514 /*int bytes =*/ GetModuleFileNameA(NULL, &buffer[0], static_cast<DWORD>(buffer.size() - 1)); 514 /*int bytes =*/ GetModuleFileNameA(NULL, &buffer[0], static_cast<DWORD>(buffer.size() - 1));
515 return std::string(&buffer[0]); 515 return std::string(&buffer[0]);
516 } 516 }
517 517
518 #elif defined(__linux) 518 #elif defined(__linux) || defined(__FreeBSD_kernel__)
519 std::string Toolbox::GetPathToExecutable() 519 std::string Toolbox::GetPathToExecutable()
520 { 520 {
521 std::vector<char> buffer(PATH_MAX + 1); 521 std::vector<char> buffer(PATH_MAX + 1);
522 ssize_t bytes = readlink("/proc/self/exe", &buffer[0], buffer.size() - 1); 522 ssize_t bytes = readlink("/proc/self/exe", &buffer[0], buffer.size() - 1);
523 if (bytes == 0) 523 if (bytes == 0)