summaryrefslogtreecommitdiffstats
path: root/private/crt32/dos/getpid.c
blob: b3967bf8710810ffb23091fcdd7e0aba472844da (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/***
*getpid.c - OS/2 get current process id
*
*	Copyright (c) 1989-1991, Microsoft Corporation. All rights reserved.
*
*Purpose:
*	Defines _getpid() - get current process id
*
*Revision History:
*	06-06-89  PHG	Module created, based on asm version
*	10-27-89  JCR	Added new Dos32GetThreadInfo code (under DCR757 switch)
*	11-17-89  JCR	Enabled DOS32GETTHREADINFO code (DCR757)
*	03-07-90  GJF	Made calling type _CALLTYPE1, added #include
*			<cruntime.h> and fixed copyright. Also, cleaned up the
*			formatting a bit.
*	07-02-90  GJF	Removed pre-DCR757 stuff.
*	08-08-90  GJF	Changed API prefix from DOS32 to DOS
*	10-03-90  GJF	New-style function declarator.
*	12-04-90  SRW	Changed to include <oscalls.h> instead of <doscalls.h>
*	12-06-90  SRW	Added _CRUISER_ and _WIN32 conditionals.
*	01-28-91  GJF	ANSI naming.
*
*******************************************************************************/

#include <cruntime.h>
#include <oscalls.h>

/***
*int _getpid() - get current process id
*
*Purpose:
*	Returns the current process id for the calling process.
*
*Entry:
*	None.
*
*Exit:
*	Returns the current process id.
*
*Uses:
*
*Exceptions:
*
*******************************************************************************/

int _CALLTYPE1 _getpid (
	void
	)
{
#ifdef	_CRUISER_
	PTIB tid_info;			/* thread info */
	PPIB pid_info;			/* process info */

	DOSGETTHREADINFO(&tid_info, &pid_info);

	return(pid_info->pib_ulpid);	/* return process id */

#else	/* ndef _CRUISER_ */

#ifdef	_WIN32_

        return GetCurrentProcessId();

#else	/* ndef _WIN32_ */

#error ERROR - ONLY CRUISER OR WIN32 TARGET SUPPORTED!

#endif	/* _WIN32_ */

#endif	/* _CRUISER_ */

}