Merge branch 'vendor/LESS'
[dragonfly.git] / sys / sys / shm.h
1 /* $FreeBSD: src/sys/sys/shm.h,v 1.14 1999/12/29 04:24:46 peter Exp $ */
2 /* $DragonFly: src/sys/sys/shm.h,v 1.6 2006/09/30 20:03:44 swildner Exp $ */
3 /*      $NetBSD: shm.h,v 1.15 1994/06/29 06:45:17 cgd Exp $     */
4
5 /*
6  * Copyright (c) 1994 Adam Glass
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by Adam Glass.
20  * 4. The name of the author may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34
35 /*
36  * As defined+described in "X/Open System Interfaces and Headers"
37  *                         Issue 4, p. XXX
38  */
39
40 #ifndef _SYS_SHM_H_
41 #define _SYS_SHM_H_
42
43 #include <sys/ipc.h>
44
45 #define SHM_RDONLY  010000  /* Attach read-only (else read-write) */
46 #define SHM_RND     020000  /* Round attach address to SHMLBA */
47 #define SHMLBA      PAGE_SIZE /* Segment low boundary address multiple */
48
49 /* "official" access mode definitions; somewhat braindead since you have
50    to specify (SHM_* >> 3) for group and (SHM_* >> 6) for world permissions */
51 #define SHM_R       (IPC_R)
52 #define SHM_W       (IPC_W)
53
54
55 struct shmid_ds {
56         struct ipc_perm shm_perm;       /* operation permission structure */
57         int             shm_segsz;      /* size of segment in bytes */
58         pid_t           shm_lpid;   /* process ID of last shared memory op */
59         pid_t           shm_cpid;       /* process ID of creator */
60         short           shm_nattch;     /* number of current attaches */
61         time_t          shm_atime;      /* time of last shmat() */
62         time_t          shm_dtime;      /* time of last shmdt() */
63         time_t          shm_ctime;      /* time of last change by shmctl() */
64         void           *shm_internal;   /* sysv stupidity */
65 };
66
67 #if defined(_KERNEL) || defined(_KERNEL_STRUCTURES)
68
69 /*
70  * System 5 style catch-all structure for shared memory constants that
71  * might be of interest to user programs.  Do we really want/need this?
72  */
73 struct shminfo {
74         int     shmmax,         /* max shared memory segment size (bytes) */
75                 shmmin,         /* min shared memory segment size (bytes) */
76                 shmmni,         /* max number of shared memory identifiers */
77                 shmseg,         /* max shared memory segments per process */
78                 shmall;         /* max amount of shared memory (pages) */
79 };
80
81 #endif
82
83 #ifdef _KERNEL
84
85 extern struct shminfo   shminfo;
86
87 struct proc;
88 struct vmspace;
89
90 void    shmexit (struct vmspace *);
91 void    shmfork (struct proc *, struct proc *);
92
93 #else /* !_KERNEL */
94
95 #include <sys/cdefs.h>
96
97 __BEGIN_DECLS
98 int shmsys (int, ...);
99 void *shmat  (int, void *, int);
100 int shmget (key_t, int, int);
101 int shmctl (int, int, struct shmid_ds *);
102 int shmdt  (void *);
103 __END_DECLS
104
105 #endif /* !_KERNEL */
106
107 #endif /* !_SYS_SHM_H_ */