Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / sys / netproto / atm / port.h
1 /*
2  *
3  * ===================================
4  * HARP  |  Host ATM Research Platform
5  * ===================================
6  *
7  *
8  * This Host ATM Research Platform ("HARP") file (the "Software") is
9  * made available by Network Computing Services, Inc. ("NetworkCS")
10  * "AS IS".  NetworkCS does not provide maintenance, improvements or
11  * support of any kind.
12  *
13  * NETWORKCS MAKES NO WARRANTIES OR REPRESENTATIONS, EXPRESS OR IMPLIED,
14  * INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
15  * AND FITNESS FOR A PARTICULAR PURPOSE, AS TO ANY ELEMENT OF THE
16  * SOFTWARE OR ANY SUPPORT PROVIDED IN CONNECTION WITH THIS SOFTWARE.
17  * In no event shall NetworkCS be responsible for any damages, including
18  * but not limited to consequential damages, arising from or relating to
19  * any use of the Software or related support.
20  *
21  * Copyright 1994-1998 Network Computing Services, Inc.
22  *
23  * Copies of this Software may be made, however, the above copyright
24  * notice must be reproduced on all copies.
25  *
26  *      @(#) $FreeBSD: src/sys/netatm/port.h,v 1.2.2.2 2003/01/23 21:06:44 sam Exp $
27  *      @(#) $DragonFly: src/sys/netproto/atm/port.h,v 1.2 2003/06/17 04:28:49 dillon Exp $
28  *
29  */
30
31 /*
32  * System Configuration
33  * --------------------
34  *
35  * Porting aides
36  *
37  */
38
39 #ifndef _NETATM_PORT_H
40 #define _NETATM_PORT_H
41
42 /*
43  * Try to ensure that this system is supported
44  */
45 #if (defined(BSD) && (BSD >= 199103))
46
47         /* 4.3 BSD Net2 based */
48
49 #elif defined(sun)
50
51         /* SunOS4.x */
52
53 #else
54
55         /* Ooops */
56         #error "Undefined/unsupported system type"
57
58 #endif
59
60
61 /*
62  * Kernel memory management
63  *
64  * KM_ALLOC(size, type, flags)
65  *                      Returns an allocated kernel memory chunk of size bytes.
66  * KM_FREE(addr, size, type)
67  *                      Free a kernel memory chunk of size bytes.
68  * KM_CMP(b1, b2, len)
69  *                      Compares len bytes of data from b1 against b2.
70  * KM_COPY(from, to, len)
71  *                      Copies len bytes of data from from to to.
72  * KM_ZERO(addr, len)
73  *                      Zeros len bytes of data from addr.
74  *
75  */
76 #ifdef ATM_KERNEL
77 #if (defined(BSD) && (BSD >= 199103))
78 #include <sys/malloc.h>
79 #define KM_ALLOC(size, type, flags)     malloc((size), (type), (flags))
80 #define KM_FREE(addr, size, type)       free((addr), (type))
81 #elif defined(sun)
82 #include <sys/kmem_alloc.h>
83 #define KM_ALLOC(size, type, flags)     kmem_alloc(size)
84 #define KM_FREE(addr, size, type)       kmem_free((addr), (size))
85 #endif
86
87 #if defined(BSD)
88 #define KM_CMP(b1, b2, len)             bcmp((void *)(b1), (void *)(b2),\
89                                                 (len))
90 #define KM_COPY(from, to, len)          bcopy((void *)(from), (void *)(to),\
91                                                 (len))
92 #define KM_ZERO(addr, len)              bzero((void *)(addr), (len))
93 #endif
94 #define XM_COPY(f, t, l)        KM_COPY((f), (t), (l))
95
96 #else
97
98 /*
99  * User-space memory management
100  *
101  * UM_ALLOC(size)       Returns an allocated kernel memory chunk of size bytes.
102  * UM_FREE(addr)        Free a kernel memory chunk of size bytes.
103  * UM_COPY(from, to, len)
104  *                      Copies len bytes of data from from to to.
105  * UM_ZERO(addr, len)   Zeros len bytes of data from addr.
106  *
107  */
108 #if (defined(BSD) && (BSD >= 199103))
109 #define UM_ALLOC(size)          malloc((size_t)(size))
110 #define UM_FREE(addr)           free((void *)(addr))
111 #define UM_COPY(from, to, len)  bcopy((void *)(from), (void *)(to),\
112                                                 (size_t)(len))
113 #define UM_ZERO(addr, len)      bzero((void *)(addr), (size_t)(len))
114 #elif defined(sun)
115 #define UM_ALLOC(size)          malloc(size)
116 #define UM_FREE(addr)           free((char *)(addr))
117 #define UM_COPY(from, to, len)  bcopy((char *)(from), (char *)(to), (len))
118 #define UM_ZERO(addr, len)      bzero((char *)(addr), (len))
119
120 #endif
121 #define XM_COPY(f, t, l)        UM_COPY((f), (t), (l))
122
123 #endif  /* ATM_KERNEL */
124
125
126 #ifdef ATM_KERNEL
127 /*
128  * Kernel buffers
129  *
130  * KBuffer              Typedef for a kernel buffer.
131  *
132  * KB_NEXT(bfr)         Access next buffer in chain (r/w).
133  * KB_LEN(bfr)          Access length of data in this buffer (r/w).
134  * KB_QNEXT(bfr)        Access next buffer in queue (r/w).
135  *
136  * KB_ALLOC(bfr, size, flags, type)
137  *                      Allocates a new kernel buffer of at least size bytes.
138  * KB_ALLOCPKT(bfr, size, flags, type)
139  *                      Allocates a new kernel packet header buffer of at
140  *                      least size bytes.
141  * KB_ALLOCEXT(bfr, size, flags, type)
142  *                      Allocates a new kernel buffer with external storage
143  *                      of at least size bytes.
144  * KB_FREEONE(bfr, nxt) Free buffer bfr and set next buffer in chain in nxt.
145  * KB_FREEALL(bfr)      Free bfr's entire buffer chain.
146  * KB_COPY(bfr, off, len, new, flags)
147  *                      Copy len bytes of user data from buffer bfr starting at
148  *                      byte offset off and return new buffer chain in new.
149  *                      If len is KB_COPYALL, copy until end of chain.
150  * KB_COPYDATA(bfr, off, len, datap)
151  *                      Copy data from buffer bfr starting at byte offset off
152  *                      for len bytes into the data area pointed to by datap.
153  *                      Returns the number of bytes not copied to datap.
154  * KB_PULLUP(bfr, n, new)
155  *                      Get at least the first n bytes of data in the buffer 
156  *                      chain headed by bfr contiguous in the first buffer.
157  *                      Returns the (potentially new) head of the chain in new.
158  *                      On failure the chain is freed and NULL is returned.
159  * KB_LINKHEAD(new, head)
160  *                      Link the kernel buffer new at the head of the buffer
161  *                      chain headed by head.  If both new and head are
162  *                      packet header buffers, new will become the packet
163  *                      header for the chain.
164  * KB_LINK(new, prev)
165  *                      Link the kernel buffer new into the buffer chain
166  *                      after the buffer prev.
167  * KB_UNLINKHEAD(head, next)
168  *                      Unlink the kernel buffer from the head of the buffer
169  *                      chain headed by head.  The buffer head will be freed
170  *                      and the new chain head will be placed in next.
171  * KB_UNLINK(old, prev, next)
172  *                      Unlink the kernel buffer old with previous buffer prev
173  *                      from its buffer chain.  The following buffer in the
174  *                      chain will be placed in next and the buffer old will
175  *                      be freed.
176  * KB_ISPKT(bfr)        Tests whether bfr is a packet header buffer.
177  * KB_ISEXT(bfr)        Tests whether bfr has external storage.
178  * KB_BFRSTART(bfr, x, t)
179  *                      Sets x (cast to type t) to point to the start of the
180  *                      buffer space in bfr.
181  * KB_BFREND(bfr, x, t)
182  *                      Sets x (cast to type t) to point one byte past the end
183  *                      of the buffer space in bfr.
184  * KB_BFRLEN(bfr)       Returns length of buffer space in bfr.
185  * KB_DATASTART(bfr, x, t)
186  *                      Sets x (cast to type t) to point to the start of the
187  *                      buffer data contained in bfr.
188  * KB_DATAEND(bfr, x, t)
189  *                      Sets x (cast to type t) to point one byte past the end
190  *                      of the buffer data contained in bfr.
191  * KB_HEADSET(bfr, n)   Sets the start address for buffer data in buffer bfr to
192  *                      n bytes from the beginning of the buffer space.
193  * KB_HEADMOVE(bfr, n)  Adjust buffer data controls to move data down (n > 0) 
194  *                      or up (n < 0) n bytes in the buffer bfr.
195  * KB_HEADADJ(bfr, n)   Adjust buffer data controls to add (n > 0) or subtract
196  *                      (n < 0) n bytes of data to/from the beginning of bfr.
197  * KB_TAILADJ(bfr, n)   Adjust buffer data controls to add (n > 0) or subtract
198  *                      (n < 0) n bytes of data to/from the end of bfr.
199  * KB_TAILALIGN(bfr, n) Set buffer data controls to place an object of size n
200  *                      at the end of bfr, longword aligned.
201  * KB_HEADROOM(bfr, n)  Set n to the amount of buffer space available before
202  *                      the start of data in bfr.
203  * KB_TAILROOM(bfr, n)  Set n to the amount of buffer space available after
204  *                      the end of data in bfr.
205  * KB_PLENGET(bfr, n)   Set n to bfr's packet length.
206  * KB_PLENSET(bfr, n)   Set bfr's packet length to n.
207  * KB_PLENADJ(bfr, n)   Adjust total packet length by n bytes.
208  *
209  */
210 #if defined(BSD)
211 #include <sys/mbuf.h>
212 typedef struct mbuf     KBuffer;
213
214 #define KB_F_WAIT       M_WAIT
215 #define KB_F_NOWAIT     M_DONTWAIT
216
217 #define KB_T_HEADER     MT_HEADER
218 #define KB_T_DATA       MT_DATA
219
220 #define KB_COPYALL      M_COPYALL
221
222 #if BSD >= 199103
223
224 #define KB_NEXT(bfr)            (bfr)->m_next
225 #define KB_LEN(bfr)             (bfr)->m_len
226 #define KB_QNEXT(bfr)           (bfr)->m_nextpkt
227 #define KB_ALLOC(bfr, size, flags, type) {              \
228         if ((size) <= MLEN) {                           \
229                 MGET((bfr), (flags), (type));           \
230         } else                                          \
231                 (bfr) = NULL;                           \
232 }
233 #define KB_ALLOCPKT(bfr, size, flags, type) {           \
234         if ((size) <= MHLEN) {                          \
235                 MGETHDR((bfr), (flags), (type));        \
236         } else                                          \
237                 (bfr) = NULL;                           \
238 }
239 #define KB_ALLOCEXT(bfr, size, flags, type) {           \
240         if ((size) <= MCLBYTES) {                       \
241                 MGET((bfr), (flags), (type));           \
242                 if ((bfr) != NULL) {                    \
243                         MCLGET((bfr), (flags));         \
244                         if (((bfr)->m_flags & M_EXT) == 0) {    \
245                                 m_freem((bfr));         \
246                                 (bfr) = NULL;           \
247                         }                               \
248                 }                                       \
249         } else                                          \
250                 (bfr) = NULL;                           \
251 }
252 #define KB_FREEONE(bfr, nxt) {                          \
253         (nxt) = m_free(bfr);                            \
254 }
255 #define KB_FREEALL(bfr) {                               \
256         m_freem(bfr);                                   \
257 }
258 #define KB_COPY(bfr, off, len, new, flags) {            \
259         (new) = m_copym((bfr), (off), (len), (flags));  \
260 }
261 #define KB_COPYDATA(bfr, off, len, datap)               \
262         (m_copydata((bfr), (off), (len), (datap)), 0)
263 #define KB_PULLUP(bfr, n, new) {                        \
264         (new) = m_pullup((bfr), (n));                   \
265 }
266 #define KB_LINKHEAD(new, head) {                        \
267         if ((head) && KB_ISPKT(new) && KB_ISPKT(head)) {\
268                 M_MOVE_PKTHDR((new), (head));           \
269         }                                               \
270         (new)->m_next = (head);                         \
271 }
272 #define KB_LINK(new, prev) {                            \
273         (new)->m_next = (prev)->m_next;                 \
274         (prev)->m_next = (new);                         \
275 }
276 #define KB_UNLINKHEAD(head, next) {                     \
277         next = m_free((head));                          \
278 }
279 #define KB_UNLINK(old, prev, next) {                    \
280         next = m_free((old));                           \
281         (prev)->m_next = (next);                        \
282 }
283 #define KB_ISPKT(bfr)           (((bfr)->m_flags & M_PKTHDR) != 0)
284 #define KB_ISEXT(bfr)           (((bfr)->m_flags & M_EXT) != 0)
285 #define KB_BFRSTART(bfr, x, t) {                        \
286         if ((bfr)->m_flags & M_EXT)                     \
287                 (x) = (t)((bfr)->m_ext.ext_buf);        \
288         else if ((bfr)->m_flags & M_PKTHDR)             \
289                 (x) = (t)(&(bfr)->m_pktdat);            \
290         else                                            \
291                 (x) = (t)((bfr)->m_dat);                \
292 }
293 #define KB_BFREND(bfr, x, t) {                          \
294         if ((bfr)->m_flags & M_EXT)                     \
295                 (x) = (t)((bfr)->m_ext.ext_buf + (bfr)->m_ext.ext_size);\
296         else if ((bfr)->m_flags & M_PKTHDR)             \
297                 (x) = (t)(&(bfr)->m_pktdat + MHLEN);    \
298         else                                            \
299                 (x) = (t)((bfr)->m_dat + MLEN);         \
300 }
301 #define KB_BFRLEN(bfr)                                  \
302         (((bfr)->m_flags & M_EXT) ? (bfr)->m_ext.ext_size :     \
303                 (((bfr)->m_flags & M_PKTHDR) ? MHLEN : MLEN))
304 #define KB_DATASTART(bfr, x, t) {                       \
305         (x) = mtod((bfr), t);                           \
306 }
307 #define KB_DATAEND(bfr, x, t) {                         \
308         (x) = (t)(mtod((bfr), caddr_t) + (bfr)->m_len); \
309 }
310 #define KB_HEADSET(bfr, n) {                            \
311         if ((bfr)->m_flags & M_EXT)                     \
312                 (bfr)->m_data = (bfr)->m_ext.ext_buf + (n);     \
313         else if ((bfr)->m_flags & M_PKTHDR)             \
314                 (bfr)->m_data = (bfr)->m_pktdat + (n);  \
315         else                                            \
316                 (bfr)->m_data = (bfr)->m_dat + (n);     \
317 }
318 #define KB_HEADMOVE(bfr, n) {                           \
319         (bfr)->m_data += (n);                           \
320 }
321 #define KB_HEADADJ(bfr, n) {                            \
322         (bfr)->m_len += (n);                            \
323         (bfr)->m_data -= (n);                           \
324 }
325 #define KB_TAILADJ(bfr, n) {                            \
326         (bfr)->m_len += (n);                            \
327 }
328 #define KB_TAILALIGN(bfr, n) {                          \
329         (bfr)->m_len = (n);                             \
330         if ((bfr)->m_flags & M_EXT)                     \
331                 (bfr)->m_data = (caddr_t)(((u_int)(bfr)->m_ext.ext_buf  \
332                         + (bfr)->m_ext.ext_size - (n)) & ~(sizeof(long) - 1));\
333         else                                            \
334                 (bfr)->m_data = (caddr_t)(((u_int)(bfr)->m_dat + MLEN - (n)) \
335                         & ~(sizeof(long) - 1));         \
336 }
337 #define KB_HEADROOM(bfr, n) {                           \
338         /* n = M_LEADINGSPACE(bfr) XXX */               \
339         (n) = ((bfr)->m_flags & M_EXT ? (bfr)->m_data - (bfr)->m_ext.ext_buf : \
340                 (bfr)->m_flags & M_PKTHDR ? (bfr)->m_data - (bfr)->m_pktdat : \
341                         (bfr)->m_data - (bfr)->m_dat);  \
342 }
343 #define KB_TAILROOM(bfr, n) {                           \
344         (n) = M_TRAILINGSPACE(bfr);                     \
345 }
346 #define KB_PLENGET(bfr, n) {                            \
347         (n) = (bfr)->m_pkthdr.len;                      \
348 }
349 #define KB_PLENSET(bfr, n) {                            \
350         (bfr)->m_pkthdr.len = (n);                      \
351 }
352 #define KB_PLENADJ(bfr, n) {                            \
353         (bfr)->m_pkthdr.len += (n);                     \
354 }
355
356
357 #else   /* ! BSD >= 199103 */
358
359
360 #define KB_NEXT(bfr)            (bfr)->m_next
361 #define KB_LEN(bfr)             (bfr)->m_len
362 #define KB_QNEXT(bfr)           (bfr)->m_act
363 #define KB_ALLOC(bfr, size, flags, type) {              \
364         if ((size) <= MLEN) {                           \
365                 MGET((bfr), (flags), (type));           \
366         } else                                          \
367                 (bfr) = NULL;                           \
368 }
369 #define KB_ALLOCPKT(bfr, size, flags, type) {           \
370         if ((size) <= MLEN) {                           \
371                 MGET((bfr), (flags), (type));           \
372         } else                                          \
373                 (bfr) = NULL;                           \
374 }
375 #define KB_ALLOCEXT(bfr, size, flags, type) {           \
376         if ((size) <= MCLBYTES) {                       \
377                 MGET((bfr), (flags), (type));           \
378                 if ((bfr) != NULL) {                    \
379                         MCLGET(bfr);                    \
380                         if ((bfr)->m_len != MCLBYTES) { \
381                                 m_freem((bfr));         \
382                                 (bfr) = NULL;           \
383                         }                               \
384                 }                                       \
385         } else                                          \
386                 (bfr) = NULL;                           \
387 }
388 #define KB_FREEONE(bfr, nxt) {                          \
389         (nxt) = m_free(bfr);                            \
390 }
391 #define KB_FREEALL(bfr) {                               \
392         m_freem(bfr);                                   \
393 }
394 #define KB_COPY(bfr, off, len, new, flags) {            \
395         (new) = m_copy((bfr), (off), (len));            \
396 }
397 #define KB_COPYDATA(bfr, off, len, datap)               \
398         m_cpytoc((bfr), (off), (len), (datap))
399 #define KB_PULLUP(bfr, n, new) {                        \
400         (new) = m_pullup((bfr), (n));                   \
401 }
402 #define KB_LINKHEAD(new, head) {                        \
403         (new)->m_next = (head);                         \
404 }
405 #define KB_LINK(new, prev) {                            \
406         (new)->m_next = (prev)->m_next;                 \
407         (prev)->m_next = (new);                         \
408 }
409 #define KB_UNLINKHEAD(head, next) {                     \
410         next = m_free((head));                          \
411 }
412 #define KB_UNLINK(old, prev, next) {                    \
413         next = m_free((old));                           \
414         (prev)->m_next = (next);                        \
415 }
416 #define KB_ISPKT(bfr)           (0)
417 #define KB_ISEXT(bfr)           M_HASCL(bfr)
418 #define KB_BFRSTART(bfr, x, t) {                        \
419         if (M_HASCL(bfr)) {                             \
420                 if ((bfr)->m_cltype == MCL_STATIC)      \
421                         (x) = (t)(mtod((bfr), int) & ~(MCLBYTES - 1));  \
422                 else                                    \
423                         (x) = (t)NULL;                  \
424         } else                                          \
425                 (x) = (t)((bfr)->m_dat);                \
426 }
427 #define KB_BFREND(bfr, x, t) {                          \
428         if (M_HASCL(bfr)) {                             \
429                 if ((bfr)->m_cltype == MCL_STATIC)      \
430                         (x) = (t)((mtod((bfr), int) & ~(MCLBYTES - 1))  \
431                                 + MCLBYTES);            \
432                 else                                    \
433                         (x) = (t)NULL;                  \
434         } else                                          \
435                 (x) = (t)((bfr)->m_dat + MLEN);         \
436 }
437 #define KB_BFRLEN(bfr)                                  \
438         (M_HASCL(bfr) ? (((bfr)->m_cltype == MCL_STATIC) ? MCLBYTES : 0) : MLEN)
439 #define KB_DATASTART(bfr, x, t) {                       \
440         (x) = mtod((bfr), t);                           \
441 }
442 #define KB_DATAEND(bfr, x, t) {                         \
443         (x) = (t)(mtod((bfr), caddr_t) + (bfr)->m_len); \
444 }
445 #define KB_HEADSET(bfr, n) {                            \
446         if (M_HASCL(bfr)) {                             \
447                 /* Assume cluster buffer is empty XXX */\
448                 (bfr)->m_off += (n);                    \
449         } else                                          \
450                 (bfr)->m_off = MMINOFF + (n);           \
451 }
452 #define KB_HEADMOVE(bfr, n) {                           \
453         (bfr)->m_off += (n);                            \
454 }
455 #define KB_HEADADJ(bfr, n) {                            \
456         (bfr)->m_len += (n);                            \
457         (bfr)->m_off -= (n);                            \
458 }
459 #define KB_TAILADJ(bfr, n) {                            \
460         (bfr)->m_len += (n);                            \
461 }
462 #define KB_TAILALIGN(bfr, n) {                          \
463         (bfr)->m_len = (n);                             \
464         if (M_HASCL(bfr)) {                             \
465                 if ((bfr)->m_cltype == MCL_STATIC)      \
466                         (bfr)->m_off = (int)(((mtod((bfr), int)         \
467                                 & ~(MCLBYTES - 1)) + MCLBYTES - (n))    \
468                                 & ~(sizeof(long) - 1)) - (int)(bfr);    \
469                 /* Out of luck for loaned buffers */    \
470         } else                                          \
471                 (bfr)->m_off = (MMAXOFF - (n))  & ~(sizeof(long) - 1);  \
472 }
473 #define KB_HEADROOM(bfr, n) {                           \
474         if (M_HASCL(bfr)) {                             \
475                 if ((bfr)->m_cltype == MCL_STATIC)      \
476                         (n) = mtod((bfr), int) & (MCLBYTES - 1);        \
477                 else                                    \
478                         (n) = 0;                        \
479         } else                                          \
480                 (n) = (bfr)->m_off - MMINOFF;           \
481 }
482 #define KB_TAILROOM(bfr, n) {                           \
483         if (M_HASCL(bfr)) {                             \
484                 if ((bfr)->m_cltype == MCL_STATIC)      \
485                         (n) = MCLBYTES - ((mtod((bfr), int) + (bfr)->m_len) \
486                                 & (MCLBYTES - 1));      \
487                 else                                    \
488                         (n) = 0;                        \
489         } else                                          \
490                 (n) = MMAXOFF - ((bfr)->m_off + (bfr)->m_len);  \
491 }
492 #define KB_PLENGET(bfr, n) {                            \
493         struct mbuf     *zz;                            \
494         for ((n) = 0, zz = (bfr); zz; zz = zz->m_next)  \
495                 (n) += zz->m_len;                       \
496 }
497 #define KB_PLENSET(bfr, n) {                            \
498 }
499 #define KB_PLENADJ(bfr, n) {                            \
500 }
501
502
503 #endif  /* ! BSD >= 199103 */
504
505 #endif  /* defined(BSD) */
506
507
508 /*
509  * Kernel time
510  *
511  * KTimeout_ret         Typedef for timeout() function return
512  *
513  * KT_TIME(t)           Sets t to the current time.
514  *
515  */
516 #if (defined(BSD) && (BSD >= 199306))
517 typedef void    KTimeout_ret;
518 #else
519 typedef int     KTimeout_ret;
520 #endif
521 #if (defined(BSD) && (BSD >= 199103))
522 #define KT_TIME(t)      microtime(&t)
523 #elif defined(sun)
524 #define KT_TIME(t)      uniqtime(&t)
525 #else
526 #define KT_TIME(t)      ((t) = time)
527 #endif
528
529 #endif  /* ATM_KERNEL */
530
531 #ifndef NTOHL
532 #if BYTE_ORDER == BIG_ENDIAN
533 #define NTOHL(x)        (x)
534 #define NTOHS(x)        (x)
535 #define HTONL(x)        (x)
536 #define HTONS(x)        (x)
537 #else
538 #define NTOHL(x)        (x) = ntohl((u_long)(x))
539 #define NTOHS(x)        (x) = ntohs((u_short)(x))
540 #define HTONL(x)        (x) = htonl((u_long)(x))
541 #define HTONS(x)        (x) = htons((u_short)(x))
542 #endif
543 #endif  /* NTOHL */
544
545 #ifndef MAX
546 #define MAX(a,b)        max((a),(b))
547 #endif
548 #ifndef MIN
549 #define MIN(a,b)        min((a),(b))
550 #endif
551
552 #if (!(defined(BSD) && (BSD >= 199306)))
553 #ifndef __BIT_TYPES_DEFINED__
554 #define __BIT_TYPES_DEFINED__
555 typedef char            int8_t;
556 typedef unsigned char   u_int8_t;
557 typedef short           int16_t;
558 typedef unsigned short  u_int16_t;
559 typedef int             int32_t;
560 typedef unsigned int    u_int32_t;
561 #endif
562 #endif
563
564 #endif  /* _NETATM_PORT_H */