X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=src%2Fcm%2Fcm_hash.c;h=2d2668d567562dfd500ae665681303d24d59760c;hb=5d74fef7c9fe6b65a965ceac6bfe812872dab323;hp=cd0427979bd59c29d030abfc8a754b9765ce38dd;hpb=829bbd114f1c3dc00c1da47bca0a8207c049df3f;p=o-du%2Fl2.git diff --git a/src/cm/cm_hash.c b/src/cm/cm_hash.c index cd0427979..2d2668d56 100644 --- a/src/cm/cm_hash.c +++ b/src/cm/cm_hash.c @@ -193,7 +193,6 @@ U16 *idx; /* idx to return */ U32 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 */ @@ -237,7 +236,7 @@ U16 *idx; /* idx to return */ else *idx = (U16) (c % hashListCp->nmbBins); - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncAnyKey */ @@ -276,7 +275,6 @@ U16 *idx; /* idx to return */ { U32 sum; /* Sum of octets for hash function */ - TRC2(cmHashFuncU32Mod); /* keyLen is marked Unused to remove compilation * warnings. */ @@ -290,7 +288,7 @@ U16 *idx; /* idx to return */ else *idx = (U16) (sum % hashListCp->nmbBins); - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncU32Mod () */ @@ -340,7 +338,6 @@ U16 *idx; /* idx to return */ U32 secondU32 = 0; /* Second U32 prepared for higher 4 octets */ U32 sum; /* Sum of the above 2 octets to get the index */ - TRC2(cmHashFuncBCD8); /* keyLen is marked Unused to remove compilation * warnings. */ @@ -371,7 +368,7 @@ U16 *idx; /* idx to return */ else *idx = (U16) (sum % hashListCp->nmbBins); - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncBCD8 () */ /* @@ -413,7 +410,6 @@ U16 *idx; /* idx to return */ U16 cntr; /* Index */ U32 sum; /* Sum of octets for hash function */ - TRC2(cmHashFuncString) sum = 0; @@ -428,7 +424,7 @@ U16 *idx; /* idx to return */ else *idx = (U16) (sum % hashListCp->nmbBins); - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncString () */ @@ -470,7 +466,6 @@ U16 *idx; /* index to return */ { U32 sum; /* sum of key string octets */ - TRC2(cmHashFuncDefault); /* add all bytes of the key */ sum = 0; @@ -485,7 +480,7 @@ U16 *idx; /* index to return */ else *idx = (U16) (sum % hashListCp->nmbBins); - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncDefault */ @@ -540,14 +535,13 @@ U16 *idx; /* index to return */ U32 prod; /* (constant multiplier * key) */ U8 shift; /* Bits to be shifted to get index */ - TRC2(cmHashFuncMult24); UNUSED(keyLen); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if (hashListCp->binBitMask == CM_HASH_NOBITMASK) - RETVALUE(RFAILED); + return RFAILED; #endif prod = CM_HASH_MULT24_CONST * *((U32 *)key); @@ -555,7 +549,7 @@ U16 *idx; /* index to return */ shift = CM_HASH_MULT24_BITPOS - hashListCp->nmbBinBits; *idx = ((U16) (prod & (hashListCp->binBitMask << shift))) >> shift; - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncMult24 */ @@ -601,7 +595,6 @@ U16 *idx; /* index to return */ #endif { - TRC2(cmHashFuncConId); /* switch based on the length of the key */ switch (keyLen) @@ -628,9 +621,9 @@ U16 *idx; /* index to return */ break; default: - RETVALUE(RFAILED); + return RFAILED; } - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncConId */ @@ -669,14 +662,13 @@ U16 keyLen; /* length of key string */ U16 *idx; /* index to return */ #endif { - TRC2(cmHashFuncDirIdx); UNUSED(hashListCp); UNUSED(keyLen); *idx = *((U16 *) key); - RETVALUE(ROK); + return ROK; } /* end of cmHashFuncDirIdx */ @@ -711,14 +703,13 @@ U8 *key2; /* second key string */ U16 keyLen2; /* length of second key string */ #endif { - TRC2(cmHashMatchKey); /* compare key lengths */ if (keyLen1 != keyLen2) - RETVALUE(RFAILED); + return RFAILED; /* compare key strings */ - RETVALUE(cmMemcmp(key1, key2, (PTR) keyLen1)); + return (cmMemcmp(key1, key2, (PTR) keyLen1)); } /* end of cmHashMatchKey */ @@ -748,14 +739,13 @@ CmListEnt *oldEntry; /* add new entry after this entry */ CmListEnt *newEntry; /* new entry to add */ #endif { - TRC2(cmListInsert); newEntry->next = oldEntry->next; newEntry->prev = oldEntry; oldEntry->next = newEntry; (newEntry->next)->prev = newEntry; - RETVALUE(ROK); + return ROK; } /* end of cmListInsert */ @@ -783,10 +773,9 @@ PRIVATE S16 cmListDelete(entry) CmListEnt *entry; /* entry to delete */ #endif { - TRC2(cmListDelete); if (entry == NULLP) - RETVALUE(RFAILED); + return RFAILED; if (entry->prev != NULLP) (entry->prev)->next = entry->next; @@ -794,7 +783,7 @@ CmListEnt *entry; /* entry to delete */ if (entry->next != NULLP) (entry->next)->prev = entry->prev; - RETVALUE(ROK); + return ROK; } /* end of cmListDelete */ @@ -836,7 +825,7 @@ CmListEnt *entry; /* entry to delete */ * */ #ifdef ANSI -PUBLIC S16 cmHashListInit +S16 cmHashListInit ( CmHashListCp *hashListCp, /* hash list to initialize */ U16 nmbBins, /* number of hash list bins */ @@ -847,7 +836,7 @@ Region region, /* memory region to allocate bins */ Pool pool /* memory pool to allocate bins */ ) #else -PUBLIC S16 cmHashListInit(hashListCp, nmbBins, offset, dupFlg, keyType, region, pool) +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 */ @@ -864,12 +853,11 @@ Pool pool; /* memory pool to allocate bins */ CmListBinEnt *hl; #endif - TRC2(cmHashListInit); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if (hashListCp == NULLP) - RETVALUE(RFAILED); + return RFAILED; #endif /* initialize control point fields */ @@ -893,7 +881,7 @@ Pool pool; /* memory pool to allocate bins */ case CM_HASH_KEYTYPE_MULT24: /* return failure if number of bins is not a power of 2 */ if (((nmbBins) & (nmbBins - 1)) != 0) - RETVALUE (RFAILED); + return (RFAILED); hashListCp->hashFunc = cmHashFuncMult24; break; @@ -934,11 +922,11 @@ Pool pool; /* memory pool to allocate bins */ #ifndef CM_MT_HASH_BIN if (SGetSBuf(region, pool, (Data **) &hashListCp->hl, (Size) (nmbBins * sizeof(CmListEnt))) != ROK) - RETVALUE(RFAILED); + return RFAILED; #else if (SGetSBuf(region, pool, (Data **) &hashListCp->hl, (Size) (nmbBins * sizeof(CmListBinEnt))) != ROK) - RETVALUE(RFAILED); + return RFAILED; #endif /* initialize bin pointers */ @@ -974,7 +962,7 @@ Pool pool; /* memory pool to allocate bins */ } } - RETVALUE(ROK); + return ROK; } /* end of cmHashListInit */ @@ -995,21 +983,20 @@ Pool pool; /* memory pool to allocate bins */ * */ #ifdef ANSI -PUBLIC S16 cmHashListDeinit +S16 cmHashListDeinit ( CmHashListCp *hashListCp /* hash list to deinitialize */ ) #else -PUBLIC S16 cmHashListDeinit(hashListCp) +S16 cmHashListDeinit(hashListCp) CmHashListCp *hashListCp; /* hash list to deinitialize */ #endif { - TRC2(cmHashListDeinit); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if (hashListCp == NULLP) - RETVALUE(RFAILED); + return RFAILED; #endif /* deallocate memory for bins */ @@ -1038,7 +1025,7 @@ CmHashListCp *hashListCp; /* hash list to deinitialize */ hashListCp->keyType = CM_HASH_KEYTYPE_DEF; hashListCp->hashFunc = NULLP; - RETVALUE(ROK); + return ROK; } /* end of cmHashListDeinit */ @@ -1064,7 +1051,7 @@ CmHashListCp *hashListCp; /* hash list to deinitialize */ */ #ifdef ANSI -PUBLIC S16 cmHashListInsert +S16 cmHashListInsert ( CmHashListCp *hashListCp, /* hash list to add to */ PTR entry, /* entry to add */ @@ -1072,7 +1059,7 @@ U8 *key, /* pointer to key */ U16 keyLen /* length of key */ ) #else -PUBLIC S16 cmHashListInsert(hashListCp, entry, key, keyLen) +S16 cmHashListInsert(hashListCp, entry, key, keyLen) CmHashListCp *hashListCp; /* hash list to add to */ PTR entry; /* entry to add */ U8 *key; /* pointer to key */ @@ -1083,13 +1070,12 @@ U16 keyLen; /* length of key */ PTR dupEntry; /* pointer to entry with duplicate key */ U16 idx; /* index for insertion into hash list */ - TRC2(cmHashListInsert); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if ((hashListCp == NULLP) || (entry == NULLP) || (key == NULLP) || (keyLen == 0)) - RETVALUE(RFAILED); + return RFAILED; #endif /* check for duplicates */ @@ -1097,7 +1083,7 @@ U16 keyLen; /* length of key */ { /* no duplicates allowed, check if key already exists */ if (cmHashListFind(hashListCp, key, keyLen, 0, &dupEntry) == ROK) - RETVALUE(ROKDUP); + return (ROKDUP); } /* get pointer to hash list entry header */ @@ -1111,7 +1097,7 @@ U16 keyLen; /* length of key */ /* compute index for insertion */ if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK) - RETVALUE(RFAILED); + return RFAILED; hashListEnt->hashVal = idx; @@ -1125,7 +1111,7 @@ U16 keyLen; /* length of key */ hashListCp->hl[idx].nmbEnt++; #endif /* #ifndef CM_MT_HASH_BIN */ - RETVALUE(ROK); + return ROK; } /* end of cmHashListInsert */ @@ -1148,13 +1134,13 @@ U16 keyLen; /* length of key */ */ #ifdef ANSI -PUBLIC S16 cmHashListDelete +S16 cmHashListDelete ( CmHashListCp *hashListCp, /* hash list to delete from */ PTR entry /* entry to delete */ ) #else -PUBLIC S16 cmHashListDelete(hashListCp, entry) +S16 cmHashListDelete(hashListCp, entry) CmHashListCp *hashListCp; /* hash list to delete from */ PTR entry; /* entry to delete */ #endif @@ -1164,12 +1150,11 @@ PTR entry; /* entry to delete */ U16 idx; /* index for selecting the right hash list bin */ #endif - TRC2(cmHashListDelete); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if ((hashListCp == NULLP) || (entry == NULLP)) - RETVALUE(RFAILED); + return RFAILED; #endif /* get pointer to hash list entry header */ @@ -1178,13 +1163,13 @@ PTR entry; /* entry to delete */ /* check if entry is already deleted if yes then return OK */ if((hashListEnt->list.next == NULLP) || (hashListEnt->list.prev == NULLP)) - RETVALUE(ROK); + return ROK; #ifdef CM_MT_HASH_BIN /* compute index for insertion */ if ((*hashListCp->hashFunc)(hashListCp, hashListEnt->key, hashListEnt->keyLen, &idx) != ROK) - RETVALUE(RFAILED); + return RFAILED; #endif /* #ifdef CM_MT_HASH_BIN */ /* delete entry from list */ @@ -1205,7 +1190,7 @@ PTR entry; /* entry to delete */ hashListCp->hl[idx].nmbEnt--; #endif /* #ifndef CM_MT_HASH_BIN */ - RETVALUE(ROK); + return ROK; } /* end of cmHashListDelete */ @@ -1232,7 +1217,7 @@ PTR entry; /* entry to delete */ */ #ifdef ANSI -PUBLIC S16 cmHashListFind +S16 cmHashListFind ( CmHashListCp *hashListCp, /* hash list to search */ U8 *key, /* pointer to key */ @@ -1241,7 +1226,7 @@ U16 seqNmb, /* used in case of duplicate keys */ PTR *entry /* entry to be returned */ ) #else -PUBLIC S16 cmHashListFind(hashListCp, key, keyLen, seqNmb, entry) +S16 cmHashListFind(hashListCp, key, keyLen, seqNmb, entry) CmHashListCp *hashListCp; /* hash list to search */ U8 *key; /* pointer to key */ U16 keyLen; /* length of key */ @@ -1259,18 +1244,17 @@ PTR *entry; /* entry to be returned */ U16 i; /* counter for sequence number */ U16 idx; /* index for insertion into hash list */ - TRC2(cmHashListFind); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if ((hashListCp == NULLP) || (key == NULLP) || (keyLen == 0) || (entry == NULLP)) - RETVALUE(RFAILED); + return RFAILED; #endif /* compute hash table index */ if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK) - RETVALUE(RFAILED); + return RFAILED; /* search this bin for exact key match */ hashListBin = &hashListCp->hl[idx]; @@ -1293,11 +1277,11 @@ PTR *entry; /* entry to be returned */ /* check for duplicates */ if (!hashListCp->dupFlg) - RETVALUE(ROK); + return ROK; /* for duplicate key, check sequence number */ if (i++ == seqNmb) - RETVALUE(ROK); + return ROK; } /* go to next entry */ @@ -1305,7 +1289,7 @@ PTR *entry; /* entry to be returned */ } /* no matching key found */ - RETVALUE(RFAILED); + return RFAILED; } /* end of cmHashListFind */ @@ -1338,14 +1322,14 @@ PTR *entry; /* entry to be returned */ * */ #ifdef ANSI -PUBLIC S16 cmHashListGetNext +S16 cmHashListGetNext ( CmHashListCp *hashListCp, /* hash list to get from */ PTR prevEnt, /* previous entry */ PTR *entry /* entry to be returned */ ) #else -PUBLIC S16 cmHashListGetNext(hashListCp, prevEnt, entry) +S16 cmHashListGetNext(hashListCp, prevEnt, entry) CmHashListCp *hashListCp; /* hash list to get from */ PTR prevEnt; /* previous entry */ PTR *entry; /* entry to be returned */ @@ -1360,12 +1344,11 @@ PTR *entry; /* entry to be returned */ CmHashListEnt *prevListEnt; /* previous hash list entry pointer */ U16 i; /* hash list counter */ - TRC2(cmHashListGetNext); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if ((hashListCp == NULLP) || (entry == NULLP)) - RETVALUE(RFAILED); + return RFAILED; #endif /* check if need to get first entry */ @@ -1386,11 +1369,11 @@ PTR *entry; /* entry to be returned */ /* requested entry is in nxtEnt */ *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); - RETVALUE(ROK); + return ROK; } /* no more entries */ - RETVALUE(ROKDNA); + return (ROKDNA); } /* use previous entry to find next entry */ @@ -1412,7 +1395,7 @@ PTR *entry; /* entry to be returned */ /* found next entry */ *entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset); - RETVALUE(ROK); + return ROK; } /* no more entries in this bin, go to next bin, check if more bins */ @@ -1426,7 +1409,7 @@ PTR *entry; /* entry to be returned */ } /* no more entries */ - RETVALUE(ROKDNA); + return (ROKDNA); } /* end of cmHashListGetNext */ #ifdef CM_MT_HASH_BIN @@ -1456,7 +1439,7 @@ PTR *entry; /* entry to be returned */ * */ #ifdef ANSI -PUBLIC S16 cmHashListBinGetNextEntry +S16 cmHashListBinGetNextEntry ( CmHashListCp *hashListCp, /* hash list to get from */ U16 binIdx, /* Bin Index to retreive the entry */ @@ -1464,7 +1447,7 @@ PTR prevEnt, /* previous entry */ PTR *entry /* entry to be returned */ ) #else -PUBLIC S16 cmHashListBinGetNextEntry(hashListCp, binIdx, prevEnt, entry) +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 */ @@ -1475,12 +1458,11 @@ PTR *entry; /* entry to be returned */ CmHashListEnt *hashListEnt; /* temporary hash list entry pointer */ CmHashListEnt *prevListEnt; /* previous hash list entry pointer */ - TRC2(cmHashListBinGetNextEntry); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if ((hashListCp == NULLP) || (entry == NULLP)) - RETVALUE(RFAILED); + return RFAILED; #endif /* check if need to get first entry */ @@ -1496,11 +1478,11 @@ PTR *entry; /* entry to be returned */ /* requested entry is in nxtEnt */ *entry = (PTR) (((U8 *) hashListEnt) - hashListCp->offset); - RETVALUE(ROK); + return ROK; } /* no more entries */ - RETVALUE(ROKDNA); + return (ROKDNA); } /* use previous entry to find next entry */ @@ -1518,11 +1500,11 @@ PTR *entry; /* entry to be returned */ /* found next entry */ *entry = (PTR) (((U8 *) prevListEnt) - hashListCp->offset); - RETVALUE(ROK); + return ROK; } /* no more entries */ - RETVALUE(ROKDNA); + return (ROKDNA); } /* end of cmHashListBinGetNextEntry */ #endif @@ -1547,14 +1529,14 @@ PTR *entry; /* entry to be returned */ * */ #ifdef ANSI -PUBLIC S16 cmHashListQuery +S16 cmHashListQuery ( CmHashListCp *hashListCp, /* hash list to query */ U8 queryType, /* type of query */ U16 *result /* result of query */ ) #else -PUBLIC S16 cmHashListQuery(hashListCp, queryType, result) +S16 cmHashListQuery(hashListCp, queryType, result) CmHashListCp *hashListCp; /* hash list to query */ U8 queryType; /* type of query */ U16 *result; /* result of query */ @@ -1564,14 +1546,13 @@ U16 *result; /* result of query */ U8 i; #endif - TRC2(cmHashListQuery); /* deal with queries that do not need hashListCp */ #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if (result == NULLP) - RETVALUE(RFAILED); + return RFAILED; #endif /* respond depending on query type */ @@ -1583,7 +1564,7 @@ U16 *result; /* result of query */ #else *result = (U16) sizeof(CmListBinEnt); #endif - RETVALUE(ROK); + return ROK; } /* deal with queries that do need hashListCp */ @@ -1591,7 +1572,7 @@ U16 *result; /* result of query */ #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if (hashListCp == NULLP) - RETVALUE(RFAILED); + return RFAILED; #endif /* respond depending on query type */ @@ -1607,30 +1588,30 @@ U16 *result; /* result of query */ *result += hashListCp->hl[i].nmbEnt; } #endif - RETVALUE(ROK); + return ROK; case CM_HASH_QUERYTYPE_BINS: /* number of bins */ *result = (U16) hashListCp->nmbBins; - RETVALUE(ROK); + return ROK; case CM_HASH_QUERYTYPE_OFFSET: /* offset of CmHashListEnt in entries */ *result = (U16) hashListCp->offset; - RETVALUE(ROK); + return ROK; case CM_HASH_QUERYTYPE_DUPFLG: /* allow duplicate keys */ *result = (U16) hashListCp->dupFlg; - RETVALUE(ROK); + return ROK; case CM_HASH_QUERYTYPE_KEYTYPE: /* key type for selecting hash functions */ *result = (U16) hashListCp->keyType; - RETVALUE(ROK); + return ROK; default: /* process other query types */ break; } /* illegal query type */ - RETVALUE(RFAILED); + return RFAILED; } /* end of cmHashListQuery */ #ifdef HASH_OPEN_ADDRESSING @@ -1658,7 +1639,7 @@ U16 *result; /* result of query */ */ #ifdef ANSI -PUBLIC S16 cmHashListOAInsert +S16 cmHashListOAInsert ( CmHashListCp *hashListCp, /* hash table to add to */ PTR entry, /* entry to add */ @@ -1666,7 +1647,7 @@ U8 *key, /* pointer to key */ U16 keyLen /* length of key */ ) #else -PUBLIC S16 cmHashListOAInsert(hashListCp, entry, key, keyLen) +S16 cmHashListOAInsert(hashListCp, entry, key, keyLen) CmHashListCp *hashListCp; /* hash table to add to */ PTR entry; /* entry to add */ U8 *key; /* pointer to key */ @@ -1686,13 +1667,12 @@ U16 keyLen; /* length of key */ /* cm_hash_c_001.main_21. Modify. Compilation Issue resolved. */ U16 nmbEnt; - TRC2(cmHashListOAInsert); #if (ERRCLASS & ERRCLS_DEBUG) /* error check on parameters */ if ((hashListCp == NULLP) || (entry == NULLP) || (key == NULLP) || (keyLen == 0)) - RETVALUE(RFAILED); + return RFAILED; #endif #ifndef CM_MT_HASH_BIN @@ -1706,7 +1686,7 @@ U16 keyLen; /* length of key */ #endif /* check if table is full */ if (hashListCp->nmbBins == nmbEnt) - RETVALUE(ROUTRES); + return (ROUTRES); /* get pointer to hash list entry header */ hashListEnt = (CmHashListEnt *) (((U8 *) entry) + hashListCp->offset); @@ -1719,7 +1699,7 @@ U16 keyLen; /* length of key */ /* compute index for insertion */ if ((*hashListCp->hashFunc)(hashListCp, key, keyLen, &idx) != ROK) - RETVALUE(RFAILED); + return RFAILED; /* * find an empty bin @@ -1741,7 +1721,7 @@ U16 keyLen; /* length of key */ /* insert into list */ if (cmListInsert(hashBin->prev, &hashListEnt->list) != ROK) - RETVALUE(RFAILED); + return RFAILED; hashListEnt->hashVal = idx; @@ -1752,7 +1732,7 @@ U16 keyLen; /* length of key */ hashBin->nmbEnt++; #endif - RETVALUE(ROK); + return ROK; } /* end of cmHashListOAInsert */