compiler/clib: Don't hide access to aroscbase behind a #define.
[AROS.git] / compiler / clib / getppid.c
blob82a89333beba939fb4cdacf66bfc056b8ed62233
1 /*
2 Copyright © 2004-2012, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <unistd.h>
7 #include <sys/types.h>
9 #include <exec/tasks.h>
10 #include <proto/exec.h>
12 #include <assert.h>
14 #include "__vfork.h"
15 #include "__arosc_privdata.h"
17 /*****************************************************************************
19 NAME */
21 pid_t getppid(
23 /* SYNOPSIS */
24 void)
26 /* FUNCTION
28 INPUTS
30 RESULT
32 NOTES
34 EXAMPLE
36 BUGS
38 SEE ALSO
40 INTERNALS
42 ******************************************************************************/
44 struct aroscbase *aroscbase = __GM_GetBase();
45 struct Task *ParentTask;
46 struct ETask *eThisTask;
47 struct ETask *et;
49 if(aroscbase->acb_flags & PRETEND_CHILD)
51 struct vfork_data *udata = aroscbase->acb_vfork_data;
52 eThisTask = GetETask(udata->child);
54 else
55 eThisTask = GetETask(FindTask(NULL));
56 assert(eThisTask);
57 ParentTask = (struct Task *)eThisTask->et_Parent;
58 if(!ParentTask)
59 return (pid_t) 1;
60 et = GetETask(ParentTask);
61 assert(et);
62 return (pid_t) et->et_UniqueID;