예제 #1
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Attach this VSocket to a pre-existing socket handle.
 *
 *  @remarks    Attaches this object to an existing socket handle and
 *              enters the processing loop.
 *
 *  @param      pHandle
 *                  Handle to the socket to attach to.
 *------------------------------------------------------------------*/
bool VSocket::Attach(SOCKET pHandle) {
	char    vAddress[51];
	VUSHORT vPort = 0;

	BEG_FUNC("Attach")("%d", pHandle);

	if (mStatus == SS_CONNECTED) {
		VTRACE("Error-socket already connected to %s:%d\n",
				mEndPoint.GetAddr(), mEndPoint.GetPort());
		mError = EISCONN;
		return END_FUNC(false);
	}

	if (mStatus == SS_BOUND) {
		VTRACE("Error-socket already bound to %s:%d\n",
				mLocal.GetAddr(), mLocal.GetPort());
		mError = EISCONN;
		return END_FUNC(false);
	}

	mStatus = SS_ALLOCATED;
	mHandle = pHandle;
	GetPeerName(vAddress, 50, &vPort);
	mEndPoint.SetPort(vPort);
	mEndPoint.SetAddr(vAddress);

	memset(vAddress, 0, 50);
	GetSockName(vAddress, 50, &vPort);
	mLocal.SetPort(vPort);
	mLocal.SetAddr(vAddress);

	mStatus = SS_CONNECTED;

	return END_FUNC(true);
}
예제 #2
0
/********************************************************************
 *                        O P E R A T I O N S                       *
 ********************************************************************/
bool VOGLWindow::Create(VWindowOpts *pOpts)
{
#if VIPER_PLATFORM == PLATFORM_WINDOWS
#elif VIPER_PLATFORM == PLATFORM_MAC
#elif VIPER_PLATFORM == PLATFORM_LINUX
	Atom	vWMDelete;
	Window	vWinDmmy;
	VUINT	vBorderDummy;

	mOpts.mFullScreen = pOpts->mFullScreen;
	mOpts.mWidth = pOpts->mWidth;
	mOpts.mHeight = pOpts->mHeight;

	mAttr.colormap = XCreateColormap(mDpy, RootWindow(mDpy, mVInfo->screen),
						mVInfo->visual, AllocNone);

	mAttr.event_mask = ExposureMask | KeyPressMask | ButtonPressMask | StructureNotifyMask;

	if (mOpts.mFullScreen)
	{
		XF86VidModeSwitchToMode(mDpy, mScreen, mMode);
		XF86VidModeSetViewPort(mDpy, mScreen, 0, 0);
		mAttr.override_redirect = True;
		mWin = XCreateWindow(mDpy, RootWindow(mDpy, mVInfo->screen),
			0, 0, mOpts.mWidth, mOpts.mHeight, 0, mVInfo->depth, InputOutput, mVInfo->visual,
			CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect, &mAttr
		);
	}
	else
	{
		mWin = XCreateWindow(mDpy, RootWindow(mDpy, mVInfo->screen),
			0, 0, mOpts.mWidth, mOpts.mHeight, 0, mVInfo->depth, InputOutput, mVInfo->visual,
			CWBorderPixel | CWColormap | CWEventMask, &mAttr
		);
		vWMDelete = XInternAtom(mDpy, "WM_DELETE_WINDOW", True);
		XSetWMProtocols(mDpy, mWin, &vWMDelete, 1);
		XSetStandardProperties(mDpy, mWin, "", "", None, NULL, 0, NULL);
	}
	XMapRaised(mDpy, mWin);

	mCtx = glXCreateContext(mDpy, mVInfo, 0, GL_TRUE);
	if (mCtx == NULL)
	{
		VTRACE(_CL("Unable to create context\n"));
		return false;
	}

	if (!glXMakeCurrent(mDpy, mWin, mCtx))
		return false;

	if (glXIsDirect(mDpy, mCtx))
		VTRACE(_CL("Direct Rendering: true\n"));
	else
		VTRACE(_CL("Direct Rendering: false\n"));
#endif

	return true;
}
예제 #3
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Begin listening for incoming client connections.
 *
 *  @param      pConnBacklog
 *                  Number of connections to allow in the
 *                  queue before rejecting.
 *------------------------------------------------------------------*/
