X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=os.hpp;h=4376c97b50eea2d55a548022907f429476a70196;hb=bb130e5395d472c8ce23012c8234b32ca38fa460;hp=8e1c2957a66b7e87b88805bf4382467b901e7fae;hpb=1630be10e241e2741af716988da3e51dded481a6;p=apitrace diff --git a/os.hpp b/os.hpp index 8e1c295..4376c97 100644 --- a/os.hpp +++ b/os.hpp @@ -23,17 +23,28 @@ * **************************************************************************/ +/* + * Simple OS abstraction layer. + */ + #ifndef _OS_HPP_ #define _OS_HPP_ -#ifdef WIN32 +#include +#include +#include + +#ifdef _WIN32 #ifndef snprintf #define snprintf _snprintf #endif #ifndef vsnprintf #define vsnprintf _vsnprintf #endif -#endif /* WIN32 */ +#define PATH_SEP '\\' +#else /* !_WIN32 */ +#define PATH_SEP '/' +#endif /* !_WIN32 */ #ifndef PATH_MAX #define PATH_MAX 1024 @@ -46,6 +57,38 @@ void AcquireMutex(void); void ReleaseMutex(void); bool GetProcessName(char *str, size_t size); +bool GetCurrentDir(char *str, size_t size); + +void DebugMessage(const char *format, ...) +#ifdef __GNUC__ + __attribute__ ((format (printf, 1, 2))) +#endif +; + +#if defined _WIN32 || defined __CYGWIN__ + /* We always use .def files on windows for now */ + #if 0 + #define PUBLIC __declspec(dllexport) + #else + #define PUBLIC + #endif + #define PRIVATE +#else + #if __GNUC__ >= 4 + #define PUBLIC __attribute__ ((visibility("default"))) + #define PRIVATE __attribute__ ((visibility("hidden"))) + #else + #define PUBLIC + #define PRIVATE + #endif +#endif + +/** + * Get the current time in microseconds from an unknown base. + */ +long long GetTime(void); + +void Abort(void); } /* namespace OS */