예제 #1
0
파일: cache.c 프로젝트: chombourger/xCOM
component_t *
cache_open (
   bundle_t *bundlePtr,
   const char *name
) {
   XML_Parser parser;
   component_t *componentPtr = NULL;
   char *path = NULL;
   char buffer [256];
   xc_result_t result = XC_ERR_INVAL;
   int fd;

   TRACE3 (("called with bundlePtr=%p", bundlePtr));
   assert (bundlePtr != NULL);

   path = malloc (PATH_MAX);
   if (path != NULL) {
      sprintf (path, "%s/" CACHE_FOLDER "/" XC_HOST "/%s.xml", bundlePtr->path, name);
      fd = open (path, O_RDONLY);
      if (fd >= 0) {
         parser = XML_ParserCreate (NULL);
         if (parser != NULL) {
            componentPtr = component_new (bundlePtr);
            if (componentPtr != NULL) {
               sprintf (path, "%s/" CODE_FOLDER "/" XC_HOST "/%s", bundlePtr->path, name);
               componentPtr->path = path;
               path = NULL;
               XML_SetUserData (parser, componentPtr);
               XML_SetElementHandler (parser, handle_cache_start_tag, NULL);
               for (;;) {
                  int n = read (fd, buffer, sizeof (buffer));
                  if (n < 0) break;
                  if (!XML_Parse (parser, buffer, n, n==0)) break;
                  if (n==0) {
                     TRACE4 (("%s: loaded meta-data from cache!", componentPtr->name));
                     result = XC_OK;
                     break;
                  }
               }
            }
            XML_ParserFree (parser);
         }
         close (fd);
      }
      else {
         TRACE2 (("%s: failed to open", path));
      }
   }
   
   if (result != XC_OK) {
      if (componentPtr != NULL) {
         component_free (componentPtr);
         componentPtr = NULL;
      }
      free (path);
   }

   TRACE3 (("exiting with result=%p", componentPtr));
   return componentPtr;
}
예제 #2
0
파일: query.c 프로젝트: chombourger/xCOM
xc_result_t
query_unlink_import (
   xc_handle_t queryHandle,
   import_t *importPtr
) {
   query_t *queryPtr;
   xc_result_t result;

   TRACE3 (("called with queryHandle=%u, importPtr=%p"));
   assert (queryHandle != XC_INVALID_HANDLE);
   assert (importPtr != NULL);
   pthread_mutex_lock (&lock);

   queryPtr = (query_t *) handle_dir_get (queryHandles, queryHandle);
   if (queryPtr != NULL) {
      if (queryPtr->firstImportPtr == importPtr) {
         queryPtr->firstImportPtr = import_get_next (importPtr);
      }
      if (queryPtr->lastImportPtr == importPtr) {
         queryPtr->lastImportPtr = NULL;
      }
   }
   else {
      TRACE1 (("invalid query handle %u", queryHandle));
      result = XC_ERR_NOENT;
   }

   pthread_mutex_unlock (&lock);
   TRACE3 (("exiting with result=%d", result));
   return result;
}
예제 #3
0
파일: cache.c 프로젝트: chombourger/xCOM
void
cache_write_port (
   FILE *cacheFile,
   port_t *portPtr
) {

   TRACE3 (("called with cacheFile=%p, portPtr=%p", cacheFile, portPtr));
   assert (cacheFile != NULL);
   assert (portPtr != NULL);

   fprintf (cacheFile,
      "<port name='%s' interface='%s' vmajor='%u' vminor='%u' size='%u' "
      "port='%s' flags='%u' component='%s'></port>",
      (portPtr->name != NULL) ? portPtr->name : "",
      (portPtr->interfaceSpec.name != NULL) ? portPtr->interfaceSpec.name : "",
      portPtr->interfaceSpec.vmajor,
      portPtr->interfaceSpec.vminor,
      portPtr->interfaceSize,
      (portPtr->port != NULL) ? portPtr->port : "",
      portPtr->flags,
      (portPtr->componentName != NULL) ? portPtr->componentName : ""
   );

   TRACE3 (("exiting"));
}
예제 #4
0
파일: query.c 프로젝트: chombourger/xCOM
xc_result_t
query_next (
   query_t *queryPtr,
   xc_handle_t *importHandlePtr
) {
   import_t *importPtr;
   xc_result_t result;

   TRACE3 (("called with queryPtr=%p, importHandlePtr=%p", queryPtr, importHandlePtr));
   assert (queryPtr != NULL);
   pthread_mutex_lock (&lock);

   importPtr = queryPtr->importPtr;
   if (importPtr != NULL) {
      TRACE4 (("%u is the next import for query %u", importPtr->importHandle, queryPtr->queryHandle));
      if (importHandlePtr != NULL) {
         *importHandlePtr = importPtr->importHandle;
      }
      queryPtr->importPtr = import_get_next (importPtr);
      result = XC_OK;
   }
   else {
      TRACE2 (("no more imports for query %u", queryPtr->queryHandle));
      result = XC_ERR_NOENT;
   }

   pthread_mutex_unlock (&lock);
   TRACE3 (("exiting with result=%d", result));
   return result;
}
예제 #5
0
파일: query.c 프로젝트: chombourger/xCOM
xc_result_t
query_add_import (
   query_t *queryPtr,
   import_t *importPtr
) {
   xc_result_t result;

   TRACE3 (("called with queryPtr=%p, importPtr=%p", queryPtr, importPtr));
   assert (queryPtr != NULL);
   assert (importPtr != NULL);

   /* Either link this import to the query if this is the first
    * one, otherwise to the previously created import. */
   if (queryPtr->lastImportPtr == NULL) {
      assert (queryPtr->firstImportPtr == NULL);
      TRACE4 (("adding first import to query %u", queryPtr->queryHandle));
      queryPtr->firstImportPtr = importPtr;
      queryPtr->lastImportPtr = importPtr;
   }
   else {
      /* TODO check if server component is already imported by this client
       * in which case, the import would be added to the front. */
      TRACE4 (("adding one more import to query %u", queryPtr->queryHandle));
      import_set_next (queryPtr->lastImportPtr, importPtr);
      queryPtr->lastImportPtr = importPtr;
   }

   /* Add import to client component */
   component_add_import (queryPtr->componentPtr, importPtr);
   result = XC_OK;

   TRACE3 (("exiting with result=%d", result));
   return result;
}
예제 #6
0
파일: query.c 프로젝트: chombourger/xCOM
void
query_free (
   query_t *queryPtr
) {

   TRACE3 (("called with queryPtr=%p", queryPtr));
   assert (queryPtr != NULL);

   /* Free imports that were not xCOM_Import'ed. */
   if (queryPtr->firstImportPtr != NULL) {
      TRACE4 (("freeing unused imports"));
      import_free_unused (queryPtr->firstImportPtr);
   }

   /* Free query handle. */
   if (queryPtr->queryHandle != XC_INVALID_HANDLE) {
      handle_dir_remove (queryHandles, queryPtr->queryHandle);
   }

   free (queryPtr->queriedPort);
   free (queryPtr->queriedComponent);
   free ((void *) queryPtr->queriedInterface.name);
   free (queryPtr->clientPortName);

   if (queryPtr->componentPtr != NULL) {
      component_unref (queryPtr->componentPtr);
   }

   free (queryPtr);

   TRACE3 (("exiting"));
}
예제 #7
0
파일: query.c 프로젝트: chombourger/xCOM
xc_result_t
query_init (
   void
) {
   xc_result_t result;

   TRACE3 (("called"));
   assert (queryHandles == NULL);

   queryHandles = handle_dir_new ();
   if (queryHandles != NULL) {
      pthread_mutexattr_t attr;
      pthread_mutexattr_init (&attr);
      pthread_mutexattr_settype (&attr, PTHREAD_MUTEX_RECURSIVE);
      pthread_mutex_init (&lock, &attr);
      result = XC_OK;
   }
   else {
      TRACE1 (("Out of memory!"));
      result = XC_ERR_NOMEM;
   }

   TRACE3 (("exiting with result=%d", result));
   return result;
}
예제 #8
0
파일: query.c 프로젝트: chombourger/xCOM
xc_result_t
query_get_candidates (
   query_t *queryPtr,
   unsigned int *matchCountPtr
) {
   struct ProvidedPortsList *listPtr;
   port_t *providerPtr;
   import_t *importPtr;
   unsigned int count = 0;
   xc_result_t result = XC_OK;

   TRACE3 (("called"));
   assert (queryPtr != NULL);

   /* Get all the providers of the queried interface. */
   listPtr = provided_ports_ref (queryPtr->queriedInterface.name);
   if (listPtr != NULL) {
      /* Check matching providers and add them as candidates. */
      providerPtr = (port_t *) XC_CLIST_HEAD (&listPtr->ports);
      while (!XC_CLIST_END (&listPtr->ports, providerPtr)) {
         if (query_match_provider (queryPtr, providerPtr)) {
            importPtr = import_new (
               queryPtr->queryHandle,
               queryPtr->componentHandle,
               queryPtr->clientPortName,
               providerPtr
            );
            if (importPtr != NULL) {
               result = query_add_import (queryPtr, importPtr);
               if (result == XC_OK) {
                  count ++;
               }
               else {
                  TRACE1 (("failed to add import to query %u (%d)", queryPtr->queryHandle, result));
                  import_free (importPtr);
                  break;
               }
            }
            else {
               result = XC_ERR_NOMEM;
               break;
            }
         }
         providerPtr = XC_CLIST_NEXT (providerPtr);
      }
      provided_ports_unref (listPtr);
   }

   if (result == XC_OK) {
      TRACE4 (("%u providers of '%s' found!", count, queryPtr->queriedInterface.name));
      queryPtr->importPtr = queryPtr->firstImportPtr;
      assert ((count == 0) || (queryPtr->importPtr != NULL));
      if (matchCountPtr != NULL) {
         *matchCountPtr = count;
      }
   }

   TRACE3 (("exiting with result=%d", result));
   return result;
}
예제 #9
0
void riceFBGetFrameBufferInfo(void *p)
{
    FrameBufferInfo * pinfo = (FrameBufferInfo *)p;
    memset(pinfo,0,sizeof(FrameBufferInfo)*6);

    //if( g_ZI.dwAddr == 0 )
    //{
    //  memset(pinfo,0,sizeof(FrameBufferInfo)*6);
    //}
    //else
    {
        for (int i=0; i<5; i++ )
        {
            if( status.gDlistCount-g_RecentCIInfo[i].lastUsedFrame > 30 || g_RecentCIInfo[i].lastUsedFrame == 0 )
            {
                //memset(&pinfo[i],0,sizeof(FrameBufferInfo));
            }
            else
            {
                pinfo[i].addr = g_RecentCIInfo[i].dwAddr;
                pinfo[i].size = 2;
                pinfo[i].width = g_RecentCIInfo[i].dwWidth;
                pinfo[i].height = g_RecentCIInfo[i].dwHeight;
                TXTRBUF_DETAIL_DUMP(TRACE3("Protect 0x%08X (%d,%d)", g_RecentCIInfo[i].dwAddr, g_RecentCIInfo[i].dwWidth, g_RecentCIInfo[i].dwHeight));
                pinfo[5].width = g_RecentCIInfo[i].dwWidth;
                pinfo[5].height = g_RecentCIInfo[i].dwHeight;
            }
        }

        pinfo[5].addr = g_ZI.dwAddr;
        //pinfo->size = g_RecentCIInfo[5].dwSize;
        pinfo[5].size = 2;
        TXTRBUF_DETAIL_DUMP(TRACE3("Protect 0x%08X (%d,%d)", pinfo[5].addr, pinfo[5].width, pinfo[5].height));
    }
}
예제 #10
0
파일: cache.c 프로젝트: chombourger/xCOM
xc_result_t
cache_create (
   component_t *componentPtr,
   const char *name
) {
   FILE *cacheFile;
   char path[PATH_MAX];
   xc_result_t result = XC_ERR_INVAL;
   int r;

   TRACE3 (("called with componentPtr=%p, name='%s'", componentPtr, name));
   assert (componentPtr != NULL);
   assert (name != NULL);

   sprintf (path, "%s/" CACHE_FOLDER "/", componentPtr->bundlePtr->path);
   r = mkdir_p (path, 0755);
   if (r == 0) {
      strcat (path, XC_HOST "/");
      r = mkdir_p (path, 0755);
      if (r == 0) {
         strcat (path, name);
         strcat (path, ".xml");
         cacheFile = fopen (path, "w");
         if (cacheFile != NULL) {
            /* Write component meta-data */
            fprintf (cacheFile,
               "<xml>"
               "<component name='%s' descr='%s' vmajor='%u' vminor='%u' ports='%u'>",
               (componentPtr->name != NULL)  ? componentPtr->name  : "",
               (componentPtr->descr != NULL) ? componentPtr->descr : "",
               componentPtr->vmajor,
               componentPtr->vminor,
               componentPtr->portsCount
            );
            /* Write ports meta-data */
            cache_write_ports (cacheFile, componentPtr);
            /* Write footer. */
            fprintf (cacheFile,
               "</component>"
               "</xml>"
            );
            fclose (cacheFile);
            result = XC_OK;
         }
         else {
            TRACE1 (("%s: failed to open for writing!", path));
         }
      }
   }

   TRACE3 (("exiting with result=%d", result));
   return result;
}
예제 #11
0
PPLLIST PLListShrink(PPLLIST pList)
  {

#ifdef ALTERNATE_MEM_MANAGMENT
  PPLLIST rc;       // 20091202 AB reallocating does not work !!!!!!!

  TRACE3("pList addr=0x%X, cbTot=%d, count=%d", pList, pList->cbTot, pList->count);
  rc = pList ? realloc(pList, pList->cbTot) : NULL;
  TRACE3("pList addr=0x%X, cbTot=%d, count=%d", pList, pList->cbTot, pList->count);
  return rc;
#endif  // ALTERNATE_MEM_MANAGMENT

  return pList;
  }
