/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* bos72L src/bos/kernel/sys/proc_compat.h 1.1.1.1                        */
/*                                                                        */
/* Licensed Materials - Property of IBM                                   */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2007,2018              */
/* All Rights Reserved                                                    */
/*                                                                        */
/* US Government Users Restricted Rights - Use, duplication or            */
/* disclosure restricted by GSA ADP Schedule Contract with IBM Corp.      */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
/* @(#)30     1.1.1.1  src/bos/kernel/sys/proc_compat.h, sysproc, bos72L, l2018_28A6 7/6/18 16:52:34 */

/*
 * This file is for backwards compatibility support for proc related functions
 */
#ifndef _H_PROC_COMPAT
#define _H_PROC_COMPAT

#include <sys/types.h>      /* All types */
#include <sys/cred.h>       /* For cred_ext_t */
#include <sys/resource.h>   /* RLIMITS */
#include <sys/user.h>       /* MAXCOMLEN, etc. */
#include <sys/signal.h>     /* NSIG64 */
#include <sys/wlm.h>        /* WLM_CLASSNAME_LENGTH */

/* These are for backwards compatibility with prior AIX releases */
#define RLIM_NLIMITS_41 6               /* backwards compat with AIX 4.1 */
#define RLIM_NLIMITS_42 8               /* backwards compat with AIX 4.2 */
#define RLIM_NLIMITS_43 8               /* backwards compat with AIX 4.3 */
#define RLIM_NLIMITS_52 8               /* backwards compat with AIX 5.2 */
#define RLIM_NLIMITS_53 8               /* backwards compat with AIX 5.3 */
#define RLIM_NLIMITS_54 RLIM_NLIMITS    /* Current value of rlimits for easier
                                           backwards compat in the future */

/*
 * This structure is part of the userx64 structure, which is part of the
 * core_dumpxx structure, used for 64-bit programs.
 *
 * The structure is size-invariant.  That is, its fields have the same size
 * and offset whether compiled in 32-bit mode or 64-bit mode.
 */
struct procentry64_53
{
	/* identification/authentication */
	pid32_t		pi_pid;		/* process ID */
	pid32_t		pi_ppid;	/* parent process ID */
	pid32_t		pi_sid;		/* session identifier */
	pid32_t		pi_pgrp;	/* process group */
	uid_t 		pi_uid;		/* real user ID */
	uid_t 		pi_suid;	/* saved user ID */

	/* controlling tty info */
	pid32_t		pi_ttyp;	/* has a controlling terminal */
	uint		pi_pad0;	/* alignment padding */
	dev64_t		pi_ttyd;	/* controlling terminal */
	longlong_t	pi_ttympx;	/*      "         "     channel */

	/* scheduler information */
	uint 		pi_nice;	/* nice for priority */
	uint 		pi_state;	/* process state -- from proc.h */
	uint 		pi_flags;	/* process flags -- from procinfo.h */
	uint 		pi_flags2;	/* process flags -- from procinfo.h */
	uint 		pi_thcount;	/* thread count */
	uint		pi_cpu;		/* first thread's tick count */
	uint		pi_pri;		/* first thread's priority */

	/* file management */
	uint		pi_maxofile;	/* maximum u_ofile index in use */
	u_longlong_t	pi_cdir;	/* current directory of process */
	u_longlong_t	pi_rdir;	/* root directory of process */
	short		pi_cmask;	/* mask for file creation */
	short		pi_pad1;	/* alignment padding */

	/* program name */
	char		pi_comm[MAXCOMLEN+1];	/* (truncated) program name */

	/* Randomization */
	char		pi_aslr;

	/* memory */
	u_longlong_t 	pi_adspace;	/* process address space */
	longlong_t 	pi_majflt;	/* i/o page faults */
	longlong_t 	pi_minflt;	/* non i/o page faults */
	longlong_t 	pi_repage;	/* repaging count */
	longlong_t 	pi_size;	/* size of image (pages) */

	/* valid when the process is a zombie only */
	time64_t	pi_utime;	/* this process user time */
	time64_t	pi_stime;	/* this process system time */

	/* credentials information */
	cred_ext_t 	pi_cred;

	/* accounting and profiling data */
	struct trusage64 pi_ru;		/* this process' rusage info */
	struct trusage64 pi_cru;	/* children's rusage info */
	longlong_t	pi_ioch;	/* I/O character count  */
	longlong_t 	pi_irss;	/* accumulator for memory integral */
	time64_t 	pi_start;	/* time at which process began */

	/* resource limits info */
	struct rlimit64 pi_rlimit[RLIM_NLIMITS_53];	/* resource limits */

	/* memory usage info */
	u_longlong_t 	pi_drss;	/* data resident set size */
	u_longlong_t 	pi_trss;	/* text resident set size */
	u_longlong_t 	pi_dvm;		/* data virtual memory size */
	u_longlong_t 	pi_prm;		/* percent real memory usage */
	u_longlong_t 	pi_tsize;	/* size of text */
	u_longlong_t 	pi_dsize;	/* current break value */
	u_longlong_t 	pi_sdsize;	/* data size from shared library*/

	/* signal management */
	u_longlong_t 	pi_signal[NSIG64];/* disposition of sigs */
	uint		pi_sigflags[NSIG64];/* sig action flags */
	sigset64_t	pi_sig;		/* pending sigs */

	/* WLM information. 34+31=65 bytes, padded to 72 */
	char            pi_classname[2*(WLM_CLASSNAME_LENGTH+1)];
	char            pi_tag[WLM_TAG_LENGTH+1];        

