summaryrefslogtreecommitdiff
path: root/support/dktools/dk4getpid.ctr
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/dktools/dk4getpid.ctr
Initial commit
Diffstat (limited to 'support/dktools/dk4getpid.ctr')
-rw-r--r--support/dktools/dk4getpid.ctr97
1 files changed, 97 insertions, 0 deletions
diff --git a/support/dktools/dk4getpid.ctr b/support/dktools/dk4getpid.ctr
new file mode 100644
index 0000000000..63ff591a48
--- /dev/null
+++ b/support/dktools/dk4getpid.ctr
@@ -0,0 +1,97 @@
+%% options
+
+copyright owner = Dirk Krause
+copyright year = 2015-xxxx
+license = bsd
+
+
+
+%% header
+
+/** @file
+ Get process ID.
+
+ CRT on Windows: Not used.
+*/
+
+#ifndef DK4CONF_H_INCLUDED
+#include "dk4conf.h"
+#endif
+
+#ifndef DK4TYPES_H_INCLUDED
+#include "dk4types.h"
+#endif
+
+#ifndef DK4ERROR_H_INCLUDED
+#include "dk4error.h"
+#endif
+
+#if DK4_HAVE_SYS_TYPES_H
+#ifndef SYS_TYPES_H_INCLUDED
+#include <sys/types.h>
+#define SYS_TYPES_H_INCLUDED 1
+#endif
+#endif
+
+#ifndef STDLIB_H_INCLUDED
+#include <stdlib.h>
+#define STDLIB_H_INCLUDED 1
+#endif
+
+#if DK4_ON_WINDOWS
+/** Process ID is a DWORD on Windows.
+*/
+typedef unsigned long dk4_pid_t;
+#else
+/** Use existing pid_t on other systems.
+*/
+typedef pid_t dk4_pid_t;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** Get current process ID.
+ @return Process ID.
+*/
+dk4_pid_t
+dk4getpid(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
+%% module
+
+
+#include "dk4getpid.h"
+
+#if DK4_ON_WINDOWS
+#ifndef WINDOWS_H_INCLUDED
+#include <windows.h>
+#define WINDOWS_H_INCLUDED 1
+#endif
+#endif
+
+#if DK4_HAVE_UNISTD_H
+#ifndef UNISTD_H_INCLUDED
+#include <unistd.h>
+#define UNISTD_H_INCLUDED 1
+#endif
+#endif
+
+
+
+dk4_pid_t
+dk4getpid(void)
+{
+#if DK4_ON_WINDOWS
+ return ((dk4_pid_t)GetCurrentProcessId());
+#else
+ return (getpid());
+#endif
+}
+