예제 #12
0
파일: query.c 프로젝트: chombourger/xCOM
void
query_destroy (
   void
) {

   TRACE3 (("called"));

   if (queryHandles != NULL) {
      handle_dir_destroy (queryHandles);
      queryHandles = NULL;
      pthread_mutex_destroy (&lock);
   }

   TRACE3 (("exiting"));
}
예제 #13
0
파일: data-compat.c 프로젝트: nobled/gpgme
static int
gpgme_error_to_errno (gpgme_error_t err)
{
  int res = gpg_err_code_to_errno (err);

  if (!err)
    {
      switch (gpg_err_code (err))
	{
	case GPG_ERR_EOF:
	  res = 0;
	  break;
	case GPG_ERR_INV_VALUE:
	  res = EINVAL;
	  break;
	case GPG_ERR_NOT_SUPPORTED:
	  res = ENOSYS;
	  break;
	default:
	  /* FIXME: Yeah, well.  */
	  res = EINVAL;
	  break;
	}
    }
  TRACE3 (DEBUG_DATA, "gpgme:gpgme_error_to_errno", 0,
	  "mapping %s <%s> to: %s", gpgme_strerror (err),
	  gpgme_strsource (err), strerror (res));
  errno = res;
  return res ? -1 : 0;
}
예제 #14
0
/** 
 * \fn     context_EnableClient / context_DisableClient
 * \brief  Enable a specific client activation
 * 
 * Called by the driver main when needed to enble/disable a specific event handling.
 * The Enable function also schedules the driver-task if the specified client is pending.
 * 
 * \note   
 * \param  hContext   - The module handle
 * \param  uClientId  - The client's index
 * \return void 
 * \sa     context_DriverTask
 */ 
