]> git.cworth.org Git - apitrace/blobdiff - common/os_process.hpp
Improvements in AttribArray / attrib/list code generation.
[apitrace] / common / os_process.hpp
index f1dd5172b6cf777b40c5363c4270f71ae11fddd5..e1b1df17179e8457239e9b021d593b30d23eaac5 100644 (file)
 #define _OS_PROCESS_HPP_
 
 
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <sys/types.h>
+#include <unistd.h>
+#endif
+
 #include "os.hpp"
 
 
 namespace os {
 
 
+typedef
+#ifdef _WIN32
+   DWORD
+#else
+   pid_t
+#endif
+ProcessId;
+
+
+static inline ProcessId
+getCurrentProcessId(void) {
+#ifdef _WIN32
+    return GetCurrentProcessId();
+#else
+    return getpid();
+#endif
+}
+
+
+static inline void
+setEnvironment(const char *name, const char *value) {
+#ifdef _WIN32
+    SetEnvironmentVariableA(name, value);
+#else
+    setenv(name, value, 1);
+#endif
+}
+
+
+static inline void
+unsetEnvironment(const char *name) {
+#ifdef _WIN32
+    SetEnvironmentVariableA(name, NULL);
+#else
+    unsetenv(name);
+#endif
+}
+
+
 int execute(char * const * args);