+
+/* Status values. */
+#define SIDL 1 /* Process being created by fork. */
+#define SRUN 2 /* Currently runnable. */
+#define SSLEEP 3 /* Sleeping on an address. */
+#define SSTOP 4 /* Process debugging or suspension. */
+#define SZOMB 5 /* Awaiting collection by parent. */
+
+/* These flags are kept in extern_proc.p_flag. */
+#define P_ADVLOCK 0x00000001 /* Process may hold POSIX adv. lock */
+#define P_CONTROLT 0x00000002 /* Has a controlling terminal */
+#define P_LP64 0x00000004 /* Process is LP64 */
+#define P_NOCLDSTOP 0x00000008 /* No SIGCHLD when children stop */
+
+#define P_PPWAIT 0x00000010 /* Parent waiting for chld exec/exit */
+#define P_PROFIL 0x00000020 /* Has started profiling */
+#define P_SELECT 0x00000040 /* Selecting; wakeup/waiting danger */
+#define P_CONTINUED 0x00000080 /* Process was stopped and continued */
+
+#define P_SUGID 0x00000100 /* Has set privileges since last exec */
+#define P_SYSTEM 0x00000200 /* Sys proc: no sigs, stats or swap */
+#define P_TIMEOUT 0x00000400 /* Timing out during sleep */
+#define P_TRACED 0x00000800 /* Debugged process being traced */
+
+#define P_DISABLE_ASLR 0x00001000 /* Disable address space layout randomization */
+#define P_WEXIT 0x00002000 /* Working on exiting */
+#define P_EXEC 0x00004000 /* Process called exec. */
+
+/* Should be moved to machine-dependent areas. */
+#define P_OWEUPC 0x00008000 /* Owe process an addupc() call at next ast. */
+
+#define P_AFFINITY 0x00010000 /* xxx */
+#define P_TRANSLATED 0x00020000 /* xxx */
+#define P_CLASSIC P_TRANSLATED /* xxx */
+
+#define P_DELAYIDLESLEEP 0x00040000 /* Process is marked to delay idle sleep on disk IO */
+#define P_CHECKOPENEVT 0x00080000 /* check if a vnode has the OPENEVT flag set on open */
+
+#define P_DEPENDENCY_CAPABLE 0x00100000 /* process is ok to call vfs_markdependency() */
+#define P_REBOOT 0x00200000 /* Process called reboot() */
+#define P_RESV6 0x00400000 /* used to be P_TBE */
+#define P_RESV7 0x00800000 /* (P_SIGEXC)signal exceptions */
+
+#define P_THCWD 0x01000000 /* process has thread cwd */
+#define P_RESV9 0x02000000 /* (P_VFORK)process has vfork children */
+#define P_ADOPTPERSONA 0x04000000 /* process adopted a persona (used to be P_NOATTACH) */
+#define P_RESV11 0x08000000 /* (P_INVFORK) proc in vfork */
+
+#define P_NOSHLIB 0x10000000 /* no shared libs are in use for proc */
+ /* flag set on exec */
+#define P_FORCEQUOTA 0x20000000 /* Force quota for root */
+#define P_NOCLDWAIT 0x40000000 /* No zombies when chil procs exit */
+#define P_NOREMOTEHANG 0x80000000 /* Don't hang on remote FS ops */
+
+#define P_INMEM 0 /* Obsolete: retained for compilation */
+#define P_NOSWAP 0 /* Obsolete: retained for compilation */
+#define P_PHYSIO 0 /* Obsolete: retained for compilation */
+#define P_FSTRACE 0 /* Obsolete: retained for compilation */
+#define P_SSTEP 0 /* Obsolete: retained for compilation */
+
+#define P_DIRTY_TRACK 0x00000001 /* track dirty state */
+#define P_DIRTY_ALLOW_IDLE_EXIT 0x00000002 /* process can be idle-exited when clean */
+#define P_DIRTY_DEFER 0x00000004 /* defer initial opt-in to idle-exit */
+#define P_DIRTY 0x00000008 /* process is dirty */
+#define P_DIRTY_SHUTDOWN 0x00000010 /* process is dirty during shutdown */
+#define P_DIRTY_TERMINATED 0x00000020 /* process has been marked for termination */
+#define P_DIRTY_BUSY 0x00000040 /* serialization flag */
+#define P_DIRTY_MARKED 0x00000080 /* marked dirty previously */
+#define P_DIRTY_AGING_IN_PROGRESS 0x00000100 /* aging in one of the 'aging bands' */
+#define P_DIRTY_LAUNCH_IN_PROGRESS 0x00000200 /* launch is in progress */
+#define P_DIRTY_DEFER_ALWAYS 0x00000400 /* defer going to idle-exit after every dirty->clean transition.
+ * For legacy jetsam policy only. This is the default with the other policies.*/
+
+#define P_DIRTY_IS_DIRTY (P_DIRTY | P_DIRTY_SHUTDOWN)
+#define P_DIRTY_IDLE_EXIT_ENABLED (P_DIRTY_TRACK|P_DIRTY_ALLOW_IDLE_EXIT)
+
+#endif /* XNU_KERNEL_PRIVATE || !KERNEL */
+
+#ifdef KERNEL
+__BEGIN_DECLS
+
+extern proc_t kernproc;
+
+extern int proc_is_classic(proc_t p);
+extern bool proc_is_exotic(proc_t p);
+extern bool proc_is_alien(proc_t p);
+proc_t current_proc_EXTERNAL(void);
+
+extern int msleep(void *chan, lck_mtx_t *mtx, int pri, const char *wmesg, struct timespec * ts );
+extern void wakeup(void *chan);
+extern void wakeup_one(caddr_t chan);
+
+/* proc kpis */
+/* this routine returns the pid of the current process */
+extern int proc_selfpid(void);
+/* this routine returns the pid of the parent of the current process */
+extern int proc_selfppid(void);
+/* this routine returns the csflags of the current process */
+extern uint64_t proc_selfcsflags(void);
+/* this routine populates the given flags param with the csflags of the given process. Returns 0 on success, -1 on error. */
+extern int proc_csflags(proc_t p, uint64_t* flags);
+/* this routine returns sends a signal signum to the process identified by the pid */
+extern void proc_signal(int pid, int signum);
+/* this routine checks whether any signal identified by the mask are pending in the process identified by the pid. The check is on all threads of the process. */
+extern int proc_issignal(int pid, sigset_t mask);
+/* this routine returns 1 if the pid1 is inferior of pid2 */
+extern int proc_isinferior(int pid1, int pid2);
+/* this routine copies the process's name of the executable to the passed in buffer. It
+ * is always null terminated. The size of the buffer is to be passed in as well. This
+ * routine is to be used typically for debugging