BSD 4_3_Net_2 release
[unix-history] / usr / src / sys / netiso / tp_timer.c
index 2c221b9..9aab647 100644 (file)
@@ -1,3 +1,38 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *     @(#)tp_timer.c  7.5 (Berkeley) 5/6/91
+ */
+
 /***********************************************************
                Copyright IBM Corporation 1987
 
 /***********************************************************
                Copyright IBM Corporation 1987
 
@@ -29,7 +64,6 @@ SOFTWARE.
  *
  * $Header: tp_timer.c,v 5.2 88/11/18 17:29:07 nhall Exp $
  * $Source: /usr/argo/sys/netiso/RCS/tp_timer.c,v $
  *
  * $Header: tp_timer.c,v 5.2 88/11/18 17:29:07 nhall Exp $
  * $Source: /usr/argo/sys/netiso/RCS/tp_timer.c,v $
- *     @(#)tp_timer.c  7.3 (Berkeley) %G% *
  *
  * Contains all the timer code.  
  * There are two sources of calls to these routines:
  *
  * Contains all the timer code.  
  * There are two sources of calls to these routines:
@@ -48,14 +82,11 @@ SOFTWARE.
  * Their "going off" is manifested by a function call w/ 3 arguments.
  */
 
  * Their "going off" is manifested by a function call w/ 3 arguments.
  */
 
-#ifndef lint
-static char *rcsid = "$Header: tp_timer.c,v 5.2 88/11/18 17:29:07 nhall Exp $";
-#endif lint
-
 #include "param.h"
 #include "types.h"
 #include "time.h"
 #include "malloc.h"
 #include "param.h"
 #include "types.h"
 #include "time.h"
 #include "malloc.h"
+#include "socket.h"
 
 #include "tp_param.h"
 #include "tp_timer.h"
 
 #include "tp_param.h"
 #include "tp_timer.h"
@@ -66,8 +97,10 @@ static char *rcsid = "$Header: tp_timer.c,v 5.2 88/11/18 17:29:07 nhall Exp $";
 #include "tp_trace.h"
 #include "tp_seq.h"
 
 #include "tp_trace.h"
 #include "tp_seq.h"
 
-static  struct Ecallout *TP_callfree;
-static  struct Ecallout TP_callout[N_TPREF*2]; 
+struct Ecallout *TP_callfree;
+struct Ecallout *TP_callout; 
+struct tp_ref *tp_ref;
+int            N_TPREF = 100;
 
 extern int tp_maxrefopen;  /* highest ref # of an open tp connection */
 
 
 extern int tp_maxrefopen;  /* highest ref # of an open tp connection */
 
@@ -81,15 +114,19 @@ extern int tp_maxrefopen;  /* highest ref # of an open tp connection */
 void
 tp_timerinit()
 {
 void
 tp_timerinit()
 {
-       register int i;
+       register struct Ecallout *e;
+       register int s;
+#define GETME(x, t, n) {s = (n)*sizeof(*x); x = (t) malloc(s, M_PCB, M_NOWAIT);\
+if (x == 0) panic("tp_timerinit"); bzero((caddr_t)x, s);}
        /*
        /*
-        * Initialize callouts
+        * Initialize storage
         */
         */
-       TP_callfree = TP_callout;
-       for (i = 1; i < N_TPREF*2; i++)
-               TP_callout[i-1].c_next = &TP_callout[i];
+       GETME(TP_callout, struct Ecallout *, 2 * N_TPREF);
+       GETME(tp_ref, struct tp_ref *, 1 +  N_TPREF);
 
 
-       bzero( (caddr_t)tp_ref, N_TPREF * sizeof(struct tp_ref) );
+       TP_callfree = TP_callout + ((2 * N_TPREF) - 1);
+       for (e = TP_callfree; e > TP_callout; e--)
+               e->c_next = e - 1;
 
        /* hate to do this but we really don't want zero to be a legit ref */
        tp_maxrefopen = 1;
 
        /* hate to do this but we really don't want zero to be a legit ref */
        tp_maxrefopen = 1;
@@ -98,7 +135,7 @@ tp_timerinit()
                * unless, of course, you make refs and address instead of an
                * index - then 0 can be allocated
                */
                * unless, of course, you make refs and address instead of an
                * index - then 0 can be allocated
                */
-
+#undef GETME
 }
 
 /**********************  e timers *************************/
 }
 
 /**********************  e timers *************************/