]> git.ozlabs.org Git - ppp.git/blobdiff - NeXT/nbq.h
does better without the includes
[ppp.git] / NeXT / nbq.h
index 73f7c1cb06983987d61dfb7f95197636597b2f63..0fd632c0b70fb582a66139867c3a5e585ab99f53 100644 (file)
 #define KERNEL 1
 
 #include <sys/types.h>
 #define KERNEL 1
 
 #include <sys/types.h>
+#if !(NS_TARGET >= 40)
 #include <kernserv/prototypes.h>
 #include <kernserv/prototypes.h>
+#endif /* NS_TARGET */
+
 #include "netbuf.h"
 #include "netbuf.h"
+typedef u_int mark_t;
+
+#define NETBUF_T netbuf_t
+#define NB_ALLOC ppp_nb_alloc
+#define NB_FREE nb_free
+#define NB_MAP nb_map
+#define NB_SIZE nb_size
+#define NB_SHRINK_TOP ppp_nb_shrink_top
+#define NB_GROW_TOP ppp_nb_grow_top
+#define NB_SHRINK_BOT nb_shrink_bot
+#define NB_GROW_BOT nb_grow_bot
+#define NB_READ nb_read
+#define NB_WRITE nb_write
+#define NB_GET_MARK nb_get_mark
+#define NB_SET_MARK nb_set_mark
+#define NB_GET_NEXT nb_get_next
+#define NB_SET_NEXT nb_set_next
+#define nb_TO_NB(nb) (nb)
+#define NB_TO_nb(NB) (NB)
+
 
 struct qparms {
     u_char     q_low, q_high, q_max;
 
 struct qparms {
     u_char     q_low, q_high, q_max;
@@ -25,34 +48,33 @@ struct qparms {
 struct nb_queue {
     char       *name;
     int                low, high, max, len, dropped;
 struct nb_queue {
     char       *name;
     int                low, high, max, len, dropped;
-    netbuf_t   head, tail;
+    NETBUF_T   head, tail;
 };
 
 };
 
-typedef u_int mark_t;
 #define NB_EXTRA (sizeof(mark_t)+sizeof(netbuf_t))
 
 static inline void
 nb_set_next(netbuf_t nb, netbuf_t ptr)
 {
 #define NB_EXTRA (sizeof(mark_t)+sizeof(netbuf_t))
 
 static inline void
 nb_set_next(netbuf_t nb, netbuf_t ptr)
 {
-if(nb) bcopy(&ptr,nb_map(nb)-sizeof(netbuf_t),sizeof(netbuf_t));
+if(nb) bcopy(&ptr,NB_MAP(nb)-sizeof(netbuf_t),sizeof(netbuf_t));
 }
 
 static inline void
 nb_get_next(netbuf_t nb, netbuf_t *ptr)
 {
 }
 
 static inline void
 nb_get_next(netbuf_t nb, netbuf_t *ptr)
 {
-if(nb && ptr) bcopy(nb_map(nb)-sizeof(netbuf_t),ptr,sizeof(netbuf_t));
+if(nb && ptr) bcopy(NB_MAP(nb)-sizeof(netbuf_t),ptr,sizeof(netbuf_t));
 }
 
 static inline void
 nb_set_mark(netbuf_t nb, mark_t ptr)
 {
 }
 
 static inline void
 nb_set_mark(netbuf_t nb, mark_t ptr)
 {
-if(nb) bcopy(&ptr,nb_map(nb)-NB_EXTRA,sizeof(mark_t));
+if(nb) bcopy(&ptr,NB_MAP(nb)-NB_EXTRA,sizeof(mark_t));
 }
 
 static inline void
 nb_get_mark(netbuf_t nb, mark_t *ptr)
 {
 }
 
 static inline void
 nb_get_mark(netbuf_t nb, mark_t *ptr)
 {
-if(nb && ptr) bcopy(nb_map(nb)-NB_EXTRA,ptr,sizeof(mark_t));
+if(nb && ptr) bcopy(NB_MAP(nb)-NB_EXTRA,ptr,sizeof(mark_t));
 }
 
 static inline void
 }
 
 static inline void
@@ -60,11 +82,11 @@ ppp_nb_shrink_top(netbuf_t nb, unsigned int size)
 {
     netbuf_t ptr;
     mark_t   mark;
 {
     netbuf_t ptr;
     mark_t   mark;
-    nb_get_next(nb,&ptr);
-    nb_get_mark(nb,&mark);
+    NB_GET_NEXT(nb,&ptr);
+    NB_GET_MARK(nb,&mark);
     nb_shrink_top(nb,size);
     nb_shrink_top(nb,size);
-    nb_set_mark(nb,mark);
-    nb_set_next(nb,ptr);
+    NB_SET_MARK(nb,mark);
+    NB_SET_NEXT(nb,ptr);
 }
 
 static inline void
 }
 
 static inline void
@@ -72,13 +94,14 @@ ppp_nb_grow_top(netbuf_t nb, unsigned int size)
 {
     netbuf_t ptr;
     mark_t   mark;
 {
     netbuf_t ptr;
     mark_t   mark;
-    nb_get_next(nb,&ptr);
-    nb_get_mark(nb,&mark);
+    NB_GET_NEXT(nb,&ptr);
+    NB_GET_MARK(nb,&mark);
     nb_grow_top(nb,size);
     nb_grow_top(nb,size);
-    nb_set_mark(nb,mark);
-    nb_set_next(nb,ptr);
+    NB_SET_MARK(nb,mark);
+    NB_SET_NEXT(nb,ptr);
 }
 
 }
 
+
 static inline netbuf_t
 ppp_nb_alloc(unsigned int size)
 {
 static inline netbuf_t
 ppp_nb_alloc(unsigned int size)
 {
@@ -88,8 +111,8 @@ ppp_nb_alloc(unsigned int size)
     nb=nb_alloc(size);
     if(nb) {
        nb_shrink_top(nb,NB_EXTRA);
     nb=nb_alloc(size);
     if(nb) {
        nb_shrink_top(nb,NB_EXTRA);
-       nb_set_next(nb,NULL);
-       nb_set_mark(nb,0);
+       NB_SET_NEXT(nb,NULL);
+       NB_SET_MARK(nb,0);
     }
     return nb;
 }
     }
     return nb;
 }