Loading...
--- xnu/xnu-2050.22.13/libkern/c++/OSSymbol.cpp
+++ xnu/xnu-1228/libkern/c++/OSSymbol.cpp
@@ -79,7 +79,7 @@
Bucket *buckets;
unsigned int nBuckets;
unsigned int count;
- lck_mtx_t *poolGate;
+ mutex_t *poolGate;
static inline void hashSymbol(const char *s,
unsigned int *hashP,
@@ -115,8 +115,8 @@
bool init();
- inline void closeGate() { lck_mtx_lock(poolGate); };
- inline void openGate() { lck_mtx_unlock(poolGate); };
+ inline void closeGate() { mutex_lock(poolGate); };
+ inline void openGate() { mutex_unlock(poolGate); };
OSSymbol *findSymbol(const char *cString) const;
OSSymbol *insertSymbol(OSSymbol *sym);
@@ -141,8 +141,6 @@
kfree(mem, size);
ACCUMSIZE(-size);
}
-
-extern lck_grp_t *IOLockGroup;
bool OSSymbolPool::init()
{
@@ -155,7 +153,7 @@
bzero(buckets, nBuckets * sizeof(Bucket));
- poolGate = lck_mtx_alloc_init(IOLockGroup, LCK_ATTR_NULL);
+ poolGate = mutex_alloc(0);
return poolGate != 0;
}
@@ -177,7 +175,7 @@
}
if (poolGate)
- lck_mtx_free(poolGate, IOLockGroup);
+ kfree(poolGate, 36 * 4);
}
unsigned long OSSymbolPool::log2(unsigned int x)
@@ -275,7 +273,7 @@
probeSymbol = (OSSymbol *) thisBucket->symbolP;
if (inLen == probeSymbol->length
- && (strncmp(probeSymbol->string, cString, probeSymbol->length) == 0))
+ && (strcmp(probeSymbol->string, cString) == 0))
return probeSymbol;
return 0;
}
@@ -283,7 +281,7 @@
for (list = thisBucket->symbolP; j--; list++) {
probeSymbol = *list;
if (inLen == probeSymbol->length
- && (strncmp(probeSymbol->string, cString, probeSymbol->length) == 0))
+ && (strcmp(probeSymbol->string, cString) == 0))
return probeSymbol;
}
@@ -312,7 +310,7 @@
probeSymbol = (OSSymbol *) thisBucket->symbolP;
if (inLen == probeSymbol->length
- && strncmp(probeSymbol->string, cString, probeSymbol->length) == 0)
+ && strcmp(probeSymbol->string, cString) == 0)
return probeSymbol;
list = (OSSymbol **) kalloc(2 * sizeof(OSSymbol *));
@@ -331,7 +329,7 @@
for (list = thisBucket->symbolP; j--; list++) {
probeSymbol = *list;
if (inLen == probeSymbol->length
- && strncmp(probeSymbol->string, cString, probeSymbol->length) == 0)
+ && strcmp(probeSymbol->string, cString) == 0)
return probeSymbol;
}
@@ -361,11 +359,8 @@
j = thisBucket->count;
list = thisBucket->symbolP;
- if (!j) {
- // couldn't find the symbol; probably means string hash changed
- panic("removeSymbol");
+ if (!j)
return;
- }
if (j == 1) {
probeSymbol = (OSSymbol *) list;
@@ -377,8 +372,6 @@
SHRINK_POOL();
return;
}
- // couldn't find the symbol; probably means string hash changed
- panic("removeSymbol");
return;
}
@@ -404,8 +397,6 @@
SHRINK_POOL();
return;
}
- // couldn't find the symbol; probably means string hash changed
- panic("removeSymbol");
return;
}
@@ -431,8 +422,6 @@
return;
}
}
- // couldn't find the symbol; probably means string hash changed
- panic("removeSymbol");
}
/*
@@ -601,33 +590,3 @@
else
return false;
}
-
-unsigned int
-OSSymbol::bsearch(
- const void * key,
- const void * array,
- unsigned int arrayCount,
- size_t memberSize)
-{
- const void **p;
- unsigned int baseIdx = 0;
- unsigned int lim;
-
- for (lim = arrayCount; lim; lim >>= 1)
- {
- p = (typeof(p)) (((uintptr_t) array) + (baseIdx + (lim >> 1)) * memberSize);
- if (key == *p)
- {
- return (baseIdx + (lim >> 1));
- }
- if (key > *p)
- {
- // move right
- baseIdx += (lim >> 1) + 1;
- lim--;
- }
- // else move left
- }
- // not found, insertion point here
- return (baseIdx + (lim >> 1));
-}