bool VSocket::Listen(int pConnBacklog) {
	bool vRetval = true;

	BEG_FUNC("Listen")("%d", pConnBacklog);

	/*
	 * Already connected?
	 */
	if (mStatus == SS_CONNECTED) {
		VTRACE("Error-Socket already connected to %s\n",
				mEndPoint.GetAddr());
		mError = EISCONN;
		vRetval = false;
	}

	/*
	 * Socket initialized and bound?
	 */
	if (vRetval && mStatus != SS_ALLOCATED && mStatus != SS_BOUND) {
		VTRACE("Error-Socket not initialized or bound\n");
		mError = ENOTCONN;
		vRetval = false;
	}

	if (vRetval) {
		/*
		 * Try to put the socket into listening mode.
		 */
		if (listen(mHandle, pConnBacklog) == 0) {
			VTRACE("Socket successfully placed in listen mode.\n");
		} else {
			SETERRNO();
			mError = errno;
			vRetval = false;
			VTRACE("Error entering listening mode.  Error-%d:%s\n",
					mError, strerror(mError));
		}

		if (vRetval) {
			/*
			 * With the socket in listening mode, start the processing
			 * thread so we can be notified of incoming connections.
			 */
			mStatus = SS_LISTENING;
		}
	}

	return END_FUNC(vRetval);
}
int psbWsbmInitialize(int drmFD)
{
    union drm_psb_extension_arg arg;
    const char drmExt[] = "psb_ttm_placement_alphadrop";
    int ret = 0;

    CTRACE();

    if (drmFD <= 0) {
        ETRACE("invalid drm fd %d", drmFD);
        return drmFD;
    }

    /*init wsbm*/
    ret = wsbmInit(wsbmNullThreadFuncs(), &vNodeFuncs);
    if (ret) {
        ETRACE("failed to initialize Wsbm, error code %d", ret);
        return ret;
    }

    VTRACE("DRM_PSB_EXTENSION %d", DRM_PSB_EXTENSION);

    /*get devOffset via drm IOCTL*/
    strncpy(arg.extension, drmExt, sizeof(drmExt));

    ret = drmCommandWriteRead(drmFD, 6/*DRM_PSB_EXTENSION*/, &arg, sizeof(arg));
    if(ret || !arg.rep.exists) {
        ETRACE("failed to get device offset, error code %d", ret);
        goto out;
    }

    VTRACE("ioctl offset %#x", arg.rep.driver_ioctl_offset);

    mainPool = wsbmTTMPoolInit(drmFD, arg.rep.driver_ioctl_offset);
    if(!mainPool) {
        ETRACE("failed to initialize TTM Pool");
        ret = -EINVAL;
        goto out;
    }

    VTRACE("Wsbm initialization succeeded. mainPool %p", mainPool);

    return 0;

out:
    psbWsbmTakedown();
    return ret;
}
예제 #5
0
파일: trap.c 프로젝트: skrll/netbsd-src
void
exitshell(int status)
{
	struct jmploc loc1, loc2;
	char *p;

	CTRACE(DBG_ERRS|DBG_PROCS|DBG_CMDS|DBG_TRAP,
	    ("pid %d, exitshell(%d)\n", getpid(), status));

	if (setjmp(loc1.loc)) {
		goto l1;
	}
	if (setjmp(loc2.loc)) {
		goto l2;
	}
	handler = &loc1;
	if ((p = trap[0]) != NULL && *p != '\0') {
		trap[0] = NULL;
		VTRACE(DBG_TRAP, ("exit trap: \"%s\"\n", p));
		evalstring(p, 0);
	}
 l1:	handler = &loc2;			/* probably unnecessary */
	flushall();
#if JOBS
	setjobctl(0);
#endif
 l2:	_exit(status);
	/* NOTREACHED */
}
bool BlankControl::blank(int disp, bool blank)
{
    // current do nothing but return true
    // use PM to trigger screen blank/unblank
    VTRACE("blank is not supported yet, disp %d, blank %d", disp, blank);
    return true;
}
bool OverlayPlaneBase::assignToDevice(int disp)
{
    uint32_t pipeConfig = 0;

    RETURN_FALSE_IF_NOT_INIT();
    VTRACE("overlay %d assigned to disp %d", mIndex, disp);

    switch (disp) {
    case IDisplayDevice::DEVICE_EXTERNAL:
        pipeConfig = (0x2 << 6);
        break;
    case IDisplayDevice::DEVICE_PRIMARY:
    default:
        pipeConfig = 0;
        break;
    }

    // if pipe switching happened, then disable overlay first
    if (mPipeConfig != pipeConfig) {
        DTRACE("overlay %d switched from %d to %d", mIndex, mDevice, disp);
        disable();
    }

    mPipeConfig = pipeConfig;
    DisplayPlane::assignToDevice(disp);

    enable();

    return true;
}
예제 #8
0
bool CTestResource::FromStr(LPCTSTR pszImage)
{
  CTestResourceProperties prop(this);
  prop.LoadFromCommandString(pszImage);
  VTRACE(_T("From command string %s\n"),pszImage);
  return true;
}
int psbWsbmWrapTTMBuffer(uint64_t handle, void **buf)
{
    int ret = 0;
    struct _WsbmBufferObject *wsbmBuf;

    if (!buf) {
        ETRACE("invalid parameter");
        return -EINVAL;
    }

    ret = wsbmGenBuffers(mainPool, 1, &wsbmBuf, 0,
                        (WSBM_PL_FLAG_VRAM | WSBM_PL_FLAG_TT |
                        /*WSBM_PL_FLAG_NO_EVICT |*/ WSBM_PL_FLAG_SHARED));

    if (ret) {
        ETRACE("wsbmGenBuffers failed with error code %d", ret);
        return ret;
    }

    ret = wsbmBOSetReferenced(wsbmBuf, handle);
    if (ret) {
        ETRACE("wsbmBOSetReferenced failed with error code %d", ret);
        return ret;
    }

    *buf = (void *)wsbmBuf;

    VTRACE("wrap buffer %p for handle %#x", wsbmBuf, handle);
    return 0;
}
예제 #10
0
OverlayBackBuffer* OverlayPlaneBase::createBackBuffer()
{
    CTRACE();

    // create back buffer
    OverlayBackBuffer *backBuffer = (OverlayBackBuffer *)malloc(sizeof(OverlayBackBuffer));
    if (!backBuffer) {
        ETRACE("failed to allocate back buffer");
        return 0;
    }


    int size = sizeof(OverlayBackBufferBlk);
    int alignment = 64 * 1024;
    void *wsbmBufferObject = 0;
    bool ret = mWsbm->allocateTTMBuffer(size, alignment, &wsbmBufferObject);
    if (ret == false) {
        ETRACE("failed to allocate TTM buffer");
        return 0;
    }

    void *virtAddr = mWsbm->getCPUAddress(wsbmBufferObject);
    uint32_t gttOffsetInPage = mWsbm->getGttOffset(wsbmBufferObject);

    backBuffer->buf = (OverlayBackBufferBlk *)virtAddr;
    backBuffer->gttOffsetInPage = gttOffsetInPage;
    backBuffer->bufObject = wsbmBufferObject;

    VTRACE("cpu %p, gtt %d", virtAddr, gttOffsetInPage);

    return backBuffer;
}
예제 #11
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Initialize this socket and prepare for use.
 *
 *  @remarks    Creates the underlying socket handle and sets the socket
 *              to non-blocking mode.  If an address/port are specified, the
 *              socket is bound automatically.
 *
 *  @param      pPort
 *                  Optional port number to bind to.
 *  @param      pSocketType
 *                  Type of socket.
 *  @param      pSockAddr
 *                  Optional address to bind to.
 *------------------------------------------------------------------*/
