]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/ipc.h
Implement pci_enable_msi() and pci_disable_msi() in the LinuxKPI.
[FreeBSD/FreeBSD.git] / sys / sys / ipc.h
1 /*-
2  * SPDX-License-Identifier: BSD-3-Clause
3  *
4  * Copyright (c) 1988 University of Utah.
5  * Copyright (c) 1990, 1993
6  *      The Regents of the University of California.  All rights reserved.
7  * (c) UNIX System Laboratories, Inc.
8  * All or some portions of this file are derived from material licensed
9  * to the University of California by American Telephone and Telegraph
10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11  * the permission of UNIX System Laboratories, Inc.
12  *
13  * This code is derived from software contributed to Berkeley by
14  * the Systems Programming Group of the University of Utah Computer
15  * Science Department.
16  *
17  * Redistribution and use in source and binary forms, with or without
18  * modification, are permitted provided that the following conditions
19  * are met:
20  * 1. Redistributions of source code must retain the above copyright
21  *    notice, this list of conditions and the following disclaimer.
22  * 2. Redistributions in binary form must reproduce the above copyright
23  *    notice, this list of conditions and the following disclaimer in the
24  *    documentation and/or other materials provided with the distribution.
25  * 3. Neither the name of the University nor the names of its contributors
26  *    may be used to endorse or promote products derived from this software
27  *    without specific prior written permission.
28  *
29  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
30  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
31  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
32  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
34  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
35  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
36  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
37  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
38  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39  * SUCH DAMAGE.
40  *
41  *      @(#)ipc.h       8.4 (Berkeley) 2/19/95
42  * $FreeBSD$
43  */
44
45 /*
46  * SVID compatible ipc.h file
47  */
48 #ifndef _SYS_IPC_H_
49 #define _SYS_IPC_H_
50
51 #include <sys/cdefs.h>
52 #include <sys/_types.h>
53
54 #ifndef _GID_T_DECLARED
55 typedef __gid_t         gid_t;
56 #define _GID_T_DECLARED
57 #endif
58
59 #ifndef _KEY_T_DECLARED
60 typedef __key_t         key_t;
61 #define _KEY_T_DECLARED
62 #endif
63
64 #ifndef _MODE_T_DECLARED
65 typedef __mode_t        mode_t;
66 #define _MODE_T_DECLARED
67 #endif
68
69 #ifndef _UID_T_DECLARED
70 typedef __uid_t         uid_t;
71 #define _UID_T_DECLARED
72 #endif
73
74 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
75     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7) || \
76     defined(COMPAT_43)
77 struct ipc_perm_old {
78         unsigned short  cuid;   /* creator user id */
79         unsigned short  cgid;   /* creator group id */
80         unsigned short  uid;    /* user id */
81         unsigned short  gid;    /* group id */
82         unsigned short  mode;   /* r/w permission */
83         unsigned short  seq;    /* sequence # (to generate unique ipcid) */
84         key_t           key;    /* user specified msg/sem/shm key */
85 };
86 #endif
87
88 struct ipc_perm {
89         uid_t           cuid;   /* creator user id */
90         gid_t           cgid;   /* creator group id */
91         uid_t           uid;    /* user id */
92         gid_t           gid;    /* group id */
93         mode_t          mode;   /* r/w permission */
94         unsigned short  seq;    /* sequence # (to generate unique ipcid) */
95         key_t           key;    /* user specified msg/sem/shm key */
96 };
97
98 #if __BSD_VISIBLE
99 /* common mode bits */
100 #define IPC_R           000400  /* read permission */
101 #define IPC_W           000200  /* write/alter permission */
102 #define IPC_M           010000  /* permission to change control info */
103 #endif
104
105 /* SVID required constants (same values as system 5) */
106 #define IPC_CREAT       001000  /* create entry if key does not exist */
107 #define IPC_EXCL        002000  /* fail if key exists */
108 #define IPC_NOWAIT      004000  /* error if request must wait */
109
110 #define IPC_PRIVATE     (key_t)0 /* private key */
111
112 #define IPC_RMID        0       /* remove identifier */
113 #define IPC_SET         1       /* set options */
114 #define IPC_STAT        2       /* get options */
115 #if __BSD_VISIBLE
116 /*
117  * For Linux compatibility.
118  */
119 #define IPC_INFO        3       /* get info */
120 #endif
121
122 #if defined(_KERNEL) || defined(_WANT_SYSVIPC_INTERNALS)
123 /* Macros to convert between ipc ids and array indices or sequence ids */
124 #define IPCID_TO_IX(id)         ((id) & 0xffff)
125 #define IPCID_TO_SEQ(id)        (((id) >> 16) & 0xffff)
126 #define IXSEQ_TO_IPCID(ix,perm) (((perm.seq) << 16) | (ix & 0xffff))
127 #endif
128
129 #ifdef _KERNEL
130 struct thread;
131 struct proc;
132 struct vmspace;
133
134 #if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
135     defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
136 void    ipcperm_old2new(struct ipc_perm_old *, struct ipc_perm *);
137 void    ipcperm_new2old(struct ipc_perm *, struct ipc_perm_old *);
138 #endif
139
140 int     ipcperm(struct thread *, struct ipc_perm *, int);
141 extern void (*shmfork_hook)(struct proc *, struct proc *);
142 extern void (*shmexit_hook)(struct vmspace *);
143
144 #else /* ! _KERNEL */
145
146 __BEGIN_DECLS
147 key_t   ftok(const char *, int);
148 __END_DECLS
149
150 #endif /* _KERNEL */
151
152 #endif /* !_SYS_IPC_H_ */