|
|
1.1 root 1: /***********************************************************
2: Copyright IBM Corporation 1987
3:
4: All Rights Reserved
5:
6: Permission to use, copy, modify, and distribute this software and its
7: documentation for any purpose and without fee is hereby granted,
8: provided that the above copyright notice appear in all copies and that
9: both that copyright notice and this permission notice appear in
10: supporting documentation, and that the name of IBM not be
11: used in advertising or publicity pertaining to distribution of the
12: software without specific, written prior permission.
13:
14: IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
15: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
16: IBM BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
17: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
18: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
19: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
20: SOFTWARE.
21:
22: ******************************************************************/
23:
24: /*
25: * ARGO Project, Computer Sciences Dept., University of Wisconsin - Madison
26: */
27: /*
28: * ARGO TP
29: *
30: * $Header: tp_seq.h,v 5.1 88/10/12 12:20:59 root Exp $
31: * $Source: /usr/argo/sys/netiso/RCS/tp_seq.h,v $
32: * @(#)tp_seq.h 7.4 (Berkeley) 1/16/90 *
33: *
34: * These macros perform sequence number arithmetic modulo (2**7 or 2**31).
35: * The relevant fields in the tpcb are:
36: * tp_seqmask : the mask of bits that define the sequence space.
37: * tp_seqbit : 1 + tp_seqmask
38: * tp_seqhalf : tp_seqbit / 2 or half the sequence space (rounded up)
39: * Not exactly fast, but at least it's maintainable.
40: */
41:
42: #ifndef __TP_SEQ__
43: #define __TP_SEQ__
44:
45: #define SEQ(tpcb,x) \
46: ((x) & (tpcb)->tp_seqmask)
47:
48: #define SEQ_GT(tpcb, seq, operand ) \
49: ( ((int)((seq)-(operand)) > 0)\
50: ? ((int)((seq)-(operand)) < (int)(tpcb)->tp_seqhalf)\
51: : !(-((int)(seq)-(operand)) < (int)(tpcb)->tp_seqhalf))
52:
53: #define SEQ_GEQ(tpcb, seq, operand ) \
54: ( ((int)((seq)-(operand)) >= 0)\
55: ? ((int)((seq)-(operand)) < (int)(tpcb)->tp_seqhalf)\
56: : !((-((int)(seq)-(operand))) < (int)(tpcb)->tp_seqhalf))
57:
58: #define SEQ_LEQ(tpcb, seq, operand ) \
59: ( ((int)((seq)-(operand)) <= 0)\
60: ? ((-(int)((seq)-(operand))) < (int)(tpcb)->tp_seqhalf)\
61: : !(((int)(seq)-(operand)) < (int)(tpcb)->tp_seqhalf))
62:
63: #define SEQ_LT(tpcb, seq, operand ) \
64: ( ((int)((seq)-(operand)) < 0)\
65: ? ((-(int)((seq)-(operand))) < (int)(tpcb)->tp_seqhalf)\
66: : !(((int)(seq)-(operand)) < (int)(tpcb)->tp_seqhalf))
67:
68: #define SEQ_MIN(tpcb, a, b) ( SEQ_GT(tpcb, a, b) ? b : a)
69:
70: #define SEQ_MAX(tpcb, a, b) ( SEQ_GT(tpcb, a, b) ? a : b)
71:
72: #define SEQ_INC(tpcb, Seq) ((++Seq), ((Seq) &= (tpcb)->tp_seqmask))
73:
74: #define SEQ_DEC(tpcb, Seq)\
75: ((Seq) = (((Seq)+(unsigned)((int)(tpcb)->tp_seqbit - 1))&(tpcb)->tp_seqmask))
76:
77: /* (amt) had better be less than the seq bit ! */
78:
79: #define SEQ_SUB(tpcb, Seq, amt)\
80: (((Seq) + (unsigned)((int)(tpcb)->tp_seqbit - amt)) & (tpcb)->tp_seqmask)
81: #define SEQ_ADD(tpcb, Seq, amt) (((Seq) + (unsigned)amt) & (tpcb)->tp_seqmask)
82:
83:
84: #define IN_RWINDOW(tpcb, seq, lwe, uwe)\
85: ( SEQ_GEQ(tpcb, seq, lwe) && SEQ_LT(tpcb, seq, uwe) )
86:
87: #define IN_SWINDOW(tpcb, seq, lwe, uwe)\
88: ( SEQ_GT(tpcb, seq, lwe) && SEQ_LEQ(tpcb, seq, uwe) )
89:
90: #endif __TP_SEQ__
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.