bool VSocket::Create(VUSHORT pPort /*=0*/,
		int pSocketType /*=SOCK_STREAM*/, const char* pSockAddr/*=NULL*/) {
	SOCKET  vSocketID = -1; // Default to an invalid state
	bool    vResult = false;
	int     vRetval = 0;
	long    vLongBlock = 0;

	BEG_FUNC("Create")("%d, %d, %p", pPort, pSocketType, pSockAddr);

	/*
	 * Make sure we aren't already created or bound.
	 */
	if (mStatus != SS_UNALLOCATED) {
		VTRACE("Socket already initialized\n");
		mError = EISCONN;
		return END_FUNC(false);
	}

	/*
	 * Create the actual socket.
	 */
	vSocketID = socket(AF_INET, pSocketType, 0);
	if (vSocketID != -1) {
		VTRACE("Socket %d created\n", vSocketID);
		mStatus = SS_ALLOCATED;
		mHandle = vSocketID;
		/*
		 * If a port/address were supplied, try and bind to them.
		 */
		if (pPort != 0)
			vResult = Bind(pPort, pSockAddr);
		else
			vResult = true;
	}

	if (vResult)
		VTRACE("Successfully created socket.\n");
	else
		VTRACE("Unable to create socket.\n");

	return END_FUNC(vResult);
}
예제 #12
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Accept a pending connection from the incoming queue.
 *
 *  @param      pNewSocket
 *                  Pointer to hold the newly accepted socket.
 *  @param      pSockAddr
 *                  Pointer to hold the address info for the remote
 *                  socket.
 *  @param      pSockAddrLen
 *                  Size of the address pointer.
 *------------------------------------------------------------------*/
