Exemplo n.º 1
0
Arquivo: pq.c Projeto: AIdrifter/DS
int pqExtractMax(struct pq_t *pThis, void *pRetKey, void *pRetObj){
    if(pThis->size == 0)
        return __DS__PQ__EMPTY__;
    void *max = pThis->keyArray, *iter;
    size_t max_i = 0, i;
    for(i=1; i<pThis->size; i++){
        /* find max */
        iter = getAddr(pThis->keyArray, i, pThis->keySize);
        if((*(pThis->cmp))(max, iter) < 0){
            max = iter;
            max_i = i;
        }
    }
    getItem(pThis->keyArray, max_i, pRetKey, pThis->keySize);
    getItem(pThis->objArray, max_i, pRetObj, pThis->objSize);

    for(i=max_i; i<pThis->size-1; i++){
        void *iter1 = getAddr(pThis->keyArray, i, pThis->keySize);
        void *iter2 = getAddr(pThis->keyArray, i+1, pThis->keySize);
        memcpy(iter1, iter2, pThis->keySize);
        iter1 = getAddr(pThis->objArray, i, pThis->objSize);
        iter2 = getAddr(pThis->objArray, i+1, pThis->objSize);
        memcpy(iter1, iter2, pThis->objSize);
        hmSet(pThis->pObjToIndex, iter1, &i);
    }
    hmDelete(pThis->pObjToIndex, pRetObj);
    pThis->size--;
    return __DS__PQ__NORMAL__;
}
Exemplo n.º 2
0
void	*getTinyOrSmall(char type, size_t size) {
	void	*ptr;

	if (type == TINY)
		ptr = getAddr(size, TINY_M, &g_memory.tiny_array, g_memory.tiny_addrs);
	else
		ptr = getAddr(size, SMALL_M, &g_memory.small_array, g_memory.small_addrs);
	return (ptr);
}
Exemplo n.º 3
0
 bool SockAddr::isLocalHost() const {
     switch (getType()) {
     case AF_INET: return getAddr() == "127.0.0.1";
     case AF_INET6: return getAddr() == "::1";
     case AF_UNIX: return true;
     default: return false;
     }
     fassert(16502, false);
     return false;
 }
/*!
 *  Create server listening on socket
 *  Subscribes to connection events with ID SERVER_ID
 */
void GdbServerWindow::createServer() {

   // Create the address
   IPaddress listenAddr;
   listenAddr.Service(shared->getGdbServerPort());
   listenAddr.Hostname(_("localhost"));
   serverAddr = getAddr(listenAddr);

   closeServer();

   // Create the socket
   serverSocket = new wxSocketServer(listenAddr, wxSOCKET_NOWAIT);

   // We use IsOk() here to see if the server is really listening
   if (!serverSocket->IsOk()) {
      statusTextControl->AppendText(_("ERROR: Could not create server at the specified port !\n"));
      return;
   }

   string bdmSerialNumber = shared->getBdmSerialNumber();
   if (bdmSerialNumber.length() > 0) {
      if (shared->getBdmMatchRequired()) {
         statusTextControl->AppendText(_("Using required USBDM interface S/N = \'")+wxString(bdmSerialNumber.c_str(), wxConvUTF8)+_("\'\n"));
      }
      else {
         statusTextControl->AppendText(_("Using preferred USBDM interface S/N = \'")+wxString(bdmSerialNumber.c_str(), wxConvUTF8)+_("\'\n"));
      }
   }
   else {
      statusTextControl->AppendText(_("Using any suitable USBDM interface\n"));
   }
   IPaddress addrReal;
   if (!serverSocket->GetLocal(addrReal) ) {
      statusTextControl->AppendText(_("ERROR: couldn't get the address we bound to\n"));
   }
   else {
      serverAddr = getAddr(addrReal);
      wxString s;
      s.Printf(_("Server created @%s\n"), (const char *)serverAddr.c_str());
      statusTextControl->AppendText(s);
   }

   // Setup the event handler and subscribe to connection events
   serverSocket->SetEventHandler(*this, SERVER_ID);
   serverSocket->SetNotify(wxSOCKET_CONNECTION_FLAG);
   serverSocket->Notify(true);

   serverState = listening;

   UpdateStatusBar();
}
Exemplo n.º 5
0
/* resetTab()
 */
