]> git.ozlabs.org Git - ppp.git/blob - modules/ppp_mod.h
added buflen arg to vj_uncompress_uncomp
[ppp.git] / modules / ppp_mod.h
1 /*
2  * Miscellaneous definitions for PPP STREAMS modules.
3  */
4
5 #if defined(osf) || defined(__osf__)
6 #define OSF1
7 #endif
8
9 /*
10  * Macros for allocating and freeing kernel memory.
11  */
12 #ifdef SVR4                     /* SVR4, including Solaris 2 */
13 #include <sys/kmem.h>
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))
17 #endif
18
19 #ifdef SUNOS4
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))
24 #endif /* SunOS 4 */
25
26 #ifdef OSF1
27 #include <kern/kalloc.h>        /* OSF/1 */
28 #undef FREE
29 #define ALLOC_SLEEP(n)          kalloc((n))
30 #define ALLOC_NOSLEEP(n)        kalloc((n))
31 #define FREE(p, n)              kfree((p), (n))
32 #endif /* OSF/1 */
33
34 #ifdef AIX4
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)
38 #endif /* AIX */
39
40 /*
41  * Macros for printing debugging stuff.
42  */
43 #ifdef DEBUG
44 #ifdef SVR4
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)
49 #else
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)
54 #endif /* SVR4 */
55
56 #else
57 #define DPRINT(f)               0
58 #define DPRINT1(f, a1)          0
59 #define DPRINT2(f, a1, a2)      0
60 #define DPRINT3(f, a1, a2, a3)  0
61 #endif /* DEBUG */
62
63 #ifndef SVR4
64 typedef unsigned char uchar_t;
65 typedef unsigned short ushort_t;
66 typedef int minor_t;
67 #endif
68
69 /*
70  * If we don't have multithreading support, define substitutes.
71  */
72 #ifndef D_MP
73 # define qprocson(q)
74 # define qprocsoff(q)
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))
78 #endif
79
80 #ifdef D_MP
81 /* Use msgpullup if we have other multithreading support. */
82 #define PULLUP(mp, len)                         \
83     do {                                        \
84         mblk_t *np = msgpullup((mp), (len));    \
85         freemsg((mp));                          \
86         mp = np;                                \
87     } while (0)
88
89 #else
90 /* Use pullupmsg if we don't have any multithreading support. */
91 #define PULLUP(mp, len)                 \
92     do {                                \
93         if (!pullupmsg((mp), (len))) {  \
94             freemsg((mp));              \
95             mp = 0;                     \
96         }                               \
97     } while (0)
98 #endif
99
100 /*
101  * How to declare the open and close procedures for a module.
102  */
103 #ifdef SVR4
104 #define MOD_OPEN_DECL(name)     \
105 static int name __P((queue_t *, dev_t *, int, int, cred_t *))
106
107 #define MOD_CLOSE_DECL(name)    \
108 static int name __P((queue_t *, int, cred_t *))
109
110 #define MOD_OPEN(name)                          \
111 static int name(q, devp, flag, sflag, credp)    \
112     queue_t *q;                                 \
113     dev_t *devp;                                \
114     int flag, sflag;                            \
115     cred_t *credp;
116
117 #define MOD_CLOSE(name)         \
118 static int name(q, flag, credp) \
119     queue_t *q;                 \
120     int flag;                   \
121     cred_t *credp;
122
123 #define OPEN_ERROR(x)           return (x)
124 #define DRV_OPEN_OK(dev)        return 0
125
126 #define NOTSUSER()              (drv_priv(credp))
127
128 #else   /* not SVR4 */
129 #define MOD_OPEN_DECL(name)     \
130 static int name __P((queue_t *, int, int, int))
131
132 #define MOD_CLOSE_DECL(name)    \
133 static int name __P((queue_t *, int))
134
135 #define MOD_OPEN(name)          \
136 static int name(q, dev, flag, sflag)    \
137     queue_t *q;                         \
138     int dev;                            \
139     int flag, sflag;
140
141 #define MOD_CLOSE(name)         \
142 static int name(q, flag)        \
143     queue_t *q;                 \
144     int flag;
145
146 #define OPEN_ERROR(x)           { u.u_error = (x); return OPENFAIL; }
147 #define DRV_OPEN_OK(dev)        return (dev)
148
149 #ifdef OSF1
150 #include <sys/proc.h>
151 #define NOTSUSER()      (suser(u.u_procp->p_rcred, &u.u_acflag))
152 #else
153 #define NOTSUSER()      (suser()? 0: EPERM)
154 #endif
155
156 #endif  /* SVR4 */