bool VSocket::Accept(VSocket* pNewSocket, sockaddr* pSockAddr/*=NULL*/,
		socklen_t* pSockAddrLen/*=NULL*/) {
	SOCKET  vTempHandle = -1; /* temp Socket ID */
	SOCKET  vNewHandle = -1; /* new Socket ID  */
	int     vPeerSize;
	bool    vRetval = false;
	bool    vOk = true;

	BEG_FUNC("Accept")("%p, %p, %p", pNewSocket, pSockAddr, pSockAddrLen);

	if (mStatus != SS_LISTENING) { /* Socket not in listening mode! */
		VTRACE("Socket not in listening mode. Cannot accept "
				"incoming connection\n");
		mError = EINVAL;
		return END_FUNC(false);
	}

	/* We are in a proper state to accept connections.  Try it! */
	vPeerSize = sizeof(mEndPoint);
	vTempHandle = mHandle;

	/* Attempt to accept the connection */
	vNewHandle = accept(vTempHandle, (struct sockaddr*)&mEndPoint, (socklen_t*)&vPeerSize);
	if (vNewHandle >= 0) {
		/* Accepted an incoming connection */
		VTRACE("Connection accepted\n");
		pNewSocket->Attach(vNewHandle);
		if (pSockAddr != NULL)
			memcpy(pSockAddr, &mEndPoint, vPeerSize);

		if (pSockAddrLen != NULL)
			*pSockAddrLen = vPeerSize;
		vRetval = true;
	} else {
		SETERRNO();
		mError = errno;
		VTRACE("accept failed with error code %d\n", errno);
	}

	return END_FUNC(vRetval);
}
예제 #13
0
CTestResource::CTestResource(LPCTSTR pszHostPort, LPCTSTR target, LPCTSTR  pszDownloadPort, int nBaud, LPCTSTR pszResetString):
  m_strReset(pszResetString),
  m_bInUse(false),
  m_nBaud(nBaud),
  m_strPort(pszDownloadPort),
  m_bLocked(false),
  m_Target(target)
{
  CeCosSocket::ParseHostPort(pszHostPort,m_strHost,m_nPort);
  VTRACE(_T("@@@ Created resource %08x %s\n"),(unsigned int)this,(LPCTSTR)Image());
  Chain();
}
void * psbWsbmGetCPUAddress(void * buf)
{
    if(!buf) {
        ETRACE("invalid ttm buffer");
        return NULL;
    }

    VTRACE("buffer object %p", buf);

    void * address = wsbmBOMap((struct _WsbmBufferObject *)buf,
                                WSBM_ACCESS_READ | WSBM_ACCESS_WRITE);
    if(!address) {
        ETRACE("failed to map buffer object");
        return NULL;
    }

    VTRACE("mapped successfully. %p, size %ld",
        address, wsbmBOSize((struct _WsbmBufferObject *)buf));

    return address;
}
예제 #15
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Clean up this socket object and reset it to an
 *              unused state.
 *
 *  @remarks    Called when all processing on this socket has finished.
 *              Once Close() is called, this socket cannot be used again
 *              until Create() is called.
 *------------------------------------------------------------------*/
