2 * Miscellaneous definitions for PPP STREAMS modules.
5 #if defined(osf) || defined(__osf__)
10 * Macros for allocating and freeing kernel memory.
12 #ifdef SVR4 /* SVR4, including Solaris 2 */
14 #define ALLOC_SLEEP(n) kmem_alloc((n), KM_SLEEP)
15 #define ALLOC_NOSLEEP(n) kmem_alloc((n), KM_NOSLEEP)
16 #define FREE(p, n) kmem_free((p), (n))
20 #include <sys/kmem_alloc.h> /* SunOS 4.x */
21 #define ALLOC_SLEEP(n) kmem_alloc((n), KMEM_SLEEP)
22 #define ALLOC_NOSLEEP(n) kmem_alloc((n), KMEM_NOSLEEP)
23 #define FREE(p, n) kmem_free((p), (n))
27 #include <kern/kalloc.h> /* OSF/1 */
29 #define ALLOC_SLEEP(n) kalloc((n))
30 #define ALLOC_NOSLEEP(n) kalloc((n))
31 #define FREE(p, n) kfree((p), (n))
35 #define ALLOC_SLEEP(n) xmalloc((n), 0, pinned_heap) /* AIX V4.x */
36 #define ALLOC_NOSLEEP(n) xmalloc((n), 0, pinned_heap) /* AIX V4.x */
37 #define FREE(p, n) xmfree((p), pinned_heap)
41 * Macros for printing debugging stuff.
45 #define DPRINT(f) cmn_err(CE_CONT, f)
46 #define DPRINT1(f, a1) cmn_err(CE_CONT, f, a1)
47 #define DPRINT2(f, a1, a2) cmn_err(CE_CONT, f, a1, a2)
48 #define DPRINT3(f, a1, a2, a3) cmn_err(CE_CONT, f, a1, a2, a3)
50 #define DPRINT(f) printf(f)
51 #define DPRINT1(f, a1) printf(f, a1)
52 #define DPRINT2(f, a1, a2) printf(f, a1, a2)
53 #define DPRINT3(f, a1, a2, a3) printf(f, a1, a2, a3)
58 #define DPRINT1(f, a1) 0
59 #define DPRINT2(f, a1, a2) 0
60 #define DPRINT3(f, a1, a2, a3) 0
64 typedef unsigned char uchar_t;
65 typedef unsigned short ushort_t;
70 * If we don't have multithreading support, define substitutes.
75 # define put(q, mp) ((*(q)->q_qinfo->qi_putp)((q), (mp)))
76 # define canputnext(q) canput((q)->q_next)
77 # define qwriter(q, mp, func, scope) (func)((q), (mp))
81 /* Use msgpullup if we have other multithreading support. */
82 #define PULLUP(mp, len) \
84 mblk_t *np = msgpullup((mp), (len)); \
90 /* Use pullupmsg if we don't have any multithreading support. */
91 #define PULLUP(mp, len) \
93 if (!pullupmsg((mp), (len))) { \
101 * How to declare the open and close procedures for a module.
104 #define MOD_OPEN_DECL(name) \
105 static int name __P((queue_t *, dev_t *, int, int, cred_t *))
107 #define MOD_CLOSE_DECL(name) \
108 static int name __P((queue_t *, int, cred_t *))
110 #define MOD_OPEN(name) \
111 static int name(q, devp, flag, sflag, credp) \
117 #define MOD_CLOSE(name) \
118 static int name(q, flag, credp) \
123 #define OPEN_ERROR(x) return (x)
124 #define DRV_OPEN_OK(dev) return 0
126 #define NOTSUSER() (drv_priv(credp))
129 #define MOD_OPEN_DECL(name) \
130 static int name __P((queue_t *, int, int, int))
132 #define MOD_CLOSE_DECL(name) \
133 static int name __P((queue_t *, int))
135 #define MOD_OPEN(name) \
136 static int name(q, dev, flag, sflag) \
141 #define MOD_CLOSE(name) \
142 static int name(q, flag) \
146 #define OPEN_ERROR(x) { u.u_error = (x); return OPENFAIL; }
147 #define DRV_OPEN_OK(dev) return (dev)
150 #include <sys/proc.h>
151 #define NOTSUSER() (suser(u.u_procp->p_rcred, &u.u_acflag))
153 #define NOTSUSER() (suser()? 0: EPERM)