%% 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 #define SYS_TYPES_H_INCLUDED 1 #endif #endif #ifndef STDLIB_H_INCLUDED #include #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 #define WINDOWS_H_INCLUDED 1 #endif #endif #if DK4_HAVE_UNISTD_H #ifndef UNISTD_H_INCLUDED #include #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 }