当前位置: 首页>>代码示例>>C++>>正文


C++ DEBUG_PRINT函数代码示例

本文整理汇总了C++中DEBUG_PRINT函数的典型用法代码示例。如果您正苦于以下问题:C++ DEBUG_PRINT函数的具体用法?C++ DEBUG_PRINT怎么用?C++ DEBUG_PRINT使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DEBUG_PRINT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char *argv[] )
{
	int fd = 0;
	int opt, opt_index;
	int result = -1;
	long bufSize = 0; 
	// long writtenSize;
	int writtenSize = 0;
	long writtenSize_long = 0;
	char *bufTop = NULL;
	CNCL_P_SETTINGS Settings;
	char jobID[CN_START_JOBID_LEN];
	char libPathBuf[CN_LIB_PATH_LEN];
	void *libclss = NULL;
	struct option long_opt[] = {
		{ "version", required_argument, NULL, OPT_VERSION }, 
		{ "filterpath", required_argument, NULL, OPT_FILTERPATH }, 
		{ "papersize", required_argument, NULL, OPT_PAPERSIZE }, 
		{ "mediatype", required_argument, NULL, OPT_MEDIATYPE }, 
		{ "grayscale", required_argument, NULL, OPT_COLORMODE }, 
		{ "duplexprint", required_argument, NULL, OPT_DUPLEXPRINT }, 
		{ "jobid", required_argument, NULL, OPT_JOBID }, 
		{ "uuid", required_argument, NULL, OPT_UUID }, 
		{ 0, 0, 0, 0 }, 
	};
	const char *p_ppd_name = getenv("PPD");
	uint8_t *xmlBuf = NULL;
	int xmlBufSize;
	int retSize;

	char *tmpBuf = NULL;

	char	uuid[UUID_LEN + 1];

	DEBUG_PRINT( "[tocanonij] start tocanonij\n" );

	/* init CNCL API */
	GETSETCONFIGURATIONCOMMAND = NULL;
	GETSENDDATAPWGRASTERCOMMAND = NULL;
	GETPRINTCOMMAND = NULL;
	GETSTRINGWITHTAGFROMFILE = NULL;
	GETSETPAGECONFIGUARTIONCOMMAND = NULL;
	MAKEBJLSETTIMEJOB = NULL;
	GetProtocol = NULL;
	ParseCapabilityResponsePrint_HostEnv=NULL;
	MakeCommand_StartJob3 = NULL;
	ParseCapabilityResponsePrint_DateTime = NULL;
	MakeCommand_SetJobConfiguration = NULL;

	/* Init Settings */
	memset( &Settings, 0x00, sizeof(CNCL_P_SETTINGS) );
	InitpSettings( &Settings );
	memset( uuid, '\0', sizeof(uuid) );

	while( (opt = getopt_long( argc, argv, "0:", long_opt, &opt_index )) != -1) {
		switch( opt ) {
			case OPT_VERSION:
				DEBUG_PRINT3( "[tocanonij] OPTION(%s):VALUE(%s)\n", long_opt[opt_index].name, optarg );
				break;
			case OPT_FILTERPATH:
				DEBUG_PRINT3( "[tocanonij] OPTION(%s):VALUE(%s)\n", long_opt[opt_index].name, optarg );
				snprintf( libPathBuf, CN_LIB_PATH_LEN, "%s%s", optarg, CN_CNCL_LIBNAME );
				break;
			case OPT_PAPERSIZE:
				DEBUG_PRINT3( "[tocanonij] OPTION(%s):VALUE(%s)\n", long_opt[opt_index].name, optarg );
				Settings.papersize = ConvertStrToID( optarg, papersizeTbl );
				if ( IsBorderless( optarg ) ){
					Settings.borderlessprint = CNCL_PSET_BORDERLESS_ON;
				}
				else {
					Settings.borderlessprint = CNCL_PSET_BORDERLESS_OFF;
				}
				break;
			case OPT_MEDIATYPE:
				DEBUG_PRINT3( "[tocanonij] OPTION(%s):VALUE(%s)\n", long_opt[opt_index].name, optarg );
				Settings.mediatype = ConvertStrToID( optarg, mediatypeTbl );
				DEBUG_PRINT2( "[tocanonij] media : %d\n", Settings.mediatype );
				break;
#if 0
			case OPT_BORDERLESSPRINT:
				DEBUG_PRINT3( "[tocanonij] OPTION(%s):VALUE(%s)\n", long_opt[opt_index].name, optarg );
				if ( IsBorderless( optarg ) ){
					Settings.borderlessprint = CNCL_PSET_BORDERLESS_ON;
				}
				else {
					Settings.borderlessprint = CNCL_PSET_BORDERLESS_OFF;
				}
				break;
#endif
			case OPT_COLORMODE:
				DEBUG_PRINT3( "[tocanonij] OPTION(%s):VALUE(%s)\n", long_opt[opt_index].name, optarg );
				Settings.colormode = ConvertStrToID( optarg, colormodeTbl );
				break;
			case OPT_DUPLEXPRINT:
				DEBUG_PRINT3( "[tocanonij] OPTION(%s):VALUE(%s)\n", long_opt[opt_index].name, optarg );
				//Settings.duplexprint = CNCL_PSET_DUPLEX_OFF;
				Settings.duplexprint = ConvertStrToID( optarg, duplexprintTbl);
				break;

			case OPT_UUID:
//.........这里部分代码省略.........
开发者ID:dbnicholson,项目名称:cnijfilter2,代码行数:101,代码来源:main.c

示例2: dprintf_oterr


//.........这里部分代码省略.........
					PRINT_CASE(kOTResAddressErr);
					PRINT_CASE(kOTQFullErr);
					PRINT_CASE(kOTProtocolErr);
					PRINT_CASE(kOTBadSyncErr);
					PRINT_CASE(kOTCanceledErr);
					PRINT_CASE(kEPERMErr);
			//		PRINT_CASE(kENOENTErr);
					PRINT_CASE(kENORSRCErr);
					PRINT_CASE(kEINTRErr);
					PRINT_CASE(kEIOErr);
					PRINT_CASE(kENXIOErr);
					PRINT_CASE(kEBADFErr);
					PRINT_CASE(kEAGAINErr);
			//		PRINT_CASE(kENOMEMErr);
					PRINT_CASE(kEACCESErr);
					PRINT_CASE(kEFAULTErr);
					PRINT_CASE(kEBUSYErr);
			//		PRINT_CASE(kEEXISTErr);
					PRINT_CASE(kENODEVErr);
					PRINT_CASE(kEINVALErr);
					PRINT_CASE(kENOTTYErr);
					PRINT_CASE(kEPIPEErr);
					PRINT_CASE(kERANGEErr);
					PRINT_CASE(kEWOULDBLOCKErr);
			//		PRINT_CASE(kEDEADLKErr);
					PRINT_CASE(kEALREADYErr);
					PRINT_CASE(kENOTSOCKErr);
					PRINT_CASE(kEDESTADDRREQErr);
					PRINT_CASE(kEMSGSIZEErr);
					PRINT_CASE(kEPROTOTYPEErr);
					PRINT_CASE(kENOPROTOOPTErr);
					PRINT_CASE(kEPROTONOSUPPORTErr);
					PRINT_CASE(kESOCKTNOSUPPORTErr);
					PRINT_CASE(kEOPNOTSUPPErr);
					PRINT_CASE(kEADDRINUSEErr);
					PRINT_CASE(kEADDRNOTAVAILErr);
					PRINT_CASE(kENETDOWNErr);
					PRINT_CASE(kENETUNREACHErr);
					PRINT_CASE(kENETRESETErr);
					PRINT_CASE(kECONNABORTEDErr);
					PRINT_CASE(kECONNRESETErr);
					PRINT_CASE(kENOBUFSErr);
					PRINT_CASE(kEISCONNErr);
					PRINT_CASE(kENOTCONNErr);
					PRINT_CASE(kESHUTDOWNErr);
					PRINT_CASE(kETOOMANYREFSErr);
					PRINT_CASE(kETIMEDOUTErr);
					PRINT_CASE(kECONNREFUSEDErr);
					PRINT_CASE(kEHOSTDOWNErr);
					PRINT_CASE(kEHOSTUNREACHErr);
					PRINT_CASE(kEPROTOErr);
					PRINT_CASE(kETIMEErr);
					PRINT_CASE(kENOSRErr);
					PRINT_CASE(kEBADMSGErr);
					PRINT_CASE(kECANCELErr);
					PRINT_CASE(kENOSTRErr);
					PRINT_CASE(kENODATAErr);
					PRINT_CASE(kEINPROGRESSErr);
					PRINT_CASE(kESRCHErr);
					PRINT_CASE(kENOMSGErr);
					PRINT_CASE(kOTClientNotInittedErr);
					PRINT_CASE(kOTPortHasDiedErr);
					PRINT_CASE(kOTPortWasEjectedErr);
					PRINT_CASE(kOTBadConfigurationErr);
					PRINT_CASE(kOTConfigurationChangedErr);
					PRINT_CASE(kOTUserRequestedErr);
					PRINT_CASE(kOTPortLostConnection);

					default:
						name = "< unknown >";
						break;
				}
				strcpy(error,name);
				
				if (ep)
				{
					switch (OTGetEndpointState(ep))
					{	
						PRINT_CASE(T_UNINIT);
						PRINT_CASE(T_UNBND);
						PRINT_CASE(T_IDLE);
						PRINT_CASE(T_OUTCON);
						PRINT_CASE(T_INCON);
						PRINT_CASE(T_DATAXFER);
						PRINT_CASE(T_OUTREL);
						PRINT_CASE(T_INREL);

						default:
							name = "< unknown >";
							break;
					}
				}
				else
					name = "<unknown>";

				strcpy(state,name);
					
				DEBUG_PRINT("EP: %p (state: %s), OTError for %s: %s (%d). File: %s, %d",ep, state, message, error, err, file, line);
			}
		}
