Пример #1
0
//设置事件
bool CRequestSocket::SetEventService(IUnknownEx * pIUnknownEx)
{
	GT_ASSERT(pIUnknownEx!=NULL);
	m_pIEventService=GET_OBJECTPTR_INTERFACE(pIUnknownEx,IEventService);
	GT_ASSERT(m_pIEventService!=NULL);
	return (m_pIEventService!=NULL);
}
Пример #2
0
//开始服务
bool __cdecl CQueueService::StartService(BYTE cbThreadCount)
{
	//效验参数
	GT_ASSERT(m_bService==false);
	GT_ASSERT(m_hCompletionPort==NULL);
	GT_ASSERT(m_pIQueueServiceSink!=NULL);

	m_cbThreadCount = cbThreadCount;

	m_hCompletionPort	 = new HANDLE[m_cbThreadCount];
	memset(m_hCompletionPort, 0, sizeof(HANDLE) * m_cbThreadCount);
	m_QueueServiceThread = new CQueueServiceThread[m_cbThreadCount];

	for(BYTE i = 0; i < m_cbThreadCount; i ++)
	{
		//建立完成端口
		m_hCompletionPort[i]=CreateIoCompletionPort(INVALID_HANDLE_VALUE,NULL,NULL,1);
		if (m_hCompletionPort[i]==NULL) throw TEXT("队列对象完成端口创建失败");

		//启动线程
		if (m_QueueServiceThread[i].InitThread(m_hCompletionPort[i], i)==false) throw TEXT("队列对象线程初始化失败");
		if (m_QueueServiceThread[i].StartThead()==false) throw TEXT("队列对象线程启动失败");

	}

	//设置参数
	m_bService=true;

	return true;
}
Пример #3
0
bool __cdecl CCalculateSink::InitCalculateSink(ITableFrame	*pITableFrame,
											   CTableFrameSink *pTableFrameSink)
{
	m_pITableFrame=pITableFrame;
	if (m_pITableFrame==NULL) return false;

	m_pTableFrameSink = pTableFrameSink;
	GT_ASSERT(m_pTableFrameSink != NULL);

	//获取参数
	m_pGameServiceAttrib=m_pITableFrame->GetGameServiceAttrib();
	GT_ASSERT(m_pGameServiceAttrib!=NULL);

	m_pGameServiceOption=m_pITableFrame->GetGameServiceOption();
	GT_ASSERT(m_pGameServiceOption!=NULL);

	m_pICalculateFrame = m_pITableFrame->GetICalculateFrame();
	GT_ASSERT(m_pICalculateFrame != NULL);

	memset(&m_decAfterTax, 0, sizeof(DECIMAL));
	DECIMAL decTemp;
	memset(&decTemp, 0, sizeof(DECIMAL));
	VarDecFromI4(-1, &decTemp);
	VarDecMul(&decTemp,(DECIMAL*) &m_pGameServiceOption->decTaxRate, &m_decAfterTax);

	return true;
}
HRESULT
CaPerfDataWriter::writeFakeTimerInfo(caperf_section_fake_timer_t* pInfo)
{
    HRESULT ret = E_FAIL;

    if ((!pInfo)
        || (0 == pInfo->numCpu)
        || (0 == pInfo->timerNanosec)
        || (NULL == pInfo->timerFds)
        || (NULL == pInfo->fakeTimerFds))
    {
        return ret;
    }

    m_offset = lseek(m_fd, 0, SEEK_END);
    ssize_t sectionStOffset = m_offset;

    // Following the structure of caperf_section_fake_timer
    ssize_t rc = write(m_fd, (const void*) &pInfo->numCpu, sizeof(gtUInt32));
    GT_ASSERT(rc != -1);
    rc = write(m_fd, (const void*) &pInfo->timerNanosec, sizeof(gtUInt32));
    GT_ASSERT(rc != -1);
    rc = write(m_fd, (const void*) pInfo->timerFds, sizeof(gtUInt32) * pInfo->numCpu);
    GT_ASSERT(rc != -1);
    rc = write(m_fd, (const void*) pInfo->fakeTimerFds, sizeof(gtUInt32) * pInfo->numCpu);
    GT_ASSERT(rc != -1);

    m_offset = lseek(m_fd, 0, SEEK_CUR);

    // update the section header entry
    updateSectionHdr(CAPERF_SECTION_FAKE_TIMER_INFO, sectionStOffset, (m_offset - sectionStOffset));

    ret = S_OK;
    return ret;
}
Пример #5
0
//设置异步
bool CCenterSocket::SetAsynchronismEngine(IUnknownEx * pIUnknownEx)
{
	GT_ASSERT(pIUnknownEx!=NULL);
	m_pIAsynchronismEngine=GET_OBJECTPTR_INTERFACE(pIUnknownEx,IAsynchronismEngine);
	GT_ASSERT(m_pIAsynchronismEngine!=NULL);
	return (m_pIAsynchronismEngine!=NULL);
}
Пример #6
0
//设置队列
bool CCenterSocket::SetQueueService(IUnknownEx * pIUnknownEx)
{
	GT_ASSERT(pIUnknownEx!=NULL);
	m_pIQueueService=GET_OBJECTPTR_INTERFACE(pIUnknownEx,IQueueService);
	GT_ASSERT(m_pIQueueService!=NULL);
	return (m_pIQueueService!=NULL);
}
bool GraphicsServerCommunication::GetCurrentFrameInfo(gtASCIIString& frameInfoAsXML, unsigned char*& pImageBuffer, unsigned long& imageSize)
{
    bool retVal = true;
    OS_DEBUG_LOG_TRACER_WITH_RETVAL(retVal);

    gtASCIIString httpRtnString;
    gtASCIIString commandPrefix = m_strApiHttpCommand;
    retVal = SendCommandPid(commandPrefix.append("/PushLayer=FrameDebugger"), httpRtnString, "");
    GT_ASSERT(retVal);

    if (retVal)
    {
        commandPrefix = m_strApiHttpCommand;
        // Send a request to get the current frame info
        retVal = SendCommandPid(commandPrefix.append("/FD/GetCurrentFrameInfo.xml"), frameInfoAsXML, "");
        GT_ASSERT(retVal);

        if (retVal)
        {
            commandPrefix = m_strApiHttpCommand;
            // Send a request to get the current frame thumbnail
            retVal = SendCommandWithBinaryData(commandPrefix.append("/FD/GetFrameBufferImage.png?width=512?height=512"), pImageBuffer, imageSize);

            if (retVal)
            {
                PopLayer();
            }
        }
    }

    return retVal;
}
Пример #8
0
//设置接口
bool __cdecl CQueueService::SetQueueServiceSink(IUnknownEx * pIUnknownEx)
{
	GT_ASSERT(pIUnknownEx!=NULL);
	m_pIQueueServiceSink=GET_OBJECTPTR_INTERFACE(pIUnknownEx,IQueueServiceSink);
	GT_ASSERT(m_pIQueueServiceSink!=NULL);
	return (m_pIQueueServiceSink!=NULL);
}
Пример #9
0
//Run函数
bool CQueueServiceThread::RepetitionRun()
{
	//效验参数
	GT_ASSERT(m_hCompletionPort!=NULL);

	//变量定义
	DWORD dwThancferred=0;
	OVERLAPPED * pOverLapped=NULL;
	CQueueService * pQueueService=NULL;

	//等待完成端口
	if (GetQueuedCompletionStatus(m_hCompletionPort,&dwThancferred,(PULONG_PTR)&pQueueService,&pOverLapped,INFINITE))
	{
		//判断退出
		if (pQueueService==NULL) return false;

		//获取数据
		tagDataHead DataHead;
		bool bSuccess=pQueueService->GetData(DataHead,m_cbBuffer,sizeof(m_cbBuffer));
		GT_ASSERT(bSuccess==true);

		//处理数据
		if (bSuccess==true) pQueueService->OnQueueServiceThread(m_cbThreadIndex, DataHead,m_cbBuffer,DataHead.wDataSize);

		return true;
	}

	return false;
}
Пример #10
0
bool __cdecl CRequestSocket::OnSocketServerRequest(CMD_Command Command, void * pBuffer, WORD wDataSize)
{
	switch(Command.wSubCmdID) 
	{
	case SUB_CS_GET_LOADERSERVERINFO_SUCCESS:
		{

			GT_ASSERT(wDataSize >= sizeof(CMD_CS_LoaderServerInfo));

			CMD_CS_LoaderServerInfo *pInfo = (CMD_CS_LoaderServerInfo*)pBuffer;
			GT_ASSERT(m_pIEventService!=NULL);
			TCHAR szDescribe[128]=TEXT("");
			_snprintf(szDescribe,sizeof(szDescribe),TEXT("【服务ID %ld】请求登陆信息成功"),(LONG)m_pInitParamter->m_wServerID);
			m_pIEventService->ShowEventNotify(szDescribe,Level_Normal);

			GT_ASSERT(m_pGameServiceParameter);
			memcpy(m_pGameServiceParameter, pInfo, sizeof(CMD_CS_LoaderServerInfo));


			CXOREncrypt::CrevasseData(pInfo->GameUserDBInfo.szDataBasePipeName,m_pInitParamter->m_szGameUserDBPipeName,CountArray(m_pInitParamter->m_szGameUserDBPipeName));
			CXOREncrypt::CrevasseData(pInfo->GameUserDBInfo.szDataBaseUser,m_pInitParamter->m_szGameUserDBUser,CountArray(m_pInitParamter->m_szGameUserDBUser));
			CXOREncrypt::CrevasseData(pInfo->GameUserDBInfo.szDataBasePass,m_pInitParamter->m_szGameUserDBPass,CountArray(m_pInitParamter->m_szGameUserDBPass));
			m_pInitParamter->m_wGameUserDBPort = pInfo->GameUserDBInfo.wDataBasePort;
			struct in_addr in;
			in.S_un.S_addr	= pInfo->GameUserDBInfo.dwDataBaseAddr;
			strcpy(m_pInitParamter->m_szGameUserDBAddr,inet_ntoa(in));
			strcpy(m_pInitParamter->m_szGameUserDBName, szGameUserDB);

			CXOREncrypt::CrevasseData(pInfo->GameScoreDBInfo.szDataBasePipeName,m_pInitParamter->m_szServerInfoDBPipeName,CountArray(m_pInitParamter->m_szServerInfoDBPipeName));
			CXOREncrypt::CrevasseData(pInfo->GameScoreDBInfo.szDataBaseUser,m_pInitParamter->m_szServerInfoDBUser,CountArray(m_pInitParamter->m_szServerInfoDBUser));
			CXOREncrypt::CrevasseData(pInfo->GameScoreDBInfo.szDataBasePass,m_pInitParamter->m_szServerInfoDBPass,CountArray(m_pInitParamter->m_szServerInfoDBPass));
			m_pInitParamter->m_wServerInfoDBPort = pInfo->GameScoreDBInfo.wDataBasePort;
			in.S_un.S_addr	= pInfo->GameScoreDBInfo.dwDataBaseAddr;
			strcpy(m_pInitParamter->m_szServerInfoDBAddr,inet_ntoa(in));
			strcpy(m_pInitParamter->m_szServerInfoDBName, szGameUserDB);


			GT_ASSERT(m_pParentContainer!=NULL);
			m_pParentContainer->OnRequestInfoOk(0,0);


			return true;
		}
	case SUB_CS_GET_LOADERSERVERINFO_FAILD:
		{
			GT_ASSERT(m_pIEventService!=NULL);
			TCHAR szDescribe[128]=TEXT("");
			_snprintf(szDescribe,sizeof(szDescribe),TEXT("【服务ID %ld】启动服务失败"),(LONG)m_pInitParamter->m_wServerID);
			m_pIEventService->ShowEventNotify(szDescribe,Level_Exception);

			return true;
		}
	default:
		break;
	}
	return false;
}
Пример #11
0
//配置函数
bool CQueueServiceThread::InitThread(HANDLE hCompletionPort,BYTE cbThreadIndex)
{
	//效验参数
	GT_ASSERT(IsRuning()==false);
	GT_ASSERT(m_hCompletionPort==NULL);

	//设置变量
	m_hCompletionPort=hCompletionPort;
	memset(m_cbBuffer,0,sizeof(m_cbBuffer));
	m_cbThreadIndex = cbThreadIndex;

	return true;
}
Пример #12
0
//请求消息
HRESULT CControlWnd::OnAsynRequest(WPARAM wParam, LPARAM lParam)
{
	//效验变量
	GT_ASSERT(m_pAsynchronismEngine!=NULL);

	//获取参数
	WORD wRequestID=(WORD)wParam;
	IAsynchronismEngineSink * pIAsynchronismEngineSink=(IAsynchronismEngineSink *)lParam;

	//请求处理
	GT_ASSERT(pIAsynchronismEngineSink!=NULL);
	m_pAsynchronismEngine->OnAsynchronismRequest(wRequestID,pIAsynchronismEngineSink);

	return 0;
}
Пример #13
0
//网络连接消息
bool __cdecl CRequestSocket::OnSocketConnect(int iErrorCode, LPCTSTR pszErrorDesc, IClientSocket * pIClientSocke)
{
	GT_ASSERT(m_pIEventService!=NULL);
	TCHAR szDescribe[128]=TEXT("");
	if(iErrorCode == 0)
	{
		_snprintf(szDescribe,sizeof(szDescribe),TEXT("【服务ID %ld】中心服务器连接成功"),(LONG)m_pInitParamter->m_wServerID);
		m_pIEventService->ShowEventNotify(szDescribe,Level_Normal);
		_snprintf(szDescribe,sizeof(szDescribe),TEXT("【服务ID %ld】正在请求登陆信息"),(LONG)m_pInitParamter->m_wServerID);
		m_pIEventService->ShowEventNotify(szDescribe,Level_Normal);

		CMD_CS_GetLoaderServerInfo sendData;


		//变量定义
		TCHAR szWriteBuffer[256]=TEXT("");
		CXOREncrypt::EncryptData(m_pInitParamter->m_szLoaderServerPass,szWriteBuffer,sizeof(szWriteBuffer));
		lstrcpyn(sendData.szLoaderServerPass,szWriteBuffer,CountArray(sendData.szLoaderServerPass));
		sendData.wServerID	= m_pInitParamter->m_wServerID;

		return SendData(MDM_CS_SERVER_REQUEST, SUB_CS_GET_LOADERSERVERINFO, &sendData, sizeof(sendData));
	}
	else
	{
		_snprintf(szDescribe,sizeof(szDescribe),TEXT("【服务ID %ld】CenterServer连接失败"),(LONG)m_pInitParamter->m_wServerID);
		m_pIEventService->ShowEventNotify(szDescribe,Level_Warning);
		return false;
	}
}
Пример #14
0
// ---------------------------------------------------------------------------
// Name:        suCallsHistoryLogger::suCallsHistoryLogger
// Description: Constructor
//
// Author:      Yaki Tebeka
// Date:        5/7/2003
// ---------------------------------------------------------------------------
suCallsHistoryLogger::suCallsHistoryLogger(apContextID contextId, apMonitoredFunctionId creationFunc, unsigned int maxLoggedFunctions, const wchar_t* loggerMessagesLabelFormat, bool threadSafeLogging)
    : _contextId(contextId),
      m_contextCreationFunc(creationFunc),
      _isLoggingEnabled(true),
      _threadSafeLogging(threadSafeLogging),
      _loggingCSEntered(false),
      _maxLoggedFunctions(maxLoggedFunctions),
      _isHTMLLogFileActive(false),
      _rawMemoryLogger(INITIALE_SIZE_OF_RAW_MEMORY, threadSafeLogging),
      _lastCalledFunctionId(apMonitoredFunctionsAmount),
      _isInOpenGLBeginEndBlock(false),
      _allocationFailureOccur(false),
      _transferableObjTypeToParameter(NULL)
{
    // Initialize the logger messages label:
    _loggerMessagesLabel.appendFormattedString(loggerMessagesLabelFormat, contextId._contextId);

    // Initialize the _transferableObjTypeToParameter vector:
    bool rc = initializeTransferableObjectTypeVec();
    GT_ASSERT(rc);

    // Register me to receive _rawMemoryLogger memory allocation failures notifications:
    _rawMemoryLogger.registerAllocationFailureObserver(this);

    // Initialize the log file creation time to the current time:
    _logCreationTime.setFromCurrentTime();
}
// ---------------------------------------------------------------------------
// Name:        osMessageBox::iconToOSStyle
// Description: Translated osMessageBoxIcon to OS message box style mask.
// Arguments:   icon - The input icon.
// Return Val:  unsigned int - The output OS style mask.
// Author:      AMD Developer Tools Team
// Date:        6/10/2004
// ---------------------------------------------------------------------------
unsigned int oaMessageBoxIconToOSStyle(osMessageBox::osMessageBoxIcon icon)
{
    // Translate from osDefaultOSIconType to Win32 message box styles:
    unsigned int retVal = 0;

    switch (icon)
    {
    case osMessageBox::OS_EXCLAMATION_POINT_ICON:
        retVal = MB_ICONEXCLAMATION;
        break;

    case osMessageBox::OS_DISPLAYED_INFO_ICON:
        retVal = MB_ICONINFORMATION;
        break;

    case osMessageBox::OS_QUESTION_MARK_ICON:
        retVal = MB_ICONQUESTION;
        break;

    case osMessageBox::OS_STOP_SIGN_ICON:
        retVal = MB_ICONSTOP;
        break;

    default:
        // Unknown icon type:
        GT_ASSERT(false);
    }

    return retVal;
}
// ---------------------------------------------------------------------------
// Name:        bool osFilePathByLastModifiedDateCompareFunctor::operator ()(const osFilePath& file1, const osFilePath& file2)
// Description: Compares files by the last modification date
// Arguments:
//              file1, file2 - the two filePaths to compare
//Return Value:
//              Returns true iff the last access date of file1 is more recent than that of file2
// Author:      AMD Developer Tools Team
// Date:        2007/12/24
// ---------------------------------------------------------------------------
bool osFilePathByLastModifiedDateCompareFunctor::operator()(const osFilePath& file1, const osFilePath& file2)
{
    // The struct that hold the files information
    osStatStructure file1Properties, file2Properties;

    // Get the filenames
    gtString file1Name = file1.asString();
    gtString file2Name = file2.asString();

    // Get the files status
    int rc1 = osWStat(file1Name, file1Properties);
    int rc2 = osWStat(file2Name, file2Properties);

    GT_ASSERT(rc1 == 0 && rc2 == 0);

    // Extract the last modified date from the properties struct
    // lastModifiedFile1Time and lastModifiedFile2Time hold the number of seconds that passed since
    // January 1, 1970 until the last modification moment.
    // Notice: Do not use access time, since on Vista, access time is hardly ever changed.
    time_t lastModifiedFile1Time = file1Properties.st_mtime;
    time_t lastModifiedFile2Time = file2Properties.st_mtime;

    // If the number of seconds since January 1st, 1970 to the last access moment is bigger,
    // then the last access date is newer
    return (lastModifiedFile1Time > lastModifiedFile2Time);
}
// ---------------------------------------------------------------------------
// Name:        osNULLSocket::read
// Description: Fails and generates an assertion failure.
// Author:      AMD Developer Tools Team
// Date:        25/8/2005
// ---------------------------------------------------------------------------
bool osNULLSocket::read(gtByte* pDataBuffer, gtSize_t dataSize)
{
    (void)(pDataBuffer); // unused
    (void)(dataSize); // unused
    GT_ASSERT(false);
    return false;
}
gpTraceSummaryTable::gpTraceSummaryTable(gpTraceDataContainer* pDataContainer, gpTraceView* pSessionView, eCallType callType)
    : acListCtrl(nullptr), m_callType(callType), m_pSessionDataContainer(pDataContainer), m_pTraceView(pSessionView), m_lastSelectedRowIndex(-1)
{
    QStringList columnCaptions;
    columnCaptions << GP_STR_SummaryTableColumnCall;
    columnCaptions << GP_STR_SummaryTableColumnMaxTime;
    columnCaptions << GP_STR_SummaryTableColumnMinTime;
    columnCaptions << GP_STR_SummaryTableColumnAvgTime;
    columnCaptions << GP_STR_SummaryTableColumnCumulativeTime;
    columnCaptions << GP_STR_SummaryTableColumnPercentageOfTotalTime;
    columnCaptions << GP_STR_SummaryTableColumnNumberOfCalls;
    initHeaders(columnCaptions, false);
    setShowGrid(true);

    m_logic.Init(m_callType, m_pSessionDataContainer, pSessionView);

    // fill Table widget
    FillTable();
    setSortingEnabled(true);
    setSelectionMode(QAbstractItemView::SingleSelection);
    setContextMenuPolicy(Qt::NoContextMenu);

    // Connect to the cell entered signal
    setMouseTracking(true);
    bool rc = connect(this, SIGNAL(cellEntered(int, int)), this, SLOT(OnCellEntered(int, int)));
    GT_ASSERT(rc);
}
Пример #19
0
HRESULT CaPerfDataWriter::writeSampleEventsInfo()
{
    size_t numEntries = 0;

    if (! m_sampleIdList.size())
    {
        return E_FAIL;
    }

    m_offset = lseek(m_fd, 0, SEEK_END);

    SampleInfoList::iterator iter = m_sampleIdList.begin();

    for (; iter != m_sampleIdList.end(); iter++)
    {
        caperf_section_sample_id_t  sinfo = *iter;

        ssize_t rc = write(m_fd, (const void*)&sinfo, sizeof(caperf_section_sample_id_t));
        GT_ASSERT(rc != -1);
        numEntries++;
    }

    // update the section header entry for CAPERF_SECTION_EVENT_ID
    updateSectionHdr(CAPERF_SECTION_EVENT_ID,
                     m_offset,
                     numEntries * sizeof(caperf_section_sample_id_t));

    m_offset = lseek(m_fd, 0, SEEK_CUR);

    return S_OK;
}
Пример #20
0
HRESULT CaPerfDataWriter::writeSampleEvent(CaPerfEvent& event)
{
    caperf_section_evtcfg  evtCfg;
    const PerfEventDataList* eventDataList = event.getEventDataList();
    caperf_section_sample_id_t  sinfo;

    evtCfg.event_config   = event.getAttribute();
    evtCfg.start_idx      = m_sampleIdList.size();
    evtCfg.number_entries = eventDataList->size();

    // TODO: Set the name of the event
    memset(evtCfg.name, 0, sizeof(evtCfg.name));

    ssize_t rc = write(m_fd, (const void*)&evtCfg, sizeof(evtCfg));
    GT_ASSERT(rc != -1);

    // save the sample-id/cpu-id stuff in m_sampleIdList;
    OS_OUTPUT_FORMAT_DEBUG_LOG(OS_DEBUG_LOG_DEBUG, L"writeSampleEvent - eventDataList size(%d)", eventDataList->size());

    PerfEventDataList::const_iterator iter = eventDataList->begin();

    for (; iter != eventDataList->end(); iter++)
    {
        sinfo.sample_id = iter->m_sampleId;
        sinfo.cpuid = iter->m_cpu;
        sinfo.misc = 0;

        OS_OUTPUT_FORMAT_DEBUG_LOG(OS_DEBUG_LOG_EXTENSIVE, L"sinfo- smaple_id(0x%lx), cpuid(%d)", sinfo.sample_id, sinfo.cpuid);

        m_sampleIdList.push_back(sinfo);
    }

    return S_OK;
}
Пример #21
0
gtString SessionActions::menuPosition(int actionIndex, afActionPositionData& positionData)
{
    gtString retVal;

    positionData.m_actionSeparatorType = afActionPositionData::AF_SEPARATOR_NONE;

    // Get the command id:
    int commandId = actionIndexToCommandId(actionIndex);

    switch (commandId)
    {
        case ID_COPY:
        case ID_FIND_NEXT:
            retVal = AF_STR_EditMenuString;
            break;

        case ID_FIND:
        case ID_SELECT_ALL:
            positionData.m_actionSeparatorType = afActionPositionData::AF_SEPARATOR_BEFORE_COMMAND;
            retVal = AF_STR_EditMenuString;
            break;

        default:
            GT_ASSERT(false);
            break;
    };

    return retVal;
}
Пример #22
0
HRESULT CaPerfDataWriter::writeDynamicPmuTypes()
{
    uint32_t type = 0;
    int ret = E_FAIL;
    char buffer[BUFSIZ] = { '\0' };

    caperf_section_pmu_types_t  pmuTypes;
    memset((void*)&pmuTypes, 0, sizeof(caperf_section_pmu_types_t));

    // Get the dynamic pmu type for IBS fetch
    strncpy(buffer, "/sys/devices/ibs_fetch/type", BUFSIZ - 1);
    ret = getDynamicPmuType(buffer, type);
    pmuTypes.ibs_fetch = (S_OK == ret) ? type : 6;

    // Get the dynamic pmu type for IBS fetch
    strncpy(buffer, "/sys/devices/ibs_op/type", BUFSIZ - 1);
    ret = getDynamicPmuType(buffer, type);
    pmuTypes.ibs_op = (S_OK == ret) ? type : 7;

    m_offset = lseek(m_fd, 0, SEEK_END);
    ssize_t sectionStOffset = m_offset;

    ssize_t rc = write(m_fd, (const void*)&pmuTypes, sizeof(pmuTypes));
    GT_ASSERT(rc != -1);

    m_offset = lseek(m_fd, 0, SEEK_CUR);

    // update the section header entry for CAPERF_SECTION_DYNAMIC_PMU_TYPES
    updateSectionHdr(CAPERF_SECTION_DYNAMIC_PMU_TYPES,
                     sectionStOffset,
                     (m_offset - sectionStOffset));

    return S_OK;
}
Пример #23
0
HRESULT CaPerfDataWriter::updateSectionHdr(caperf_section_type_t section, gtUInt64 startOffset, gtUInt64 size)
{
    struct caperf_section_hdr hdr;
    memset((void*)&hdr, 0, sizeof(caperf_section_hdr));

    int ret = S_OK;
    gtUInt32 idx = getIdx(section);

    if (CAPERF_MAX_SECTIONS > idx)
    {
        lseek(m_fd, m_sectionHdrOffsets[idx], SEEK_SET);
        ssize_t rc = read(m_fd, &hdr, sizeof(hdr));
        GT_ASSERT(rc != -1);

        hdr.offset = startOffset;
        hdr.size = size;

        lseek(m_fd, m_sectionHdrOffsets[idx], SEEK_SET);

        ssize_t ret = write(m_fd, (const void*)&hdr, sizeof(hdr));

        if (ret != sizeof(hdr))
        {
            OS_OUTPUT_DEBUG_LOG(L"Error while updating section header", OS_DEBUG_LOG_ERROR);
            ret = E_FAIL;
        }
    }

    return ret;
}
Пример #24
0
HRESULT CaPerfDataWriter::writeTargetPids(gtUInt32 numPids, pid_t* pPids)
{
    HRESULT ret = E_FAIL;

    if (!pPids || 0 == numPids)
    {
        return ret;
    }

    m_offset = lseek(m_fd, 0, SEEK_END);
    ssize_t sectionStOffset = m_offset;

    ssize_t rc = write(m_fd, (const void*)pPids, sizeof(pid_t) * numPids);
    GT_ASSERT(rc != -1);

    m_offset = lseek(m_fd, 0, SEEK_CUR);

    // update the section header entry for CAPERF_SECTION_TARGET_PIDS
    updateSectionHdr(CAPERF_SECTION_TARGET_PIDS,
                     sectionStOffset,
                     (m_offset - sectionStOffset));

    ret = S_OK;
    return ret;
}
Пример #25
0
HRESULT CaPerfDataWriter::writeCpuInfo()
{
    caperf_section_cpuinfo_t  cpuinfo;
    memset((void*)&cpuinfo, 0, sizeof(caperf_section_cpuinfo_t));

    gtUInt32  fn = 1;
    gtUInt32  eax, ebx, ecx, edx;

    getCpuId(fn, &eax, &ebx, &ecx, &edx);

    cpuinfo.function = fn;
    cpuinfo.value[0] = eax;
    cpuinfo.value[1] = ebx;
    cpuinfo.value[2] = ecx;
    cpuinfo.value[3] = edx;

    m_offset = lseek(m_fd, 0, SEEK_END);
    ssize_t sectionStOffset = m_offset;

    ssize_t rc = write(m_fd, (const void*)&cpuinfo, sizeof(cpuinfo));
    GT_ASSERT(rc != -1);

    // TODO: add L1 data cache identifier; CPUID Fn 8000_00005 for CLU ?

    m_offset = lseek(m_fd, 0, SEEK_CUR);

    // update the section header entry for CAPERF_SECTION_CPU_INFO
    updateSectionHdr(CAPERF_SECTION_CPU_INFO,
                     sectionStOffset,
                     (m_offset - sectionStOffset));

    return S_OK;
}
Пример #26
0
//放弃事件
bool CTableFrameSink::OnUserGiveUp(WORD wChairID)
{
	//状态判断
	GT_ASSERT(m_bPlayStatus[wChairID]==TRUE);
	if (m_bPlayStatus[wChairID]==FALSE) return false;

	//设置数据
	m_bPlayStatus[wChairID]=FALSE;
	//m_bTableCardCount[wChairID]=0;

	//发送放弃消息
	CMD_S_GiveUp GiveUp;
	GiveUp.wUserChairID=wChairID;
	m_pITableFrame->SendTableData(INVALID_CHAIR,SUB_S_GIVE_UP,&GiveUp,sizeof(GiveUp));
	m_pITableFrame->SendLookonData(INVALID_CHAIR,SUB_S_GIVE_UP,&GiveUp,sizeof(GiveUp));


	//判断结束
	WORD wPlayerCount=0;
	for (WORD i=0;i<m_wPlayerCount;i++)
	{
		if (m_bPlayStatus[i]==TRUE) wPlayerCount++;
	}
	if (wPlayerCount>=2)
	{
		if (m_wCurrentUser==wChairID) OnUserAddGold(wChairID,0L,true);
	}
	else OnEventGameEnd(INVALID_CHAIR,NULL,GER_NO_PLAYER);

	return true;
}
Пример #27
0
//初始化计算上下文
bool __cdecl CCalculateSink::InitCalculateContext(CMD_S_GameEnd* pGameEnd)
{
	GT_ASSERT(pGameEnd != NULL);
	m_pGameEnd = pGameEnd;

	return true;
}
// ---------------------------------------------------------------------------
// Name:        osSharedMemorySocket::write
// Description: Writes a block of data into the shared memory socket.
// Arguments:   pDataBuffer - A pointer to a buffer that contains the
//                            data to be written.
//              dataSize - The data size.
// Return Val:  bool - Success / failure.
// Author:      AMD Developer Tools Team
// Date:        17/8/2005
// Implementation notes:
//   The data buffer is cyclic, therefore, we write the data in 2 chunks:
//   - All data that fits until we reach the end of the buffer.
//   - All the remaining data (if any) will be written from the buffer begin point.
// ---------------------------------------------------------------------------
bool osSharedMemorySocket::write(const gtByte* pDataBuffer, unsigned long dataSize)
{
    bool retVal = false;

    // Verify that the socket is open:
    if (isOpen())
    {
        // Wait for enough space to be available in my outgoing data:
        bool hasEnoughSpaceToWriteData = waitForAvailableSpaceToWriteData(dataSize, _writeOperationTimeOut);

        // If after waiting the time interval, we still don't have enough space available:
        if (!hasEnoughSpaceToWriteData)
        {
            // Do not write the data and trigger an assertion:
            GT_ASSERT(0);
        }
        else
        {
            // Lock / wait for my outgoing buffer resources:
            lockBufferResources(_pMyOutgoingBuffLocked);

            // Update the outgoing buffer free space:
            *_pMyOutgoingDataBuffFreeSpace -= dataSize;

            // Calculate the first and second chunk sizes (see "implementation notes" above):
            int firstChunkSize = min(int(dataSize), (_communicationBufferSize - *_pMyWritePos));
            int secondChunkSize = dataSize - firstChunkSize;

            // Copy the first data chunk:
            void* pWriteLocation = _pMyOutgoingDataBuff + *_pMyWritePos;
            memcpy(pWriteLocation, pDataBuffer, firstChunkSize);

            // If we need a second chunk:
            if (secondChunkSize > 0)
            {
                // Copy the second data chunk (from the beginning of our outgoing buffer):
                memcpy(_pMyOutgoingDataBuff, (pDataBuffer + firstChunkSize), secondChunkSize);
                *_pMyWritePos = secondChunkSize;
            }
            else
            {
                *_pMyWritePos += dataSize;
            }

            // If my next write position passed the end of the buffer:
            if (_communicationBufferSize <= *_pMyWritePos)
            {
                *_pMyWritePos = 0;
            }

            // Release my outgoing buffer resources:
            unlockBufferResources(_pMyOutgoingBuffLocked);

            retVal = true;
        }
    }

    return retVal;
}
Пример #29
0
//设置事件
bool CCenterService::SetEventService(IUnknownEx * pIEventService)
{
	//获取接口
	GT_ASSERT(pIEventService!=NULL);
	m_pIEventService=(IEventService *)pIEventService->QueryInterface(IID_IEventService,VER_IEventService);
	GT_ASSERT(m_pIEventService!=NULL);

	//设置接口
	m_DataBaseSink.SetEventService(pIEventService);
	m_AttemperSink.SetEventService(pIEventService);
	if (m_ServiceEngine.IsValid()) 
	{
		m_ServiceEngine->SetEventService(pIEventService);
	}

	return (m_pIEventService!=NULL);
}
Пример #30
0
//数据消息
void CQueueService::OnQueueServiceThread(BYTE cbThreadIndex, const tagDataHead & DataHead, void * pBuffer, WORD wDataSize)
{
	GT_ASSERT(m_pIQueueServiceSink!=NULL);
	_BEGIN_TRY	
	{ 
		m_pIQueueServiceSink->OnQueueServiceSink(cbThreadIndex,DataHead.wIdentifier,pBuffer,DataHead.wDataSize,DataHead.dwInsertTime); 
	}
	CATCH_COMMON_EXCEPTION(;)