コード例 #1
0
ファイル: FakeSMCDevice.cpp プロジェクト: Bitesher/HWSensors
FakeSMCKey *FakeSMCDevice::getKey(const char *name)
{
    KEYSLOCK;
    OSCollection *snapshotKeys = keys->copyCollection();
    KEYSUNLOCK;
    
    if (OSCollectionIterator *iterator = OSCollectionIterator::withCollection(snapshotKeys)) {

        char validKeyNameBuffer[5];
        copySymbol(name, validKeyNameBuffer);
        
		while (FakeSMCKey *key = OSDynamicCast(FakeSMCKey, iterator->getNextObject())) {
            UInt32 key1 = HWSensorsKeyToInt(&validKeyNameBuffer);
			UInt32 key2 = HWSensorsKeyToInt(key->getKey());
			if (key1 == key2) {
				OSSafeRelease(iterator);
                OSSafeRelease(snapshotKeys);
				return key;
			}
		}
        
        OSSafeRelease(iterator);
	}
    
    OSSafeRelease(snapshotKeys);
    
 	FakeSMCDebugLog("key %s not found", name);
    
	return 0;
}
コード例 #2
0
FakeSMCKey *FakeSMCDevice::getKey(const char *name)
{
    KEYSLOCK;
    
    FakeSMCKey* key = 0;
    if (OSCollectionIterator *iterator = OSCollectionIterator::withCollection(keys)) {
        
        // Made the key name valid (4 char long): add trailing spaces if needed
        char validKeyNameBuffer[5];
        copySymbol(name, validKeyNameBuffer);
        
		while ((key = OSDynamicCast(FakeSMCKey, iterator->getNextObject()))) {
            UInt32 key1 = HWSensorsKeyToInt(&validKeyNameBuffer);
			UInt32 key2 = HWSensorsKeyToInt(key->getKey());
			if (key1 == key2) {
				break;
			}
		}
        
        OSSafeRelease(iterator);
	}
    KEYSUNLOCK;
    
    if (!key)
        FakeSMCDebugLog("key %s not found", name);
    
	return key;
}
コード例 #3
0
ファイル: FakeSMCKey.cpp プロジェクト: ritzcarltn/HWSensors
bool FakeSMCKey::setType(const char *aType)
{
    if (aType) {
        copySymbol(aType, type);
        return true;
    }
    
    return false;
}
コード例 #4
0
ファイル: SDCCmem.c プロジェクト: doniexun/kcc
/*-----------------------------------------------------------------*/
void
deallocParms (value * val)
{
  value *lval;

  for (lval = val; lval; lval = lval->next)
    {
      /* unmark is myparm */
      lval->sym->ismyparm = 0;

      /* delete it from the symbol table  */
      deleteSym (SymbolTab, lval->sym, lval->sym->name);

      if (!lval->sym->isref)
        {
          lval->sym->allocreq = 0;
            werror (W_NO_REFERENCE,
                    currFunc ? currFunc->name : "(unknown)",
                    "function argument", lval->sym->name);
        }

      /* move the rname if any to the name for both val & sym */
      /* and leave a copy of it in the symbol table           */
      if (lval->sym->rname[0])
        {
          char buffer[SDCC_NAME_MAX];
          symbol * argsym = lval->sym;

          strncpyz (buffer, lval->sym->rname, sizeof(buffer));
          lval->sym = copySymbol (lval->sym);
          strncpyz (lval->sym->rname, buffer, sizeof(lval->sym->rname));

          strncpyz (lval->sym->name, buffer, sizeof(lval->sym->name));
          /* need to keep the original name for inlining to work */
          /*strncpyz (lval->name, buffer, sizeof(lval->name)); */

          addSym (SymbolTab, lval->sym, lval->sym->name,
                  lval->sym->level, lval->sym->block, 1);
          lval->sym->_isparm = 1;
          if (!isinSet (operKeyReset, lval->sym))
            {
              addSet(&operKeyReset, lval->sym);
            }

          /* restore the original symbol */
          lval->sym = argsym;
        }
    }
  return;
}
コード例 #5
0
ファイル: cof_syms.c プロジェクト: skitlab/ti-xdctools
int COF_getSymbol(COF_Handle desc, String name, COF_Symbol *symbol)
{
    Char        symName[COF_MAXEXPR];
    Int         error = COF_EBADARG;
    Long        i;
    COF_Symbol  temp;

    if (symbol == NULL) {
        return (COF_EBADARG);
    }

    (*desc->attrs.fseek)(desc->file, desc->header.symTabPtr, SEEK_SET);
    
    for (i = 0; i < desc->header.nSyms; ) {

        i += getNextSymbol(desc, desc->file, symbol);

        _COF_getName(desc, &symbol->nameDesc, symName);

        if (strcmp(name, symName) == 0) {
            copySymbol(symbol, &temp);
            /* If we find an external definition, we get out, otherwise save
             * the found one to return it, if we can't find and external one.
             */
            if (symbol->type == COF_C_EXT) {
                error = COF_EOK;
                break;
            }
            else {
                copySymbol(symbol, &temp);
                error = COF_EOK;
            }
        }
    }
    copySymbol(&temp, symbol);
    return (error);
}
コード例 #6
0
ファイル: FakeSMCKey.cpp プロジェクト: alexandrezia/HWSensors
bool FakeSMCKey::init(const char * aKey, const char * aType, unsigned char aSize, const void *aValue, IOService * aHandler)
{
    if (!super::init())
        return false;

	if (!aKey || strlen(aKey) == 0 || !(key = (char *)IOMalloc(5))) 
		return false;
	
	copySymbol(aKey, key);
    
	size = aSize;
	
	if (!(type = (char *)IOMalloc(5)))
		return false;
    
	if (!aType || strlen(aType) == 0) {
		switch (size) 
		{
			case 1:
				copySymbol("ui8", type);
				break;
			case 2:
				copySymbol("ui16", type);
				break;
			case 4:
				copySymbol("ui32", type);
				break;
			default:
				copySymbol("ch8*", type);
				break;
		}
        //copySymbol("\0\0\0\0", type);
	}
	else 
        copySymbol(aType, type);
	
	if (size == 0)
		size++;
    
	if (!(value = IOMalloc(size)))
		return false;
	
	if (aValue)
		bcopy(aValue, value, size);
	else
		bzero(value, size);
	
	handler = aHandler;
	
    return true;
}