static void
resetTab (hTab * tabPtr)
{
  int lastSize;
  int slot;
  struct hLinks *lastSlotPtr;
  struct hLinks *lastList;
  hEnt *hEntPtr;

  lastSlotPtr = tabPtr->slotPtr;
  lastSize = tabPtr->size;

  h_initTab_ (tabPtr, tabPtr->size * RESETFACTOR);

  for (lastList = lastSlotPtr; lastSize > 0; lastSize--, lastList++)
    {
      while (lastList != lastList->bwPtr)
	{
	  hEntPtr = (hEnt *) lastList->bwPtr;
	  remList_ ((struct hLinks *) hEntPtr);
	  slot = getAddr (tabPtr, (char *) hEntPtr->keyname);
	  insList_ ((struct hLinks *) hEntPtr,
		    (struct hLinks *) (&(tabPtr->slotPtr[slot])));
	  tabPtr->numEnts++;
	}
    }

  free (lastSlotPtr);

}
Exemplo n.º 6
0
static int ncp6335d_get_voltage(struct regulator_dev *rdev)
{
	unsigned int val;
	int rc;
	struct ncp6335d_info *dd = rdev_get_drvdata(rdev);
	struct i2c_client *client = to_i2c_client(dd->dev);

	mutex_lock(&dd->ncp_mutex);
	if (dd->is_suspend) {
		rc = dd->curr_voltage;
		dev_dbg(dd->dev, "Get voltage after suspend, (%d)\n", rc);
		goto out;
	}

	rc = regmap_read(dd->regmap, dd->vsel_reg, &val);
	if (rc) {
		dev_err(dd->dev, "Unable to get volatge rc(%d), %x\n", rc, client->addr);
		getAddr(client);
		rc = regmap_read(dd->regmap, dd->vsel_reg, &val);
		if (rc) {
			dev_err(dd->dev, "Unable to get voltage rc(%d), %x\n", rc, client->addr);
			goto out;
		}
	}
	dd->curr_voltage = ((val & NCP6335D_VOUT_SEL_MASK) * dd->step_size) +
				dd->min_voltage;

	rc = dd->curr_voltage;

	dump_registers(dd, dd->vsel_reg, __func__);

out:
	mutex_unlock(&dd->ncp_mutex);
	return rc;
}
Exemplo n.º 7
0
void FstopComms::respondWrite()
{
    if(!checkcheck())
        return;

    unsigned int addr=getAddr();
    char len=cmd[PKT_LEN];

    if(len < 1 || len > PKT_MAXREQ || addr < EEPROM_MIN_WRITE || addr+len > EEPROM_MAX_WRITE){
        nak(BAD_WRITE);
        return;
    }

    // copy from buffer to EEPROM
    char bp=PKT_SHORTHDR;
    for(char i=0;i<len;++i){
        EEPROM.write(addr++, cmd[bp++]);
    }

    cmd[PKT_CMD]=COM_WRITEACK;
    buflen=PKT_SHORTHDR;

    // recompute checksum, send without data
    txCmd();
}
Exemplo n.º 8
0
unsigned char SONAR::initAddr(unsigned char addr) {
	debug();
	if(0x11<=addr && addr<=0x30) _addr=addr;
	generateTrigCmd();
	generateDistCmd();
	return getAddr();
}
Exemplo n.º 9
0
static asynStatus uint32Read(void *pvt,asynUser *pasynUser,
                             epicsUInt32 *value,epicsUInt32 mask)
{
    drvPvt *pdrvPvt = (drvPvt *)pvt;
    int        addr;
    asynStatus status;

    status = getAddr(pdrvPvt,pasynUser,&addr,0);
    if(status!=asynSuccess) return status;
    asynPrint(pasynUser, ASYN_TRACE_FLOW,
              "%s %d uint32DigitalDriver:readInt32\n",pdrvPvt->portName,addr);
    if(!pdrvPvt->connected) {
        asynPrint(pasynUser,ASYN_TRACE_ERROR,
                  "%s uint32DigitalDriver:read  not connected\n",pdrvPvt->portName);
        epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
                      "%s uint32DigitalDriver:read not connected",pdrvPvt->portName);
        return asynError;
    }
    epicsMutexMustLock(pdrvPvt->lock);
    *value = mask & pdrvPvt->channel[addr].value;
    epicsMutexUnlock(pdrvPvt->lock);
    asynPrint(pasynUser,ASYN_TRACEIO_DRIVER,
              "%s read %d\n",pdrvPvt->portName,*value);
    return asynSuccess;
}
Exemplo n.º 10
0
InspectorItem::InspectorItem(Any pointer, List<IFieldMeta*>* fields, InspectorItem* parent, int row)
    : pointer{pointer}
    , fields{fields}
    , parent{parent}
    , row{row}
{
    for (auto i = 0; i < fields->size(); i++)
    {
        InspectorItem* child = nullptr;

        auto field = fields->at(i);
        auto type = field->getType();
        auto subFields = getFields(type);
        if (subFields->size() > 0)
        {
            bool isProperty = dynamic_cast<PropertyMeta*>(field);
            if (!isProperty)
            {
                auto subPointer = field->getAddr(pointer);
                child = new InspectorItem(subPointer, subFields, this, i);
            }
        }

        childs.push_back(child);
    }
}
Exemplo n.º 11
0
static unsigned int ncp6335d_get_mode(struct regulator_dev *rdev)
{
	unsigned int val;
	int rc;
	struct ncp6335d_info *dd = rdev_get_drvdata(rdev);
	struct i2c_client *client = to_i2c_client(dd->dev);

	rc = regmap_read(dd->regmap, REG_NCP6335D_COMMAND, &val);
	if (rc) {
		dev_err(dd->dev, "Unable to get regulator mode rc(%d), %x\n", rc, client->addr);
		getAddr(client);
		rc = regmap_read(dd->regmap, REG_NCP6335D_COMMAND, &val);
		if (rc) {
			dev_err(dd->dev, "Unable to get regulator mode rc1(%d), %x\n", rc, client->addr);
			return rc;
		}
	}

	dump_registers(dd, REG_NCP6335D_COMMAND, __func__);

	if (val & dd->mode_bit)
		return REGULATOR_MODE_FAST;

	return REGULATOR_MODE_NORMAL;
}
Exemplo n.º 12
0
void MemBufferEntry::mergeDestroy()
{
  if (wrmask)
    chunkCopy(realAddr, getAddr(), wrmask);

  mePool.in(this);
}
Exemplo n.º 13
0
/******************************************************************
 Title:instruction
 Function:Pin calls this function every time a new instruction is 
 executed
 Input:
 RTN rtn:The current instruction.
 VOID *v:The second argument.
 Output:
 VOID
******************************************************************/
VOID instruction(INS ins, VOID *v)
{
	/*fprintf(trace,insName.c_str());
	fprintf(trace,"\n");
	decode(ins);*/
	if(flag==0&&hasFound==0)
		return;
	else
		hasFound=1;
	if(flag==1&&hasFound==1){
		fprintf(output,"****************************************************\n");
		fprintf(output,"Before the application\n");
		ADDRINT baseAdd = getAddr();
		ADDRINT length = getSizeL();
		memManager->markTaintedBlock(baseAdd,length);
		memManager->printState(output);
		flag=0;
	}
	OPCODE opcode  = INS_Opcode(ins);
	UINT32 operandCount = INS_OperandCount(ins);
	UINT insExt = INS_Extension(ins);
	unsigned int realOpcode = opcode&0xffff;
	OperandKind kind = getOperandKind(ins);
	unsigned int insKind = INSNUM(realOpcode,kind);
	handleIns(insKind,ins);
}
Exemplo n.º 14
0
static asynStatus float64Read(void *pvt,asynUser *pasynUser,
                              epicsFloat64 *value)
{
    drvPvt *pdrvPvt = (drvPvt *)pvt;
    int        addr;
    asynStatus status;

    status = getAddr(pdrvPvt,pasynUser,&addr,0);
    if(status!=asynSuccess) return status;
    asynPrint(pasynUser, ASYN_TRACE_FLOW,
              "%s %d uint32DigitalDriver:float64Read\n",pdrvPvt->portName,addr);
    if(!pdrvPvt->connected) {
        asynPrint(pasynUser,ASYN_TRACE_ERROR,
                  "%s uint32DigitalDriver:read  not connected\n",pdrvPvt->portName);
        epicsSnprintf(pasynUser->errorMessage,pasynUser->errorMessageSize,
                      "%s uint32DigitalDriver:read not connected",pdrvPvt->portName);
        return asynError;
    }
    epicsMutexMustLock(pdrvPvt->lock);
    *value = pdrvPvt->interruptDelay;
    epicsMutexUnlock(pdrvPvt->lock);
    asynPrint(pasynUser,ASYN_TRACEIO_DRIVER,
              "%s read %f\n",pdrvPvt->portName,*value);
    return asynSuccess;
}
Exemplo n.º 15
0
static asynStatus float64Write(void *pvt,asynUser *pasynUser,
                               epicsFloat64 value)
{
    drvPvt   *pdrvPvt = (drvPvt *)pvt;
    int        addr;
    asynStatus status;
    ELLLIST *pclientList;
    interruptNode *pnode;
    asynFloat64Interrupt *pinterrupt;

    status = getAddr(pdrvPvt,pasynUser,&addr,0);
    if(status!=asynSuccess) return status;
    epicsMutexMustLock(pdrvPvt->lock);
    pdrvPvt->interruptDelay = value;
    epicsMutexUnlock(pdrvPvt->lock);
    epicsEventSignal(pdrvPvt->waitWork);
    asynPrint(pasynUser,ASYN_TRACEIO_DRIVER,
              "%s addr %d write %f\n",pdrvPvt->portName,addr,value);
    pasynManager->interruptStart(pdrvPvt->asynFloat64Pvt, &pclientList);
    pnode = (interruptNode *)ellFirst(pclientList);
    while (pnode) {
        pinterrupt = pnode->drvPvt;
        if(addr==pinterrupt->addr && pinterrupt->pasynUser->reason==1) {
            pinterrupt->callback(pinterrupt->userPvt,pinterrupt->pasynUser,value);
            break;
        }
        pnode = (interruptNode *)ellNext(&pnode->node);
    }
    pasynManager->interruptEnd(pdrvPvt->asynFloat64Pvt);
    return asynSuccess;
}
Exemplo n.º 16
0
void RegSettingsDlg::setupEventHandlers()
{
    QObject::connect(mLeName, SIGNAL(textChanged(QString)), this, SLOT(getName(QString)));
    QObject::connect(mLeSrvAddr, SIGNAL(textChanged(QString)), this, SLOT(getAddr(QString)));
    QObject::connect(mLeSrvPort, SIGNAL(textChanged(QString)), this, SLOT(getPort(QString)));
    QObject::connect(mBtnOk, SIGNAL(clicked()), this, SLOT(saveSettings()));
    QObject::connect(mBtnCancel, SIGNAL(clicked()), this, SLOT(close()));
}
Exemplo n.º 17
0
void InstStore::dump(const Cfg *Func) const {
  Ostream &Str = Func->getContext()->getStrDump();
  Type Ty = getData()->getType();
  Str << "store " << Ty << " ";
  getData()->dump(Func);
  Str << ", " << Ty << "* ";
  getAddr()->dump(Func);
  Str << ", align " << typeAlignInBytes(Ty);
}
Exemplo n.º 18
0
/* h_getEnt_()
 * Get an entry from the hash table based on
 * a given key.
 */