void context_EnableClient (TI_HANDLE hContext, TI_UINT32 uClientId)
{
	TContext *pContext = (TContext *)hContext;

#ifdef TI_DBG
    if (pContext->aClientEnabled[uClientId])
    {
        TRACE0(pContext->hReport, REPORT_SEVERITY_ERROR , "context_EnableClient() Client  already enabled!!\n");
        return;
    }
    TRACE3(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_EnableClient(): Client=, ID=%d, enabled=%d, pending=%d\n", uClientId, pContext->aClientEnabled[uClientId], pContext->aClientPending[uClientId]);
#endif /* TI_DBG */

    /* Enable client */
    pContext->aClientEnabled[uClientId] = TI_TRUE;

    /* If client is pending, schedule driver task */
    if (pContext->aClientPending[uClientId])
    {
        /* 
         * If configured to switch context, request driver task scheduling.
         * Else (context switch not required) call the driver task directly. 
         */
        if (pContext->bContextSwitchRequired)
        {
            os_RequestSchedule (pContext->hOs);
        }
        else 
        {
            context_DriverTask (hContext);
        }
    }
}
예제 #15
0
/** 
 * \fn     context_RequestSchedule
 * \brief  Handle client's switch to driver's context.
 * 
 * This function is called by a client from external context event.
 * It sets the client's Pending flag and requests the driver's task scheduling.
 * Thus, the client's callback will be called afterwards from the driver context.
 * 
 * \note   
 * \param  hContext   - The module handle
 * \param  uClientId  - The client's index
 * \return void 
 * \sa     context_DriverTask
 */ 
void context_RequestSchedule (TI_HANDLE hContext, TI_UINT32 uClientId)
{
	TContext *pContext = (TContext *)hContext;
#ifdef TI_DBG
    pContext->aRequestCount[uClientId]++; 
    TRACE3(pContext->hReport, REPORT_SEVERITY_INFORMATION , "context_RequestSchedule(): Client=, ID=%d, enabled=%d, pending=%d\n", uClientId, pContext->aClientEnabled[uClientId], pContext->aClientPending[uClientId]);
#endif /* TI_DBG */

    /* Set client's Pending flag */
    pContext->aClientPending[uClientId] = TI_TRUE;

    /* 
     * If configured to switch context, request driver task scheduling.
     * Else (context switch not required) call the driver task directly. 
     */
    if (pContext->bContextSwitchRequired)
     {
        os_RequestSchedule (pContext->hOs);
    }
    else 

    {
        context_DriverTask (hContext);
    }
}
예제 #16
0
int AFX_CDECL AfxCriticalNewHandler(size_t nSize)
	// nSize is already rounded
{
	// called during critical memory allocation
	//  free up part of the app's safety cache
	TRACE0("Warning: Critical memory allocation failed!\n");
	_AFX_THREAD_STATE* pThreadState = AfxGetThreadState();
	if (pThreadState != NULL && pThreadState->m_pSafetyPoolBuffer != NULL)
	{
		size_t nOldBufferSize = _msize(pThreadState->m_pSafetyPoolBuffer);
		if (nOldBufferSize <= nSize + MIN_MALLOC_OVERHEAD)
		{
			// give it all up
			TRACE0("Warning: Freeing application's memory safety pool!\n");
			free(pThreadState->m_pSafetyPoolBuffer);
			pThreadState->m_pSafetyPoolBuffer = NULL;
		}
		else
		{
			BOOL bEnable = AfxEnableMemoryTracking(FALSE);
			_expand(pThreadState->m_pSafetyPoolBuffer,
				nOldBufferSize - (nSize + MIN_MALLOC_OVERHEAD));
			AfxEnableMemoryTracking(bEnable);
			TRACE3("Warning: Shrinking safety pool from %d to %d to satisfy request of %d bytes.\n",
				 nOldBufferSize, _msize(pThreadState->m_pSafetyPoolBuffer), nSize);
		}
		return 1;       // retry it
	}

	TRACE0("ERROR: Critical memory allocation from safety pool failed!\n");
	AfxThrowMemoryException();      // oops
	return 0;
}
/*
** This routine checks if there is a RESERVED lock held on the specified
** file by this or any other process. If such a lock is held, return
** non-zero.  If the file is unlocked or holds only SHARED locks, then
** return zero.
*/
int sqlite3OsCheckReservedLock(OsFile *id){
  int r = 0;

  assert( id->isOpen );
  sqlite3OsEnterMutex(); /* Needed because id->pLock is shared across threads */

  /* Check if a thread in this process holds such a lock */
  if( id->pLock->locktype>SHARED_LOCK ){
    r = 1;
  }

  /* Otherwise see if some other process holds it.
  */
  if( !r ){
    struct flock lock;
    lock.l_whence = SEEK_SET;
    lock.l_start = RESERVED_BYTE;
    lock.l_len = 1;
    lock.l_type = F_WRLCK;
    fcntl(id->h, F_GETLK, &lock);
    if( lock.l_type!=F_UNLCK ){
      r = 1;
    }
  }
  
  sqlite3OsLeaveMutex();
  TRACE3("TEST WR-LOCK %d %d\n", id->h, r);

  return r;
}
예제 #18
0
void CWirelessManagerDlg::PostStatus()
{
	ExtraStatus enExtraStatus = UN_KNOW;
	//当前状态不为断开时,重置g_enExtraStatus
	if(g_enConnectStatus == CONNECT_STATUS_DISCONNECTED)
		enExtraStatus = g_enExtraStatus;

	int i=0;
	//遍历已有的进程ID,向每一个进程窗口发送消息
	while( 0 != m_stHWNDSet[i].dwProcID && i<32 )
	{
		if( 0 != m_stHWNDSet[i].hStatusWnd )
		{
			::PostMessage(
				m_stHWNDSet[i].hStatusWnd, 
				WM_CONNECT_STATUS, 
				g_enConnectStatus, 
				enExtraStatus);
			TRACE3("\nPostMessage: HWND-%d, Status-%d, ExtraStatus-%d\n", 
				m_stHWNDSet[i].hStatusWnd, g_enConnectStatus, g_enExtraStatus);
			Sleep(50);
		}
		i++;
	}
}
예제 #19
0
TI_STATUS admCtrl_getAuthEncrCapability(admCtrl_t *pAdmCtrl, 
                                        rsnAuthEncrCapability_t   *authEncrCapability)
{
    int i = 0;

    if(!authEncrCapability)
        return TI_NOK;

    /* The current driver code version  uses the above hardcoded list */
    /* of auth/encr pairs */

    authEncrCapability->NoOfAuthEncrPairSupported = MAX_AUTH_ENCR_PAIR;
    authEncrCapability->NoOfPMKIDs                = PMKID_MAX_NUMBER;

    TRACE2(pAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "admCtrl get AuthEncr capability:  No. of auth/encr pairs = %d, No of PMKIDs = %d \n", authEncrCapability->NoOfAuthEncrPairSupported, authEncrCapability->NoOfPMKIDs);

    /* Copy the hardcoded table of the auth.mode/cipher type */
    for (i = 0; i < MAX_AUTH_ENCR_PAIR; i++)
    {
        authEncrCapability->authEncrPairs[i].authenticationMode = 
            supportedAuthEncrPairs[i].authenticationMode;
        authEncrCapability->authEncrPairs[i].cipherSuite        = 
            supportedAuthEncrPairs[i].cipherSuite;

        TRACE3(pAdmCtrl->hReport, REPORT_SEVERITY_INFORMATION, "admCtrl get AuthEncr pair list: i = %d, auth mode = %d , cipher suite = %d \n", i, authEncrCapability->authEncrPairs[i].authenticationMode, authEncrCapability->authEncrPairs[i].cipherSuite);
    }
    
    return TI_OK;
}
예제 #20
0
/*
** Attempt to open a new file for exclusive access by this process.
** The file will be opened for both reading and writing.  To avoid
** a potential security problem, we do not allow the file to have
** previously existed.  Nor do we allow the file to be a symbolic
** link.
**
** If delFlag is true, then make arrangements to automatically delete
** the file when it is closed.
**
** On success, write the file handle into *id and return SQLITE_OK.
**
** On failure, return SQLITE_CANTOPEN.
*/
int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){
  HANDLE h;
  int fileflags;
  assert( !id->isOpen );
  if( delFlag ){
    fileflags = FILE_ATTRIBUTE_TEMPORARY | FILE_FLAG_RANDOM_ACCESS 
                     | FILE_FLAG_DELETE_ON_CLOSE;
  }else{
    fileflags = FILE_FLAG_RANDOM_ACCESS;
  }
  h = CreateFileA(zFilename,
     GENERIC_READ | GENERIC_WRITE,
     0,
     NULL,
     CREATE_ALWAYS,
     fileflags,
     NULL
  );
  if( h==INVALID_HANDLE_VALUE ){
    return SQLITE_CANTOPEN;
  }
  id->h = h;
  id->locktype = NO_LOCK;
  id->sharedLockByte = 0;
  id->isOpen = 1;
  OpenCounter(+1);
  TRACE3("OPEN EX %d \"%s\"\n", h, zFilename);
  return SQLITE_OK;
}
static void si_procrun()
{
	extern struct ptab *tet_ptab;
	register struct ptab *pp;
	register int done;

	TRACE2(tet_Tloop, 8, "si_procrun START: tet_ptab = %s",
		tet_i2x(tet_ptab));

	do {
		TRACE2(tet_Tloop, 8, "si_procrun RESTART: tet_ptab = %s",
			tet_i2x(tet_ptab));
		done = 1;
		for (pp = tet_ptab; pp; pp = pp->pt_next) {
			TRACE3(tet_Tloop, 8, "pp = %s, next = %s",
				tet_i2x(pp), tet_i2x(pp->pt_next));
			ASSERT(pp->pt_magic == PT_MAGIC);
			if (pp->pt_flags & PF_ATTENTION) {
				pp->pt_flags &= ~PF_ATTENTION;
				tet_si_service(pp);
				done = 0;
				break;
			}
		}
	} while (!done);

	TRACE2(tet_Tloop, 8, "si_procrun END: tet_ptab = %s",
		tet_i2x(tet_ptab));

	/* call the server-specific end-procrun routine */
	tet_ss_procrun();
}
예제 #22
0
파일: RefObj.cpp 프로젝트: heger-valter/CAD
ULONG CRefObj::release()
{ 
  ASSERT_VALID( this );
  ASSERT( 0 != m_iRef);
  m_iRef--;
#ifdef  EXPOSE      
  TRACE3("\tC%sStep::release(), (#%d ), m_iRef=%u\n", m_szTheClass.GetBuffer(m_szTheClass.GetLength()), getNum(), m_iRef);
  m_szTheClass.ReleaseBuffer();

  fprintf( g_errorLog, "\tC%sStep::release(), (#%d ), m_iRef=%u\n", m_szTheClass.GetBuffer(m_szTheClass.GetLength()), getNum(), m_iRef);
  m_szTheClass.ReleaseBuffer();
#endif//EXPOSE   

#ifdef GARBAGE_COLLECTION
  if (0 == m_iRef){ 
    delete this;
    return 0;
  }
  else if (0xFFFFFFFF == m_iRef){
    return 0xFFFFFFFF;// since this->m_iRef has been returned to the heap
  }
#endif //GARBAGE_COLLECTION

  return m_iRef;
}
/*
 * \brief	Read mailbox address
 *
 * \param  hEventMbox  - Handle to EventMbox
 * \param  fCb		   - CB function to return in Async mode
 * \param  hCb		   - CB Habdle
 * \return TXN_STATUS_COMPLETE, TXN_STATUS_PENDING, TXN_STATUS_ERROR
 *
 * \par Description
 * This function is called for initialize the Event MBOX addresses.
 * It issues a read transaction from the Twif with a CB.
 *
 * \sa
 */
