/* $Header: types.h,v 1.46.106.3 97/07/28 18:55:38 huongho Exp $ */

#ifndef _SYS_TYPES_INCLUDED
#define _SYS_TYPES_INCLUDED

#ifdef _KERNEL_BUILD
#include "../h/stdsyms.h"
#include "../h/_inttypes.h"
#else  /* ! _KERNEL_BUILD */
#include <sys/stdsyms.h>
#include <sys/_inttypes.h>
#endif /* _KERNEL_BUILD */

#ifdef _INCLUDE_POSIX_SOURCE

#	ifndef _MQD_T
#		define _MQD_T
		typedef int	mqd_t;	/* POSIX MQ descriptor index */
#	endif /* _MQD_T */


#  ifndef _DEV_T
#    define _DEV_T
     typedef int32_t dev_t;		/* For device numbers */
#  endif /* _DEV_T */


#  ifndef _INO32_T
#    define _INO32_T
	typedef uint32_t ino32_t;
#  endif /* _INO32_T */


#  ifndef _INO64_T
#    define _INO64_T
#    if !defined(__STDC_32_MODE__)
       typedef uint64_t ino64_t;
#    endif
#  endif /* _INO32_T */


/*
 * ino_t is 64-bits for LP64 app so that API is extensible beyond
 * 32 bits (stat, readdir).  Inside kernel, ino_t is still 32 bits,
 * though this will eventually change.
 */
#  ifndef _INO_T
#    define _INO_T
#    ifdef _KERNEL
         typedef ino32_t ino_t;
#    else
	 typedef unsigned long ino_t;
#    endif
#  endif /* _INO_T */

#  ifndef _MODE_T
#    define _MODE_T
     typedef uint16_t mode_t;		/* For file types and modes */
#  endif /* _MODE_T */

#  ifndef _NLINK_T
#    define _NLINK_T
     typedef uint16_t nlink_t;		/* For link counts */
#  endif /* _NLINK_T */

#  ifndef _FPOS32_T
#   define _FPOS32_T
    typedef int32_t fpos32_t;		/* 32bit position inside a file */
#  endif /* _FPOS32_T */

#  ifndef _FPOS64_T
#    define _FPOS64_T
#    if !defined(__STDC_32_MODE__)
       typedef int64_t fpos64_t;	/* 64bit position inside a file */
#    endif
#  endif /* _FPOS64_T */

#  ifndef _FPOS_T
#    define _FPOS_T
#    ifdef _APP32_64BIT_OFF_T
       typedef int64_t fpos_t;		/* position inside a file */
#    else
       typedef long fpos_t;		
#    endif
#  endif /* _FPOS_T */

#  ifndef _FSBLOCKS32_T
#    define _FSBLOCKS32_T
     typedef uint32_t fsblkcnt32_t;	/* blocks within a file system */
#  endif /* _FSBLOCKS32_T */

#  ifndef _FSBLOCKS64_T
#    define _FSBLOCKS64_T
#    if !defined(__STDC_32_MODE__)
       typedef uint64_t fsblkcnt64_t;	/* blocks within a file system */
#    endif
#  endif /* _FSBLOCKS64_T */

#  ifndef _FSBLOCKS_T
#    define _FSBLOCKS_T
#    if defined(_APP32_64BIT_OFF_T) || defined(_KERNEL)
       typedef uint64_t fsblkcnt_t;	/* block count */
#      define k_fsblkcnt_t fsblkcnt_t
#    else
       typedef unsigned long fsblkcnt_t;	
#    endif
#  endif /* _FSBLOCKS_T */

#  ifndef _OFF32_T
#    define _OFF32_T
     typedef int32_t off32_t;	/* 32bit offsets and sizes */
#  endif /* _OFF32_T */

#  ifndef _OFF64_T
#    define _OFF64_T
#    if !defined(__STDC_32_MODE__)
        typedef int64_t off64_t;	/* 64bit offsets and sizes */
#    endif
#  endif /* _OFF64_T */

#  ifndef _OFF_T
#    define _OFF_T
#    if defined(_APP32_64BIT_OFF_T) || defined(_KERNEL)
        typedef int64_t off_t;		/* For offsets and sizes */
#       define k_off_t off_t
#    else
        typedef long off_t;		
#    endif 
#  endif /* _OFF_T */

#  ifndef _FSFILCNT32_T
#    define _FSFILCNT32_T
     typedef uint32_t fsfilcnt32_t;	/* free file nodes */
