]> git.ozlabs.org Git - ppp.git/blob - modules/ppp_mod.h
remove extraneous NOTSUSER def
[ppp.git] / modules / ppp_mod.h
1 /*
2  * Miscellaneous definitions for PPP STREAMS modules.
3  */
4
5 /*
6  * Macros for allocating and freeing kernel memory.
7  */
8 #ifdef SVR4                     /* SVR4, including Solaris 2 */
9 #include <sys/kmem.h>
10 #define ALLOC_SLEEP(n)          kmem_alloc((n), KM_SLEEP)
11 #define ALLOC_NOSLEEP(n)        kmem_alloc((n), KM_NOSLEEP)
12 #define FREE(p, n)              kmem_free((p), (n))
13 #endif
14
15 #ifdef SUNOS4
16 #include <sys/kmem_alloc.h>     /* SunOS 4.x */
17 #define ALLOC_SLEEP(n)          kmem_alloc((n), KMEM_SLEEP)
18 #define ALLOC_NOSLEEP(n)        kmem_alloc((n), KMEM_NOSLEEP)
19 #define FREE(p, n)              kmem_free((p), (n))
20 #define NOTSUSER()              (suser()? 0: EPERM)
21 #endif /* SunOS 4 */
22
23 #ifdef __osf__
24 #include <sys/malloc.h>
25
26 /* caution: this mirrors macros in sys/malloc.h, and uses interfaces
27  * which are subject to change.
28  * The problems are that:
29  *     - the official MALLOC macro wants the lhs of the assignment as an argument,
30  *       and it takes care of the assignment itself (yuck.)
31  *     - PPP insists on using "FREE" which conflicts with a macro of the same name.
32  *
33  */
34 #ifdef BUCKETINDX /* V2.0 */
35 #define ALLOC_SLEEP(n)          (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_WAITOK)
36 #define ALLOC_NOSLEEP(n)        (void *)malloc((u_long)(n), BUCKETP(n), M_DEVBUF, M_NOWAIT)
37 #else
38 #define ALLOC_SLEEP(n)          (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_WAITOK)
39 #define ALLOC_NOSLEEP(n)        (void *)malloc((u_long)(n), BUCKETINDEX(n), M_DEVBUF, M_NOWAIT)
40 #endif
41
42 #ifdef FREE
43 #undef FREE
44 #endif
45 #define FREE(p, n)              free((void *)(p), M_DEVBUF)
46
47 #define NO_DLPI 1
48
49 #ifndef IFT_PPP
50 #define IFT_PPP 0x17
51 #endif
52
53 #include <sys/proc.h>
54 #define NOTSUSER()              (suser(u.u_procp->p_rcred, &u.u_acflag) ? EPERM : 0)
55
56 #include "ppp_osf.h"
57
58 #endif /* __osf__ */
59
60 #ifdef AIX4
61 #define ALLOC_SLEEP(n)          xmalloc((n), 0, pinned_heap)    /* AIX V4.x */
62 #define ALLOC_NOSLEEP(n)        xmalloc((n), 0, pinned_heap)    /* AIX V4.x */
63 #define FREE(p, n)              xmfree((p), pinned_heap)
64 #define NOTSUSER()              (suser()? 0: EPERM)
65 #endif /* AIX */
66
67 /*
68  * Macros for printing debugging stuff.
69  */
70 #ifdef DEBUG
71 #if defined(SVR4) || defined(__osf__)
72 #define DPRINT(f)               cmn_err(CE_CONT, f)
73 #define DPRINT1(f, a1)          cmn_err(CE_CONT, f, a1)
74 #define DPRINT2(f, a1, a2)      cmn_err(CE_CONT, f, a1, a2)
75 #define DPRINT3(f, a1, a2, a3)  cmn_err(CE_CONT, f, a1, a2, a3)
76 #else
77 #define DPRINT(f)               printf(f)
78 #define DPRINT1(f, a1)          printf(f, a1)
79 #define DPRINT2(f, a1, a2)      printf(f, a1, a2)
80 #define DPRINT3(f, a1, a2, a3)  printf(f, a1, a2, a3)
81 #endif /* SVR4 */
82
83 #else
84 #define DPRINT(f)               0
85 #define DPRINT1(f, a1)          0
86 #define DPRINT2(f, a1, a2)      0
87 #define DPRINT3(f, a1, a2, a3)  0
88 #endif /* DEBUG */
89
90 #ifndef SVR4
91 typedef unsigned char uchar_t;
92 typedef unsigned short ushort_t;
93 #ifndef __osf__
94 typedef int minor_t;
95 #endif
96 #endif
97
98 /*
99  * If we don't have multithreading support, define substitutes.
100  */
101 #ifndef D_MP
102 # define qprocson(q)
103 # define qprocsoff(q)
104 # define put(q, mp)     ((*(q)->q_qinfo->qi_putp)((q), (mp)))
105 # define canputnext(q)  canput((q)->q_next)
106 # define qwriter(q, mp, func, scope)    (func)((q), (mp))
107 #endif
108
109 #ifdef D_MP
110 /* Use msgpullup if we have other multithreading support. */
111 #define PULLUP(mp, len)                         \
112     do {                                        \
113         mblk_t *np = msgpullup((mp), (len));    \
114         freemsg((mp));                          \
115         mp = np;                                \
116     } while (0)
117
118 #else
119 /* Use pullupmsg if we don't have any multithreading support. */
120 #define PULLUP(mp, len)                 \
121     do {                                \
122         if (!pullupmsg((mp), (len))) {  \
123             freemsg((mp));              \
124             mp = 0;                     \
125         }                               \
126     } while (0)
127 #endif
128
129 /*
130  * How to declare the open and close procedures for a module.
131  */
132 #ifdef SVR4
133 #define MOD_OPEN_DECL(name)     \
134 static int name __P((queue_t *, dev_t *, int, int, cred_t *))
135
136 #define MOD_CLOSE_DECL(name)    \
137 static int name __P((queue_t *, int, cred_t *))
138
139 #define MOD_OPEN(name)                          \
140 static int name(q, devp, flag, sflag, credp)    \
141     queue_t *q;                                 \
142     dev_t *devp;                                \
143     int flag, sflag;                            \
144     cred_t *credp;
145
146 #define MOD_CLOSE(name)         \
147 static int name(q, flag, credp) \
148     queue_t *q;                 \
149     int flag;                   \
150     cred_t *credp;
151
152 #define OPEN_ERROR(x)           return (x)
153 #define DRV_OPEN_OK(dev)        return 0
154
155 #define NOTSUSER()              (drv_priv(credp))
156
157 #else   /* not SVR4 */
158 #define MOD_OPEN_DECL(name)     \
159 static int name __P((queue_t *, int, int, int))
160
161 #define MOD_CLOSE_DECL(name)    \
162 static int name __P((queue_t *, int))
163
164 #define MOD_OPEN(name)          \
165 static int name(q, dev, flag, sflag)    \
166     queue_t *q;                         \
167     int dev;                            \
168     int flag, sflag;
169
170 #define MOD_CLOSE(name)         \
171 static int name(q, flag)        \
172     queue_t *q;                 \
173     int flag;
174
175 #define OPEN_ERROR(x)           { u.u_error = (x); return OPENFAIL; }
176 #define DRV_OPEN_OK(dev)        return (dev)
177
178 #endif  /* SVR4 */