void VSocket::Close() {
	BEG_FUNC("Close")(NULL);

	if (mHandle != -1) {
		SOCKET vHandle = Detach();
		closesocket(vHandle);
	} else {
		VTRACE("Socket already closed\n");
	}

	END_FUNCV();
}
예제 #16
0
파일: trap.c 프로젝트: ozaki-r/netbsd-src
void
ignoresig(int signo, int vforked)
{
	if (sigmode[signo] == 0)
		setsignal(signo, vforked);

	VTRACE(DBG_TRAP, ("ignoresig(%d%s)\n", signo, vforked ? ", VF" : ""));
	if (sigmode[signo] != S_IGN && sigmode[signo] != S_HARD_IGN) {
		signal(signo, SIG_IGN);
		if (!vforked)
			sigmode[signo] = S_IGN;
	}
}
예제 #17
0
bool CTestResource::LoadSocket(LPCTSTR pszResourceHostPort,Duration dTimeout/*=10*1000*/)
{
  bool rc=false;
  ENTERCRITICAL;
  CTestResource *pResource;
  // If the resource is in use, we don't dare delete it!
  for(pResource=CTestResource::First();pResource;pResource=pResource->Next()){
    pResource->m_bFlag=false;
  }
  CeCosSocket sock;
  if(sock.Connect(pszResourceHostPort,dTimeout)){
    // Write the message to the socket
    int nRequest=0; // read
    if(!sock.sendInteger(nRequest)){
      ERROR(_T("Failed to write to socket\n"));
    } else {
      int nResources;
      if(sock.recvInteger(nResources,_T(""),dTimeout)){
        rc=true;
        while(nResources--){
          String strImage;
          if(sock.recvString(strImage,_T(""),dTimeout)){
            VTRACE(_T("Recv \"%s\"\n"),(LPCTSTR)strImage);
            CTestResource tmp;
            tmp.FromStr(strImage);
            CTestResource *pResource=Lookup(tmp.HostPort());
            if(0==pResource){
              pResource=new CTestResource(_T(""),_T(""));
            }
            pResource->FromStr(strImage);
            pResource->m_bFlag=true;
          } else {
            rc=false;
            break;
          }
        }
      }
    }
  }
  // If the resource is in use, we don't dare delete it!
  CTestResource *pNext;
  for(pResource=CTestResource::First();pResource;pResource=pNext){
    pNext=pResource->Next();
    if(!pResource->m_bFlag && !pResource->m_bInUse){
      delete pResource;
    }
  }
  
  LEAVECRITICAL;
  return rc;
}
int psbWsbmAllocateFromUB(uint32_t size, uint32_t align, void ** buf, void *user_pt)
{
    struct _WsbmBufferObject * wsbmBuf = NULL;
    int ret = 0;
    int offset = 0;

    ATRACE("size %d", align_to(size, 4096));

    if(!buf || !user_pt) {
        ETRACE("invalid parameter");
        return -EINVAL;
    }

    VTRACE("mainPool %p", mainPool);

    ret = wsbmGenBuffers(mainPool, 1, &wsbmBuf, align,
                        DRM_PSB_FLAG_MEM_MMU | WSBM_PL_FLAG_CACHED |
                        WSBM_PL_FLAG_NO_EVICT | WSBM_PL_FLAG_SHARED);
    if(ret) {
        ETRACE("wsbmGenBuffers failed with error code %d", ret);
        return ret;
    }

    ret = wsbmBODataUB(wsbmBuf,
                       align_to(size, 4096), NULL, NULL, 0,
                       user_pt, -1);

    if(ret) {
        ETRACE("wsbmBOData failed with error code %d", ret);
        /*FIXME: should I unreference this buffer here?*/
        return ret;
    }

    *buf = wsbmBuf;

    VTRACE("ttm UB buffer allocated. %p", *buf);
    return 0;
}
예제 #19
0
CDirstatDoc::CDirstatDoc()
{
    ASSERT(NULL == _theDocument);
    _theDocument = this;
    m_rootItem = NULL;
    m_workingItem = NULL;
    m_zoomItem = NULL;

    m_showFreeSpace = CPersistence::GetShowFreeSpace();
    m_showUnknown = CPersistence::GetShowUnknown();
    m_extensionDataValid = false;

    VTRACE(_T("sizeof(CItem) = %d"), sizeof(CItem));
}
void VideoDecoderAVCSecure::stop(void) {
    VTRACE("VideoDecoderAVCSecure::stop");
    VideoDecoderAVC::stop();

    if (mClearData) {
        delete [] mClearData;
        mClearData = NULL;
    }

    if (mCachedHeader) {
        delete [] mCachedHeader;
        mCachedHeader = NULL;
    }
}
int psbWsbmAllocateTTMBuffer(uint32_t size, uint32_t align, void ** buf)
{
    struct _WsbmBufferObject * wsbmBuf = NULL;
    int ret = 0;
    int offset = 0;

    ATRACE("size %d", align_to(size, 4096));

    if(!buf) {
        ETRACE("invalid parameter");
        return -EINVAL;
    }

    VTRACE("mainPool %p", mainPool);

    ret = wsbmGenBuffers(mainPool, 1, &wsbmBuf, align,
                        (WSBM_PL_FLAG_VRAM | WSBM_PL_FLAG_TT |
                         WSBM_PL_FLAG_SHARED | WSBM_PL_FLAG_NO_EVICT));
    if(ret) {
        ETRACE("wsbmGenBuffers failed with error code %d", ret);
        return ret;
    }

    ret = wsbmBOData(wsbmBuf, align_to(size, 4096), NULL, NULL, 0);
    if(ret) {
        ETRACE("wsbmBOData failed with error code %d", ret);
        /*FIXME: should I unreference this buffer here?*/
        return ret;
    }

    /* wsbmBOReference(wsbmBuf); */ /* no need to add reference */

    *buf = wsbmBuf;

    VTRACE("ttm buffer allocated. %p", *buf);
    return 0;
}
예제 #22
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Retrieve data pending on this socket.
 *
 *  @remarks    Should be called by OnReceive(), when data is known
 *              to be available.
 *
 *  @param      pBuffer
 *                  Buffer to hold the retrieved data.
 *  @param      pBufLen
 *                  Maximum length of pcBuffer.
 *  @param      pFlags
 *                  Options to be passed to recv().
 *------------------------------------------------------------------*/
