1*ce099b40Smartin /* $NetBSD: linux_shm.h,v 1.12 2008/04/28 20:23:44 martin Exp $ */ 2b64f5d3bSerh 3b64f5d3bSerh /*- 48096c25aSfvdl * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. 5b64f5d3bSerh * All rights reserved. 6b64f5d3bSerh * 7b64f5d3bSerh * This code is derived from software contributed to The NetBSD Foundation 88096c25aSfvdl * by Frank van der Linden and Eric Haszlakiewicz. 9b64f5d3bSerh * 10b64f5d3bSerh * Redistribution and use in source and binary forms, with or without 11b64f5d3bSerh * modification, are permitted provided that the following conditions 12b64f5d3bSerh * are met: 13b64f5d3bSerh * 1. Redistributions of source code must retain the above copyright 14b64f5d3bSerh * notice, this list of conditions and the following disclaimer. 15b64f5d3bSerh * 2. Redistributions in binary form must reproduce the above copyright 16b64f5d3bSerh * notice, this list of conditions and the following disclaimer in the 17b64f5d3bSerh * documentation and/or other materials provided with the distribution. 18b64f5d3bSerh * 19b64f5d3bSerh * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20b64f5d3bSerh * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21b64f5d3bSerh * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22b64f5d3bSerh * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23b64f5d3bSerh * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24b64f5d3bSerh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25b64f5d3bSerh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26b64f5d3bSerh * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27b64f5d3bSerh * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28b64f5d3bSerh * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29b64f5d3bSerh * POSSIBILITY OF SUCH DAMAGE. 30b64f5d3bSerh */ 313bf459f3Sfvdl 32908291d2Schristos #ifndef _LINUX_SHM_H 33908291d2Schristos #define _LINUX_SHM_H 34b64f5d3bSerh 35b64f5d3bSerh #include <sys/shm.h> 363bf459f3Sfvdl 373bf459f3Sfvdl /* 383bf459f3Sfvdl * shm segment control structure 393bf459f3Sfvdl */ 403bf459f3Sfvdl struct linux_shmid_ds { 413bf459f3Sfvdl struct linux_ipc_perm l_shm_perm; 423bf459f3Sfvdl int l_shm_segsz; 433bf459f3Sfvdl linux_time_t l_shm_atime; 443bf459f3Sfvdl linux_time_t l_shm_dtime; 453bf459f3Sfvdl linux_time_t l_shm_ctime; 463bf459f3Sfvdl ushort l_shm_cpid; 473bf459f3Sfvdl ushort l_shm_lpid; 483bf459f3Sfvdl short l_shm_nattch; 493bf459f3Sfvdl ushort l_private1; 503bf459f3Sfvdl void *l_private2; 513bf459f3Sfvdl void *l_private3; 523bf459f3Sfvdl }; 533bf459f3Sfvdl 5465de380aSchristos struct linux_shmid64_ds { 5565de380aSchristos struct linux_ipc64_perm l_shm_perm; 56ff736356Snjoly size_t l_shm_segsz; 5765de380aSchristos linux_time_t l_shm_atime; 58ff736356Snjoly #ifndef _LP64 5965de380aSchristos u_long l____unused1; 60ff736356Snjoly #endif 6165de380aSchristos linux_time_t l_shm_dtime; 62ff736356Snjoly #ifndef _LP64 6365de380aSchristos u_long l____unused2; 64ff736356Snjoly #endif 6565de380aSchristos linux_time_t l_shm_ctime; 66ff736356Snjoly #ifndef _LP64 6765de380aSchristos u_long l____unused3; 68ff736356Snjoly #endif 6965de380aSchristos int l_shm_cpid; 7065de380aSchristos int l_shm_lpid; 7165de380aSchristos u_long l_shm_nattch; 7265de380aSchristos u_long l___unused4; 7365de380aSchristos u_long l___unused5; 7465de380aSchristos }; 7565de380aSchristos 7665de380aSchristos struct linux_shminfo64 { 7765de380aSchristos u_long l_shmmax; 7865de380aSchristos u_long l_shmmin; 7965de380aSchristos u_long l_shmmni; 8065de380aSchristos u_long l_shmseg; 8165de380aSchristos u_long l_shmall; 8265de380aSchristos u_long l___unused1; 8365de380aSchristos u_long l___unused2; 8465de380aSchristos u_long l___unused3; 8565de380aSchristos u_long l___unused4; 8665de380aSchristos }; 8765de380aSchristos 8865de380aSchristos struct linux_shm_info { 8965de380aSchristos int l_used_ids; 9065de380aSchristos u_long l_shm_tot; 9165de380aSchristos u_long l_shm_rss; 9265de380aSchristos u_long l_shm_swp; 9365de380aSchristos u_long l_swap_attempts; 9465de380aSchristos u_long l_swap_successes; 9565de380aSchristos }; 9665de380aSchristos 973bf459f3Sfvdl #define LINUX_SHM_RDONLY 0x1000 983bf459f3Sfvdl #define LINUX_SHM_RND 0x2000 993bf459f3Sfvdl #define LINUX_SHM_REMAP 0x4000 1003bf459f3Sfvdl 1013bf459f3Sfvdl #define LINUX_SHM_LOCK 11 1023bf459f3Sfvdl #define LINUX_SHM_UNLOCK 12 1033bf459f3Sfvdl #define LINUX_SHM_STAT 13 1043bf459f3Sfvdl #define LINUX_SHM_INFO 14 1053bf459f3Sfvdl 106b64f5d3bSerh 107b64f5d3bSerh /* Pretend the sys_shmat and sys_shmctl syscalls are defined */ 108b64f5d3bSerh struct linux_sys_shmat_args { 109b64f5d3bSerh syscallarg(int) shmid; 110b64f5d3bSerh syscallarg(void *) shmaddr; 111b64f5d3bSerh syscallarg(int) shmflg; 112b64f5d3bSerh syscallarg(u_long *) raddr; 113b64f5d3bSerh }; 114b64f5d3bSerh 115b64f5d3bSerh struct linux_sys_shmctl_args { 116b64f5d3bSerh syscallarg(int) shmid; 117b64f5d3bSerh syscallarg(int) cmd; 118b64f5d3bSerh syscallarg(struct linux_shmid_ds *) buf; 119b64f5d3bSerh }; 1207e2790cfSdsl 1217e2790cfSdsl struct linux_sys_shmget_args { 1227e2790cfSdsl syscallarg(key_t) key; 1237e2790cfSdsl syscallarg(size_t) size; 1247e2790cfSdsl syscallarg(int) shmflg; 1257e2790cfSdsl }; 126b64f5d3bSerh 127b64f5d3bSerh #ifdef SYSVSHM 128b64f5d3bSerh #ifdef _KERNEL 129b64f5d3bSerh __BEGIN_DECLS 1307e2790cfSdsl int linux_sys_shmget(struct lwp *, const struct linux_sys_shmget_args *, register_t *); 1317e2790cfSdsl int linux_sys_shmat(struct lwp *, const struct linux_sys_shmat_args *, register_t *); 1327e2790cfSdsl int linux_sys_shmctl(struct lwp *, const struct linux_sys_shmctl_args *, register_t *); 133f2af9174Sdsl void linux_to_bsd_shmid_ds(struct linux_shmid_ds *, 134f2af9174Sdsl struct shmid_ds *); 135f2af9174Sdsl void linux_to_bsd_shmid64_ds(struct linux_shmid64_ds *, 136f2af9174Sdsl struct shmid_ds *); 137f2af9174Sdsl void bsd_to_linux_shmid_ds(struct shmid_ds *, 138f2af9174Sdsl struct linux_shmid_ds *); 139f2af9174Sdsl void bsd_to_linux_shmid64_ds(struct shmid_ds *, 140f2af9174Sdsl struct linux_shmid64_ds *); 141b64f5d3bSerh __END_DECLS 142b64f5d3bSerh #endif /* !_KERNEL */ 143b64f5d3bSerh #endif /* !SYSVSHM */ 144b64f5d3bSerh 145908291d2Schristos #endif /* !_LINUX_SHM_H */ 146