00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _UXSYSVIPC_HPP_
00019 #define _UXSYSVIPC_HPP_
00020
00021 #include <sys/ipc.h>
00022 #include <sys/msg.h>
00023 #include <sys/shm.h>
00024 #include <sys/sem.h>
00025
00026 namespace Ux {
00027
00028
00029
00030
00031 class SysVIPC : public Base {
00032 protected:
00033 int id;
00034
00035 public:
00036 SysVIPC(int n = -1)
00037 : id(n)
00038 { }
00039 static key_t ftok(const char *path, int id);
00040 operator int()
00041 { return id; }
00042 };
00043
00044
00045
00046
00047 class SysVMsg : public SysVIPC {
00048 public:
00049 void get(key_t key, int flags = IPC_CREAT | PERM_FILE);
00050 void ctl(int cmd, struct msqid_ds *data = NULL);
00051 void snd(const void *msgp, size_t msgsize, int flags = 0);
00052 ssize_t rcv(void *msgp, size_t mtextsize, long msgtype = 0, int flags = 0);
00053 };
00054
00055
00056
00057
00058 class SysVShm : public SysVIPC {
00059 public:
00060 void get(key_t key, size_t size, int flags = IPC_CREAT | PERM_FILE);
00061 void ctl(int cmd, struct shmid_ds *data = NULL);
00062 void * at(const void *shmaddr = NULL, int flags = 0);
00063 void dt(const void *shmaddr);
00064 };
00065
00066
00067
00068
00069
00070 union semun {
00071 int val;
00072 struct semid_ds *buf;
00073 unsigned short *array;
00074 };
00075
00076
00077
00078
00079 class SysVSem : public SysVIPC {
00080 public:
00081 void get(key_t key, int nsems, int flags = IPC_CREAT | PERM_FILE);
00082 int ctl(int semnum, int cmd, union semun arg);
00083 void op(struct sembuf *sops, size_t nsops);
00084 };
00085
00086 }
00087
00088 #endif // _UXSYSVIPC_HPP_