X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcm%2Fcm_hash.c;h=61074e5179dc59d9440a53fa915f6b90619f49e2;hb=14136d98405a2fb8d8c078b755efb63b95cdc7a3;hp=4016ea95bada383c85b286608550d0eba29c6bd2;hpb=0a26c487f1b6bbb5217e47b15fa8273b2e749283;p=o-du%2Fl2.git diff --git a/src/cm/cm_hash.c b/src/cm/cm_hash.c index 4016ea95b..61074e517 100644 --- a/src/cm/cm_hash.c +++ b/src/cm/cm_hash.c @@ -110,34 +110,34 @@ extern "C" { #endif -PRIVATE S16 cmHashFuncBCD8 ARGS((CmHashListCp *hashListCp, U8 *key, - U16 keyLen, U16 *idx)); +static S16 cmHashFuncBCD8 ARGS((CmHashListCp *hashListCp, uint8_t *key, + uint16_t keyLen, uint16_t *idx)); -PRIVATE S16 cmHashFuncConId ARGS((CmHashListCp *hashListCp, U8 *key, - U16 keyLen, U16 *idx)); +static S16 cmHashFuncConId ARGS((CmHashListCp *hashListCp, uint8_t *key, + uint16_t keyLen, uint16_t *idx)); -PRIVATE S16 cmHashFuncU32Mod ARGS((CmHashListCp *hashListCp, U8 *key, - U16 keyLen, U16 *idx)); +static S16 cmHashFuncU32Mod ARGS((CmHashListCp *hashListCp, uint8_t *key, + uint16_t keyLen, uint16_t *idx)); -PRIVATE S16 cmHashFuncString ARGS((CmHashListCp *hashListCp, U8 *key, - U16 keyLen, U16 *idx)); +static S16 cmHashFuncString ARGS((CmHashListCp *hashListCp, uint8_t *key, + uint16_t keyLen, uint16_t *idx)); -PRIVATE S16 cmHashFuncDefault ARGS((CmHashListCp *hashListCp, U8 *key, - U16 keyLen, U16 *idx)); +static S16 cmHashFuncDefault ARGS((CmHashListCp *hashListCp, uint8_t *key, + uint16_t keyLen, uint16_t *idx)); -PRIVATE S16 cmHashFuncAnyKey ARGS((CmHashListCp *hashListCp, U8 *key, - U16 keyLen, U16 *idx)); +static S16 cmHashFuncAnyKey ARGS((CmHashListCp *hashListCp, uint8_t *key, + uint16_t keyLen, uint16_t *idx)); -PRIVATE S16 cmHashMatchKey ARGS((U8 *key1, U16 keyLen1, U8 *key2, U16 keyLen2)); +static S16 cmHashMatchKey ARGS((uint8_t *key1, uint16_t keyLen1, uint8_t *key2, uint16_t keyLen2)); -PRIVATE S16 cmListInsert ARGS((CmListEnt *oldEntry, CmListEnt *newEntry)); +static S16 cmListInsert ARGS((CmListEnt *oldEntry, CmListEnt *newEntry)); -PRIVATE S16 cmListDelete ARGS((CmListEnt *entry)); +static S16 cmListDelete ARGS((CmListEnt *entry)); /* cm_hash_c_001.main_22: Fixing warnings on GCC compiler */ -PRIVATE S16 cmHashFuncMult24 ARGS((CmHashListCp *hashListCp, U8 *key, U16 keyLen, U16 *idx)); +static S16 cmHashFuncMult24 ARGS((CmHashListCp *hashListCp, uint8_t *key, uint16_t keyLen, uint16_t *idx)); -PRIVATE S16 cmHashFuncDirIdx ARGS((CmHashListCp *hashListCp, U8 *key, U16 keyLen, U16 *idx)); +static S16 cmHashFuncDirIdx ARGS((CmHashListCp *hashListCp, uint8_t *key, uint16_t keyLen, uint16_t *idx)); #ifdef __cplusplus } @@ -171,29 +171,20 @@ PRIVATE S16 cmHashFuncDirIdx ARGS((CmHashListCp *hashListCp, U8 *key, U16 keyLen * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncAnyKey +static S16 cmHashFuncAnyKey ( -CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* idx to return */ +CmHashListCp *hashListCp, /* hash list control point */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* idx to return */ ) -#else -PRIVATE S16 cmHashFuncAnyKey (hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* idx to return */ -#endif { - U32 a; /* hash variables */ - U32 b; /* hash variables */ - U32 c; /* hash variables */ - U32 len; /* length */ + uint32_t a; /* hash variables */ + uint32_t b; /* hash variables */ + uint32_t c; /* hash variables */ + uint32_t len; /* length */ /*cm_hash_c_001.main_23 : Fix for TRACE5 feature crash due to missing TRC MACRO*/ - TRC2(cmHashFuncAnyKey); /* Set up the internal state */ len = keyLen; /* key length */ a = 0x9e3779b9; /* a = b = the golden ratio; an arbitrary value */ @@ -203,9 +194,9 @@ U16 *idx; /* idx to return */ /*---------------------------------------- handle most of the key */ while (len >= 12) { - a += (key[0] +((U32)key[1]<<8) +((U32)key[2]<<16) +((U32)key[3]<<24)); - b += (key[4] +((U32)key[5]<<8) +((U32)key[6]<<16) +((U32)key[7]<<24)); - c += (key[8] +((U32)key[9]<<8) +((U32)key[10]<<16)+((U32)key[11]<<24)); + a += (key[0] +((uint32_t)key[1]<<8) +((uint32_t)key[2]<<16) +((uint32_t)key[3]<<24)); + b += (key[4] +((uint32_t)key[5]<<8) +((uint32_t)key[6]<<16) +((uint32_t)key[7]<<24)); + c += (key[8] +((uint32_t)key[9]<<8) +((uint32_t)key[10]<<16)+((uint32_t)key[11]<<24)); CM_HASH_MIX(a, b, c); key += 12; len -= 12; } @@ -214,17 +205,17 @@ U16 *idx; /* idx to return */ c += keyLen; switch(len) /* all the case statements fall through */ { - case 11: c+=((U32)key[10]<<24); - case 10: c+=((U32)key[9]<<16); - case 9 : c+=((U32)key[8]<<8); + case 11: c+=((uint32_t)key[10]<<24); + case 10: c+=((uint32_t)key[9]<<16); + case 9 : c+=((uint32_t)key[8]<<8); /* the first byte of c is reserved for the keyLen */ - case 8 : b+=((U32)key[7]<<24); - case 7 : b+=((U32)key[6]<<16); - case 6 : b+=((U32)key[5]<<8); + case 8 : b+=((uint32_t)key[7]<<24); + case 7 : b+=((uint32_t)key[6]<<16); + case 6 : b+=((uint32_t)key[5]<<8); case 5 : b+=key[4]; - case 4 : a+=((U32)key[3]<<24); - case 3 : a+=((U32)key[2]<<16); - case 2 : a+=((U32)key[1]<<8); + case 4 : a+=((uint32_t)key[3]<<24); + case 3 : a+=((uint32_t)key[2]<<16); + case 2 : a+=((uint32_t)key[1]<<8); case 1 : a+=key[0]; /* case 0: nothing left to add */ } @@ -233,9 +224,9 @@ U16 *idx; /* idx to return */ /* if nmbBins is a power of 2, use shift, else use division */ if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (c & hashListCp->binBitMask); + *idx = (uint16_t) (c & hashListCp->binBitMask); else - *idx = (U16) (c % hashListCp->nmbBins); + *idx = (uint16_t) (c % hashListCp->nmbBins); return ROK; } /* end of cmHashFuncAnyKey */ @@ -258,37 +249,28 @@ U16 *idx; /* idx to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncU32Mod +static S16 cmHashFuncU32Mod ( -CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* idx to return */ +CmHashListCp *hashListCp, /* hash list control point */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* idx to return */ ) -#else -PRIVATE S16 cmHashFuncU32Mod (hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* idx to return */ -#endif { - U32 sum; /* Sum of octets for hash function */ + uint32_t sum; /* Sum of octets for hash function */ - TRC2(cmHashFuncU32Mod); /* keyLen is marked Unused to remove compilation * warnings. */ UNUSED(keyLen); - sum = *((U32 *)key); + sum = *((uint32_t *)key); /* if nmbBins is a power of 2, use shift, else use division */ if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (sum & hashListCp->binBitMask); + *idx = (uint16_t) (sum & hashListCp->binBitMask); else - *idx = (U16) (sum % hashListCp->nmbBins); + *idx = (uint16_t) (sum % hashListCp->nmbBins); return ROK; @@ -302,9 +284,9 @@ U16 *idx; /* idx to return */ * key of type CM_HASH_KEYTYPE_BCD8. * * Steps: -* 1. Converts the 8 BCD coded octets into 2 U32s -* 2. Adds 2 U32s to get one U32. -* 3. Apply U32Mod technique to get the index +* 1. Converts the 8 BCD coded octets into 2 uint32_ts +* 2. Adds 2 uint32_ts to get one uint32_t. +* 3. Apply uint32_tMod technique to get the index * 4. Return the index * * Note: @@ -319,57 +301,48 @@ U16 *idx; /* idx to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncBCD8 +static S16 cmHashFuncBCD8 ( CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* idx to return */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* idx to return */ ) -#else -PRIVATE S16 cmHashFuncBCD8 (hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* idx to return */ -#endif { - U16 tmp16 = 0; - U32 firstU32 = 0; /* First U32 prepared for lower 4 octets */ - U32 secondU32 = 0; /* Second U32 prepared for higher 4 octets */ - U32 sum; /* Sum of the above 2 octets to get the index */ + uint16_t tmp16 = 0; + uint32_t firstUInt32 = 0; /* First uint32_t prepared for lower 4 octets */ + uint32_t secondUInt32 = 0; /* Second uint32_t prepared for higher 4 octets */ + uint32_t sum; /* Sum of the above 2 octets to get the index */ - TRC2(cmHashFuncBCD8); /* keyLen is marked Unused to remove compilation * warnings. */ UNUSED(keyLen); - /* Compute second U32 */ - tmp16 = (U16) PutHiByte(tmp16, (U8) key[0]); - tmp16 = (U16) PutLoByte(tmp16, (U8) key[1]); - secondU32 = (U32) PutHiWord(secondU32, (U16) tmp16); - tmp16 = (U16) PutHiByte(tmp16, (U8) key[2]); - tmp16 = (U16) PutLoByte(tmp16, (U8) key[3]); - secondU32 = (U32) PutLoWord(secondU32, (U16) tmp16); + /* Compute second uint32_t */ + tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) key[0]); + tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) key[1]); + secondUInt32 = (uint32_t) PutHiWord(secondUInt32, (uint16_t) tmp16); + tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) key[2]); + tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) key[3]); + secondUInt32 = (uint32_t) PutLoWord(secondUInt32, (uint16_t) tmp16); - /* Compute first U32 */ - tmp16 = (U16) PutHiByte(tmp16, (U8) key[4]); - tmp16 = (U16) PutLoByte(tmp16, (U8) key[5]); - firstU32 = (U32) PutHiWord(firstU32, (U16) tmp16); - tmp16 = (U16) PutHiByte(tmp16, (U8) key[6]); - tmp16 = (U16) PutLoByte(tmp16, (U8) key[7]); - firstU32 = (U32) PutLoWord(firstU32, (U16) tmp16); + /* Compute first uint32_t */ + tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) key[4]); + tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) key[5]); + firstUInt32 = (uint32_t) PutHiWord(firstUInt32, (uint16_t) tmp16); + tmp16 = (uint16_t) PutHiByte(tmp16, (uint8_t) key[6]); + tmp16 = (uint16_t) PutLoByte(tmp16, (uint8_t) key[7]); + firstUInt32 = (uint32_t) PutLoWord(firstUInt32, (uint16_t) tmp16); - sum = firstU32 + secondU32; + sum = firstUInt32 + secondUInt32; /* if nmbBins is a power of 2, use shift, else use division */ if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (sum & hashListCp->binBitMask); + *idx = (uint16_t) (sum & hashListCp->binBitMask); else - *idx = (U16) (sum % hashListCp->nmbBins); + *idx = (uint16_t) (sum % hashListCp->nmbBins); return ROK; } /* end of cmHashFuncBCD8 () */ @@ -394,26 +367,17 @@ U16 *idx; /* idx to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncString +static S16 cmHashFuncString ( -CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* idx to return */ +CmHashListCp *hashListCp, /* hash list control point */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* idx to return */ ) -#else -PRIVATE S16 cmHashFuncString (hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* idx to return */ -#endif { - U16 cntr; /* Index */ - U32 sum; /* Sum of octets for hash function */ + uint16_t cntr; /* Index */ + uint32_t sum; /* Sum of octets for hash function */ - TRC2(cmHashFuncString) sum = 0; @@ -424,9 +388,9 @@ U16 *idx; /* idx to return */ /* if nmbBins is a power of 2, use shift, else use division */ if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (sum & hashListCp->binBitMask); + *idx = (uint16_t) (sum & hashListCp->binBitMask); else - *idx = (U16) (sum % hashListCp->nmbBins); + *idx = (uint16_t) (sum % hashListCp->nmbBins); return ROK; @@ -452,38 +416,29 @@ U16 *idx; /* idx to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncDefault +static S16 cmHashFuncDefault ( -CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* index to return */ +CmHashListCp *hashListCp, /* hash list control point */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* index to return */ ) -#else -PRIVATE S16 cmHashFuncDefault(hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* index to return */ -#endif { - U32 sum; /* sum of key string octets */ + uint32_t sum; /* sum of key string octets */ - TRC2(cmHashFuncDefault); /* add all bytes of the key */ sum = 0; while (keyLen--) - sum += (U32) (*key++); + sum += (uint32_t) (*key++); /* compute index by dividing the range into the sum */ /* if nmbBins is a power of 2, use shift, else use division */ if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (sum & hashListCp->binBitMask); + *idx = (uint16_t) (sum & hashListCp->binBitMask); else - *idx = (U16) (sum % hashListCp->nmbBins); + *idx = (uint16_t) (sum % hashListCp->nmbBins); return ROK; @@ -521,26 +476,17 @@ U16 *idx; /* index to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncMult24 +static S16 cmHashFuncMult24 ( -CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* index to return */ +CmHashListCp *hashListCp, /* hash list control point */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* index to return */ ) -#else -PRIVATE S16 cmHashFuncMult24(hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* index to return */ -#endif { - U32 prod; /* (constant multiplier * key) */ - U8 shift; /* Bits to be shifted to get index */ + uint32_t prod; /* (constant multiplier * key) */ + uint8_t shift; /* Bits to be shifted to get index */ - TRC2(cmHashFuncMult24); UNUSED(keyLen); @@ -550,10 +496,10 @@ U16 *idx; /* index to return */ return RFAILED; #endif - prod = CM_HASH_MULT24_CONST * *((U32 *)key); + prod = CM_HASH_MULT24_CONST * *((uint32_t *)key); shift = CM_HASH_MULT24_BITPOS - hashListCp->nmbBinBits; - *idx = ((U16) (prod & (hashListCp->binBitMask << shift))) >> shift; + *idx = ((uint16_t) (prod & (hashListCp->binBitMask << shift))) >> shift; return ROK; } /* end of cmHashFuncMult24 */ @@ -569,7 +515,7 @@ U16 *idx; /* index to return */ * key of type CM_HASH_KEYTYPE_CONID. * * This function can be used for keys that are an integer whose -* size is U8, U16 or U32. Instead of adding all octets of the key, +* size is uint8_t, uint16_t or uint32_t. Instead of adding all octets of the key, * this fn computes the "index" of the bin in which the entry * needs to be inserted by taking a modulo of the integer with the * total number of bins. @@ -584,47 +530,38 @@ U16 *idx; /* index to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncConId +static S16 cmHashFuncConId ( -CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* index to return */ +CmHashListCp *hashListCp, /* hash list control point */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* index to return */ ) -#else -PRIVATE S16 cmHashFuncConId(hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* index to return */ -#endif { - TRC2(cmHashFuncConId); /* switch based on the length of the key */ switch (keyLen) { - case CM_HASHKEYLEN_U32: + case CM_HASHKEYLEN_UINT32: if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (((U32) *((U32 *)key)) & hashListCp->binBitMask); + *idx = (uint16_t) (((uint32_t) *((uint32_t *)key)) & hashListCp->binBitMask); else - *idx = (U16) (((U32) *((U32 *)key)) % hashListCp->nmbBins); + *idx = (uint16_t) (((uint32_t) *((uint32_t *)key)) % hashListCp->nmbBins); break; - case CM_HASHKEYLEN_U16: + case CM_HASHKEYLEN_UINT16: if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (((U16)*((U16 *)key)) & hashListCp->binBitMask); + *idx = (uint16_t) (((uint16_t)*((uint16_t *)key)) & hashListCp->binBitMask); else - *idx = (U16) (((U16)*((U16 *)key)) % hashListCp->nmbBins); + *idx = (uint16_t) (((uint16_t)*((uint16_t *)key)) % hashListCp->nmbBins); break; - case CM_HASHKEYLEN_U8: + case CM_HASHKEYLEN_UINT8: if (hashListCp->binBitMask != CM_HASH_NOBITMASK) - *idx = (U16) (((U8)*((U8 *)key)) & hashListCp->binBitMask); + *idx = (uint16_t) (((uint8_t)*((uint8_t *)key)) & hashListCp->binBitMask); else - *idx = (U16) (((U8)*((U8 *)key)) % hashListCp->nmbBins); + *idx = (uint16_t) (((uint8_t)*((uint8_t *)key)) % hashListCp->nmbBins); break; default: @@ -653,28 +590,19 @@ U16 *idx; /* index to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashFuncDirIdx +static S16 cmHashFuncDirIdx ( -CmHashListCp *hashListCp, /* hash list control point */ -U8 *key, /* key string */ -U16 keyLen, /* length of key string */ -U16 *idx /* index to return */ +CmHashListCp *hashListCp, /* hash list control point */ +uint8_t *key, /* key string */ +uint16_t keyLen, /* length of key string */ +uint16_t *idx /* index to return */ ) -#else -PRIVATE S16 cmHashFuncDirIdx(hashListCp, key, keyLen, idx) -CmHashListCp *hashListCp; /* hash list control point */ -U8 *key; /* key string */ -U16 keyLen; /* length of key string */ -U16 *idx; /* index to return */ -#endif { - TRC2(cmHashFuncDirIdx); UNUSED(hashListCp); UNUSED(keyLen); - *idx = *((U16 *) key); + *idx = *((uint16_t *) key); return ROK; } /* end of cmHashFuncDirIdx */ @@ -695,23 +623,14 @@ U16 *idx; /* index to return */ * */ -#ifdef ANSI -PRIVATE S16 cmHashMatchKey +static S16 cmHashMatchKey ( -U8 *key1, /* first key string */ -U16 keyLen1, /* length of first key string */ -U8 *key2, /* second key string */ -U16 keyLen2 /* length of second key string */ +uint8_t *key1, /* first key string */ +uint16_t keyLen1, /* length of first key string */ +uint8_t *key2, /* second key string */ +uint16_t keyLen2 /* length of second key string */ ) -#else -PRIVATE S16 cmHashMatchKey(key1, keyLen1, key2, keyLen2) -U8 *key1; /* first key string */ -U16 keyLen1; /* length of first key string */ -U8 *key2; /* second key string */ -U16 keyLen2; /* length of second key string */ -#endif { - TRC2(cmHashMatchKey); /* compare key lengths */ if (keyLen1 != keyLen2) @@ -736,19 +655,12 @@ U16 keyLen2; /* length of second key string */ * */ -#ifdef ANSI -PRIVATE S16 cmListInsert +static S16 cmListInsert ( CmListEnt *oldEntry, /* add new entry after this entry */ CmListEnt *newEntry /* new entry to add */ ) -#else -PRIVATE S16 cmListInsert(oldEntry, newEntry) -CmListEnt *oldEntry; /* add new entry after this entry */ -CmListEnt *newEntry; /* new entry to add */ -#endif { - TRC2(cmListInsert); newEntry->next = oldEntry->next; newEntry->prev = oldEntry; @@ -773,17 +685,11 @@ CmListEnt *newEntry; /* new entry to add */ * */ -#ifdef ANSI -PRIVATE S16 cmListDelete +static S16 cmListDelete ( CmListEnt *entry /* entry to delete */ ) -#else -PRIVATE S16 cmListDelete(entry) -CmListEnt *entry; /* entry to delete */ -#endif { - TRC2(cmListDelete); if (entry == NULLP) return RFAILED; @@ -835,36 +741,24 @@ CmListEnt *entry; /* entry to delete */ * File: cm_hash.c * */ -#ifdef ANSI S16 cmHashListInit ( CmHashListCp *hashListCp, /* hash list to initialize */ -U16 nmbBins, /* number of hash list bins */ -U16 offset, /* offset of CmHashListEnt in entries */ +uint16_t nmbBins, /* number of hash list bins */ +uint16_t offset, /* offset of CmHashListEnt in entries */ Bool dupFlg, /* allow duplicate keys */ -U16 keyType, /* key type for selecting hash fn */ +uint16_t keyType, /* key type for selecting hash fn */ Region region, /* memory region to allocate bins */ Pool pool /* memory pool to allocate bins */ ) -#else -S16 cmHashListInit(hashListCp, nmbBins, offset, dupFlg, keyType, region, pool) -CmHashListCp *hashListCp; /* hash list to initialize */ -U16 nmbBins; /* number of hash list bins */ -U16 offset; /* offset of CmHashListEnt in entries */ -Bool dupFlg; /* allow duplicate keys */ -U16 keyType; /* key type for selecting hash fn */ -Region region; /* memory region to allocate bins */ -Pool pool; /* memory pool to allocate bins */ -#endif { - U16 i; + uint16_t i; #ifndef CM_MT_HASH_BIN CmListEnt *hl; #else CmListBinEnt *hl; #endif - TRC2(cmHashListInit); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -906,7 +800,7 @@ Pool pool; /* memory pool to allocate bins */ hashListCp->hashFunc = cmHashFuncString; break; - case CM_HASH_KEYTYPE_U32MOD: + case CM_HASH_KEYTYPE_UINT32_MOD: hashListCp->hashFunc = cmHashFuncU32Mod; break; @@ -962,7 +856,7 @@ Pool pool; /* memory pool to allocate bins */ /* initialize bin bit mask */ if (((nmbBins) & (nmbBins - 1)) == 0) { - U16 binBitMask; + uint16_t binBitMask; /* number of bins is a power of 2 */ hashListCp->binBitMask = nmbBins - 1; @@ -994,17 +888,11 @@ Pool pool; /* memory pool to allocate bins */ * File: cm_hash.c * */ -#ifdef ANSI S16 cmHashListDeinit ( CmHashListCp *hashListCp /* hash list to deinitialize */ ) -#else -S16 cmHashListDeinit(hashListCp) -CmHashListCp *hashListCp; /* hash list to deinitialize */ -#endif { - TRC2(cmHashListDeinit); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -1063,27 +951,18 @@ CmHashListCp *hashListCp; /* hash list to deinitialize */ * */ -#ifdef ANSI S16 cmHashListInsert ( CmHashListCp *hashListCp, /* hash list to add to */ PTR entry, /* entry to add */ -U8 *key, /* pointer to key */ -U16 keyLen /* length of key */ +uint8_t *key, /* pointer to key */ +uint16_t keyLen /* length of key */ ) -#else -S16 cmHashListInsert(hashListCp, entry, key, keyLen) -CmHashListCp *hashListCp; /* hash list to add to */ -PTR entry; /* entry to add */ -U8 *key; /* pointer to key */ -U16 keyLen; /* length of key */ -#endif { CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ PTR dupEntry; /* pointer to entry with duplicate key */ - U16 idx; /* index for insertion into hash list */ + uint16_t idx; /* index for insertion into hash list */ - TRC2(cmHashListInsert); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -1101,7 +980,7 @@ U16 keyLen; /* length of key */ } /* get pointer to hash list entry header */ - hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset); + hashListEnt = (CmHashListEnt *) (((uint8_t *) entry) + hashListCp->offset); /* initialize hash list entry header */ hashListEnt->list.next = NULLP; @@ -1147,24 +1026,17 @@ U16 keyLen; /* length of key */ * */ -#ifdef ANSI S16 cmHashListDelete ( CmHashListCp *hashListCp, /* hash list to delete from */ PTR entry /* entry to delete */ ) -#else -S16 cmHashListDelete(hashListCp, entry) -CmHashListCp *hashListCp; /* hash list to delete from */ -PTR entry; /* entry to delete */ -#endif { CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ #ifdef CM_MT_HASH_BIN - U16 idx; /* index for selecting the right hash list bin */ + uint16_t idx; /* index for selecting the right hash list bin */ #endif - TRC2(cmHashListDelete); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -1173,7 +1045,7 @@ PTR entry; /* entry to delete */ #endif /* get pointer to hash list entry header */ - hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset); + hashListEnt = (CmHashListEnt *) (((uint8_t *) entry) + hashListCp->offset); /* check if entry is already deleted if yes then return OK */ if((hashListEnt->list.next == NULLP) || @@ -1231,35 +1103,25 @@ PTR entry; /* entry to delete */ * */ -#ifdef ANSI S16 cmHashListFind ( CmHashListCp *hashListCp, /* hash list to search */ -U8 *key, /* pointer to key */ -U16 keyLen, /* length of key */ -U16 seqNmb, /* used in case of duplicate keys */ +uint8_t *key, /* pointer to key */ +uint16_t keyLen, /* length of key */ +uint16_t seqNmb, /* used in case of duplicate keys */ PTR *entry /* entry to be returned */ ) -#else -S16 cmHashListFind(hashListCp, key, keyLen, seqNmb, entry) -CmHashListCp *hashListCp; /* hash list to search */ -U8 *key; /* pointer to key */ -U16 keyLen; /* length of key */ -U16 seqNmb; /* used in case of duplicate keys */ -PTR *entry; /* entry to be returned */ -#endif { CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ #ifndef CM_MT_HASH_BIN CmListEnt *hashListBin; /* pointer to hash list bin */ #else CmListBinEnt *hashListBin; /* pointer to hash list bin */ - U16 entCnt=0; /* counter for number of entries */ + uint16_t entCnt=0; /* counter for number of entries */ #endif - U16 i; /* counter for sequence number */ - U16 idx; /* index for insertion into hash list */ + uint16_t i; /* counter for sequence number */ + uint16_t idx; /* index for insertion into hash list */ - TRC2(cmHashListFind); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -1289,7 +1151,7 @@ PTR *entry; /* entry to be returned */ == ROK) { /* matching key */ - *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); + *entry = (PTR) (((uint8_t *) hashListEnt) - hashListCp->offset); /* check for duplicates */ if (!hashListCp->dupFlg) @@ -1337,19 +1199,12 @@ PTR *entry; /* entry to be returned */ * File: cm_hash.c * */ -#ifdef ANSI S16 cmHashListGetNext ( CmHashListCp *hashListCp, /* hash list to get from */ PTR prevEnt, /* previous entry */ PTR *entry /* entry to be returned */ ) -#else -S16 cmHashListGetNext(hashListCp, prevEnt, entry) -CmHashListCp *hashListCp; /* hash list to get from */ -PTR prevEnt; /* previous entry */ -PTR *entry; /* entry to be returned */ -#endif { #ifndef CM_MT_HASH_BIN CmListEnt *hashListBin; /* temporary hash list bin pointer */ @@ -1358,9 +1213,8 @@ PTR *entry; /* entry to be returned */ #endif CmHashListEnt *hashListEnt; /* temporary hash list entry pointer */ CmHashListEnt *prevListEnt; /* previous hash list entry pointer */ - U16 i; /* hash list counter */ + uint16_t i; /* hash list counter */ - TRC2(cmHashListGetNext); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -1384,7 +1238,7 @@ PTR *entry; /* entry to be returned */ hashListEnt = (CmHashListEnt *) hashListCp->hl[i].next; /* requested entry is in nxtEnt */ - *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); + *entry = (PTR) (((uint8_t *) hashListEnt) - hashListCp->offset); return ROK; } @@ -1396,7 +1250,7 @@ PTR *entry; /* entry to be returned */ /* use previous entry to find next entry */ /* get pointer to previous hash list entry header */ - prevListEnt = (CmHashListEnt *) (((U8 *) prevEnt) + hashListCp->offset); + prevListEnt = (CmHashListEnt *) (((uint8_t *) prevEnt) + hashListCp->offset); /* get index of previous entry */ i = prevListEnt->hashVal; @@ -1410,7 +1264,7 @@ PTR *entry; /* entry to be returned */ if (prevListEnt != (CmHashListEnt *) hashListBin) { /* found next entry */ - *entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset); + *entry = (PTR) (((uint8_t *) prevListEnt) - hashListCp->offset); return ROK; } @@ -1455,27 +1309,18 @@ PTR *entry; /* entry to be returned */ * File: cm_hash.c * */ -#ifdef ANSI S16 cmHashListBinGetNextEntry ( CmHashListCp *hashListCp, /* hash list to get from */ -U16 binIdx, /* Bin Index to retreive the entry */ +uint16_t binIdx, /* Bin Index to retreive the entry */ PTR prevEnt, /* previous entry */ PTR *entry /* entry to be returned */ ) -#else -S16 cmHashListBinGetNextEntry(hashListCp, binIdx, prevEnt, entry) -CmHashListCp *hashListCp; /* hash list to get from */ -U16 binIdx; /* Bin Index to retreive the entry */ -PTR prevEnt; /* previous entry */ -PTR *entry; /* entry to be returned */ -#endif { CmListBinEnt *hashListBin; /* temporary hash list bin pointer */ CmHashListEnt *hashListEnt; /* temporary hash list entry pointer */ CmHashListEnt *prevListEnt; /* previous hash list entry pointer */ - TRC2(cmHashListBinGetNextEntry); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -1494,7 +1339,7 @@ PTR *entry; /* entry to be returned */ hashListEnt = (CmHashListEnt *) hashListCp->hl[binIdx].next; /* requested entry is in nxtEnt */ - *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); + *entry = (PTR) (((uint8_t *) hashListEnt) - hashListCp->offset); return ROK; } @@ -1506,7 +1351,7 @@ PTR *entry; /* entry to be returned */ /* use previous entry to find next entry */ /* get pointer to previous hash list entry header */ - prevListEnt = (CmHashListEnt *) (((U8 *) prevEnt) + hashListCp->offset); + prevListEnt = (CmHashListEnt *) (((uint8_t *) prevEnt) + hashListCp->offset); /* set pointers to get next entry */ hashListBin = &hashListCp->hl[binIdx]; @@ -1516,7 +1361,7 @@ PTR *entry; /* entry to be returned */ if (prevListEnt != (CmHashListEnt *) hashListBin) { /* found next entry */ - *entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset); + *entry = (PTR) (((uint8_t *) prevListEnt) - hashListCp->offset); return ROK; } @@ -1546,25 +1391,17 @@ PTR *entry; /* entry to be returned */ * File: cm_hash.c * */ -#ifdef ANSI S16 cmHashListQuery ( CmHashListCp *hashListCp, /* hash list to query */ -U8 queryType, /* type of query */ -U16 *result /* result of query */ +uint8_t queryType, /* type of query */ +uint16_t *result /* result of query */ ) -#else -S16 cmHashListQuery(hashListCp, queryType, result) -CmHashListCp *hashListCp; /* hash list to query */ -U8 queryType; /* type of query */ -U16 *result; /* result of query */ -#endif { #ifdef CM_MT_HASH_BIN - U8 i; + uint8_t i; #endif - TRC2(cmHashListQuery); /* deal with queries that do not need hashListCp */ @@ -1579,9 +1416,9 @@ U16 *result; /* result of query */ { /* storage for each bin */ #ifndef CM_MT_HASH_BIN - *result = (U16) sizeof(CmListEnt); + *result = (uint16_t) sizeof(CmListEnt); #else - *result = (U16) sizeof(CmListBinEnt); + *result = (uint16_t) sizeof(CmListBinEnt); #endif return ROK; } @@ -1599,7 +1436,7 @@ U16 *result; /* result of query */ { case CM_HASH_QUERYTYPE_ENTRIES: /* current number of entries */ #ifndef CM_MT_HASH_BIN - *result = (U16) hashListCp->nmbEnt; + *result = (uint16_t) hashListCp->nmbEnt; #else *result = 0; for (i=0; i < hashListCp->nmbBins; i++) @@ -1610,19 +1447,19 @@ U16 *result; /* result of query */ return ROK; case CM_HASH_QUERYTYPE_BINS: /* number of bins */ - *result = (U16) hashListCp->nmbBins; + *result = (uint16_t) hashListCp->nmbBins; return ROK; case CM_HASH_QUERYTYPE_OFFSET: /* offset of CmHashListEnt in entries */ - *result = (U16) hashListCp->offset; + *result = (uint16_t) hashListCp->offset; return ROK; case CM_HASH_QUERYTYPE_DUPFLG: /* allow duplicate keys */ - *result = (U16) hashListCp->dupFlg; + *result = (uint16_t) hashListCp->dupFlg; return ROK; case CM_HASH_QUERYTYPE_KEYTYPE: /* key type for selecting hash functions */ - *result = (U16) hashListCp->keyType; + *result = (uint16_t) hashListCp->keyType; return ROK; default: /* process other query types */ @@ -1657,21 +1494,13 @@ U16 *result; /* result of query */ * */ -#ifdef ANSI S16 cmHashListOAInsert ( CmHashListCp *hashListCp, /* hash table to add to */ PTR entry, /* entry to add */ -U8 *key, /* pointer to key */ -U16 keyLen /* length of key */ +uint8_t *key, /* pointer to key */ +uint16_t keyLen /* length of key */ ) -#else -S16 cmHashListOAInsert(hashListCp, entry, key, keyLen) -CmHashListCp *hashListCp; /* hash table to add to */ -PTR entry; /* entry to add */ -U8 *key; /* pointer to key */ -U16 keyLen; /* length of key */ -#endif { /* cm_hash_c_001.main_21. Modify. Compilation Issue resolved. */ #ifndef CM_MT_HASH_BIN @@ -1680,13 +1509,12 @@ U16 keyLen; /* length of key */ CmListBinEnt *hashBin; /* temporary hash list bin pointer */ #endif CmHashListEnt *hashListEnt; /* pointer to hash list entry header */ - U16 idx; /* index for insertion into hash list */ - U16 hashSize; /* hash size */ - U16 i; + uint16_t idx; /* index for insertion into hash list */ + uint16_t hashSize; /* hash size */ + uint16_t i; /* cm_hash_c_001.main_21. Modify. Compilation Issue resolved. */ - U16 nmbEnt; + uint16_t nmbEnt; - TRC2(cmHashListOAInsert); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ @@ -1709,7 +1537,7 @@ U16 keyLen; /* length of key */ return (ROUTRES); /* get pointer to hash list entry header */ - hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset); + hashListEnt = (CmHashListEnt *) (((uint8_t *) entry) + hashListCp->offset); /* initialize hash list entry header */ hashListEnt->list.next = NULLP;