//
// Prototypes for IPC operations.
// Included for use in dumb systems without proper prototypes
// - these are the linux versions.
//

#ifndef __DB_IPCPROTO_H__
#define __DB_IPCPROTO_H__

#include <diamond/dbconf.h>

#if HAVE_SYS_IPC_H
extern "C" {
#include <sys/ipc.h>
}
#endif

#if HAVE_SYS_SHM_H
extern "C" {
#include <sys/shm.h>
}
#endif

#if HAVE_SYS_MSG_H
extern "C" {
#include <sys/msg.h>
}
#endif

#include <sys/types.h>

//extern "C" {
//key_t ftok(char*, char);
// }

#if !defined(HAVE_SHMGET_PROTO)

//
// Assume that the other information is probably missing too.
//

struct shmid_ds;
struct msgbuf;
struct msqid_ds;
struct sembuf;


extern "C" {

extern key_t ftok (char *__pathname, char __proc_id);
extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf);
extern int shmget (key_t __key, int __size, int __flag);
extern char *shmat (int __shmid, char *__shmaddr, int __shmflg);
extern int shmdt (char *__shmaddr);
extern int msgget (key_t __key, int __msgflg);
extern int msgsnd (int __msqid, struct msgbuf *__msgp, int __msgsz,
		       int __msgflg);
extern int msgrcv (int __msqid, struct msgbuf *__msgp, int __msgsz,
		       int32 __msgtyp, int __msgflg);
extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf);
extern int semget (key_t __key, int __nsems, int __semflg);
extern int semop (int __semid, struct sembuf *__sops, unsigned __nsops);
extern int semctl (int __semid, int __semnum, int __cmd,
		       union semun __arg);
}
#endif

//
// It's a sad truth at the moment, but the actual structure/size of
// a message is not architecture dependant.  There is always a long
// at the start (on alphas + all other platforms) that holds the
// channel number.  Unfortunately the long is varibly sized, hence this
// structure.
//

typedef long DiaMsgId_t; // MUST be a long
struct DiaMsgQ {
	DiaMsgId_t	msgid;
	int32	content[10];
};
#endif
