1 /* $NetBSD: linux_shm.h,v 1.8 2006/02/09 19:18:56 manu Exp $ */ 2 3 /*- 4 * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Frank van der Linden and Eric Haszlakiewicz. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef _LINUX_SHM_H 40 #define _LINUX_SHM_H 41 42 #include <sys/shm.h> 43 44 /* 45 * shm segment control structure 46 */ 47 struct linux_shmid_ds { 48 struct linux_ipc_perm l_shm_perm; 49 int l_shm_segsz; 50 linux_time_t l_shm_atime; 51 linux_time_t l_shm_dtime; 52 linux_time_t l_shm_ctime; 53 ushort l_shm_cpid; 54 ushort l_shm_lpid; 55 short l_shm_nattch; 56 ushort l_private1; 57 void *l_private2; 58 void *l_private3; 59 }; 60 61 struct linux_shmid64_ds { 62 struct linux_ipc64_perm l_shm_perm; 63 uint l_shm_segsz; 64 linux_time_t l_shm_atime; 65 u_long l____unused1; 66 linux_time_t l_shm_dtime; 67 u_long l____unused2; 68 linux_time_t l_shm_ctime; 69 u_long l____unused3; 70 int l_shm_cpid; 71 int l_shm_lpid; 72 u_long l_shm_nattch; 73 u_long l___unused4; 74 u_long l___unused5; 75 }; 76 77 struct linux_shminfo64 { 78 u_long l_shmmax; 79 u_long l_shmmin; 80 u_long l_shmmni; 81 u_long l_shmseg; 82 u_long l_shmall; 83 u_long l___unused1; 84 u_long l___unused2; 85 u_long l___unused3; 86 u_long l___unused4; 87 }; 88 89 struct linux_shm_info { 90 int l_used_ids; 91 u_long l_shm_tot; 92 u_long l_shm_rss; 93 u_long l_shm_swp; 94 u_long l_swap_attempts; 95 u_long l_swap_successes; 96 }; 97 98 #define LINUX_SHM_RDONLY 0x1000 99 #define LINUX_SHM_RND 0x2000 100 #define LINUX_SHM_REMAP 0x4000 101 102 #define LINUX_SHM_LOCK 11 103 #define LINUX_SHM_UNLOCK 12 104 #define LINUX_SHM_STAT 13 105 #define LINUX_SHM_INFO 14 106 107 108 /* Pretend the sys_shmat and sys_shmctl syscalls are defined */ 109 #ifndef __amd64__ 110 struct linux_sys_shmat_args { 111 syscallarg(int) shmid; 112 syscallarg(void *) shmaddr; 113 syscallarg(int) shmflg; 114 syscallarg(u_long *) raddr; 115 }; 116 117 struct linux_sys_shmctl_args { 118 syscallarg(int) shmid; 119 syscallarg(int) cmd; 120 syscallarg(struct linux_shmid_ds *) buf; 121 }; 122 #endif 123 124 #ifdef SYSVSHM 125 #ifdef _KERNEL 126 __BEGIN_DECLS 127 int linux_sys_shmget __P((struct lwp *, void *, register_t *)); 128 int linux_sys_shmat __P((struct lwp *, void *, register_t *)); 129 int linux_sys_shmctl __P((struct lwp *, void *, register_t *)); 130 void linux_to_bsd_shmid_ds __P((struct linux_shmid_ds *, 131 struct shmid_ds *)); 132 void linux_to_bsd_shmid64_ds __P((struct linux_shmid64_ds *, 133 struct shmid_ds *)); 134 void bsd_to_linux_shmid_ds __P((struct shmid_ds *, 135 struct linux_shmid_ds *)); 136 void bsd_to_linux_shmid64_ds __P((struct shmid_ds *, 137 struct linux_shmid64_ds *)); 138 __END_DECLS 139 #endif /* !_KERNEL */ 140 #endif /* !SYSVSHM */ 141 142 #endif /* !_LINUX_SHM_H */ 143