int VSocket::Receive(char *pBuffer, int pBufLen, int pFlags) {
	bool    vContinue = true;
	int     vRetval = -1;

	BEG_FUNC("Receive")("%p, %d, %d", pBuffer, pBufLen, pFlags);

	/*
	 * Are we connected?
	 */
	if (mStatus != SS_CONNECTED) {
		VTRACE("Error-not connected\n");
		mError = ENOTCONN;
		vContinue = false;
	}

	if (pBuffer == NULL) {
		VTRACE("Error-null buffer passed\n");
		mError = EINVAL;
		vContinue = false;
	} else {
		if (pBufLen <= 0) {
			VTRACE("Error-invalid buffer length specified\n");
			mError = EINVAL;
		} else {
			vRetval = recv(mHandle, pBuffer, pBufLen, pFlags);
			if (vRetval == -1) {
				SETERRNO();
				mError = errno;
			} else if (vRetval > 0) {
				pBuffer[vRetval] = 0;
				VTRACE("Received-%s\n", pBuffer);
			}
		}
	}

	return END_FUNC(vRetval);
}
예제 #23
0
파일: trap.c 프로젝트: ozaki-r/netbsd-src
void
free_traps(void)
{
	char * volatile *tp;

	VTRACE(DBG_TRAP, ("free_traps%s\n", traps_invalid ? "(invalid)" : ""));
	INTOFF;
	for (tp = trap ; tp < &trap[NSIG] ; tp++)
		if (*tp && **tp) {
			ckfree(*tp);
			*tp = NULL;
		}
	traps_invalid = 0;
	INTON;
}
uint32_t psbWsbmGetGttOffset(void * buf)
{
    if(!buf) {
        ETRACE("invalid ttm buffer");
        return 0;
    }

    VTRACE("buffer object %p", buf);

    uint32_t offset =
        wsbmBOOffsetHint((struct _WsbmBufferObject *)buf) - 0x10000000;

    VTRACE("offset %#x", offset >> 12);

    return offset >> 12;
}
예제 #25
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Shutdown communications on this socket.
 *
 *  @remarks    Called when the local side wishes to disconnect
 *              communications.  Optional parameter specifies which
 *              communications should be closed (send, recv, or both).
 *
 *  @param      pHow
 *                  Designates whether the socket should allow sends or
 *                  receives to finish.
 *
 *  @return     If the call is successful, returns 0.  Otherwise, -1 is
 *              returned, and a specific error code can be retrieved by
 *              calling GetLastError().
 *------------------------------------------------------------------*/
