00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 static const char source_file[] = __FILE__;
00038 static const char rcs_id[] = "$Source: /depot/CVSROOT/javi/src/sw/cmplr/common/util/x_prop.c,v $ $Revision: 1.1 $";
00039
00040 #include <bstring.h>
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 _X_PROP_TYPE_ *
00053 _X_PROP_CREATE_(
00054 INT32 universe_size,
00055 MEM_POOL *pool
00056 )
00057 {
00058
00059
00060
00061 UINT32 words = ( (universe_size + _X_PROP_TYPE_SIZE_ - 1)
00062 >> _X_PROP_TYPE_SIZE_LOG2_) + 1;
00063 _X_PROP_TYPE_ *prop = TYPE_MEM_POOL_ALLOC_N(_X_PROP_TYPE_, pool, words);
00064 if ( ! MEM_POOL_Zeroed(pool) ) BZERO(prop, words * sizeof(_X_PROP_TYPE_));
00065 prop[0] = universe_size;
00066 return prop;
00067 }
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079 void
00080 _X_PROP_SET_(
00081 _X_PROP_TYPE_ *prop,
00082 _X_PROP_LOCAL_BASE_TYPE_ x
00083 )
00084 {
00085 UINT32 id = _X_id_(x);
00086
00087 Is_True(id < prop[0], ("property id out of range"));
00088
00089 (prop+1)[id >> _X_PROP_TYPE_SIZE_LOG2_] |=
00090 (_X_PROP_TYPE_)1 << (id & (_X_PROP_TYPE_SIZE_-1));
00091 }
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 void
00104 _X_PROP_RESET_(
00105 _X_PROP_TYPE_ *prop,
00106 _X_PROP_LOCAL_BASE_TYPE_ x
00107 )
00108 {
00109 UINT32 id = _X_id_(x);
00110
00111 Is_True(id < prop[0], ("property id out of range"));
00112
00113 (prop+1)[id >> _X_PROP_TYPE_SIZE_LOG2_] &=
00114 ~((_X_PROP_TYPE_)1 << (id & (_X_PROP_TYPE_SIZE_-1)));
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127 BOOL
00128 _X_PROP_GET_(
00129 _X_PROP_TYPE_ *prop,
00130 _X_PROP_LOCAL_BASE_TYPE_ x
00131 )
00132 {
00133 UINT32 id = _X_id_(x);
00134
00135 Is_True(id < prop[0], ("property id out of range"));
00136
00137 return ((prop+1)[id >> _X_PROP_TYPE_SIZE_LOG2_]
00138 & ((_X_PROP_TYPE_)1 << (id & (_X_PROP_TYPE_SIZE_-1)))) != 0;
00139 }
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151 void
00152 _X_PROP_UNIOND_(
00153 _X_PROP_TYPE_ *prop0,
00154 _X_PROP_TYPE_ *prop1
00155 )
00156 {
00157 UINT32 i;
00158 UINT32 universe_size = prop0[0];
00159 UINT32 words = (universe_size + _X_PROP_TYPE_SIZE_-1)
00160 >> _X_PROP_TYPE_SIZE_LOG2_;
00161
00162 Is_True(universe_size == prop1[0], ("vectors are different length"));
00163
00164 for ( i = 1; i <= words; ++i ) prop0[i] |= prop1[i];
00165 }
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 BOOL
00178 _X_PROP_INTERSECTION_IS_NONEMPTY_(
00179 _X_PROP_TYPE_ *prop0,
00180 _X_PROP_TYPE_ *prop1
00181 )
00182 {
00183 UINT32 i;
00184 UINT32 universe_size = prop0[0];
00185 UINT32 words = (universe_size + _X_PROP_TYPE_SIZE_-1)
00186 >> _X_PROP_TYPE_SIZE_LOG2_;
00187
00188 Is_True(universe_size == prop1[0], ("vectors are different length"));
00189
00190 for ( i = 1; i <= words; ++i ) {
00191 if ( (prop0[i] & prop1[i]) != 0 ) return TRUE;
00192 }
00193 return FALSE;
00194 }