TI_STATUS eventMbox_InitMboxAddr(TI_HANDLE hEventMbox, fnotify_t fCb, TI_HANDLE hCb)
{
	TTxnStruct  *pTxn;
	TEventMbox* pEventMbox;
	ETxnStatus  rc;
	pEventMbox = (TEventMbox*)hEventMbox;
	pTxn = &pEventMbox->iTxnGenRegSize.tTxnReg;

	/* Store the Callabck address of the modules that called us in case of Asynchronuous transaction that will complete later */
	pEventMbox->fCb = fCb;
	pEventMbox->hCb = hCb;

	/* Build the command TxnStruct */
	TXN_PARAM_SET(pTxn, TXN_LOW_PRIORITY, TXN_FUNC_ID_WLAN, TXN_DIRECTION_READ, TXN_INC_ADDR)
	/* Applying a CB in case of an async read */
	BUILD_TTxnStruct(pTxn, REG_EVENT_MAILBOX_PTR, &pEventMbox->iTxnGenRegSize.iRegBuffer, REGISTER_SIZE, eventMbox_ReadAddrCb, hEventMbox)
	rc = twIf_Transact(pEventMbox->hTwif,pTxn);
	if (rc == TXN_STATUS_COMPLETE) {
		pEventMbox->EventMboxAddr[0] = pEventMbox->iTxnGenRegSize.iRegBuffer;
		pEventMbox->EventMboxAddr[1] = pEventMbox->EventMboxAddr[0] + sizeof(EventMailBox_t);
		TRACE3(pEventMbox->hReport, REPORT_SEVERITY_INIT , "eventMbox_ConfigHw: event A Address=0x%x, event B Address=0x%x, sizeof=%d\n", pEventMbox->EventMboxAddr[0], pEventMbox->EventMboxAddr[1], sizeof(EventMailBox_t));

	}
	return rc;
}
예제 #24
0
void
CVaultEvents::WriteEventsToDiskIfModified()
	{
	Endorse(m_pEventLastSaved == NULL);	// Always write the vault to disk
	IEvent * pEventLastSaved = PGetEventLast_YZ();
	if (pEventLastSaved != m_pEventLastSaved)
		{
		int cEvents = m_arraypaEvents.GetSize();
		CBinXospStanzaForDisk binXmlEvents;
		binXmlEvents.PbbAllocateMemoryAndEmpty_YZ(100 + 64 * cEvents);	// Pre-allocate about 64 bytes per event.  This estimate will reduce the number of memory re-allocations.
		binXmlEvents.BinAppendText_VE("<E v='1' c='$i'>\n", cEvents);
		m_arraypaEvents.EventsSerializeForDisk(INOUT &binXmlEvents);
		binXmlEvents.BinAppendText_VE("</E>");
		TRACE3("CVaultEvents::WriteEventsToDiskIfModified($Q) for $s ^C", &m_sPathFileName, m_pParent->TreeItem_PszGetNameDisplay(), m_pParent);
		if (binXmlEvents.BinFileWriteE(m_sPathFileName) == errSuccess)
			m_pEventLastSaved = pEventLastSaved;
		}
	else
		{
		//TRACE2("CVaultEvents::WriteEventsToDiskIfModified(^s) m_pEventLastSaved == pEventLastSaved = 0x$p", m_pParent->TreeItem_PszGetNameDisplay(), pEventLastSaved);
		if (pEventLastSaved == NULL)
			{
			Assert(m_arraypaEvents.FIsEmpty());
			}
		}
	}