int VSocket::Shutdown(int pHow /*=SHUT_WR*/) {
	int vRetval = 0;

	BEG_FUNC("Shutdown")("%d", pHow);

	if (mHandle != -1) {
		vRetval = shutdown(mHandle, pHow);
		if (vRetval != 0) {
			SETERRNO();
			mError = errno;
			VTRACE("Error calling shutdown: %d:%s\n", errno, strerror(errno));
		}
	}

	return END_FUNC(vRetval);
}
예제 #26
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      Transmit data on this socket.
 *
 *  @remarks    Since we're in non-blocking mode, the number of bytes
 *              transmitted can be less than the number desired.
 *
 *  @param      pBuffer
 *                  Buffer containing the data to be sent.
 *  @param      pBufLen
 *                  Number of bytes to be transmitted.
 *
 *  @return     Returns the number of bytes actually sent, or -1 in
 *              case of an error.  Call GetLastError() to get the
 *              actual error code.
 *------------------------------------------------------------------*/
int VSocket::Send(const char *pBuffer, int pBufLen) {
	int vRetval = 0;

	BEG_FUNC("Send")("%p, %d", pBuffer, pBufLen);

	vRetval = send(mHandle, pBuffer, pBufLen, MSG_NOSIGNAL);

	if (vRetval > 0) {
		VTRACE("%d bytes transmitted\n", vRetval);
	} else if (vRetval < 0) {
		SETERRNO();
		mError = errno;
	}

	return END_FUNC(vRetval);
}
예제 #27
0
CTestResource::~CTestResource()
{
  ENTERCRITICAL;
  VTRACE(_T("@@@ Destroy resource %08x %s\n"),this,(LPCTSTR)Image());
  if(m_pPrevInstance || m_pNextInstance){
    nCount--;
  }
  if(pFirstInstance==this){
    pFirstInstance=m_pNextInstance;
  }
  if(m_pPrevInstance){
    m_pPrevInstance->m_pNextInstance=m_pNextInstance;
  }
  if(m_pNextInstance){
    m_pNextInstance->m_pPrevInstance=m_pPrevInstance;
  }
  LEAVECRITICAL;
}
예제 #28
0
파일: trap.c 프로젝트: ozaki-r/netbsd-src
/*
 * Clear traps on a fork or vfork.
 * Takes one arg vfork, to tell it to not be destructive of
 * the parents variables.
 */
