Subject: Re: hpux msg/sem/shm header files
To: None <thorpej@nas.nasa.gov>
From: Steve Peurifoy <swp@alumni.rice.edu>
List: port-hp300
Date: 08/16/1999 22:43:38
Hope this helps.  Lemme know if you need any others (though I'll be
on vacation shortly, so response may not be immediate)...

-Steve

> I noticed that the HP-UX emulation uses the old SVR2-derived 386 ABI
> for these system calls, and I'm not sure that's entirely correct.  Would
> someone be so kind as to tell me the definition of the following structures
> and data types in HP-UX 9?
> 
> 	* struct msqid_ds

   struct __msg {
        struct __msg            *msg_next;      /* ptr to next message on q */
        long                    msg_type;       /* message type */
        unsigned short int      msg_ts;         /* message text size */
        long                    msg_spot;       /* message text map address */
   };

   struct msqid_ds {
        struct ipc_perm    msg_perm;       /* operation permission struct */
        struct __msg       *msg_first;     /* ptr to first message on q */
        struct __msg       *msg_last;      /* ptr to last message on q */
        unsigned short int msg_qnum;       /* # of messages on q */
        unsigned short int msg_qbytes;     /* max # of bytes on q */
#   ifdef _CLASSIC_ID_TYPES
        unsigned short int msg_filler_lspid;
        unsigned short int msg_lspid;      /* pid of last msgsnd */
        unsigned short int msg_filler_lrpid;
        unsigned short int msg_lrpid;      /* pid of last msgrcv */
#   else
        pid_t              msg_lspid;      /* pid of last msgsnd */
        pid_t              msg_lrpid;      /* pid of last msgrcv */
#   endif
        time_t             msg_stime;      /* last msgsnd time */
        time_t             msg_rtime;      /* last msgrcv time */
        time_t             msg_ctime;      /* last change time */
        unsigned short int msg_cbytes;     /* current # bytes on q */
        char               msg_pad[22];    /* room for future expansion */
   };

> 	* struct semid_ds

   struct __sem {
     unsigned short int semval;         /* semaphore text map address */
     unsigned short int sempid;         /* pid of last operation */
     unsigned short int semncnt;        /* # awaiting semval > cval */
     unsigned short int semzcnt;        /* # awaiting semval = 0 */
   };

   struct semid_ds {
     struct ipc_perm    sem_perm;       /* operation permission struct */
     struct __sem       *sem_base;      /* ptr to first semaphore in set */
     time_t             sem_otime;      /* last semop time */
     time_t             sem_ctime;      /* last change time */
     unsigned short int sem_nsems;      /* # of semaphores in set */
     char               sem_pad[22];    /* room for future expansion */
   };

> 	* struct sembuf

   struct sembuf {
     unsigned short int sem_num;        /* semaphore # */
     short              sem_op;         /* semaphore operation */
     short              sem_flg;        /* operation flags */
   };

> 	* struct shmid_ds

   struct shmid_ds {
       struct ipc_perm  shm_perm;       /* operation permission struct */
       int              shm_segsz;      /* size of segment in bytes */
       struct vas       *shm_vas;       /* virtual address space this entry */
#ifdef _CLASSIC_ID_TYPES
        unsigned short  shm_filler_lpid;
        unsigned short  shm_lpid;       /* pid of last shmop */
        unsigned short  shm_filler_cpid;
        unsigned short  shm_cpid;       /* pid of creator */
#else
        pid_t           shm_lpid;       /* pid of last shmop */
        pid_t           shm_cpid;       /* pid of creator */
#endif
       unsigned short int shm_nattch;   /* current # attached (accurate) */
       unsigned short int shm_cnattch;  /* in memory # attached (inaccurate) */
       time_t           shm_atime;      /* last shmat time */
       time_t           shm_dtime;      /* last shmdt time */
       time_t           shm_ctime;      /* last change time */
       char             shm_pad[24];    /* room for future expansion */
   };

> 	* key_t

 typedef long key_t;

> ...and any other related data types that might also be defined?

   struct ipc_perm {
#    ifdef _CLASSIC_ID_TYPES
        unsigned short  filler_uid;
        unsigned short  uid;    /* owner's user id */
        unsigned short  filler_gid;
        unsigned short  gid;    /* owner's group id */
        unsigned short  filler_cuid;
        unsigned short  cuid;   /* creator's user id */
        unsigned short  filler_cgid;
        unsigned short  cgid;   /* creator's group id */
#    else
        uid_t           uid;    /* owner's user id */
        gid_t           gid;    /* owner's group id */
        uid_t           cuid;   /* creator's user id */
        gid_t           cgid;   /* creator's group id */
#    endif
        mode_t          mode;   /* access modes */
        unsigned short  seq;    /* slot usage sequence number */
        key_t           key;    /* key */
#  ifdef __hp9000s800
        unsigned short  ndx;    /* ndx of proc who has lock */
        unsigned short  wait;   /* waits, wanted, lock bits; reserved for 
                                   specific ipc facilities */
#  endif /* __hp9000s800 */
        char            pad[20]; /* room for future expansion */
   };