/************************************************************************ * emaWasDeleted * purpose: Check if an element in EMA was deleted after a call to * emaMark(). * input : elem - Element to mark * output : none * return : TRUE if element was deleted * FALSE if element still exists ************************************************************************/ BOOL emaWasDeleted(IN EMAElement elem) { emaObject* ema; emaElem* rElem; /* Find out our element information */ rElem = (emaElem *)((char*)elem - sizeof(emaElem)); ema = rElem->ema; /* NexTone: added check for NULL ema */ if (ema != NULL) { logPrint(ema->log, RV_DEBUG, (ema->log, RV_DEBUG, "emaWasDeleted (%s): Checking 0x%p (refCount=%d)", raGetName(ema->ra), rElem, EMA_GET_REFERENCE(rElem))); #ifdef RV_EMA_DEBUG if ((rElem->debug1 != EMA_DEBUG_BYTES) || (rElem->debug2 != EMA_DEBUG_BYTES)) { logPrint(ema->log, RV_EXCEP, (ema->log, RV_EXCEP, "emaWasDeleted (%s): Someone is messing with memory 0x%p", raGetName(ema->ra), rElem)); } #endif } /* Check if element was deleted */ return ((rElem->flags & EMA_ALREADY_DELETED) != 0); }
void LogAudit::logDmesg() { int len = klogctl(KLOG_SIZE_BUFFER, NULL, 0); if (len <= 0) { return; } len++; char buf[len]; int rc = klogctl(KLOG_READ_ALL, buf, len); buf[len - 1] = '\0'; for(char *tok = buf; (rc >= 0) && ((tok = strtok(tok, "\r\n"))); tok = NULL) { char *audit = strstr(tok, " audit("); if (!audit) { continue; } *audit++ = '\0'; char *type = strstr(tok, "type="); if (type) { rc = logPrint("%s %s", type, audit); } else { rc = logPrint("%s", audit); } } }
VkBool32 VKTS_APIENTRY engineAttachDisplayToUpdateThread(const INativeDisplayWP& display, const IUpdateThreadSP& updateThread) { if (g_engineState != VKTS_ENGINE_INIT_STATE) { logPrint(VKTS_LOG_ERROR, "Engine: Adding attaching display failed! Not in initialize state."); return VK_FALSE; } if (!updateThread.get()) { logPrint(VKTS_LOG_ERROR, "Engine: No display or update thread."); return VK_FALSE; } auto sharedDisplay = display.lock(); if (!sharedDisplay.get()) { return VK_FALSE; } const auto nativeDisplay = visualGetDisplayInternal(sharedDisplay->getIndex()); if (!nativeDisplay.get()) { return VK_FALSE; } g_allAttachedDisplays.insert(std::pair<IUpdateThreadSP, const NativeDisplaySP>(updateThread, nativeDisplay)); return VK_TRUE; }
int process_clsr(){ int ret; int free_no; char buff[1024]; //T_MESSAGE_QUEUE_FMT mbuff; T_CLIENT_REQUEST req; //受信処理 if ( tcpSelect(l_server_fd,0,G_ConfTbl->select_timeout) != 1 ){ return 0; } l_client_fd=tcpAccept(l_server_fd); logPrint(DEBUG_DEBUG,"tcpAccept(%d) => %d",l_server_fd,l_client_fd); if ( l_client_fd == 0 ){ return 0; } //クライアント要求をタスクに割り振る free_no=cacheGetFreeTaskNo(); if ( free_no < 0 ){ logPrint(DEBUG_WARNING,"task is busy (no slot)"); tcpClose(l_client_fd); return 0; } sprintf(l_sock_file,"%s/ud%03d.sock",G_TempDir,free_no); l_gate_fd=udConnect(l_sock_file); ret=udSend(l_gate_fd, l_client_fd, &req, sizeof(req),G_ConfTbl->send_timeout); logPrint(DEBUG_DEBUG,"udSend(%d,%d,*,%d,%d) => %d", l_gate_fd, l_client_fd,sizeof(req),G_ConfTbl->send_timeout,ret); tcpClose(l_client_fd); return 0; }
// connect to remote server timeout call. bool connect_timeout(int sockfd, const struct sockaddr *addr, socklen_t addrlen, struct timeval* tv_to) { bool result = false; set_non_blocking(sockfd, true); int res = connect(sockfd, addr, addrlen); if ( res < 0 ) { if ( errno == EINPROGRESS ) { fd_set set; FD_ZERO(&set); FD_SET(sockfd, &set); if ( select(sockfd + 1, NULL, &set, NULL, tv_to) > 0 ) { int valopt; int lon = sizeof(int); getsockopt(sockfd, SOL_SOCKET, SO_ERROR, (void*)(&valopt), &lon); if ( valopt ) { logPrint("connect_timeout error in connect(%d): %s", sockfd, strerror(errno)); } } else { logPrint("connect_timeout select(%d) timeout or error: %s", sockfd, strerror(errno)); } } else { logPrint("connect_timeout connect(%d) error: %s", sockfd, strerror(errno)); } } set_non_blocking(sockfd, false); return true; }
VkBool32 VKTS_APIENTRY engineAttachWindowToUpdateThread(const INativeWindowWP& window, const IUpdateThreadSP& updateThread) { if (g_engineState != VKTS_ENGINE_INIT_STATE) { logPrint(VKTS_LOG_ERROR, "Engine: Adding attaching window failed! Not in initialize state."); return VK_FALSE; } if (!updateThread.get()) { logPrint(VKTS_LOG_ERROR, "Engine: No window or update thread."); return VK_FALSE; } auto sharedWindow = window.lock(); if (!sharedWindow.get()) { return VK_FALSE; } const auto nativeWindow = visualGetWindowInternal(sharedWindow->getIndex()); if (!nativeWindow.get()) { return VK_FALSE; } g_allAttachedWindows.insert(std::pair<IUpdateThreadSP, const NativeWindowSP>(updateThread, nativeWindow)); return VK_TRUE; }
VkBool32 VKTS_APIENTRY engineAddUpdateThread(const IUpdateThreadSP& updateThread) { if (g_engineState != VKTS_ENGINE_INIT_STATE) { logPrint(VKTS_LOG_ERROR, "Engine: Adding update thread failed! Not in initialize state."); return VK_FALSE; } if (!updateThread.get()) { logPrint(VKTS_LOG_ERROR, "Engine: Adding update thread failed! No update thread."); return VK_FALSE; } if (engineGetNumberUpdateThreads() >= VKTS_MAX_UPDATE_THREADS) { logPrint(VKTS_LOG_ERROR, "Engine: Adding update thread failed! Too many update threads."); return VK_FALSE; } g_allUpdateThreads.append(updateThread); return VK_TRUE; }
/** This method prints the contents of the matrix - testing purpose only. */ void Matrix::printMatrix() const{ for (unsigned int i=0;i<this->matrix->size1;i++){ for (unsigned int j=0;j<this->matrix->size2;j++) logPrint("%2.6lf\t", this->get(i,j)); logPrint("\n"); } }
/************************************************************************ * cmRASGetTransaction * purpose: Returns the type of RAS transaction * input : hsRas - Stack's handle for the RAS transaction * output : transaction - The type of transaction * return : If an error occurs, the function returns a negative value. * If no error occurs, the function returns a non-negative value. ************************************************************************/ RVAPI int RVCALLCONV cmRASGetTransaction( IN HRAS hsRas, OUT cmRASTransaction* transaction) { rasModule* ras; int status = 0; ras = (rasModule *)emaGetUserData((EMAElement)hsRas); cmiAPIEnter(ras->app, "cmRASGetTransaction(hsRas=0x%x)", hsRas); /* Get the transaction type */ if(emaLock((EMAElement)hsRas)) { /* Check if it's an incoming or an outgong transaction */ switch (emaGetType((EMAElement)hsRas)) { case RAS_OUT_TX: { rasOutTx* tx; tx = rasGetOutgoing(hsRas); if (tx != NULL) *transaction = tx->transactionType; else { logPrint(ras->log, RV_ERROR, (ras->log, RV_ERROR, "cmRASGetTransaction: Bad outgoing transaction handle (0x%x)", hsRas)); status = RVERROR; } break; } case RAS_IN_TX: { rasInTx* tx; tx = rasGetIncoming(hsRas); if (tx != NULL) *transaction = tx->transactionType; else { logPrint(ras->log, RV_ERROR, (ras->log, RV_ERROR, "cmRASGetTransaction: Bad incoming transaction handle (0x%x)", hsRas)); status = RVERROR; } break; } default: status = RVERROR; } emaUnlock((EMAElement)hsRas); } cmiAPIExit(ras->app, "cmRASGetTransaction(hsRas=0x%x,tx=%d,ret=%d)", hsRas, *transaction, status); return status; }
ITextureSP VKTS_APIENTRY textureCreate(const IInitialResourcesSP& initialResources, const std::string& name, const VkBool32 mipmap, const VkBool32 cubemap, const IMemoryImageSP& memoryImage, const VkSamplerCreateInfo& samplerCreateInfo, const VkImageViewCreateInfo& imageViewCreateInfo) { if (!memoryImage.get()) { return ITextureSP(); } // VkSamplerCreateInfo finalSamplerCreateInfo; memcpy(&finalSamplerCreateInfo, &samplerCreateInfo, sizeof(VkImageViewCreateInfo)); finalSamplerCreateInfo.maxLod = mipmap ? (float) memoryImage->getImageData()->getMipLevels() : 0.0f; auto sampler = samplerCreate(initialResources->getDevice()->getDevice(), finalSamplerCreateInfo.flags, finalSamplerCreateInfo.magFilter, finalSamplerCreateInfo.minFilter, finalSamplerCreateInfo.mipmapMode, samplerCreateInfo.addressModeU, samplerCreateInfo.addressModeV, finalSamplerCreateInfo.addressModeW, finalSamplerCreateInfo.mipLodBias, finalSamplerCreateInfo.anisotropyEnable, finalSamplerCreateInfo.maxAnisotropy, finalSamplerCreateInfo.compareEnable, finalSamplerCreateInfo.compareOp, finalSamplerCreateInfo.minLod, finalSamplerCreateInfo.maxLod, finalSamplerCreateInfo.borderColor, finalSamplerCreateInfo.unnormalizedCoordinates); if (!sampler.get()) { logPrint(VKTS_LOG_ERROR, "Texture: Could not create sampler."); return ITextureSP(); } // VkImageViewCreateInfo finalImageViewCreateInfo; memcpy(&finalImageViewCreateInfo, &imageViewCreateInfo, sizeof(VkImageViewCreateInfo)); finalImageViewCreateInfo.image = memoryImage->getImage()->getImage(); finalImageViewCreateInfo.viewType = cubemap ? VK_IMAGE_VIEW_TYPE_CUBE : VK_IMAGE_VIEW_TYPE_2D; finalImageViewCreateInfo.format = memoryImage->getImage()->getFormat(); finalImageViewCreateInfo.subresourceRange.levelCount = mipmap ? memoryImage->getImageData()->getMipLevels() : 1; finalImageViewCreateInfo.subresourceRange.layerCount = cubemap ? memoryImage->getImageData()->getArrayLayers() : 1; auto imageView = imageViewCreate(initialResources->getDevice()->getDevice(), finalImageViewCreateInfo.flags, finalImageViewCreateInfo.image, finalImageViewCreateInfo.viewType, finalImageViewCreateInfo.format, finalImageViewCreateInfo.components, finalImageViewCreateInfo.subresourceRange); if (!imageView.get()) { logPrint(VKTS_LOG_ERROR, "Texture: Could not create image view."); return ITextureSP(); } // auto newInstance = new Texture(initialResources, name, memoryImage, sampler, imageView); if (!newInstance) { newInstance->destroy(); return ITextureSP(); } return ITextureSP(newInstance); }
/************************************************************************ * emaDelete * purpose: Delete an element from EMA * input : elem - Element to delete * return : RVERROR on failure ************************************************************************/ int emaDelete(IN EMAElement elem) { emaObject* ema; emaElem* rElem; int location; if (elem == NULL) return RVERROR; /* Find out our element information */ rElem = (emaElem *)((char*)elem - sizeof(emaElem)); ema = rElem->ema; /* Find the location */ location = raGetByPtr(ema->ra, rElem); logPrint(ema->log, RV_DEBUG, (ema->log, RV_DEBUG, "emaDelete (%s): Deleting %d,0x%p (refCount=%d)", raGetName(ema->ra), location, rElem, EMA_GET_REFERENCE(rElem))); #ifdef RV_EMA_DEBUG if ((rElem->debug1 != EMA_DEBUG_BYTES) || (rElem->debug2 != EMA_DEBUG_BYTES)) { logPrint(ema->log, RV_EXCEP, (ema->log, RV_EXCEP, "emaDelete (%s): Someone is messing with memory 0x%p", raGetName(ema->ra), rElem)); } #endif /* Check the reference count */ if (rElem->flags == 0) { /* No one is looking for this guy - we can delete it */ emaDeleteElement(ema, rElem, location, FALSE, "emaDelete"); } else { meiEnter(ema->lock); #ifdef RV_EMA_DEBUG if ((rElem->flags & EMA_ALREADY_DELETED) != 0) { logPrint(ema->log, RV_EXCEP, (ema->log, RV_EXCEP, "emaDelete (%s): Deleting an element 0x%p for the second time", raGetName(ema->ra), rElem)); } #endif ema->markCount++; rElem->flags |= EMA_ALREADY_DELETED; meiExit(ema->lock); } return 0; }
int main() { logPrint("Ahoj svet !\n"); logPrint("Ahoj svet %d \n", 15); logPrintFile(stderr, "FRPNT %d\n", 10); printer(); return 0; }
/************************************************************************ * cmRASClose * purpose: Close a RAS transaction * input : hsRas - Stack's handle for the RAS transaction * output : none * return : If an error occurs, the function returns a negative value. * If no error occurs, the function returns a non-negative value. ************************************************************************/ RVAPI int RVCALLCONV cmRASClose( IN HRAS hsRas) { rasModule* ras; int status = 0; if (hsRas == NULL) return RVERROR; ras = (rasModule *)emaGetUserData((EMAElement)hsRas); cmiAPIEnter(ras->app, "cmRASClose(hsRas=0x%x)", hsRas); /* Check if it's an incoming or an outgong transaction */ switch (emaGetType((EMAElement)hsRas)) { case RAS_OUT_TX: { rasOutTx* tx; tx = rasGetOutgoing(hsRas); if (tx != NULL) status = rasCloseOutTx(ras, tx); else { logPrint(ras->log, RV_ERROR, (ras->log, RV_ERROR, "cmRASClose: Bad outgoing transaction handle (0x%x)", hsRas)); status = RVERROR; } break; } case RAS_IN_TX: { rasInTx* tx; tx = rasGetIncoming(hsRas); if (tx != NULL) status = rasCloseInTx(ras, tx); else { logPrint(ras->log, RV_ERROR, (ras->log, RV_ERROR, "cmRASClose: Bad incoming transaction handle (0x%x)", hsRas)); status = RVERROR; } break; } default: status = RVERROR; } cmiAPIExit(ras->app, "cmRASClose(hsRas=0x%x,ret=%d)", hsRas, status); return status; }
int daemon_NodeTableInit(){ int i; int ck; char sfilename[MAX_FILE_PATH+1]; FILE *fp; char buff[20480]; u_long addr; T_NODE_TABLE wk; //ステイタス初期化 for(i=0; i<=G_ConfTbl->max_node; i++){ G_NodeTbl[i].sts=SYSTEM_STATUS_UNKNOWN; G_NodeTbl[i].master_flg=MASTER_FLG_NONE; } //server.lstでデータ設定 sprintf(sfilename,"%s/conf/server.lst",G_BaseDir); if ( filisFile(sfilename) != 1 ){ logPrint(DEBUG_INFO,"no file (%s)",sfilename); return 0; } if ( (fp=fopen(sfilename,"r")) == NULL ){ return -1; } while( fgets(buff,sizeof(buff),fp) != NULL ){ utlCurNewLine(buff); if ( (addr=utlHostnameToAddress(buff)) == 0 ){ continue; } memset(&wk,0,sizeof(T_NODE_TABLE)); strcpy(wk.run_hostname, buff); wk.svr_ip=addr; wk.clt_ip=addr; wk.sts=SYSTEM_STATUS_UNKNOWN; wk.master_flg=MASTER_FLG_NONE; utlGetSHA1(wk.run_hostname, wk.node_id); time(&wk.alv); //検索 ck=-1; for(i=0; i<=G_ConfTbl->max_node; i++){ if ( G_NodeTbl[i].run_hostname[0] == NULL ){ break; } if ( strcmp(G_NodeTbl[i].run_hostname, wk.run_hostname) == 0 ){ ck=i; break; } if ( G_NodeTbl[i].svr_ip == wk.svr_ip ){ ck=i; break; } if ( G_NodeTbl[i].clt_ip == wk.clt_ip ){ ck=i; break; } } if ( ck >= 0 ){ continue; } memcpy(&(G_NodeTbl[i]), &wk, sizeof(T_NODE_TABLE)); logPrint(DEBUG_INFO,"G_NodeTbl[%d] %s %s",i,G_NodeTbl[i].run_hostname, utlDisplyIP((u_char*)&G_NodeTbl[i].svr_ip)); } fclose(fp); return 0; }
int emaMark(IN EMAElement elem) #endif { emaObject* ema; emaElem* rElem; if (elem == NULL) return RVERROR; /* Find out our element information */ rElem = (emaElem *)((char*)elem - sizeof(emaElem)); ema = rElem->ema; #ifdef RV_EMA_DEBUG logPrint(ema->log, RV_DEBUG, (ema->log, RV_DEBUG, "emaMark (%s): Marking 0x%p, refCount=%d (%s:%d)", raGetName(ema->ra), rElem, EMA_GET_REFERENCE(rElem), filename, lineno)); if ((rElem->debug1 != EMA_DEBUG_BYTES) || (rElem->debug2 != EMA_DEBUG_BYTES)) { logPrint(ema->log, RV_EXCEP, (ema->log, RV_EXCEP, "emaMark (%s): Someone is messing with memory 0x%p", raGetName(ema->ra), rElem)); } #else logPrint(ema->log, RV_DEBUG, (ema->log, RV_DEBUG, "emaMark (%s): Marking 0x%p, refCount=%d", raGetName(ema->ra), rElem, EMA_GET_REFERENCE(rElem))); #endif /* Increase the reference count */ switch (ema->lockType) { case emaNoLocks: break; case emaNormalLocks: meiEnter((HMEI)((char*)elem + ema->elemSize)); break; case emaLinkedLocks: emaLock(*((EMAElement*)((char*)elem + ema->elemSize))); emaMark(*((EMAElement*)((char*)elem + ema->elemSize))); break; } EMA_INC_REFERENCE(rElem,1); switch (ema->lockType) { case emaNoLocks: break; case emaNormalLocks: meiExit((HMEI)((char*)elem + ema->elemSize)); break; case emaLinkedLocks: emaUnlock(*((EMAElement*)((char*)elem + ema->elemSize))); break; } return 0; }
/************************************************************************ * logRegister * purpose: Register a new type of log. * This will create a new log handle, handling all the messages * under the given 'name' variable. * input : logMgr - Log manager to use * name - Name of log to create * If the name already exists in this log manager * instance, its handle will be returned. * description - Description of the log * output : none * return : Log handle on success * NULL on failure ************************************************************************/ RVAPI RVHLOG RVCALLCONV logRegister( IN RVHLOGMGR logMgr, IN const char* name, IN const char* description) { int i; int firstFree=RVERROR; if (logMgr == NULL) return NULL; for (i = 0; i < MAX_INFO; i++) { if (msInfo[i].inUse && !strcmp(name,msInfo[i].name)) { msInfo[i].inUse++; return (RVHLOG)(i-1); } if (!msInfo[i].inUse) firstFree=i; } if (firstFree>=0) { strncpy(msInfo[firstFree].name,name,sizeof(msInfo[firstFree].name)-1); strncpy(msInfo[firstFree].description,description,sizeof(msInfo[firstFree].description)-1); msInfo[firstFree].inUse=TRUE; logPrint((RVHLOG)(firstFree-1), RV_DEBUG, ((RVHLOG)(firstFree-1), RV_DEBUG, "Registered %-11.11s %s",name,description)); return (RVHLOG)(firstFree-1); } return NULL; }
/************************************************************************ * cmRASInProgress * purpose: Sends a RIP (ReplyInProgress) message on a transaction * input : hsRas - Stack's handle for the RAS transaction * delay - Delay to use in RIP message (in milliseconds) * output : none * return : If an error occurs, the function returns a negative value. * If no error occurs, the function returns a non-negative value. ************************************************************************/ RVAPI int RVCALLCONV cmRASInProgress( IN HRAS hsRas, IN int delay) { rasModule* ras; rasInTx* tx; int status = 0; if (hsRas == NULL) return RVERROR; ras = (rasModule *)emaGetUserData((EMAElement)hsRas); cmiAPIEnter(ras->app, "cmRASInProgress(hsRas=0x%x, delay=%d)", hsRas, delay); /* Get the transaction */ tx = rasGetIncoming(hsRas); if (tx != NULL) status = rasSendRIP(ras, tx, delay, TRUE); else { logPrint(ras->log, RV_ERROR, (ras->log, RV_ERROR, "cmRASInProgress: Bad outgoing transaction handle (0x%x)", hsRas)); status = RVERROR; } cmiAPIExit(ras->app, "cmRASInProgress(hsRas=0x%x,ret=%d)", hsRas, status); return status; }
/************************************************************************ * emaGetApplicationHandle * purpose: Get the application's handle of an element in EMA * input : elem - Element in EMA * output : appHandle - Application's handle for the element * return : Pointer to the application handle * NULL on failure ************************************************************************/ void* emaGetApplicationHandle(IN EMAElement elem) { emaElem* rElem; if (elem == NULL) return NULL; /* Find out our element information */ rElem = (emaElem *)((char*)elem - sizeof(emaElem)); #ifdef RV_EMA_DEBUG { /* Make sure element is not vacant */ emaObject* ema; int location; ema = rElem->ema; /* NexTone: added check for NULL ema */ if (ema != NULL) { location = raGetByPtr(ema->ra, rElem); if (raElemIsVacant(ema->ra, location)) { logPrint(ema->log, RV_EXCEP, (ema->log, RV_EXCEP, "emaGetApplicationHandle (%s): Element %d,0x%p is vacant", raGetName(ema->ra), location, rElem)); } } } #endif return rElem->appHandle; }
int updateMainWin() { int ch = 0; switch (mainWinState) { case MSW_INIT: resetMenuPos(); displayMenu(mainWin); mainWinState = MWS_IDLE; break; case MWS_IDLE: logPrint("Waiting for command to begin or quit\n"); ch = wgetch(mainWin); if (ch == 'b' || ch == 'B') { moveMenuHorizontal(1);// highlight the first menu item in the first run. displayMenu(mainWin); mainWinState = MWS_MENU_NAV; } break; case MWS_MENU_NAV: ch = wgetch(mainWin); menuNavigate(ch); displayMenu(mainWin); //printMenuGraph(); break; case MWS_PRINT: break; } return 0; }
/************************************************************************ * cmRASReject * purpose: Sends a reject response on an incoming RAS request * input : hsRas - Stack's handle for the RAS transaction * reason - The reject reason to use * output : none * return : If an error occurs, the function returns a negative value. * If no error occurs, the function returns a non-negative value. ************************************************************************/ RVAPI int RVCALLCONV cmRASReject( IN HRAS hsRas, IN cmRASReason reason) { rasModule* ras; rasInTx* tx; int status; if (hsRas == NULL) return RVERROR; ras = (rasModule *)emaGetUserData((EMAElement)hsRas); cmiAPIEnter(ras->app, "cmRASReject(hsRas=0x%x)", hsRas); /* Get the transaction */ tx = rasGetIncoming(hsRas); if (tx != NULL) status = rasSendRejectMessage(ras, tx, reason); else { logPrint(ras->log, RV_ERROR, (ras->log, RV_ERROR, "cmRASReject: Bad outgoing transaction handle (0x%x)", hsRas)); status = RVERROR; } cmiAPIExit(ras->app, "cmRASReject(hsRas=0x%x,ret=%d)", hsRas, status); return status; }
void UserControlledSignal(int sign) { g_dStopFlag = 1; logPrint (trcLogId,FL, "[%s] RECEIVED TERMINATED SIGNAL, sig=%d, when=%ld\n" ,__FUNCTION__, sign, time(0)); }/*End of UserControlledSignal()*/
/** * This method is used to create a physical world and load the objects in it. */ void ControllerEditor::loadFramework( int controlShot ){ this->world = NULL; //create a new world, and load some bodies try{ if( controlShot < 0 ) { conF = new SimBiConFramework(inputFile, NULL); } else { char conFile[256]; sprintf(conFile, "..\\controlShots\\cs%05d.sbc", controlShot); conF = new SimBiConFramework(inputFile, conFile); } avgSpeed = 0; timesVelSampled = 0; Globals::changeCurrControlShotStr( controlShot ); conF->getState(&conState); this->world = conF->getWorld(); }catch(const char* msg){ conF = NULL; tprintf("Error: %s\n", msg); logPrint("Error: %s\n", msg); } }
bool set_close_on_exec(int fd) { int flags; int dummy = 0; if ((flags = fcntl(fd, F_GETFL, dummy)) < 0) { logPrint("FD %d: fcntl F_GETFL: %s\n", fd, strerror(errno)); return false; } if (fcntl(fd, F_SETFD, flags | FD_CLOEXEC) < 0) { logPrint("FD %d: set close-on-exec failed: %s\n", fd, strerror(errno)); return false; } return true; }
/************************************************************************ * cmRASDummyRequest * purpose: Called after cmRASStartTransaction() on cmRASUnsolicitedIRR. * It allows the application to wait for an unsolicited IRR on * a specific call. * input : hsRas - Stack's handle for the RAS transaction * output : none * return : If an error occurs, the function returns a negative value. * If no error occurs, the function returns a non-negative value. ************************************************************************/ RVAPI int RVCALLCONV cmRASDummyRequest( IN HRAS hsRas) { rasModule* ras; rasOutTx* tx; int status; if (hsRas == NULL) return RVERROR; ras = (rasModule *)emaGetUserData((EMAElement)hsRas); cmiAPIEnter(ras->app, "cmRASDummyRequest(hsRas=0x%x)", hsRas); /* Get the transaction */ tx = rasGetOutgoing(hsRas); if (tx != NULL) status = rasDummyRequest(ras, tx); else { logPrint(ras->log, RV_ERROR, (ras->log, RV_ERROR, "cmRASDummyRequest: Bad outgoing transaction handle (0x%x)", hsRas)); status = RVERROR; } cmiAPIExit(ras->app, "cmRASDummyRequest(hsRas=0x%x,ret=%d)", hsRas, status); return status; }
/************************************************************************ * emaAdd * purpose: Allocate an element in EMA for use, without initializing its * value. * This automatically locks the EMA object. * input : emaH - Handle of the EMA object * appHandle - Application's handle for the EMA object * output : none * return : Pointer to element added on success * NULL on failure ************************************************************************/ EMAElement emaAdd(IN HEMA emaH, IN void* appHandle) { emaObject* ema = (emaObject *)emaH; emaElem* elem; char* ptr; int location; /* Use RA for our purposes */ meiEnter(ema->lock); location = raAddExt(ema->ra, (RAElement*)&elem); meiExit(ema->lock); /* Make sure it was allocated */ if (location < 0) { logPrint(ema->log, RV_ERROR, (ema->log, RV_ERROR, "emaAdd (%s): Out of resources", raGetName(ema->ra))); return NULL; } /* Set the element's OO information */ elem->ema = ema; elem->flags = 0; elem->appHandle = appHandle; #ifdef RV_EMA_DEBUG elem->debug1 = EMA_DEBUG_BYTES; elem->debug2 = EMA_DEBUG_BYTES; #endif logPrint(ema->log, RV_DEBUG, (ema->log, RV_DEBUG, "emaAdd (%s): Got 0x%p (location=%d)", raGetName(ema->ra), elem, location)); ptr = (char*)elem + sizeof(emaElem); /* Allocate a mutex if necessary */ switch (ema->lockType) { case emaLinkedLocks: memset(ptr + ema->elemSize, 0, sizeof(EMAElement*)); break; default: break; } /* Calculate and return the position of the true element */ return (EMAElement*)ptr; }
VKAPI_ATTR VkBool32 VKAPI_CALL vktsDebugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData) { std::lock_guard<std::mutex> lockGuard(g_debugMutex); logPrint(VKTS_LOG_INFO, "Debug: Flags 0x%x ObjectType %d Object %u Location %u MessageCode %d LayerPrefix '%s' Message '%s' UserData #%p", flags, objectType, object, location, messageCode, pLayerPrefix, pMessage, pUserData); return VK_TRUE; }
void IgnoreSignal(int sign) { if (sign != SIGALRM){ logPrint (trcLogId,FL, "[%s] UNWANTED SIGNAL IS RECEIVED, sig=%d\n" ,__FUNCTION__, sign); } signal(sign, IgnoreSignal); }
int LogAudit::log(char *buf, size_t len) { char *audit = strstr(buf, " audit("); if (!audit || (audit >= &buf[len])) { return 0; } *audit = '\0'; int rc; char *type = strstr(buf, "type="); if (type && (type < &buf[len])) { rc = logPrint("%s %s", type, audit + 1); } else { rc = logPrint("%s", audit + 1); } *audit = ' '; return rc; }
void VKTS_APIENTRY scenegraphParseUnknownBuffer(const char* buffer) { if (!buffer) { return; } std::string unknown(buffer); if (unknown.length() > 0 && (unknown[unknown.length() - 1] == '\r' || unknown[unknown.length() - 1] == '\n')) { logPrint(VKTS_LOG_WARNING, __FILE__, __LINE__, "Could not parse line '%s'", unknown.substr(0, unknown.length() - 1).c_str()); } else { logPrint(VKTS_LOG_WARNING, __FILE__, __LINE__, "Could not parse line '%s'", unknown.c_str()); } }
bool set_reuse_addr(int fd) { int on = 1; if ( setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(on)) < 0 ) { logPrint("set_reuse_addr: FD %d: %s\n", fd, strerror(errno)); return false; } return true; }