1 /* Copyright (C) 1998, 1990 Transarc Corporation - All rights reserved */
4 #ifndef TRANSARC_AFS_CONFIG_STDS_H
5 #define TRANSARC_AFS_CONFIG_STDS_H 1
10 #define IN /* indicates a parameter is read in */
11 #define OUT /* indicates a parameter is sent out (a ptr) */
12 #define INOUT /* indicates a parameter is read in and sent out (a ptr) */
15 #define MACRO_BEGIN do {
18 #define MACRO_END } while (0)
24 #if defined(__HIGHC__)
26 * keep HC from complaining about the use of "old-style" function definitions
29 pragma Off(Prototype_override_warnings);
30 #endif /* defined(__HIGHC__) */
33 * This makes including the RCS id in object files less painful. Put this near
34 * the beginning of .c files (not .h files). Do NOT follow it with a
35 * semi-colon. The argument should be a double quoted string containing the
36 * standard RCS Header keyword.
39 /* Now some types to enhance portability. Always use these on the wire or when
40 * laying out shared structures on disk. */
42 /* Imagine that this worked...
43 #if (sizeof(long) != 4) || (sizeof(short) != 2)
44 #error We require size of long and pointers to be equal
47 typedef short afs_int16;
48 typedef unsigned short afs_uint16;
50 typedef int afs_int32;
51 typedef unsigned int afs_uint32;
52 #else /* AFS_64BIT_ENV */
53 typedef long afs_int32;
54 typedef unsigned long afs_uint32;
55 #endif /* AFS_64BIT_ENV */
57 /* you still have to include <netinet/in.h> to make these work */
65 /* Since there is going to be considerable use of 64 bit integers we provide
66 * some assistence in this matter. The hyper type is supposed to be compatible
67 * with the afsHyper type: the same macros will work on both. */
69 #if defined(AFS_64BIT_ENV) && 0
71 typedef unsigned long afs_hyper_t;
73 #define hcmp(a,b) ((a) < (b) ? -1 : ((a) > (b) ? 1 : 0))
74 #define hsame(a,b) ((a) == (b))
75 #define hiszero(a) ((a) == 0)
76 #define hfitsin32(a) ((a) & 0xffffffff00000000) == 0)
77 #define hset(a,b) ((a) = (b))
78 #define hzero(a) ((a) = 0)
79 #define hones(a) ((a) = ~((unsigned long)0))
80 #define hget32(i,a) ((i) = (unsigned int)(a))
81 #define hget64(hi,lo,a) ((lo) = ((unsigned int)(a)), (hi) = ((a) & (0xffffffff00000000)))
82 #define hset32(a,i) ((a) = ((unsigned int)(i)))
83 #define hset64(a,hi,lo) ((a) = (((hi) << 32) | (lo)))
84 #define hgetlo(a) ((a) & 0xffffffff)
85 #define hgethi(a) (((unsigned int)(a)) >> 32)
86 #define hadd(a,b) ((a) += (b))
88 #define hadd32(a,b) ((a) += (b))
89 #define hshlft(a,n) ((a)<<(n))
91 #else /* AFS_64BIT_ENV */
93 typedef struct afs_hyper_t { /* unsigned 64 bit integers */
98 #define hcmp(a,b) ((a).high<(b).high? -1 : ((a).high > (b).high? 1 : \
99 ((a).low <(b).low? -1 : ((a).low > (b).low? 1 : 0))))
100 #define hsame(a,b) ((a).low == (b).low && (a).high == (b).high)
101 #define hiszero(a) ((a).low == 0 && (a).high == 0)
102 #define hfitsin32(a) ((a).high == 0)
103 #define hset(a,b) ((a) = (b))
104 #define hzero(a) ((a).low = 0, (a).high = 0)
105 #define hones(a) ((a).low = 0xffffffff, (a).high = 0xffffffff)
106 #define hget32(i,a) ((i) = (a).low)
107 #define hget64(hi,lo,a) ((lo) = (a).low, (hi) = (a).high)
108 #define hset32(a,i) ((a).high = 0, (a).low = (i))
109 #define hset64(a,hi,lo) ((a).high = (hi), (a).low = (lo))
110 #define hgetlo(a) ((a).low)
111 #define hgethi(a) ((a).high)
112 #define hshlft(a,n) \
113 { /*Shift Left n bits*/ \
114 int s = sizeof((a).low) * 8; /*#bits*/ \
115 if ((n) <= 0) { /*No shift*/ \
116 } else if ((n) >= 2*s) { /*Shift off all bits*/ \
117 (a).high = (a).low = 0; \
118 } else if ((n) < s) { /*Part of low shifted into high*/ \
119 (a).high = ((a).high<<(n)) | (((a).low>>(s-(n))) & (1<<(n))-1); \
120 (a).low = (a).low << (n); \
121 } else if ((n) >= s) { /*All of low shifted into high plus some*/ \
122 (a).high = (a).low << ((n)-s); \
127 /* The algorithm here is to check for two cases that cause a carry. If the top
128 * two bits are different then if the sum has the top bit off then there must
129 * have been a carry. If the top bits are both one then there is always a
130 * carry. We assume 32 bit ints and twos complement arithmetic. */
132 #define SIGN 0x80000000
133 #define hadd32(a,i) \
134 (((((a).low ^ (int)(i)) & SIGN) \
135 ? (((((a).low + (int)(i)) & SIGN) == 0) && (a).high++) \
136 : (((a).low & (int)(i) & SIGN) && (a).high++)), \
139 #define hadd(a,b) (hadd32(a,(b).low), (a).high += (b).high)
140 #endif /* AFS_64BIT_ENV */
144 #define max(a, b) ((a) < (b) ? (b) : (a))
145 #define min(a, b) ((a) > (b) ? (b) : (a))
147 /*#define abs(x) ((x) >= 0 ? (x) : -(x))*/
150 #if defined(AFS_LINUX20_ENV) && defined(KERNEL)
151 /* This is here instead of osi_machdep.h so fcrypt.c can pick it up. */
152 #include "../h/string.h"
153 #define bcopy(F,T,C) memcpy((T), (F), (C))
157 /* minumum length of string to pass to int_to_base64 */
158 typedef char b64_string_t[8];
159 #if defined(AFS_HPUX_ENV) || defined(AFS_USR_HPUX_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV))
160 char *int_to_base64();
163 char *int_to_base64(b64_string_t s, int a);
164 int base64_to_int(char *s);
168 * The afsUUID data type is built in to RX
173 afs_uint16 time_hi_and_version;
174 char clock_seq_hi_and_reserved;
178 typedef struct afsUUID afsUUID;
179 extern int xdr_afsUUID();
181 #endif /* TRANSARC_CONFIG_AFS_STDS_H */