void
clear_traps(int vforked)
{
	char * volatile *tp;

	VTRACE(DBG_TRAP, ("clear_traps(%d)\n", vforked));
	if (!vforked)
		traps_invalid = 1;

	for (tp = &trap[1] ; tp < &trap[NSIG] ; tp++) {
		if (*tp && **tp) {	/* trap not NULL or SIG_IGN */
			INTOFF;
			setsignal(tp - trap, vforked == 1);
			INTON;
		}
	}
	if (vforked == 2)
		free_traps();
}
예제 #29
0
bool TngPlaneManager::isValidZOrder(int dsp, ZOrderConfig& config)
{
    // check whether it's a supported z order config
    int firstRGB = -1;
    int lastRGB = -1;
    int firstOverlay = -1;
    int lastOverlay = -1;

    for (int i = 0; i < (int)config.size(); i++) {
        const ZOrderLayer *layer = config[i];
        switch (layer->planeType) {
        case DisplayPlane::PLANE_PRIMARY:
        case DisplayPlane::PLANE_SPRITE:
            if (firstRGB == -1) {
                firstRGB = i;
                lastRGB = i;
            } else {
                lastRGB = i;
            }
            break;
        case DisplayPlane::PLANE_OVERLAY:
        case DisplayPlane::PLANE_CURSOR:
            if (firstOverlay == -1) {
                firstOverlay = i;
                lastOverlay = i;
            } else {
                lastOverlay = i;
            }
            break;
        }
    }

    if ((lastRGB < firstOverlay) || (firstRGB > lastOverlay)) {
        return true;
    } else {
        VTRACE("invalid z order config. rgb (%d, %d) yuv (%d, %d)",
               firstRGB, lastRGB, firstOverlay, lastOverlay);
        return false;
    }
}
예제 #30
0
파일: VSocket.cpp 프로젝트: t3hpr1m3/vutils
/**
 *  @brief      DNS lookup function.  Converts host to IP address.
 *
 *  @param      pHost
 *                  Host name to be converted.
 *  @param      pIPaddr
 *                  Buffer to hold the converted addr.
 *  @param      pSize
 *                  Size of pcIPaddr.
 *------------------------------------------------------------------*/
bool VSocket::GetIPbyName(const char *pHost, char *pIPaddr, int pSize) {
	struct  hostent *vHostInfo;
	bool    vRetval = false;

	BEG_FUNC("GetIPbyName")("%p, %p, %d", pHost, pIPaddr, pSize);

	*pIPaddr = 0;
	vHostInfo = gethostbyname(pHost);

	if (vHostInfo) {
		struct in_addr *vAddr;
		vAddr = (struct in_addr*)vHostInfo->h_addr_list[0];
		strncpy(pIPaddr, inet_ntoa(*vAddr), pSize-1);
		VTRACE("Address (%s) resolved to (%s)\n", pHost, pIPaddr);
		vRetval = true;
	} else {
		SETERRNO();
		mError = errno;
	}

	return END_FUNC(vRetval);
}