	/* pagesize information */
	char            pi_data_l2psize;     /* log2 of a proc's data pg sz */
	char            pi_text_l2psize;     /* log2 of a proc's text pg sz */
	char            pi_stack_l2psize;    /* log2 of a proc's stack pg sz */
	char            pi_pad4[4]; 
                                    
	suseconds_t	pi_chk_utime;	/* user time at checkpoint  */
	suseconds_t	pi_chk_ctime;	/* child time at checkpoint  */

	/* other scheduler information */
	uint            pi_policy;           /* process policy */
	uint            pi_ppri;             /* process priority */

	/* loader segment for 64bit process */
	u_longlong_t    pi_adspace_ldr;
};

/*
 * This structure is part of the userx structure, which is part of the
 * core_dumpx structure, used by default for 32-bit programs.
 *
 * The structure is size-invariant.  That is, its fields have the same size
 * and offset whether compiler in 32-bit mode or 64-bit mode.
 */
struct procsinfo64_53
{
	/* identification/authentication */
	pid_t 		pi_pid;		/* process ID */
	pid_t		pi_ppid;	/* parent process ID */
	pid_t 		pi_sid;		/* session identifier */
	pid_t 		pi_pgrp;	/* process group */
	uid_t 		pi_uid;		/* real user ID */
	uid_t 		pi_suid;	/* saved user ID */

	/* controlling tty info */
	pid_t 		pi_ttyp;	/* has a controlling terminal */
#ifdef __64BIT__
	dev32_t		pi_ttyd;	/* controlling terminal */
#else
	dev_t		pi_ttyd;	/* controlling terminal */
#endif
	uint 		pi_ttympx;	/*      "         "     channel */

	/* scheduler information */
	uint 		pi_nice;	/* nice for priority */
	uint 		pi_state;	/* process state -- from proc.h */
	uint 		pi_flags;	/* process flags -- from procinfo.h */
	uint 		pi_flags2;	/* process flags -- from procinfo.h */
	uint 		pi_thcount;	/* thread count */
	uint		pi_cpu;		/* first thread's tick count */
	uint		pi_pri;		/* first thread's priority */

	/* memory */
	uint		pi_adspace;	/* process address space */
	__INTPAD(pi_pad1)               /* padding if required */
	long long 	pi_majflt;	/* i/o page faults */
	long long 	pi_minflt;	/* non i/o page faults */
	long long 	pi_repage;	/* repaging count */
	long long 	pi_size;	/* size of image (pages) */

	/* valid when the process is a zombie only */
	uint		pi_r1;		/* reserved field */
	uint 		pi_utime;	/* this process user time */
	uint		pi_r2;		/* reserved field */
	uint		pi_stime;	/* this process system time */

	/* credentials information */
	struct ucred	pi_cred;
	__INTPAD(pi_pad2)               /* padding if required */

	/* accounting and profiling data */
	struct rusage64	pi_ru;		/* this process' rusage info */
	struct rusage64	pi_cru;		/* children's rusage info */
	long long	pi_ioch;	/* I/O character count  */
	long long 	pi_irss;	/* accumulator for memory integral */
	long long 	pi_start;	/* time at which process began */

	/* resource limits info */
	struct rlimit64 pi_rlimit[RLIM_NLIMITS_53];	/* resource limits */

	/* file management */
	short		pi_cmask;	/* mask for file creation */
	unsigned int	pi_cdir;	/* current directory of process */
	unsigned int	pi_rdir;	/* root directory of process */
	unsigned int	pi_maxofile;	/* maximum u_ofile index in use */

	/* program name */
	char		pi_comm[MAXCOMLEN+1];	/* (truncated) program name */

	/* Randomization */
	char		pi_aslr;

	/* memory usage info */
	unsigned long long pi_drss;	/* data resident set size */
	unsigned long long pi_trss;	/* text resident set size */
	unsigned long long pi_dvm;	/* data virtual memory size */
	unsigned long long pi_prm;	/* percent real memory usage */
	unsigned long long pi_tsize;	/* size of text */
	unsigned long long pi_dsize;	/* current break value */
	unsigned long long pi_sdsize;	/* data size from shared library*/

	/* signal management */
#ifdef __64BIT__
	unsigned long long pi_signal[NSIG32];	/* disposition of sigs */
	char		   pi_sigflags[NSIG32];	/* sig action flags */
	sigset32_t	   pi_sig;	/* pending sigs */
#else
	unsigned long long pi_signal[NSIG];	/* disposition of sigs */
	char		   pi_sigflags[NSIG];	/* sig action flags */
	sigset_t	   pi_sig;	/* pending sigs */
#endif
	/* WLM information. 34+31=65 bytes, padded to 72 */
	char               pi_classname[2*(WLM_CLASSNAME_LENGTH+1)];
	char               pi_tag[WLM_TAG_LENGTH+1];
	
	/* pagesize information */
	char               pi_data_l2psize;     /* log2 of a proc's data pg sz */
	char               pi_text_l2psize;     /* log2 of a proc's text pg sz */
	char               pi_stack_l2psize;    /* log2 of a proc's stack pg sz */
	char               pi_pad4[4]; 

	/* other scheduler information */
	uint               pi_policy;           /* process policy */
	uint               pi_ppri;             /* process priority */

	/* project information */
	unsigned long long pi_subproj;
	int		   pi_projid;
	short		   pi_acctflags;
	
	/* struct size rounded to 1.5 K */
	char 		   pi_resvd[10];	/* reserve space for future use */
};

#endif /* _H_PROC_COMPAT */