예제 #25
0
파일: TxnQueue.c 프로젝트: aleho/ti_wilink
ETxnStatus txnQ_Transact (TI_HANDLE hTxnQ, TTxnStruct *pTxn)
{
    TTxnQObj    *pTxnQ   = (TTxnQObj*)hTxnQ;
    TI_UINT32    uFuncId = TXN_PARAM_GET_FUNC_ID(pTxn);
    ETxnStatus   rc;

    if (TXN_PARAM_GET_SINGLE_STEP(pTxn)) 
    {
        pTxnQ->aFuncInfo[uFuncId].pSingleStep = pTxn;
        TRACE0(pTxnQ->hReport, REPORT_SEVERITY_INFORMATION, "txnQ_Transact(): Single step Txn\n");
    }
    else 
    {
        TI_STATUS eStatus;
        TI_HANDLE hQueue = pTxnQ->aTxnQueues[uFuncId][TXN_PARAM_GET_PRIORITY(pTxn)];
        context_EnterCriticalSection (pTxnQ->hContext);
        eStatus = que_Enqueue (hQueue, (TI_HANDLE)pTxn);
        context_LeaveCriticalSection (pTxnQ->hContext);
        if (eStatus != TI_OK)
        {
            TRACE3(pTxnQ->hReport, REPORT_SEVERITY_ERROR, "txnQ_Transact(): Enqueue failed, pTxn=0x%x, HwAddr=0x%x, Len0=%d\n", pTxn, pTxn->uHwAddr, pTxn->aLen[0]);
            return TXN_STATUS_ERROR;
        }
        TRACE0(pTxnQ->hReport, REPORT_SEVERITY_INFORMATION, "txnQ_Transact(): Regular Txn\n");
    }

    /* Send queued transactions as possible */
    rc = txnQ_RunScheduler (pTxnQ, pTxn); 

    return rc;
}
예제 #26
0
// Yoshi's Story uses this - 0x03
void RSP_S2DEX_OBJ_RECTANGLE(Gfx *gfx)
{
    uint32 dwAddr = RSPSegmentAddr((gfx->words.w1));
    uObjSprite *ptr = (uObjSprite*)(g_pRDRAMu8+dwAddr);

    uObjTxSprite objtx;
    memcpy(&objtx.sprite,ptr,sizeof(uObjSprite));

    if( g_TxtLoadBy == CMD_LOAD_OBJ_TXTR )
    {
        memcpy(&(objtx.txtr.block),&(gObjTxtr->block),sizeof(uObjTxtr));
        CRender::g_pRender->LoadObjSprite(objtx, true);
    }
    else
    {
        PrepareTextures();
    }
    CRender::g_pRender->DrawSprite(objtx, false);

#ifdef DEBUGGER
    if( (pauseAtNext && (eventToPause == NEXT_OBJ_TXT_CMD||eventToPause == NEXT_FLUSH_TRI)) || logTextures )
    {
        if( debuggerPauseCount > 0 ) 
            debuggerPauseCount--; 
        if( debuggerPauseCount == 0 )
        {
            eventToPause = false;
            debuggerPause = true;
            TRACE3("Paused at RSP_S2DEX_OBJ_RECTANGLE\nptr=%08X, img=%08X, TMEM=%08X",
                dwAddr,objtx.txtr.block.image, ptr->imageAdrs);
            CGraphicsContext::g_pGraphicsContext->UpdateFrame(false);
        }
    }
#endif
}
/** set the toggles???
 * 
 * \param wh the button 
 * \param i in or out
 */