开发者ID:MaddTheSane,项目名称:tntbasic,代码行数:101,代码来源:OPUtils.cpp

示例3: dprintf_err

	NMErr
	dprintf_err(
		char	*message,
		NMErr	err,
		char		*file,
		NMSInt32	line)
	{
	char 	*name;
		
		if (err != -1)
		{
			DEBUG_PRINT("error value %d passed to dprintf_sockerr for %s. not checking errno. %s line %d",err,message,file,line);
			return 0;
		}
			
		switch (errno)
		{
			PRINT_CASE(EPERM);
			PRINT_CASE(ENOENT);
			PRINT_CASE(ESRCH);
			PRINT_CASE(EINTR);
			PRINT_CASE(EIO);
			PRINT_CASE(ENXIO);
			PRINT_CASE(E2BIG);
			PRINT_CASE(ENOEXEC);
			PRINT_CASE(EBADF);
			PRINT_CASE(ECHILD);
			PRINT_CASE(EDEADLK);
			PRINT_CASE(ENOMEM);
			PRINT_CASE(EACCES);
			PRINT_CASE(EFAULT);
			PRINT_CASE(ENOTBLK);
			PRINT_CASE(EBUSY);
			PRINT_CASE(EEXIST);
			PRINT_CASE(EXDEV);
			PRINT_CASE(ENODEV);
			PRINT_CASE(ENOTDIR);
			PRINT_CASE(EISDIR);
			PRINT_CASE(EINVAL);
			PRINT_CASE(ENFILE);
			PRINT_CASE(EMFILE);
			PRINT_CASE(ENOTTY);
			PRINT_CASE(ETXTBSY);
			PRINT_CASE(EFBIG);
			PRINT_CASE(ENOSPC);
			PRINT_CASE(ESPIPE);
			PRINT_CASE(EROFS);
			PRINT_CASE(EMLINK);
			PRINT_CASE(EPIPE);
			PRINT_CASE(EDOM);
			PRINT_CASE(ERANGE);
			PRINT_CASE(EWOULDBLOCK);
			PRINT_CASE(EINPROGRESS);
			PRINT_CASE(EALREADY);
			PRINT_CASE(ENOTSOCK);
			PRINT_CASE(EDESTADDRREQ);
			PRINT_CASE(EMSGSIZE);
			PRINT_CASE(EPROTOTYPE);
			PRINT_CASE(ENOPROTOOPT);
			PRINT_CASE(EPROTONOSUPPORT);
			PRINT_CASE(ESOCKTNOSUPPORT);
			PRINT_CASE(ENOTSUP);
			PRINT_CASE(EPFNOSUPPORT);
			PRINT_CASE(EAFNOSUPPORT);
			PRINT_CASE(EADDRINUSE);
			PRINT_CASE(EADDRNOTAVAIL);
			PRINT_CASE(ENETDOWN);
			PRINT_CASE(ENETUNREACH);
			PRINT_CASE(ENETRESET);
			PRINT_CASE(ECONNABORTED);
			PRINT_CASE(ECONNRESET);
			PRINT_CASE(ENOBUFS);
			PRINT_CASE(EISCONN);
			PRINT_CASE(ENOTCONN);
			PRINT_CASE(ESHUTDOWN);
			PRINT_CASE(ETOOMANYREFS);
			PRINT_CASE(ETIMEDOUT);
			PRINT_CASE(ECONNREFUSED);
			PRINT_CASE(ELOOP);
			PRINT_CASE(ENAMETOOLONG);
			PRINT_CASE(EHOSTDOWN);
			PRINT_CASE(EHOSTUNREACH);
			PRINT_CASE(ENOTEMPTY);
			PRINT_CASE(EUSERS);
			PRINT_CASE(EDQUOT);
			PRINT_CASE(ESTALE);
			PRINT_CASE(EREMOTE);
			PRINT_CASE(ENOLCK);
			PRINT_CASE(ENOSYS);
			PRINT_CASE(EOVERFLOW);
#if (OP_PLATFORM_MAC_MACHO)
				PRINT_CASE(EPROCLIM);
				PRINT_CASE(EBADRPC);
				PRINT_CASE(ERPCMISMATCH);
				PRINT_CASE(EPROGUNAVAIL);
				PRINT_CASE(EFTYPE);
				PRINT_CASE(ENEEDAUTH);
				PRINT_CASE(EPWROFF);
				PRINT_CASE(EDEVERR);
				PRINT_CASE(EBADEXEC);
//.........这里部分代码省略.........
开发者ID:MaddTheSane,项目名称:tntbasic,代码行数:101,代码来源:OPUtils.cpp

示例4: __ASSERT_ALWAYS

// -----------------------------------------------------------------------------
// CExprUDPMsg::TryParsingL
// -----------------------------------------------------------------------------
//
TInt CExprUDPMsg::TryParsingL( TDes8& aData, TInt& aLength )
    {
    __ASSERT_ALWAYS( aData.Left( KUDPPrefix().Length() ) == KUDPPrefix,
        User::Panic( _L("Protocol"), 1 ) );

    // UDP:0123,000e,[Some test data]
    TInt frameOverhead =
        KUDPPrefix().Length() +
        KHexDecimalLength +
        KPortSuffix().Length() +
        KHexDecimalLength +
        KLengthSuffix().Length() +
        KDataSuffix().Length() +
        KMessageSuffix().Length();

    if ( aData.Length() >= frameOverhead )
        {
        TPtrC8 portPtr(
            aData.Mid( KUDPPrefix().Length(), KHexDecimalLength ) );

        TLex8 portLexer( portPtr );
        TUint port;
        if ( portLexer.Val( port, EHex ) != KErrNone )
            {
            return KErrCorrupt;
            }
        DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, port = %d" ), port );

        //Check port suffix
        if ( aData.Mid( KUDPPrefix().Length() +
            KHexDecimalLength, KPortSuffix().Length() ) != KPortSuffix )
            {
            return KErrCorrupt;
            }

        TPtrC8 lengthPtr( aData.Mid( KUDPPrefix().Length() +
            KHexDecimalLength + KPortSuffix().Length(), KHexDecimalLength ) );
        TLex8 lengthLexer( lengthPtr );
        TUint length;
        if ( lengthLexer.Val( length, EHex ) != KErrNone )
            {
            return KErrCorrupt;
            }
        DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, length = %d" ), length );

        //Check length suffix
        if ( aData.Mid(
            KUDPPrefix().Length() +
            KHexDecimalLength +
            KPortSuffix().Length() +
            KHexDecimalLength, KLengthSuffix().Length() ) != KLengthSuffix )
            {
            return KErrCorrupt;
            }

        DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, parsing data" ), length );

        if ( aData.Length() >= TInt( frameOverhead + length ) )
            {
            TInt messagePos = KUDPPrefix().Length() +
                KHexDecimalLength +
                KPortSuffix().Length() +
                KHexDecimalLength +
                KLengthSuffix().Length();

            TPtrC8 message( aData.Mid( messagePos, length ) );
            if ( aData.Mid( messagePos + length,
                KDataSuffix().Length() ) != KDataSuffix )
                {
                return KErrCorrupt;
                }
            DEBUG_PRINT( DEBUG_STRING( "CExprUDPMsg::TryParsingL, message OK" ) );

            if ( aData.Mid( messagePos + length + KDataSuffix().Length(),
                KMessageSuffix().Length() ) != KMessageSuffix )
                {
                return KErrCorrupt;
                }

            // send parsed results
            iObserver->FrameParsedL( port, message );
            // set the length of the handled message
            aLength = frameOverhead + length;

            return KErrNone;
            }

        }
    return KErrNone;
    }
开发者ID:cdaffara,项目名称:symbiandump-os2,代码行数:94,代码来源:CExprUDPMsg.cpp

示例5: printPMTList

void printPMTList(void)
{
    PmtTable*    psTempPmt;
    ProgElement* psTempElement;
    int iDescCounter,iElemStreamIdx;

    psTempPmt = m_psPmtList;
    while(psTempPmt)
    {
        DEBUG_PRINT("ProgNumber      = %d\n",psTempPmt->iProgNumber);
        DEBUG_PRINT("VersionNumber   = %d\n",psTempPmt->iVersionNumber);
        DEBUG_PRINT("ValidPmt        = %d\n",psTempPmt->bValidPmt);
        DEBUG_PRINT("PcrPid          = 0x%04X\n",psTempPmt->iPcrPid);
        if (psTempPmt->iOuterDescLength > 0)
        {
            DEBUG_PRINT("OuterDescLength = %d\n",psTempPmt->iOuterDescLength);
            DEBUG_PRINT("Outer Private Descriptor:\n");
            for (iDescCounter=0; iDescCounter < psTempPmt->iOuterDescLength; iDescCounter++)
            {
                DEBUG_PRINT("0x%02X ",psTempPmt->pcOuterDesc[iDescCounter]&0xFF);
            }
        }
        DEBUG_PRINT("\n");

        psTempElement = psTempPmt->psElementList;
        iElemStreamIdx = 0;
	while (psTempElement)
        {
            DEBUG_PRINT("	StreamType       = 0x%02X\n",psTempElement->iStreamType);
            DEBUG_PRINT("	Pid              = 0x%04X\n",psTempElement->iPid);
            if (psTempElement->iProgElDescLength > 0)
            {
                DescAttr sDescAttr;
                iDescCounter=0;

                {
                    int j;
                    DEBUG_PRINT("	Raw Descriptor\n");
		    DEBUG_PRINT("	");
                    for (j = 0; j < psTempElement->iProgElDescLength; j++)
                    {
                        DEBUG_PRINT("0x%02X ",psTempElement->pcProgElDesc[j]&0xFF);
                    }
                    DEBUG_PRINT("\n");
                }

                sDescAttr.eParam = PMT_PRIVATE_DESCRIPTOR_TAG;
                while (getElementaryPrivateDescPayload(psTempPmt,iElemStreamIdx,iDescCounter,&sDescAttr) == PMT_OK)
                {
                    DEBUG_PRINT("	Tag 0x%02X, ",sDescAttr.uAttr.iDescTag&0xFF);
                    DEBUG_PRINT("%s\n",getDescTypeString(sDescAttr.uAttr.iDescTag));
                    memset(&sDescAttr,0,sizeof(DescAttr));
                    sDescAttr.eParam = PMT_PRIVATE_DESCRIPTOR_PAYLOAD;
                    if (getElementaryPrivateDescPayload(psTempPmt,iElemStreamIdx,iDescCounter,&sDescAttr) == PMT_OK)
                    {
                        int i;
                        DEBUG_PRINT("	Descriptor Payload Length %d\n",sDescAttr.uAttr.sPayload.iPayloadLength);
			DEBUG_PRINT("	");
                        for (i=0; i < sDescAttr.uAttr.sPayload.iPayloadLength; i++)
                        {
                            DEBUG_PRINT("0x%02X ",sDescAttr.uAttr.sPayload.pcPayload[i]&0xFF);
                        }
                        DEBUG_PRINT("\n");
                    }
                    iDescCounter += 1;
                    memset(&sDescAttr,0,sizeof(DescAttr));
                    sDescAttr.eParam = PMT_PRIVATE_DESCRIPTOR_TAG;
                }
            }
            DEBUG_PRINT("\n");
            psTempElement = psTempElement->psNext;
            iElemStreamIdx += 1;
        }
        DEBUG_PRINT("\n");
        psTempPmt = psTempPmt->psNext;
    }    
}
开发者ID:iourigordon,项目名称:soft_dev,代码行数:77,代码来源:pmtTable.c

示例6: tk_opn_dev_impl


//.........这里部分代码省略.........
	OPNFN	openfn;
	VP	exinf;
#if TA_GP
	VP	gp;
#endif
	UB	pdevnm[L_DEVNM + 1];
	INT	unitno;
	ResCB	*rescb;
	DevCB	*devcb;
	OpnCB	*opncb;
	ER	ercd;
	ID	semid;

	unitno = knl_phydevnm(pdevnm, devnm);

	/* Get resource management information */
	rescb = knl_GetResCB();
	if ( rescb == NULL ) {
		ercd = E_CTX;
		goto err_ret1;
	}

	LockDM();

	/* Search device to open */
	devcb = knl_searchDevCB(pdevnm);
	if ( devcb == NULL || unitno > devcb->ddev.nsub ) {
		ercd = E_NOEXS;
		goto err_ret2;
	}

	/* Check open mode */
	ercd = chkopenmode(devcb, unitno, omode);
	if ( ercd < E_OK ) {
		goto err_ret2;
	}

	openfn = (OPNFN)devcb->ddev.openfn;
	exinf = devcb->ddev.exinf;
#if TA_GP
	gp = devcb->ddev.gp;
#endif

	/* Is device driver call required? */
	if ( knl_chkopen(devcb, unitno) && (devcb->ddev.drvatr & TDA_OPENREQ) == 0 ) {
		openfn = NULL;
	}

	/* Get open management block */
	opncb = newOpnCB(devcb, unitno, omode, rescb);
	if ( opncb == NULL ) {
		ercd = E_LIMIT;
		goto err_ret2;
	}

	semid = tk_cre_sem_impl(&knl_pk_csem_DM);
	if ( semid < E_OK ) {
		ercd = E_SYS;
		goto err_ret2_5;
	}
	opncb->abort_semid = semid;

	UnlockDM();

	if ( openfn != NULL ) {
		/* Device driver call */
		DISABLE_INTERRUPT;
		knl_ctxtsk->sysmode++;
		ENABLE_INTERRUPT;
#if TA_GP
		ercd = CallDeviceDriver(DEVID(devcb, unitno), omode, exinf, 0,
								(FP)openfn, gp);
#else
		ercd = (*openfn)(DEVID(devcb, unitno), omode, exinf);
#endif
		DISABLE_INTERRUPT;
		knl_ctxtsk->sysmode--;
		ENABLE_INTERRUPT;

		if ( ercd < E_OK ) {
			goto err_ret3;
		}
	}

	LockDM();
	opncb->resid = 1; /* Indicate that open processing is completed */
	UnlockDM();

	return DD(opncb);

err_ret3:
	LockDM();
err_ret2_5:
	knl_delOpnCB(opncb, TRUE);
err_ret2:
	UnlockDM();
err_ret1:
	DEBUG_PRINT(("tk_opn_dev_impl ercd = %d\n", ercd));
	return ercd;
}
开发者ID:chenyifu,项目名称:utkernel-pi,代码行数:101,代码来源:deviceio.c

示例7: knl_request

/*
 * Request for starting input/output to device
 */
EXPORT ID knl_request( ID dd, W start, VP buf, W size, TMO tmout, INT cmd )
{
	EXCFN	execfn;
	VP	exinf;
#if TA_GP
	VP	gp;
#endif
	OpnCB	*opncb;
	DevCB	*devcb;
	ReqCB	*reqcb;
	UINT	m;
	ER	ercd;

	LockDM();

	if ( start <= -0x00010000 && start >= -0x7fffffff ) {
		m = 0; /* Ignore open mode */
	} else {
		m = ( cmd == TDC_READ )? TD_READ: TD_WRITE;
	}
	ercd = knl_check_devdesc(dd, m, &opncb);
	if ( ercd < E_OK ) {
		goto err_ret1;
	}

	devcb = opncb->devcb;
	execfn = (EXCFN)devcb->ddev.execfn;
	exinf = devcb->ddev.exinf;
#if TA_GP
	gp = devcb->ddev.gp;
#endif

	/* Get request management block */
	reqcb = newReqCB(opncb);
	if ( reqcb == NULL ) {
		ercd = E_LIMIT;
		goto err_ret1;
	}

	/* Set request packet */
	reqcb->req.next   = NULL;
	reqcb->req.exinf  = NULL;
	reqcb->req.devid  = DEVID(devcb, opncb->unitno);
	reqcb->req.cmd    = cmd;
	reqcb->req.abort  = FALSE;
	reqcb->req.start  = start;
	reqcb->req.size   = size;
	reqcb->req.buf    = buf;
	reqcb->req.asize  = 0;
	reqcb->req.error  = 0;

	/* Indicate that it is during processing */
	reqcb->tskid = tk_get_tid_impl();

	UnlockDM();

	/* Device driver call */
	DISABLE_INTERRUPT;
	knl_ctxtsk->sysmode++;
	ENABLE_INTERRUPT;
#if TA_GP
	ercd = CallDeviceDriver(&reqcb->req, tmout, exinf, 0, (FP)execfn, gp);
#else
	ercd = (*execfn)(&reqcb->req, tmout, exinf);
#endif
	DISABLE_INTERRUPT;
	knl_ctxtsk->sysmode--;
	ENABLE_INTERRUPT;

	LockDM();

	/* Indicate that it is not during processing */
	reqcb->tskid = 0;

	/* If there is an abort completion wait task,
	   notify abort completion */
	if ( opncb->abort_tskid > 0 && --opncb->abort_cnt == 0 ) {
		tk_sig_sem_impl(opncb->abort_semid, 1);
	}

	if ( ercd < E_OK ) {
		goto err_ret2;
	}

	UnlockDM();

	return REQID(reqcb);

err_ret2:
	knl_delReqCB(reqcb);
err_ret1:
	UnlockDM();
	DEBUG_PRINT(("knl_request ercd = %d\n", ercd));
	return ercd;
}
开发者ID:chenyifu,项目名称:utkernel-pi,代码行数:98,代码来源:deviceio.c

示例8: MRAILI_Release_vbuf

void MRAILI_Release_vbuf(vbuf* v)
{
#ifdef _ENABLE_UD_
    /* This message might be in progress. Wait for ib send completion 
     * to release this buffer to avoid to reusing buffer
     */
    if(v->transport== IB_TRANSPORT_UD 
        && v->flags & UD_VBUF_SEND_INPROGRESS) {
        v->flags |= UD_VBUF_FREE_PENIDING;
        return;
    }
#endif

    /* note this correctly handles appending to empty free list */
#if !defined(CKPT)
    if (MPIDI_CH3I_RDMA_Process.has_srq
#if defined(RDMA_CM)
        || MPIDI_CH3I_RDMA_Process.use_rdma_cm_on_demand
#endif /* defined(RDMA_CM) */
        || MPIDI_CH3I_Process.cm_type == MPIDI_CH3I_CM_ON_DEMAND)
#endif /* !defined(CKPT) */
    {
        pthread_spin_lock(&vbuf_lock);
    }

    DEBUG_PRINT("release_vbuf: releasing %p previous head = %p, padding %d\n", v, free_vbuf_head, v->padding);

#ifdef _ENABLE_UD_
    if(v->transport == IB_TRANSPORT_UD) {
        MPIU_Assert(v != ud_free_vbuf_head);
        v->desc.next = ud_free_vbuf_head;
        ud_free_vbuf_head = v;
        ++ud_num_free_vbuf;
        ++ud_num_vbuf_freed;
    } 
    else 
#endif /* _ENABLE_UD_ */
    {
        MPIU_Assert(v != free_vbuf_head);
        v->desc.next = free_vbuf_head;
        free_vbuf_head = v;
        ++num_free_vbuf;
        ++num_vbuf_freed;
    }

    if (v->padding != NORMAL_VBUF_FLAG
        && v->padding != RPUT_VBUF_FLAG
        && v->padding != RGET_VBUF_FLAG
        && v->padding != RDMA_ONE_SIDED)
    {
        ibv_error_abort(GEN_EXIT_ERR, "vbuf not correct.\n");
    }

    *v->head_flag = 0;
    v->pheader = NULL;
    v->content_size = 0;
    v->sreq = NULL;
    v->vc = NULL;

#if !defined(CKPT)
    if (MPIDI_CH3I_RDMA_Process.has_srq
#if defined(RDMA_CM)
        || MPIDI_CH3I_RDMA_Process.use_rdma_cm_on_demand
#endif /* defined(RDMA_CM) */
        || MPIDI_CH3I_Process.cm_type == MPIDI_CH3I_CM_ON_DEMAND)
#endif /* !defined(CKPT) */
    {
        pthread_spin_unlock(&vbuf_lock);
    }
}
开发者ID:hpc,项目名称:mvapich2-cce,代码行数:70,代码来源:vbuf.c

示例9: sensorsDeviceInit

static void sensorsDeviceInit(void)
{
  isMagnetometerPresent = false;
  isBarometerPresent = false;

  // Wait for sensors to startup
  while (xTaskGetTickCount() < 1000);

  i2cdevInit(I2C3_DEV);
  mpu6500Init(I2C3_DEV);
  if (mpu6500TestConnection() == true)
  {
    DEBUG_PRINT("MPU9250 I2C connection [OK].\n");
  }
  else
  {
    DEBUG_PRINT("MPU9250 I2C connection [FAIL].\n");
  }

  mpu6500Reset();
  vTaskDelay(M2T(50));
  // Activate MPU6500
  mpu6500SetSleepEnabled(false);
  // Delay until registers are reset
  vTaskDelay(M2T(100));
  // Set x-axis gyro as clock source
  mpu6500SetClockSource(MPU6500_CLOCK_PLL_XGYRO);
  // Delay until clock is set and stable
  vTaskDelay(M2T(200));
  // Enable temp sensor
  mpu6500SetTempSensorEnabled(true);
  // Disable interrupts
  mpu6500SetIntEnabled(false);
  // Connect the MAG and BARO to the main I2C bus
  mpu6500SetI2CBypassEnabled(true);
  // Set gyro full scale range
  mpu6500SetFullScaleGyroRange(SENSORS_GYRO_FS_CFG);
  // Set accelerometer full scale range
  mpu6500SetFullScaleAccelRange(SENSORS_ACCEL_FS_CFG);
  // Set accelerometer digital low-pass bandwidth
  mpu6500SetAccelDLPF(MPU6500_ACCEL_DLPF_BW_41);

#if SENSORS_MPU6500_DLPF_256HZ
  // 256Hz digital low-pass filter only works with little vibrations
  // Set output rate (15): 8000 / (1 + 7) = 1000Hz
  mpu6500SetRate(7);
  // Set digital low-pass bandwidth
  mpu6500SetDLPFMode(MPU6500_DLPF_BW_256);
#else
  // To low DLPF bandwidth might cause instability and decrease agility
  // but it works well for handling vibrations and unbalanced propellers
  // Set output rate (1): 1000 / (1 + 0) = 1000Hz
  mpu6500SetRate(0);
  // Set digital low-pass bandwidth for gyro
  mpu6500SetDLPFMode(MPU6500_DLPF_BW_98);
  // Init second order filer for accelerometer
  for (uint8_t i = 0; i < 3; i++)
  {
    lpf2pInit(&gyroLpf[i], 1000, GYRO_LPF_CUTOFF_FREQ);
    lpf2pInit(&accLpf[i],  1000, ACCEL_LPF_CUTOFF_FREQ);
  }
#endif


#ifdef SENSORS_ENABLE_MAG_AK8963
  ak8963Init(I2C3_DEV);
  if (ak8963TestConnection() == true)
  {
    isMagnetometerPresent = true;
    ak8963SetMode(AK8963_MODE_16BIT | AK8963_MODE_CONT2); // 16bit 100Hz
    DEBUG_PRINT("AK8963 I2C connection [OK].\n");
  }
  else
  {
    DEBUG_PRINT("AK8963 I2C connection [FAIL].\n");
  }
#endif

#ifdef SENSORS_ENABLE_PRESSURE_LPS25H
  lps25hInit(I2C3_DEV);
  if (lps25hTestConnection() == true)
  {
    lps25hSetEnabled(true);
    isBarometerPresent = true;
    DEBUG_PRINT("LPS25H I2C connection [OK].\n");
  }
  else
  {
    //TODO: Should sensor test fail hard if no connection
    DEBUG_PRINT("LPS25H I2C connection [FAIL].\n");
  }
#endif

  cosPitch = cosf(configblockGetCalibPitch() * (float) M_PI/180);
  sinPitch = sinf(configblockGetCalibPitch() * (float) M_PI/180);
  cosRoll = cosf(configblockGetCalibRoll() * (float) M_PI/180);
  sinRoll = sinf(configblockGetCalibRoll() * (float) M_PI/180);
}
开发者ID:ISUCTQuadcopterTeam,项目名称:crazyflie-firmware,代码行数:98,代码来源:sensors_cf2.c

示例10: perf_timer_exit

/*
 *Return the difference between 2 timeval structs 
 * in microseconds
 */
static void perf_timer_exit(void)
{
	DEBUG_PRINT("Perf Timer:NOTIFY	:Exiting Performance timer");
}
开发者ID:Nan619,项目名称:ltp-ddt,代码行数:8,代码来源:kSt_timer.c

示例11: allocate_vbuf_region

static int allocate_vbuf_region(int nvbufs)
{

    struct vbuf_region *reg = NULL;
    void *mem = NULL;
    int i = 0;
    vbuf *cur = NULL;
    void *vbuf_dma_buffer = NULL;
    int alignment_vbuf = 64;
    int alignment_dma = getpagesize();
    int result = 0;

    DEBUG_PRINT("Allocating a new vbuf region.\n");

    if (free_vbuf_head != NULL)
    {
        ibv_error_abort(GEN_ASSERT_ERR, "free_vbuf_head = NULL");
    }

    /* are we limiting vbuf allocation?  If so, make sure
     * we dont alloc more than allowed
     */
    if (rdma_vbuf_max > 0)
    {
        nvbufs = MIN(nvbufs, rdma_vbuf_max - vbuf_n_allocated);

        if (nvbufs <= 0)
        {
            ibv_error_abort(GEN_EXIT_ERR, "VBUF alloc failure, limit exceeded");
        }
    }

    reg = (struct vbuf_region *) MPIU_Malloc (sizeof(struct vbuf_region));

    if (NULL == reg)
    {
        ibv_error_abort(GEN_EXIT_ERR, "Unable to malloc a new struct vbuf_region");
    }

    if (rdma_enable_hugepage) {
        result = alloc_hugepage_region (&reg->shmid, &vbuf_dma_buffer, &nvbufs, rdma_vbuf_total_size);
    }

    /* do posix_memalign if enable hugepage disabled or failed */
    if (rdma_enable_hugepage == 0 || result != 0 )  
    {
        reg->shmid = -1;
        result = posix_memalign(&vbuf_dma_buffer, alignment_dma, nvbufs * rdma_vbuf_total_size);
    }

    if ((result!=0) || (NULL == vbuf_dma_buffer))
    {
       ibv_error_abort(GEN_EXIT_ERR, "unable to malloc vbufs DMA buffer");
    }
    
    if (posix_memalign(
        (void**) &mem,
        alignment_vbuf,
        nvbufs * sizeof(vbuf)))
    {
        fprintf(stderr, "[%s %d] Cannot allocate vbuf region\n", __FILE__, __LINE__);
        return -1;
    }
  
    /* region should be registered for all of the hca */
    for (i=0 ; i < rdma_num_hcas; ++i)
    {
        reg->mem_handle[i] = ibv_reg_mr(
            ptag_save[i],
            vbuf_dma_buffer,
            nvbufs * rdma_vbuf_total_size,
            IBV_ACCESS_LOCAL_WRITE | IBV_ACCESS_REMOTE_WRITE);

        if (!reg->mem_handle[i])
        {
            /* de-register already registered with other hcas*/
            for (i = i-1; i >=0 ; --i)
            {
                if (reg->mem_handle[i] != NULL
                        && ibv_dereg_mr(reg->mem_handle[i]))
                {
                    fprintf(stderr, "[%s %d] Cannot de-register vbuf region\n", __FILE__, __LINE__);
                }
            }
            /* free allocated buffers */
            free(vbuf_dma_buffer);
            free(mem);
            MPIU_Free(reg);
            fprintf(stderr, "[%s %d] Cannot register vbuf region\n", __FILE__, __LINE__);
            return -1;
        }
    }

    MPIU_Memset(mem, 0, nvbufs * sizeof(vbuf));
    MPIU_Memset(vbuf_dma_buffer, 0, nvbufs * rdma_vbuf_total_size);

    vbuf_n_allocated += nvbufs;
    num_free_vbuf += nvbufs;
    reg->malloc_start = mem;
    reg->malloc_buf_start = vbuf_dma_buffer;
//.........这里部分代码省略.........
开发者ID:hpc,项目名称:mvapich2-cce,代码行数:101,代码来源:vbuf.c

示例12: MPIDI_CH3I_MRAILI_Cq_poll

int MPIDI_CH3I_MRAILI_Cq_poll(vbuf **vbuf_handle, 
        MPIDI_VC_t * vc_req, int receiving, int is_blocking)
{
    int ne, ret;
    MPIDI_VC_t *vc = NULL;
    struct ibv_wc wc;
    vbuf *v;
    int i = 0;
    int cq_choice = 0;
    int num_cqs = 0;
    int needed;
    int is_send_completion;
    int type = T_CHANNEL_NO_ARRIVE;
    static unsigned long nspin = 0;
    struct ibv_cq *ev_cq; 
    struct ibv_cq *chosen_cq; 
    void *ev_ctx;
    MPIDI_CH3I_MRAILI_Pkt_comm_header *p;

    int myrank;
    MPIDI_STATE_DECL(MPID_GEN2_MRAILI_CQ_POLL);
    MPIDI_FUNC_ENTER(MPID_GEN2_MRAILI_CQ_POLL);
    myrank = PMI_Get_rank(&myrank);

    *vbuf_handle = NULL;
    needed = 0;

    if (!receiving && !vc_req) {
        type = MPIDI_CH3I_MRAILI_Test_pkt(vbuf_handle);
        if (type == T_CHANNEL_EXACT_ARRIVE 
                || type == T_CHANNEL_CONTROL_MSG_ARRIVE)
            goto fn_exit;
    }

    if (rdma_iwarp_use_multiple_cq &&
        MV2_IS_CHELSIO_IWARP_CARD(MPIDI_CH3I_RDMA_Process.hca_type) &&
        (MPIDI_CH3I_RDMA_Process.cluster_size != VERY_SMALL_CLUSTER)) {
        num_cqs = 2;
    } else {
        num_cqs = 1;
    }

    for (; i < rdma_num_hcas; ++i) {
        for (cq_choice = 0; cq_choice < num_cqs; ++cq_choice) {
            if (1 == num_cqs) {
	            chosen_cq = MPIDI_CH3I_RDMA_Process.cq_hndl[i];
	        } else {
	            if (0 == cq_choice) {
	                chosen_cq = MPIDI_CH3I_RDMA_Process.send_cq_hndl[i];
                } else {
	                chosen_cq = MPIDI_CH3I_RDMA_Process.recv_cq_hndl[i];
                }
	        }
	        ne = ibv_poll_cq(chosen_cq, 1, &wc);
	        if (ne < 0 ) {
	            ibv_error_abort(IBV_RETURN_ERR, "Fail to poll cq\n");
	        } else if (ne) {         
	            v = (vbuf *) ((uintptr_t) wc.wr_id);
	
	            vc = (MPIDI_VC_t *) (v->vc);
                cq_poll_completion = 1;
	
	            if (wc.status != IBV_WC_SUCCESS) {
	                if (wc.opcode == IBV_WC_SEND ||
	                    wc.opcode == IBV_WC_RDMA_WRITE ) {
			    		fprintf(stderr, "[%d->%d] send desc error, wc_opcode=%d\n",myrank, vc->pg_rank, wc.opcode );
	                } else {
			    		fprintf(stderr, "[%d<-%d] recv desc error, wc_opcode=%d\n",myrank, vc->pg_rank, wc.opcode);
					}
                    fprintf(stderr, "[%d->%d] wc.status=%d, wc.wr_id=%p, wc.opcode=%d, vbuf->phead->type=%d = %s\n", 
                           myrank, vc->pg_rank, wc.status, v, 
			               wc.opcode,((MPIDI_CH3I_MRAILI_Pkt_comm_header*)v->pheader)->type, 
           			MPIDI_CH3_Pkt_type_to_string[((MPIDI_CH3I_MRAILI_Pkt_comm_header*)v->pheader)->type] );
	
	                ibv_va_error_abort(IBV_STATUS_ERR,
	                        "[] Got completion with error %d, "
	                        "vendor code=0x%x, dest rank=%d\n",
	                        wc.status,    
	                        wc.vendor_err, 
	                        ((MPIDI_VC_t *)v->vc)->pg_rank
	                        );
	            }

                is_send_completion = (wc.opcode == IBV_WC_SEND
                    || wc.opcode == IBV_WC_RDMA_WRITE
                    || wc.opcode == IBV_WC_RDMA_READ);
	
                if (2 == num_cqs) {
    	            if (0 == cq_choice) {
    	                if (MPIDI_CH3I_RDMA_Process.global_used_send_cq) {
                             MPIDI_CH3I_RDMA_Process.global_used_send_cq--;
    	                } else {
                            DEBUG_PRINT("[%d] Possibly received a duplicate \
                                       send completion event \n", 
                                       MPIDI_Process.my_pg_rank);
    	                }
    	            } 
                } else {
                       if(is_send_completion && 
                              (MPIDI_CH3I_RDMA_Process.global_used_send_cq > 0)) {
//.........这里部分代码省略.........
开发者ID:hpc,项目名称:mvapich2-cce,代码行数:101,代码来源:ibv_channel_manager.c

示例13: MPIDI_CH3I_MRAILI_Waiting_msg

int MPIDI_CH3I_MRAILI_Waiting_msg(MPIDI_VC_t * vc, vbuf ** vbuf_handle, int blocking) 
{
    MRAILI_Channel_manager * cmanager = &vc->mrail.cmanager;
    int i = 0;
    int seq;
    int seq_expected = vc->mrail.seqnum_next_torecv;
    int type = T_CHANNEL_NO_ARRIVE;
    MPIDI_STATE_DECL(MPID_GEN2_MPIDI_CH3I_MRAILIWAITING_MSG);
    MPIDI_FUNC_ENTER(MPID_GEN2_MPIDI_CH3I_MRAILIWAITING_MSG);

    *vbuf_handle = NULL;

    if (blocking) {
        DEBUG_PRINT("{entering} solve_out_of_order next expected %d, channel %d, head %p (%d)\n", 
                vc->mrail.seqnum_next_torecv, cmanager->num_channels, 
                cmanager->msg_channels[0].v_queue_head,
                GetSeqNumVbuf(cmanager->msg_channels[0].v_queue_head));
    }

    for (; i < cmanager->num_channels; ++i)
    {
        seq = GetSeqNumVbuf(cmanager->msg_channels[i].v_queue_head);
        if (seq == seq_expected) {
            *vbuf_handle = VQUEUE_DEQUEUE(cmanager, i);
            type = T_CHANNEL_EXACT_ARRIVE;
            ++vc->mrail.seqnum_next_torecv;
            goto fn_exit;
        } else if (PKT_NO_SEQ_NUM == seq) {
            *vbuf_handle = VQUEUE_DEQUEUE(cmanager, i);
            type = T_CHANNEL_CONTROL_MSG_ARRIVE;
            goto fn_exit;
        } else if (PKT_IS_NULL == seq) {
            /* Do nothing */
        } else {
            *vbuf_handle = cmanager->msg_channels[i].v_queue_head;
            type = T_CHANNEL_OUT_OF_ORDER_ARRIVE;
        }
    }

    /* Obviously the packet with correct sequence hasn't arrived */
    while (blocking) {
        /* poll local subrails*/
        for (i = 0; i < cmanager->num_local_pollings; ++i) {
            seq = GetSeqNumVbuf(cmanager->msg_channels[INDEX_LOCAL(cmanager,i)].v_queue_head);
            if (seq == seq_expected) {
                *vbuf_handle = VQUEUE_DEQUEUE(cmanager, INDEX_LOCAL(cmanager,i));
                ++vc->mrail.seqnum_next_torecv;
                type = T_CHANNEL_EXACT_ARRIVE;
                goto fn_exit;
            } else if (seq == PKT_NO_SEQ_NUM) {
                *vbuf_handle = VQUEUE_DEQUEUE(cmanager, INDEX_LOCAL(cmanager,i));
                type = T_CHANNEL_CONTROL_MSG_ARRIVE;
                goto fn_exit;
            }
            else if (vc->mrail.rfp.in_polling_set) {
                *vbuf_handle = MPIDI_CH3I_RDMA_poll(vc);
                seq = GetSeqNumVbuf(*vbuf_handle);
                if (seq == seq_expected) {
                    type = T_CHANNEL_EXACT_ARRIVE;
                    ++vc->mrail.seqnum_next_torecv;
                    goto fn_exit;
                }
                else if( seq == PKT_NO_SEQ_NUM) {
                    type = T_CHANNEL_CONTROL_MSG_ARRIVE;
                    goto fn_exit;
                } else if (*vbuf_handle != NULL){
                    VQUEUE_ENQUEUE(cmanager, INDEX_LOCAL(cmanager,i), *vbuf_handle);
                    *vbuf_handle = NULL;
                }
            }
        }

        type = MPIDI_CH3I_MRAILI_Cq_poll(vbuf_handle, vc, 0, blocking);
        if (type != T_CHANNEL_NO_ARRIVE) {
            switch(type) {
                case (T_CHANNEL_EXACT_ARRIVE):
                    goto fn_exit;
                case (T_CHANNEL_OUT_OF_ORDER_ARRIVE):
                    continue;
                case (T_CHANNEL_CONTROL_MSG_ARRIVE):
                    goto fn_exit;
                default:
                    ibv_error_abort(GEN_ASSERT_ERR, "Unexpected return type\n");
                    break;
            }
        } else {

        }
    } 
fn_exit:
    if (blocking) {
        DEBUG_PRINT("{return} solve_out_of_order, type %d, next expected %d\n", 
                type, vc->mrail.seqnum_next_torecv);
    }
    MPIDI_FUNC_EXIT(MPID_GEN2_MPIDI_CH3I_MRAILIWAITING_MSG);
    return type;
}
开发者ID:hpc,项目名称:mvapich2-cce,代码行数:97,代码来源:ibv_channel_manager.c

示例14: MPIDI_CH3I_MRAILI_Get_next_vbuf

int MPIDI_CH3I_MRAILI_Get_next_vbuf(MPIDI_VC_t** vc_ptr, vbuf** vbuf_ptr) 
{
    *vc_ptr = NULL;
    *vbuf_ptr = NULL;
    VBUF_FLAG_TYPE size;
    int type;
    MPIDI_STATE_DECL(MPID_GEN2_MPIDI_CH3I_MRAILI_GET_NEXT_VBUF);
    MPIDI_FUNC_ENTER(MPID_GEN2_MPIDI_CH3I_MRAILI_GET_NEXT_VBUF);

    type = MPIDI_CH3I_MRAILI_Test_pkt(vbuf_ptr);

    switch(type)
    { 
    case T_CHANNEL_CONTROL_MSG_ARRIVE:
    case T_CHANNEL_EXACT_ARRIVE:
            *vc_ptr = (*vbuf_ptr)->vc;
        goto fn_exit;
    case T_CHANNEL_OUT_OF_ORDER_ARRIVE:
            type = T_CHANNEL_NO_ARRIVE;
            *vbuf_ptr = NULL;
        break;
    }

    if (num_rdma_buffer == 0)
    {
        goto fn_exit;
    }

    int i = 0;
    MPIDI_VC_t* vc = NULL;
    int seq;
    vbuf* v = NULL;
    volatile VBUF_FLAG_TYPE* tail = NULL;
    volatile VBUF_FLAG_TYPE* head = NULL;

    /* no msg is queued, poll rdma polling set */
    for (; i < MPIDI_CH3I_RDMA_Process.polling_group_size; ++i)
    {
        vc = MPIDI_CH3I_RDMA_Process.polling_set[i];
        seq  = GetSeqNumVbuf(vc->mrail.cmanager.msg_channels[INDEX_LOCAL(&vc->mrail.cmanager,0)].v_queue_head);

        if (seq == PKT_IS_NULL)
        {
            v = &(vc->mrail.rfp.RDMA_recv_buf[vc->mrail.rfp.p_RDMA_recv]);
            head = v->head_flag;

            if (*head && vc->mrail.rfp.p_RDMA_recv != vc->mrail.rfp.p_RDMA_recv_tail)
            {
                size = (*head & FAST_RDMA_SIZE_MASK);
                tail = (VBUF_FLAG_TYPE *) (v->buffer + size);
                /* If the tail has not received yet, than go ahead and
                ** poll next connection */
                if (*head != *tail) {
                    continue;
                }
                
                DEBUG_PRINT("Get one!\n");

                if (++vc->mrail.rfp.p_RDMA_recv >= num_rdma_buffer)
                {
                    vc->mrail.rfp.p_RDMA_recv = 0;
                }

                v->pheader = v->buffer;
                v->content_size = size;
                *head = 0;

                seq = GetSeqNumVbuf(v);

#ifdef _ENABLE_UD_
                if (rdma_enable_hybrid){
                    v->seqnum = seq;
                    type = T_CHANNEL_HYBRID_MSG_ARRIVE;
                    *vbuf_ptr = v;
                    *vc_ptr = v->vc;
                    PRINT_DEBUG(DEBUG_UD_verbose>1,"received seqnum:%d expected:%d vc_ptr:%p\n",seq, vc->mrail.seqnum_next_torecv, v->vc);
                    goto fn_exit;
                } 
                else
#endif
                {
                    if (seq == vc->mrail.seqnum_next_torecv)
                    {
                        DEBUG_PRINT("Get one exact seq: %d\n", seq);
                        type = T_CHANNEL_EXACT_ARRIVE;
                        ++vc->mrail.seqnum_next_torecv;
                        *vbuf_ptr = v;
                        *vc_ptr = v->vc;
                        goto fn_exit;
                    }
                    else if (seq == PKT_NO_SEQ_NUM)
                    {
                        type = T_CHANNEL_CONTROL_MSG_ARRIVE;
                        DEBUG_PRINT("[vbuf_local]: get control msg\n");
                        *vbuf_ptr = v;
                        *vc_ptr = v->vc;
                        goto fn_exit;
                    }
                    else
                    {
//.........这里部分代码省略.........
开发者ID:hpc,项目名称:mvapich2-cce,代码行数:101,代码来源:ibv_channel_manager.c

示例15: usbOpenDevice

static int usbOpenDevice(union filedescriptor *fdp, int vendor, char *vendorName,
			 int product, char *productName, int usesReportIDs)
{
    GUID                                hidGuid;        /* GUID for HID driver */
    HDEVINFO                            deviceInfoList;
    SP_DEVICE_INTERFACE_DATA            deviceInfo;
    SP_DEVICE_INTERFACE_DETAIL_DATA     *deviceDetails = NULL;
    DWORD                               size;
    int                                 i, openFlag = 0;  /* may be FILE_FLAG_OVERLAPPED */
    int                                 errorCode = USB_ERROR_NOTFOUND;
    HANDLE                              handle = INVALID_HANDLE_VALUE;
    HIDD_ATTRIBUTES                     deviceAttributes;

    HidD_GetHidGuid(&hidGuid);
    deviceInfoList = SetupDiGetClassDevs(&hidGuid, NULL, NULL,
					 DIGCF_PRESENT | DIGCF_INTERFACEDEVICE);
    deviceInfo.cbSize = sizeof(deviceInfo);
    for(i=0;;i++){
        if(handle != INVALID_HANDLE_VALUE){
            CloseHandle(handle);
            handle = INVALID_HANDLE_VALUE;
        }
        if(!SetupDiEnumDeviceInterfaces(deviceInfoList, 0, &hidGuid, i, &deviceInfo))
            break;  /* no more entries */
        /* first do a dummy call just to determine the actual size required */
        SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, NULL, 0, &size, NULL);
        if(deviceDetails != NULL)
            free(deviceDetails);
        deviceDetails = malloc(size);
        deviceDetails->cbSize = sizeof(*deviceDetails);
        /* this call is for real: */
        SetupDiGetDeviceInterfaceDetail(deviceInfoList, &deviceInfo, deviceDetails,
					size, &size, NULL);
        DEBUG_PRINT(("checking HID path \"%s\"\n", deviceDetails->DevicePath));
        /* attempt opening for R/W -- we don't care about devices which can't be accessed */
        handle = CreateFile(deviceDetails->DevicePath, GENERIC_READ|GENERIC_WRITE,
			    FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
			    openFlag, NULL);
        if(handle == INVALID_HANDLE_VALUE){
            DEBUG_PRINT(("opening failed: %d\n", (int)GetLastError()));
            /* errorCode = USB_ERROR_ACCESS; opening will always fail for mouse -- ignore */
            continue;
        }
        deviceAttributes.Size = sizeof(deviceAttributes);
        HidD_GetAttributes(handle, &deviceAttributes);
        DEBUG_PRINT(("device attributes: vid=%d pid=%d\n",
		     deviceAttributes.VendorID, deviceAttributes.ProductID));
        if(deviceAttributes.VendorID != vendor || deviceAttributes.ProductID != product)
            continue;   /* ignore this device */
        errorCode = USB_ERROR_NOTFOUND;
        if(vendorName != NULL && productName != NULL){
            char    buffer[512];
            if(!HidD_GetManufacturerString(handle, buffer, sizeof(buffer))){
                DEBUG_PRINT(("error obtaining vendor name\n"));
                errorCode = USB_ERROR_IO;
                continue;
            }
            convertUniToAscii(buffer);
            DEBUG_PRINT(("vendorName = \"%s\"\n", buffer));
            if(strcmp(vendorName, buffer) != 0)
                continue;
            if(!HidD_GetProductString(handle, buffer, sizeof(buffer))){
                DEBUG_PRINT(("error obtaining product name\n"));
                errorCode = USB_ERROR_IO;
                continue;
            }
            convertUniToAscii(buffer);
            DEBUG_PRINT(("productName = \"%s\"\n", buffer));
            if(strcmp(productName, buffer) != 0)
                continue;
        }
        break;  /* we have found the device we are looking for! */
    }
    SetupDiDestroyDeviceInfoList(deviceInfoList);
    if(deviceDetails != NULL)
        free(deviceDetails);
    if(handle != INVALID_HANDLE_VALUE){
	fdp->pfd = (void *)handle;
	errorCode = 0;
    }
    return errorCode;
}
开发者ID:JasonBeard,项目名称:usbprog5,代码行数:82,代码来源:ser_avrdoper.c


注:本文中的DEBUG_PRINT函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。