#  endif /* _FSFILCNT32_T */

#  ifndef _FSFILCNT64_T
#    define _FSFILCNT64_T
#    if !defined(__STDC_32_MODE__)
       typedef uint64_t fsfilcnt64_t;	/* free file nodes */
#    endif
#  endif /* _FSFILCNT64_T */

#  ifndef _FSFILCNT_T
#   define _FSFILCNT_T
#     if defined(_APP32_64BIT_OFF_T) || defined(_KERNEL)
        typedef uint64_t fsfilcnt_t;	/* free file nodes */
#       define k_fsfilcnt_t fsfilcnt_t
#     else
        typedef unsigned long fsfilcnt_t;	
#     endif
#  endif /* _FSFILCNT_T */

#  ifndef _BLKCNT32_T
#    define _BLKCNT32_T
     typedef int32_t blkcnt32_t;	/* 32-bit # of blocks */
#  endif /* _BLKCNT32_T */

#  ifndef _BLKCNT64_T
#    define _BLKCNT64_T
#    if !defined(__STDC_32_MODE__)
       typedef int64_t blkcnt64_t;	/* 64-bit # of blocks */
#    endif
#  endif /* _BLKCNT64_T */

#  ifndef _BLKCNT_T
#   define _BLKCNT_T
#     if defined(_APP32_64BIT_OFF_T) || defined(_KERNEL)
        typedef int64_t blkcnt_t;	/* # of blocks */
#	define k_blkcnt_t blkcnt_t
#     else
        typedef long blkcnt_t;	
#     endif
#  endif /* _BLKCNT_T */

#  ifndef _PID_T
#    define _PID_T
     typedef int32_t pid_t;		/* For process and session IDs */
#  endif /* _PID_T */

#  ifndef _LWPID_T
#    define _LWPID_T
     typedef int32_t lwpid_t;              /* For process and session IDs */
#  endif /* _LWPID_T */

#  ifndef _GID_T
#    define _GID_T
     typedef int32_t gid_t;		/* For group IDs */
#  endif /* _GID_T */

#  ifndef _UID_T
#    define _UID_T
     typedef int32_t uid_t;		/* For user IDs */
#  endif /* _UID_T */

#  ifndef _TID_T
#    define _TID_T
     typedef int32_t tid_t;		/* For thread IDs */
#  endif /* _TID_T */

#  ifndef _SSIZE_T
#    define _SSIZE_T
	typedef long ssize_t;
#  endif /* _SSIZE_T */

#  ifndef _SITE_T
#    define _SITE_T
     typedef uint16_t __site_t;		/* see stat.h */
#  endif /* _SITE_T */

#  ifndef _CNODE_T
#    define _CNODE_T
     typedef uint16_t __cnode_t;	/* see stat.h */
#  endif /* _CNODE_T */
#endif /* _INCLUDE_POSIX_SOURCE */

#if defined(_INCLUDE_POSIX_SOURCE) || defined(_INCLUDE__STDC__)
#  ifndef _TIME_T
#    define _TIME_T
#       ifdef _KERNEL
                typedef int32_t time_t;
#       else
                typedef long time_t;
#       endif
#  endif /* _TIME_T */
#endif /* _INCLUDE_POSIX_SOURCE || _INCLUDE__STDC__ */

#if defined(_INCLUDE_POSIX_SOURCE) || (defined(_INCLUDE__STDC__) && (!defined(_XPG4_EXTENDED) || defined(_INCLUDE_HPUX_SOURCE)))
#  ifndef _SIZE_T
#    define _SIZE_T
#ifndef __SIZE_TYPE__
#define __SIZE_TYPE__ long unsigned int
#endif
#ifndef _GCC_SIZE_T
#define _GCC_SIZE_T
	typedef __SIZE_TYPE__ size_t;
#endif
#  endif /* _SIZE_T */
#endif /* _INCLUDE_POSIX_SOURCE || (_INCLUDE__STDC__ && (!_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE)) */

#if defined(_INCLUDE_XOPEN_SOURCE) || (defined(_INCLUDE__STDC__) && (!defined(_XPG4_EXTENDED) || defined(_INCLUDE_HPUX_SOURCE)))
#  ifndef _CLOCK_T
#    define _CLOCK_T
     typedef uint32_t clock_t;		/* For clock ticks */