void Toggle(int wh,int i) 
{
 TRACE3("->Toggle(wh %d, i %d)", wh, i);
 switch(wh)
   {
    case 1:if (i==1) gxVirtualDisplay(&vh,1,21,55,49,89,81,0);else
	  gxVirtualDisplay(&vh,1,56,55,49,89,81,0); break;

    case 2:if(i==1)  gxVirtualDisplay(&vh,38,21,92,49,127,81,0);else
	  gxVirtualDisplay(&vh,38,56,92,49,127,81,0); break;

    case 3:if(i==1)  gxVirtualDisplay(&vh,75,21,129,49,163,81,0);else
	  gxVirtualDisplay(&vh,75,56,129,49,163,81,0); break;

    case 4:if(i==1)  gxVirtualDisplay(&vh,112,21,166,49,200,81,0);else
	  gxVirtualDisplay(&vh,112,56,166,49,200,81,0); break;

    case 5:if (i==1)  gxVirtualDisplay(&vh,153,1,5,49,52,71,0);
	     else gxVirtualDisplay(&vh,153,26,5,49,52,71,0); break;

  default:break;
 }
 TRACE1("<-Toggle()");
 return;
}
/*
** Attempt to open a new file for exclusive access by this process.
** The file will be opened for both reading and writing.  To avoid
** a potential security problem, we do not allow the file to have
** previously existed.  Nor do we allow the file to be a symbolic
** link.
**
** If delFlag is true, then make arrangements to automatically delete
** the file when it is closed.
**
** On success, write the file handle into *id and return SQLITE_OK.
**
** On failure, return SQLITE_CANTOPEN.
*/
int sqlite3OsOpenExclusive(const char *zFilename, OsFile *id, int delFlag){
  int rc;
  assert( !id->isOpen );
  if( access(zFilename, 0)==0 ){
    return SQLITE_CANTOPEN;
  }
  id->dirfd = -1;
  id->h = open(zFilename,
                O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE|O_BINARY, 0600);
  if( id->h<0 ){
    return SQLITE_CANTOPEN;
  }
  sqlite3OsEnterMutex();
  rc = findLockInfo(id->h, &id->pLock, &id->pOpen);
  sqlite3OsLeaveMutex();
  if( rc ){
    close(id->h);
    unlink(zFilename);
    return SQLITE_NOMEM;
  }
  id->locktype = 0;
  id->isOpen = 1;
  if( delFlag ){
    unlink(zFilename);
  }
  TRACE3("OPEN-EX %-3d %s\n", id->h, zFilename);
  OpenCounter(+1);
  return SQLITE_OK;
}
예제 #29
0
BOOL CWnd::SubclassWindow(HWND hWnd)
{
	if (!Attach(hWnd))
		return FALSE;

	// allow any other subclassing to occur
	PreSubclassWindow();

	// now hook into the AFX WndProc
	WNDPROC* lplpfn = GetSuperWndProcAddr();
	WNDPROC oldWndProc = (WNDPROC)::SetWindowLong(hWnd, GWL_WNDPROC,
		(DWORD)AfxGetAfxWndProc());
	ASSERT(oldWndProc != (WNDPROC)AfxGetAfxWndProc);

	if (*lplpfn == NULL)
		*lplpfn = oldWndProc;   // the first control of that type created
#ifdef _DEBUG
	else if (*lplpfn != oldWndProc)
	{
		TRACE0("Error: Trying to use SubclassWindow with incorrect CWnd\n");
		TRACE0("\tderived class.\n");
		TRACE3("\thWnd = $%04X (nIDC=$%04X) is not a %hs.\n", (UINT)hWnd,
			_AfxGetDlgCtrlID(hWnd), GetRuntimeClass()->m_lpszClassName);
		ASSERT(FALSE);
		// undo the subclassing if continuing after assert
		::SetWindowLong(hWnd, GWL_WNDPROC, (DWORD)oldWndProc);
	}
#endif

	return TRUE;
}
예제 #30
0
bool RDOPROCSeize::onCheckCondition(const LPRDORuntime& pRuntime)
{
	if (m_transacts.empty())
		return false;

	const std::size_t Size_Seizes = forRes.size();
	for (std::size_t i = 0; i < Size_Seizes; i++)
	{
		// если свободен
		if (forRes[i].rss->getParam(forRes[i].Id_param) == forRes[i].enum_free)
		{
			const std::size_t idBlocksTransact = m_transacts.front()->getTraceID();
			const std::size_t idResourcesTransact = forRes[i].rss->transacts.front()->getTraceID();
			if (idBlocksTransact != idResourcesTransact)
				return false;

			RDOTrace* tracer = pRuntime->getTracer();
			forRes[i].rss->setParam(forRes[i].Id_param, forRes[i].enum_buzy);
			TRACE3("%7.1f SEIZES-%d, resId = %d\n", pRuntime->getCurrentTime(), index, forRes[i].rss->getTraceID());
			if (!tracer->isNull())
				tracer->getOStream() << forRes[i].rss->traceResourceState('\0', pRuntime) << tracer->getEOL();

			m_transacts.front()->setRes(forRes[i].rss);
			return true;
		}
	}
	return false;
}