hEnt *
h_getEnt_ (hTab * tabPtr, const char *key)
{
  if (tabPtr->numEnts == 0)
    return NULL;

  return (h_findEnt (key, &(tabPtr->slotPtr[getAddr (tabPtr, key)])));

}
Exemplo n.º 19
0
static int ncp6335d_set_mode(struct regulator_dev *rdev,
					unsigned int mode)
{
	int rc;
	struct ncp6335d_info *dd = rdev_get_drvdata(rdev);
	struct i2c_client *client = to_i2c_client(dd->dev);

	
	if (mode != REGULATOR_MODE_FAST && mode != REGULATOR_MODE_NORMAL) {
		dev_err(dd->dev, "Mode %d not supported\n", mode);
		return -EINVAL;
	}

	rc = regmap_update_bits(dd->regmap, REG_NCP6335D_COMMAND, dd->mode_bit,
			(mode == REGULATOR_MODE_FAST) ? dd->mode_bit : 0);
	if (rc) {
		dev_err(dd->dev, "Unable to set operating mode rc(%d), %x", rc, client->addr);
		getAddr(client);
		rc = regmap_update_bits(dd->regmap, REG_NCP6335D_COMMAND, dd->mode_bit,
			(mode == REGULATOR_MODE_FAST) ? dd->mode_bit : 0);
		if (rc)
			dev_err(dd->dev, "Unable to set operating mode rc1(%d), %x", rc, client->addr);
		return rc;
	}

	rc = regmap_update_bits(dd->regmap, REG_NCP6335D_COMMAND,
					NCP6335D_DVS_PWM_MODE,
					(mode == REGULATOR_MODE_FAST) ?
					NCP6335D_DVS_PWM_MODE : 0);
	if (rc) {
		dev_err(dd->dev, "Unable to set DVS trans. mode rc(%d), %x", rc, client->addr);
		getAddr(client);
		rc = regmap_update_bits(dd->regmap, REG_NCP6335D_COMMAND,
					NCP6335D_DVS_PWM_MODE,
					(mode == REGULATOR_MODE_FAST) ?
					NCP6335D_DVS_PWM_MODE : 0);
		if (rc)
			dev_err(dd->dev, "Unable to set DVS trans. mode rc1(%d), %x", rc, client->addr);
	}

	dump_registers(dd, REG_NCP6335D_COMMAND, __func__);

	return rc;
}
Exemplo n.º 20
0
void Instruction::dump(const char *str) const
{
  MSG("%s:0x%8x: reg[%2d] = reg[%2d] [%8s:%2d] reg[%2d] (uEvent=%d)", str,
      (int)getAddr(), dest, src1, opcode2Name(opcode), subCode, src2, uEvent);

#if !((defined TRACE_DRIVEN)||(defined MIPS_EMUL)||(defined QEMU_DRIVEN))
  // This is mint-only junk
  Itext[currentID()]->dump();
#endif
}
Exemplo n.º 21
0
tDMA_TAG *DMACh::DMAtransfer(u32 addr, u32 num)
{
	tDMA_TAG *tag = getAddr(addr, num, false);

	if (tag == NULL) return NULL;

    chcrTransfer(tag);
    qwcTransfer(tag);
    return tag;
}
Exemplo n.º 22
0
unsigned char* SONAR::generateDistCmd() {
	debug();
	for(int i=0;i<sizeof(distCmdTemplate);++i) {
		_distCmd[i]=distCmdTemplate[i];
	}
	_distCmd[2]=getAddr();
	for(int i=0;i<sizeof(distCmdTemplate)-1;++i) {
		_distCmd[sizeof(distCmdTemplate)-1]+=_distCmd[i];
	}
	return _distCmd;
}
Exemplo n.º 23
0
static void handleEvent(evutil_socket_t socket, short eventType, void* vcontext)
{
    // We don't care about this, there's only one event registered under this socket.
    eventType = eventType;

    struct UDPInterface* context = (struct UDPInterface*) vcontext;

    struct Message message =
        { .bytes = context->messageBuff + PADDING, .padding = PADDING, .length = MAX_PACKET_SIZE };

    struct sockaddr_storage addrStore;
    memset(&addrStore, 0, sizeof(struct sockaddr_storage));
    int addrLen = sizeof(struct sockaddr_storage);
    int rc = recvfrom(socket,
                      message.bytes,
                      MAX_PACKET_SIZE,
                      0,
                      (struct sockaddr*) &addrStore,
                      (socklen_t*) &addrLen);
    /*
    Log_debug1(context->logger,
               "Got message from peer on port %u\n",
               Endian_bigEndianToHost16(((struct sockaddr_in*) &addrStore)->sin_port));
    */
    if (addrLen != context->addrLen) {
        return;
    }
    if (rc < 0) {
        return;
    }
    message.length = rc;

    uint32_t addr = getAddr(&addrStore);
    for (uint32_t i = 0; i < context->endpointCount; i++) {
        if (addr == context->addresses[i]
              && memcmp(&context->endpoints[i].addr,
                        &addrStore,
                        sizeof(struct sockaddr_storage)) == 0)
        {
            struct Interface* iface = &context->endpoints[i].interface;
            if (iface->receiveMessage != NULL) {
                iface->receiveMessage(&message, iface);
            }
            return;
        }
    }

    // Otherwise just send it to the default interface.
    if (context->defaultInterface != NULL && context->defaultInterface->receiveMessage != NULL) {
        context->defaultInterfaceSender = &addrStore;
        context->defaultInterface->receiveMessage(&message, context->defaultInterface);
        context->defaultInterfaceSender = NULL;
    }
}
Exemplo n.º 24
0
unsigned char* SONAR::generateTrigCmd() {
	debug();
	for(int i=0;i<sizeof(trigCmdTemplate);++i) {
		_trigCmd[i]=trigCmdTemplate[i];
	}
	_trigCmd[2]=getAddr();
	for(int i=0;i<sizeof(trigCmdTemplate)-1;++i) {
		_trigCmd[sizeof(trigCmdTemplate)-1]+=_trigCmd[i];
	}
	return _trigCmd;
}
Exemplo n.º 25
0
void GotoStatement::adjustFixedDest(int delta)
{
    // Ensure that the destination is fixed.
    if (!m_dest || !m_dest->isIntConst()) {
        LOG_ERROR("Can't adjust destination of non-static CTI");
        return;
    }

    auto theConst = std::static_pointer_cast<Const>(m_dest);
    theConst->setAddr(theConst->getAddr() + delta);
}
Exemplo n.º 26
0
String Plugin::getHash(int8_t sensor) {
  char addr_c[32];
  if (getAddr(&addr_c[0], sensor)) {
    MD5Builder md5 = ::getHashBuilder();
    md5.add(getName());
    md5.add(addr_c);
    md5.calculate();
    return md5.toString();
  }
  return "";
}
Exemplo n.º 27
0
int Pass2_LinkingLoader_M(char *record, Linkedlist *RSymbol){
	
	int ModifyLocation,q,r,ModifyValueInt,sum,carry=0;
	char *ModifyValueString;
	char *externalSymbol;
	Linkedlist ex;

	ModifyLocation = StringToHex(copy(1,6,record)) + csaddress; // Modification location
	q=ModifyLocation/16;
	r=ModifyLocation%16;
	if((externalSymbol = getAddr(copy(10,11,record),*RSymbol)) == NULL){ // Get Symbol that fit in refenrence Number
			printf("%s / Undefined Reference Symbol\n",copy(10,11,record));
			return -1;
	}
	ex = external_table[MneToOp(externalSymbol)];
	if((ModifyValueString = getAddr(externalSymbol,ex)) == NULL){ //Get ADdr of Symbol using ESTAB
			printf("%s / Undefined External Symbol\n",externalSymbol);
			return -1;
	}
	ModifyValueInt = StringToHex(ModifyValueString);
	
	/* carry out Add, Sub using Carry bit and Borrow bit */
	if(record[9] == '+'){
		
		if(r+2>0xf){ r=(r+2)%16; q++;} 
		else{r+=2;}


		carry = addAndCarryCheck((int)memory[r][q],(ModifyValueInt & 0x000000FF),carry,&sum); // 5,6 bit
		memory[r][q] = sum;
		RExcess16(&q,&r);

		carry = addAndCarryCheck((int)memory[r][q],((ModifyValueInt >> 8) & 0x000000FF),carry,&sum); // 3,4 bit
		memory[r][q] = sum;
		RExcess16(&q,&r);

		if(!strcmp(copy(7,8,record),"05")){ // 1,2 bit
			carry = addAndCarryCheck((int)memory[r][q],((ModifyValueInt >> 16) & 0x0000000F),carry,&sum);
			memory[r][q] = sum;
		}
		else if(!strcmp(copy(7,8,record),"06")){
Exemplo n.º 28
0
void readPerfData(gzFile file, bool computeArcWeight) {
  char line[BUFLEN];

  while (gzgets(file, line, BUFLEN) != Z_NULL) {
    HFTRACE(2, "readPerfData: line: %s\n", line);
    if (line[0] == '#') continue;
    if (isspace(line[0])) continue;

    // process one sample
    if (gzgets(file, line, BUFLEN) == Z_NULL) error("reading perf data");
    auto addrTop = getAddr(line);
    FuncId idTop = getFuncId(addrTop);
    if (idTop == InvalidId) continue;
    cg.funcs[idTop].samples++;
    HFTRACE(2, "readPerfData: idTop: %u %s\n", idTop,
            cg.funcs[idTop].mangledNames[0].c_str());
    if (gzgets(file, line, BUFLEN) == Z_NULL) error("reading perf data");
    auto addrCaller = getAddr(line);
    FuncId idCaller = getFuncId(addrCaller);
    if (idCaller != InvalidId) {
      auto arc = cg.getArc(idCaller, idTop);
      if (computeArcWeight) {
        arc->weight++;
        arc->avgCallOffset += addrCaller - cg.funcs[idCaller].addr;
      }
      HFTRACE(2, "readPerfData: idCaller: %u %s\n", idCaller,
              cg.funcs[idCaller].mangledNames[0].c_str());
    }
  }

  if (!computeArcWeight) return;

  // Normalize incoming arc weights and compute avgCallOffset for each node.
  for (auto& func : cg.funcs) {
    for (auto arc : func.inArcs) {
      arc->normalizedWeight = arc->weight / func.samples;
      arc->avgCallOffset = arc->avgCallOffset / arc->weight;
    }
  }
}
/*!
 *  Handler for Server events (before connection)
 *
 *  - Only expects connection events wxSOCKET_CONNECTION
 *  - Creates new socket and adds handler for socket events
 *
 *  @param event Event to handle
 */
void GdbServerWindow::OnServerEvent(wxSocketEvent& event) {
   if (event.GetSocketEvent() != wxSOCKET_CONNECTION) {
      statusTextControl->AppendText(_("Unexpected event on Server\n"));
      // Ignore
      return;
   }

   if (clientSocket != NULL) {
      statusTextControl->AppendText(_("Client connection while busy - rejected\n"));
      wxSocketBase *clientSocket = serverSocket->Accept(false);
      clientSocket->Destroy();
      return;
   }

   // Accept new connection if there is one in the pending
   // connections queue, else exit. We use Accept(false) for
   // non-blocking accept (although if we got here, there
   // should ALWAYS be a pending connection).

   clientSocket = serverSocket->Accept(false);
   if (clientSocket == NULL) {
      statusTextControl->AppendText(_("Error: couldn't accept a new connection\n"));
      return;
   }

   IPaddress peerAddr;
   if ( !clientSocket->GetPeer(peerAddr) ) {
      statusTextControl->AppendText(_("New connection from unknown client accepted.\n"));
   }
   else {
      clientAddr = getAddr(peerAddr);
      statusTextControl->AppendText(_(
            "\n=====================================\n"
            "New client connection from ")+ clientAddr + _(" accepted\n"));
   }

   // Subscribe to socket events
   //  wxSOCKET_INPUT_FLAG - received data
   //  wxSOCKET_LOST_FLAG  - lost connection
   clientSocket->SetEventHandler(*this, SOCKET_ID);
   clientSocket->SetNotify(wxSOCKET_INPUT_FLAG | wxSOCKET_LOST_FLAG);
   clientSocket->Notify(true);

   setDeferredFail(false);
   deferredOpen = true;

   statusTimer = new wxTimer(this, SERVER_STATUSTIMER);
   statusTimer->Start(pollIntervalSlow, wxTIMER_ONE_SHOT);

   serverState = connected;
   UpdateStatusBar();
}
Exemplo n.º 30
0
/*
 * 获取进入TX或者是RX模式的命令
 */
void getRT(void)
{
    while (uartRecvData == '\0');

    switch (uartRecvData)
    {
        case 'b':
            mode = CMD_MODE;
            break;
        case 't':
            while (!getAddr());
            mode = TX_MODE;
            break;
        case 'r':
            while (!getAddr());
            mode = RX_MODE;
            break;
        default:
            printf ("ERROR: command error\n");
    }
    uartRecvData = '\0';
}