#  endif /* _CLOCK_T */
#endif /* _INCLUDE_XOPEN_SOURCE || (_INCLUDE__STDC__ && (!_XPG4_EXTENDED || _INCLUDE_HPUX_SOURCE)) */

#ifdef _INCLUDE_XOPEN_SOURCE
#  ifndef _KEY_T
#    define _KEY_T
      typedef int32_t key_t;		/* For interprocess communication ID */
#  endif /* _KEY_T */

   typedef unsigned short __ushort;	/* Try to avoid using this */

   typedef int32_t __daddr_t;		/* For disk block addresses */
   typedef char *__caddr_t;		/* For character addresses */
   typedef int32_t __swblk_t;
#endif /* _INCLUDE_XOPEN_SOURCE */


#ifdef _INCLUDE_AES_SOURCE
#  ifndef _CADDR_T
#    define _CADDR_T
     typedef __caddr_t		caddr_t;
#  endif /* _CADDR_T */
#endif /* _INCLUDE_AES_SOURCE */

#ifdef _INCLUDE_XOPEN_SOURCE_EXTENDED

#  ifndef _ID_T
#    define _ID_T
     typedef int32_t id_t;	/* For IDs that can be pid_t, uid_t, gid_t */
#  endif /* _ID_T */

#  ifndef _USECONDS_T
#    define _USECONDS_T
     typedef uint32_t useconds_t;	/*  Time in microseconds */
#  endif /* _USECONDS_T */

/* For getrlimit() */

#   ifndef _RLIM32_T
#     define _RLIM32_T
      typedef uint32_t rlim32_t;
#   endif /* _RLIM32_T */

#   ifndef _RLIM64_T
#     define _RLIM64_T
#    if !defined(__STDC_32_MODE__)
        typedef uint64_t rlim64_t;
#     endif
#   endif /* _RLIM64_T */

#  ifndef _RLIM_T
#    define _RLIM_T
#    if defined(_APP32_64BIT_OFF_T) || defined(_KERNEL)
#      if !defined(__STDC_32_MODE__)
         typedef uint64_t rlim_t;
#        define k_rlim_t rlim_t
#      endif /* __STDC_32_MODE__ */
#    else
       typedef unsigned long rlim_t;
#    endif /* _APP32_64BIT_OFF_T || _KERNEL */
#  endif /* _RLIM_T */

/* For "struct statvfs" in statvfs.h */
   typedef __site_t		site_t;
#endif /* _INCLUDE_XOPEN_SOURCE_EXTENDED */

#ifdef _INCLUDE_HPUX_SOURCE
   typedef unsigned char	u_char;	   /* Try to avoid using these */
   typedef unsigned short	u_short;   /* Try to avoid using these */
   typedef unsigned int		u_int;     /* Try to avoid using these */
   typedef unsigned long	u_long;    /* Try to avoid using these */
   typedef unsigned int		uint;	   /* Try to avoid using these */
   typedef unsigned short	ushort;	   /* Try to avoid using these */
   typedef unsigned char  ubit8;
   typedef unsigned short ubit16;
   typedef uint32_t	  ubit32;
   typedef char           sbit8;
   typedef short          sbit16;
   typedef int32_t        sbit32;

   typedef __swblk_t		swblk_t;
   typedef __daddr_t		daddr_t;
   typedef __cnode_t		cnode_t;

   /* For physical memory and virtual addresses and/or offsets */
#ifdef _KERNEL_BUILD
#include "../machine/vmtypes.h"
#else
#include <machine/vmtypes.h>
#endif

#  ifndef _ULONG_T
#  define _ULONG_T
   typedef unsigned long ulong_t;
#  endif

   typedef int16_t		cnt_t;
   typedef uint32_t             cdno_t;
   typedef uint16_t		use_t;

   typedef struct _physadr { intptr_t r[1]; } *physadr;
   typedef struct _quad { long val[2]; } quad;

   typedef int spu_t;


#  define MAXSUSE	65535	/* maximum share count on swap device */


     typedef short cpu_t;

     typedef struct label_t {
#ifdef __LP64__
	int64_t     lbl_rp;
	int64_t     lbl_sp;
	int64_t     lbl_s[17];	
	int64_t     lbl_ss[1];
 	int64_t     lbl_sf[10];
#else
	int32_t     lbl_rp;
	int32_t     lbl_sp;
	int32_t     lbl_s[17];	
	int32_t     lbl_ss[1];
 	double      lbl_sf[10];
#endif
    } label_t;

