Home | History | Annotate | Line # | Download | only in common
linux_shm.h revision 1.10
      1 /*	$NetBSD: linux_shm.h,v 1.10 2007/12/20 23:02:56 dsl 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 struct linux_sys_shmat_args {
    110 	syscallarg(int) shmid;
    111 	syscallarg(void *) shmaddr;
    112 	syscallarg(int) shmflg;
    113 	syscallarg(u_long *) raddr;
    114 };
    115 
    116 struct linux_sys_shmctl_args {
    117 	syscallarg(int) shmid;
    118 	syscallarg(int) cmd;
    119 	syscallarg(struct linux_shmid_ds *) buf;
    120 };
    121 
    122 struct linux_sys_shmget_args {
    123 	syscallarg(key_t) key;
    124 	syscallarg(size_t) size;
    125 	syscallarg(int) shmflg;
    126 };
    127 
    128 #ifdef SYSVSHM
    129 #ifdef _KERNEL
    130 __BEGIN_DECLS
    131 int linux_sys_shmget(struct lwp *, const struct linux_sys_shmget_args *, register_t *);
    132 int linux_sys_shmat(struct lwp *, const struct linux_sys_shmat_args *, register_t *);
    133 int linux_sys_shmctl(struct lwp *, const struct linux_sys_shmctl_args *, register_t *);
    134 void linux_to_bsd_shmid_ds(struct linux_shmid_ds *,
    135     struct shmid_ds *);
    136 void linux_to_bsd_shmid64_ds(struct linux_shmid64_ds *,
    137     struct shmid_ds *);
    138 void bsd_to_linux_shmid_ds(struct shmid_ds *,
    139     struct linux_shmid_ds *);
    140 void bsd_to_linux_shmid64_ds(struct shmid_ds *,
    141     struct linux_shmid64_ds *);
    142 __END_DECLS
    143 #endif	/* !_KERNEL */
    144 #endif	/* !SYSVSHM */
    145 
    146 #endif /* !_LINUX_SHM_H */
    147