diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2003-11-19 18:50:23 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2003-11-19 18:50:23 +0000 |
commit | a6df500f7daacc08cd7c66f4212cb6ab6cbe803e (patch) | |
tree | f81a85de384145f0d97d3f717f54359b00800e3f /winsup/cygwin/cygserver_ipc.h | |
parent | 282113ba894449ed17e85b296cf0760d5206ac8d (diff) | |
download | cygnal-a6df500f7daacc08cd7c66f4212cb6ab6cbe803e.tar.gz cygnal-a6df500f7daacc08cd7c66f4212cb6ab6cbe803e.tar.bz2 cygnal-a6df500f7daacc08cd7c66f4212cb6ab6cbe803e.zip |
* cygserver.h (client_request::request_code_t): Add
CYGSERVER_REQUEST_MSG and CYGSERVER_REQUEST_SEM.
(admininstrator_group_sid): Add extern declaration.
* cygserver_ipc.h: Rewrite.
* cygserver_msg.h: New file.
* cygserver_sem.h: New file.
* cygserver_shm.h: More or less rewrite.
* cygwin.din: Add msgctl, msgget, msgrcv, msgsnd, semctl, semget and
semop.
* msg.cc: Rewrite.
* safe_memory.h: Remove.
* sem.cc: Rewrite.
* shm.cc: Rewrite.
* include/cygwin/ipc.h: Use appropriate guard.
(struct ipc_perm): Add seq.
(IPCID_TO_IX): New define from BSD.
(IPCID_TO_SEQ): Ditto.
(IXSEQ_TO_IPCID): Ditto.
(IPC_R): Ditto.
(IPC_W): Ditto.
(IPC_M): Ditto.
* include/cygwin/msg.h: Use appropriate guard. #ifdef _KERNEL all stuff
not explicitely defined by SUSv3. Use signed types in structs to match
types used in BSD.
(msgqnum_t): Define unsigned.
(msglen_t): Ditto.
(struct msqid_ds): Add msg_first and msg_last.
(struct msginfo): Remove msgpool. Add msgssz and msgseg.
* include/cygwin/sem.h: Use appropriate guard. #ifdef _KERNEL all stuff
not explicitely defined by SUSv3. Use signed types in structs to match
types used in BSD.
(SEM_UNDO): Define appropriately.
(struct semid_ds): Add sem_base.
(struct seminfo): Add semmap and semusz.
(SEM_A): New define from BSD.
(SEM_R): Ditto.
(SEM_ALLOC): Ditto.
(union semun): Define.
* include/cygwin/shm.h: Use appropriate guard. #ifdef _KERNEL all stuff
not explicitely defined by SUSv3. Use signed types in structs to match
types used in BSD.
(SHMLBA): Define using cygwin_internal(CW_GET_SHMLBA) call.
(struct shmid_ds): Add shm_internal.
(struct shm_info): Rename shm_ids to used_ids as in BSD. Add define
for shm_ids.
* include/cygwin/sysproto.h: New file.
* include/cygwin/version.h: Bump API minor number.
* include/sys/ipc.h: New file.
* include/sys/msg.h: New file.
* include/sys/queue.h: New file from BSD.
* include/sys/sem.h: New file.
* include/sys/shm.h: New file.
* include/sys/sysproto.h: New file.
Diffstat (limited to 'winsup/cygwin/cygserver_ipc.h')
-rw-r--r-- | winsup/cygwin/cygserver_ipc.h | 120 |
1 files changed, 59 insertions, 61 deletions
diff --git a/winsup/cygwin/cygserver_ipc.h b/winsup/cygwin/cygserver_ipc.h index 0d0ebbc76..37f5730bc 100644 --- a/winsup/cygwin/cygserver_ipc.h +++ b/winsup/cygwin/cygserver_ipc.h @@ -1,8 +1,6 @@ /* cygserver_ipc.h - Copyright 2002 Red Hat, Inc. - - Originally written by Conrad Scott <conrad.scott@dsl.pipex.com> + Copyright 2002, 2003 Red Hat, Inc. This file is part of Cygwin. @@ -13,72 +11,72 @@ details. */ #ifndef __CYGSERVER_IPC_H__ #define __CYGSERVER_IPC_H__ -#include <assert.h> -#include <limits.h> /* For OPEN_MAX. */ - /* - * The sysv ipc id's (msgid, semid, shmid) are integers arranged such - * that they no subsystem will generate the same id as some other - * subsystem; nor do these ids overlap file descriptors (the other - * common integer ids). Since Cygwin can allocate more than OPEN_MAX - * file descriptors, it can't be guaranteed not to overlap, but it - * should help catch some errors. - * - * msgid's: OPEN_MAX, OPEN_MAX + 3, OPEN_MAX + 6, . . . - * semid's: OPEN_MAX + 1, OPEN_MAX + 4, OPEN_MAX + 7, . . . - * shmid's: OPEN_MAX + 2, OPEN_MAX + 5, OPEN_MAX + 8, . . . - * - * To further ensure that ids are unique, if ipc objects are created - * and destroyed and then re-created, they are given new ids by - * munging the basic id (as above) with a sequence number. - * - * Internal ipc id's, which are 0, 1, ... within each subsystem (and - * not munged with a sequence number), are used solely by the ipcs(8) - * interface. + * Datastructure which is part of any IPC input parameter block. */ - -enum ipc_subsys_t - { - IPC_MSGOP = 0, - IPC_SEMOP = 1, - IPC_SHMOP = 2, - IPC_SUBSYS_COUNT +struct vmspace { + void *vm_map; /* UNUSED */ + struct shmmap_state *vm_shm; +}; + +struct proc { + pid_t cygpid; + DWORD winpid; + __uid32_t uid; + __gid32_t gid; + int gidcnt; + __gid32_t *gidlist; + bool is_admin; + struct vmspace *p_vmspace; +}; + +#ifdef __INSIDE_CYGWIN__ +inline void +ipc_set_proc_info (proc &blk) +{ + blk.cygpid = getpid (); + blk.winpid = GetCurrentProcessId (); + blk.uid = geteuid32 (); + blk.gid = getegid32 (); + blk.gidcnt = 0; + blk.gidlist = NULL; + blk.is_admin = false; +} +#endif /* __INSIDE_CYGWIN__ */ + +#ifndef __INSIDE_CYGWIN__ +class ipc_retval { +private: + union { + int i; + unsigned int u; + vm_offset_t off; + vm_object_t obj; }; -/* - * IPCMNI - The absolute maximum number of simultaneous ipc ids for - * any one subsystem. - */ +public: + ipc_retval (int ni) { i = ni; } -enum - { - IPCMNI = 0x10000 // Must be a power of two. - }; + operator int () const { return i; } + int operator = (int ni) { return i = ni; } -inline int -ipc_int2ext (const int intid, const ipc_subsys_t subsys, long & sequence) -{ - assert (0 <= intid && intid < IPCMNI); + operator unsigned int () const { return u; } + unsigned int operator = (unsigned int nu) { return u = nu; } - const long tmp = InterlockedIncrement (&sequence); + operator vm_offset_t () const { return off; } + vm_offset_t operator = (vm_offset_t noff) { return off = noff; } - return (((tmp & 0x7fff) << 16) - | (OPEN_MAX + (intid * IPC_SUBSYS_COUNT) + subsys)); -} + operator vm_object_t () const { return obj; } + vm_object_t operator = (vm_object_t nobj) { return obj = nobj; } +}; -inline int -ipc_ext2int_subsys (const int extid) -{ - return ((extid & (IPCMNI - 1)) - OPEN_MAX) % IPC_SUBSYS_COUNT; -} - -inline int -ipc_ext2int (const int extid, const ipc_subsys_t subsys) -{ - if (ipc_ext2int_subsys (extid) != subsys) - return -1; - else - return ((extid & (IPCMNI - 1)) - OPEN_MAX) / IPC_SUBSYS_COUNT; -} +struct thread { + class process *client; + proc *ipcblk; + ipc_retval td_retval[2]; +}; +#define td_proc ipcblk +#define p_pid cygpid +#endif #endif /* __CYGSERVER_IPC_H__ */ |