/*
 * Locking declarations used by mod_k.h and stream.h.
 */
typedef struct lkinfo {
       char    *lk_name;
       int      lk_flags;
       long     lk_pad[2];
} lkinfo_t;

typedef unsigned long   pl_t;

#  ifndef _KERNEL
   typedef char *dm_message;
#  endif /* not _KERNEL */

#  ifndef _AID_T
#     define _AID_T
      typedef int32_t	aid_t;
#  endif /* _AID_T */


/* These probably should be moved to some other header */

#  define UID_NO_CHANGE  ((uid_t) -1)  /* for chown(2) and setresuid(2) */
#  define GID_NO_CHANGE  ((gid_t) -1)  /* for chown(2) and setresgid(2) */

   typedef pid_t		sid_t;	   /* For session IDs */

#  define PGID_NOT_SET   ((pid_t) -1)  /* for no pgrp */
#  define SID_NOT_SET	 ((sid_t) -1)  /* for no session */
#  define PGID_USE_PID   ((pid_t) -2)  /* set pgrp to pid */
#  define SID_USE_PID	 ((sid_t) -2)  /* set session to pid*/


   /* Types, macros, etc. for select() */
#  ifndef MAXFUPLIM

#    define __fd_set fd_set
#    ifdef _KERNEL_BUILD
#    include "../h/_fd_macros.h"
#    else  /* ! _KERNEL_BUILD */
#    include <sys/_fd_macros.h>
#    endif /* _KERNEL_BUILD */
#    undef __fd_set

     /* NOTE: the other use of ifndef MAXFUPLIM (in _types.h goes away)*/
#    define MAXFUPLIM  _MAXFUPLIM
#    define NFDBITS    _NFDBITS
#    ifndef howmany
#      define howmany(x,y)  (((x)+((y)-1))/(y))
#    endif
     typedef __fd_mask  fd_mask;
#  endif /* not MAXFUPLIM */

#  ifndef _KERNEL
#    ifdef __cplusplus
	extern "C" {
#    endif /* __cplusplus */

#    ifdef _CLASSIC_ID_TYPES
#      ifdef _SVID3
	  extern int setpgrp();
#      endif /* _SVID3 */
#    else /* not _CLASSIC_ID_TYPES */
#      ifdef _PROTOTYPES
#        ifdef _SVID3
	   extern pid_t setpgrp(void);
#        endif /* _SVID3 */
#      else /* not _PROTOTYPES */
#        ifdef _SVID3
	   extern pid_t setpgrp();
#        endif /* _SVID3 */
#      endif /* not _PROTOTYPES */
#    endif /* not _CLASSIC_ID_TYPES */

#    ifdef _PROTOTYPES
#      ifdef _SVID3
	  extern int ptrace(int, pid_t, int, int, int);
	  extern int ioctl(int, int, ...);
	  extern int acct(const char *);
#      endif /* _SVID3 */
#    else /* not _PROTOTYPES */
#      ifdef _SVID3
	  extern int ptrace();
	  extern int ioctl();
	  extern int acct();
#      endif /* _SVID3 */
#    endif /* not _PROTOTYPES */

#    ifdef __cplusplus
	}
#    endif /* __cplusplus */
#  endif /* not _KERNEL */

#endif /* _INCLUDE_HPUX_SOURCE */

#if !defined(__STDC_32_MODE__)

/* Make these kernel types available as some commands need 
 * these types (via vnode.h). They will be available in 
 * ANSI-EXT mode, K&R or LP64 mode.
 */

#  ifndef _DIR_OFF_T
#    define _DIR_OFF_T
	typedef int32_t dir_off_t;
#  endif
#endif /* ! __STDC_32_MODE */

#ifdef _UNSUPPORTED

	/* 
	 * NOTE: The following header file contains information specific
	 * to the internals of the HP-UX implementation. The contents of 
	 * this header file are subject to change without notice. Such
	 * changes may affect source code, object code, or binary
	 * compatibility between releases of HP-UX. Code which uses 
	 * the symbols contained within this header file is inherently
	 * non-portable (even between HP-UX implementations).
	*/
#ifdef _KERNEL_BUILD
#include "../h/_types.h"
#else  /* ! _KERNEL_BUILD */
#include <.unsupp/sys/_types.h>
#endif /* _KERNEL_BUILD */
#endif /* _UNSUPPORTED */

#endif /* _SYS_TYPES_INCLUDED */
