コード例 #1
0
ファイル: FfController.cpp プロジェクト: JoeAltmaier/Odyssey
void FF_Controller::Mark_Unit_Not_Busy(Flash_Address flash_address)
{
 	// Check to see if the unit_index is busy.
	// For the HBC, only one device can be accessed at one time.
	U32 unit_index = flash_address.Unit_Index();
	CT_ASSERT(unit_index < Flash_Address::Num_Units(), FF_Controller::Mark_Unit_Not_Busy);

	CT_ASSERT(FF_Controller::m_p_controller_context[unit_index], 
		FF_Controller::Mark_Unit_Not_Busy);
	
	// Set callback context for this unit_index to null because it is
	// no longer busy.
	m_p_controller_context[unit_index] = 0;
		
	if (m_can_units_overlap)
	{
		// See if another context is waiting for this unit_index.
		if (!LIST_IS_EMPTY(&m_context_list_wait_unit[unit_index]))
		{
			m_p_flash->m_stats.Dec_Num_Waits_Unit(unit_index);

			FF_Controller_Context *p_controller_context;
			p_controller_context = (FF_Controller_Context *)LIST_REMOVE_HEAD(
				&m_context_list_wait_unit[unit_index]);
			
 			TRACEF(TRACE_L5, 
				(EOL "Mark_Unit_Not_Busy Making context ready for unit_index = %d", 
				p_controller_context->m_flash_address.Unit_Index()));
 		
			// Queue context back on ready list for execution.
			p_controller_context->Make_Ready();
		}
	} // m_can_units_overlap

	else
	{
		// See if another context is waiting for any unit.
		U32 num_units = Flash_Address::Num_Units();
		for (U32 any_unit_index = 0; any_unit_index < num_units; any_unit_index++)
		{
			if (!LIST_IS_EMPTY(&m_context_list_wait_unit[any_unit_index]))
			{
				m_p_flash->m_stats.Dec_Num_Waits_Unit(any_unit_index);

				FF_Controller_Context *p_controller_context;
				p_controller_context = (FF_Controller_Context *)LIST_REMOVE_HEAD(
					&m_context_list_wait_unit[any_unit_index]);
				
 				TRACEF(TRACE_L5, 
					(EOL "Mark_Unit_Not_Busy Making context ready for unit_index = %d", 
					p_controller_context->m_flash_address.Unit_Index()));
 			
				// Queue context back on ready list for execution.
				p_controller_context->Make_Ready();
				return;
			}
		}
	} // NOT m_can_units_overlap
		
} // FF_Controller::Mark_Unit_Not_Busy
コード例 #2
0
ファイル: base1.c プロジェクト: matthewjmiller1/C-OO-Examples
/**
 * Fill in the child vtable with values inherited from the parent_vtable for all
 * functions left NULL in the child vtable.
 *
 * @param parent_vtable The parent vtable from which to inherit.
 * @param child_vtable The child vtable to which functions may be inherited.
 * @param do_null_check Indicates whether an error should be thrown if a
 * function in the child vtable is NULL after inheritance.
 */
my_rc_e
base1_inherit_vtable (const base1_vtable_st *parent_vtable,
                      base1_vtable_st *child_vtable,
                      bool do_null_check)
{
    my_rc_e rc = MY_RC_E_SUCCESS;

    /* Always add a new check here if functions are added. */
    CT_ASSERT(5 == (sizeof(base1_vtable_st)/sizeof(void*)));

    if ((NULL == parent_vtable) || (NULL == child_vtable)) {
        LOG_ERR("Invalid input, parent_vtable(%p) "
                "child_vtable(%p)", parent_vtable, child_vtable);
        return (MY_RC_E_EINVAL);
    }

    INHERIT_VTABLE_FN(parent_vtable, child_vtable, delete_fn, do_null_check,
                      rc);
    INHERIT_VTABLE_FN(parent_vtable, child_vtable, type_string_fn,
                      do_null_check, rc);
    INHERIT_VTABLE_FN(parent_vtable, child_vtable, string_fn, do_null_check,
                      rc);
    INHERIT_VTABLE_FN(parent_vtable, child_vtable, string_size_fn,
                      do_null_check, rc);
    INHERIT_VTABLE_FN(parent_vtable, child_vtable, increase_val3_fn,
                      do_null_check, rc);

    return (MY_RC_E_SUCCESS);

err_exit:

    return (rc);
}
コード例 #3
0
ファイル: SsdRequest.cpp プロジェクト: JoeAltmaier/Odyssey
void SSD_Ddm::Decrement_Requests_Outstanding()
{
	// Decrement the number of requests outstanding.
	CT_ASSERT(m_num_requests_outstanding, Respond_To_BSA_Request);
	m_num_requests_outstanding--;
	
	TRACEF(TRACE_L5, ("\nDecrement_Requests_Outstanding: requests outstanding = %d after decrement", 
		m_num_requests_outstanding));

	// Are there any requests outstanding?
	if (m_num_requests_outstanding == 0)
	{
		// Are we waiting to process a format request?
		if (m_p_format_message)
		{
			SSD_Ddm::Process_Format_Request(m_p_format_message);
			return;
		}

		// Are we waiting to process a quiesce request?
		if (m_p_quiesce_message)
		{
			Quiesce(m_p_quiesce_message);
			return;
		}
	}

} // Decrement_Requests_Outstanding
コード例 #4
0
ファイル: CmFlush.cpp プロジェクト: JoeAltmaier/Odyssey
Status CM_Frame_Table::Flush_Cache(Callback_Context *p_callback_context,
	CM_CACHE_HANDLE cache_handle, int destroy)
{
	TRACE_ENTRY(CM_Frame_Table::Flush_Cache);

	// Allocate a child context of the caller's context.
	// When our child context terminates, the parent
	// context will be scheduled to run.
	CT_ASSERT((sizeof(CM_Cache_Context) <= Callback_Context::Get_Max_Context_Size()), 
		CM_Frame_Table::Flush_Cache);
	CM_Cache_Context *p_child_context = 
		(CM_Cache_Context *)p_callback_context->Allocate_Child(sizeof(CM_Cache_Context));
	if (p_child_context == 0)
		return CM_NO_MEMORY;

	// Save parameters in context.
	p_child_context->m_p_frame_table = this;
	p_child_context->m_cache_handle = cache_handle;
	p_child_context->m_destroy = destroy;

	// Start the flush operation
	p_child_context->Set_Callback(&Flush_Next);
	p_callback_context->Make_Children_Ready();

	// Return to caller.
	return OK;

} // CM_Frame_Table::Flush_Cache
コード例 #5
0
ファイル: CmValidate.cpp プロジェクト: JoeAltmaier/Odyssey
void CM_Frame_Table::Validate_Frames()
{
	CM_Frame	*p_frame;
	CM_Frame	*p_frame1;
	I64			 page_number;

	// Look at every frame
	U32 index;
	U32 index1;
	for (index = 0; index < m_num_page_frames; index++)
	{
		p_frame = m_p_frame_array + index;

		page_number = p_frame->Get_Page_Number();
		if (page_number != -1)
		{

			// Make sure no other frame has the same address
			for (index1 = 0; index1 < m_num_page_frames; index1++)
			{
				if (index != index1)
				{
					p_frame1 = m_p_frame_array + index1;
					CT_ASSERT((p_frame->Get_Page_Number() != 
						p_frame1->Get_Page_Number()), Validate_Frames);
				}
			}
		}
	}

} // Validate_Frames
コード例 #6
0
ファイル: core.hpp プロジェクト: B-sound/rethinkdb
 perfmon_multi_membership_t(perfmon_collection_t *collection,
                            // This block of (perfmon_t *perfmon, const char
                            // *name, ) is to be repeated as many times as needed.
                            Args... args) {
     CT_ASSERT(check_perfmon_multi_membership_args_t<Args...>::value);
     init(collection, sizeof...(Args) / 2, args...);
 }
コード例 #7
0
ファイル: CmValidate.cpp プロジェクト: JoeAltmaier/Odyssey
void CM_Frame_Table::Validate_Dirty_Clock()
{
	if (m_num_pages_dirty_clock == 0)
		return;

	// Count the number of frames in the clock.
	U32 num_pages_clock = 0;

	// Point to the first frame in the clock.
	CM_Frame *p_first_frame = m_p_dirty_clock_frame;

	// Point to the first frame to test.
	CM_Frame *p_frame = m_p_dirty_clock_frame;

	while(true)

	{
		if (!p_frame->Is_Dummy_Frame())
			num_pages_clock++;

		// Point to the next frame in the list each time around
		p_frame = (CM_Frame *)p_frame->m_list.forward_link;

		// Are we back at the beginning?
		if (p_frame == p_first_frame)
		{
			CT_ASSERT((num_pages_clock == m_num_pages_dirty_clock), Validate_Dirty_Clock);
			return;
		}
	}


} // Validate_Dirty_Clock
コード例 #8
0
ファイル: nv_event.cpp プロジェクト: morsya/omim
const char* NVEventGetEventStr(NVEventType eventType)
{
  switch(eventType)
  {
    case NV_EVENT_KEY:              return "NV_EVENT_KEY";
    case NV_EVENT_CHAR:             return "NV_EVENT_CHAR";
    case NV_EVENT_TOUCH:            return "NV_EVENT_TOUCH";
    case NV_EVENT_MULTITOUCH:       return "NV_EVENT_MULTITOUCH";
    case NV_EVENT_ACCEL:            return "NV_EVENT_ACCEL";
    case NV_EVENT_START:            return "NV_EVENT_START";
    case NV_EVENT_RESTART:          return "NV_EVENT_RESTART";
    case NV_EVENT_RESUME:           return "NV_EVENT_RESUME";
    case NV_EVENT_FOCUS_GAINED:     return "NV_EVENT_FOCUS_GAINED";
    case NV_EVENT_SURFACE_CREATED:   return "NV_EVENT_SURFACE_CREATED";
    case NV_EVENT_SURFACE_SIZE:      return "NV_EVENT_SURFACE_SIZE";
    case NV_EVENT_SURFACE_DESTROYED: return "NV_EVENT_SURFACE_DESTROYED";
    case NV_EVENT_FOCUS_LOST:       return "NV_EVENT_FOCUS_LOST";
    case NV_EVENT_PAUSE:            return "NV_EVENT_PAUSE";
    case NV_EVENT_STOP:             return "NV_EVENT_STOP";
    case NV_EVENT_QUIT:             return "NV_EVENT_QUIT";
    case NV_EVENT_USER:             return "NV_EVENT_USER";
    case NV_EVENT_LONG_CLICK:       return "NV_EVENT_LONG_CLICK";
    case NV_EVENT_MWM:              return "NV_EVENT_MWM";
  }

  // update this if you end up having to edit something.
  CT_ASSERT(NEED_TO_ADD_STRING_HERE, NV_EVENT_NUM_EVENTS == 19);
  return "unknown event type!";
}
コード例 #9
0
static inline uint32 * GetToneWritingBaseAddr_Core( uint32 chid, uint32 sid,
		uint32 ToneBuf[][TONE_FIFO_SIZE*RX_BUF_SIZE/4*MAX_BAND_FACTOR],
		uint32 tone_r[], uint32 tone_w[],
		uint32 tone_sid[] )
{
	CT_ASSERT( RX_BUF_SIZE == TX_BUF_SIZE );	// make sure the two are the same 
	
	uint32 next_wi;
	
	if( tone_w[ chid ] == tone_r[ chid ] )
		tone_sid[ chid ] = sid;	/* fifo is empty, so accept this sid */
	else if( tone_sid[ chid ] == sid )
		;	/* fifo is not empty, so accept identical sid only */
	else {
		printk( "tone sid=%d,%d\n", tone_sid[ chid ], sid );	/* fifo is full, or sid not match */
		return NULL;
	}
	
	next_wi = ( tone_w[ chid ] + 1 ) % TONE_FIFO_SIZE;
	
	if( next_wi == tone_r[ chid ] ) {
		printk( "tF(%d) ", chid );
		return NULL;
	}
	
	return &ToneBuf[ chid ][tone_w[ chid ] * RX_BUF_SIZE/4 * MAX_BAND_FACTOR ];
}
コード例 #10
0
void test_b5(Functor&& f) {
    NonCopyable arg;

    // Run invoke and check the return value.
    auto ret = ct::can_invoke(std::forward<Functor>(f), std::move(arg));
    //assert(ret == 42);
    CT_ASSERT(decltype(ret){});
}
コード例 #11
0
ファイル: CmValidate.cpp プロジェクト: JoeAltmaier/Odyssey
void CM_Frame_Table::Validate_Clock()
{
	if (m_num_pages_clock == 0)
		return;

	// Count the number of frames in the clock.
	U32 num_pages_clock = 0;

	// Count the number of replaceable frames in the clock.
	U32 num_pages_replaceable = 0;

	// Point to the first frame in the clock.
	CM_Frame *p_first_frame = m_p_clock_frame;

	// Point to the first frame to test.
	CM_Frame *p_frame = m_p_clock_frame;

	while(true)

	{
		// If we are pointing to the head of the list
		if (!p_frame->Is_Dummy_Frame())
		{
			num_pages_clock++;

			// If this frame is locked, we can't replace it.
			if (!p_frame->Is_Page_Locked())
				num_pages_replaceable++;

		} // NOT dummy frame

		// Point to the next frame in the list each time around
		p_frame = (CM_Frame *)p_frame->m_list.forward_link;

		// Are we back at the beginning?
		if (p_frame == p_first_frame)
		{
			CT_ASSERT((num_pages_clock == m_num_pages_clock), Validate_Clock);
			CT_ASSERT((num_pages_replaceable == m_num_pages_replaceable), Validate_Clock);
			return;
		}
	}


} // Validate_Clock
コード例 #12
0
int main() {

    {
        using f = sig<N<0>, N<1>, N<2>, N<3>, N<4>>;
        using test = ct::push_back_args_t<f, int&, char*>;
        using expect = sig<N<0>, N<1>, N<2>, N<3>, N<4>, int&, char*>;
        CT_ASSERT(std::is_same<test, expect>::value);
    }
}
コード例 #13
0
void Set_Bad_Block(Flash_Address flash_address, U32 offset)
{
	// Get array number for the next byte.
	U32 array = flash_address.Array();

	U32 column = flash_address.Column();

	U32 unit = flash_address.Unit_Index();

	// Get the device index for the next byte.
	// a concatenation of bank and device number.
	// C C C C C C C C C b b D D D
	U32 device_index = Flash_Address::Device_Index_From_Offset(offset);

	// Get the offset in the device page for the next byte.
	U32 device_column = Flash_Address::Device_Column_From_Offset(offset);

	// Get the page address for the next byte.
	U32 page_address = flash_address.Page_Index();

	// Calculate the byte address in simulated memory for the
	// next dest byte.
	char *p_destination;
	U32 column_offset = (U32)(column * Flash_Address::Bytes_Per_Column() );
	U32 device_offset = device_index * Flash_Address::Bytes_Per_Device_Page();
	U32 page_offset = page_address * Flash_Address::Bytes_Per_Page();
	U32 array_offset = array * (U32)Flash_Address::Bytes_Per_Array();

			p_destination = p_mem_file 
				+ column_offset
				+ device_offset
				+ page_offset
				+ array_offset
				+ device_column;

	// Make sure we don't write past the end of memory buffer.
	CT_ASSERT((p_destination <= p_mem_file_last), Set_Bad_Block);

	U32 num_bytes = Flash_Address::Bytes_Per_Device_Page();

	U32 num_devices = Flash_Address::Device_Pages_Per_Page();
	char *p_device_byte;

#if 0
	for (U32 index = 0; index < num_bytes; index++)
	{
		p_device_byte = p_destination + index * num_devices;

		// Store the next byte in the destination.
		*(p_device_byte) = 0;
	}
#else
	*p_destination = 0;
#endif

} // Set_Bad_Block
コード例 #14
0
void test_b34(Functor&& f) {
    // Create the callable object.
    typedef int TestClass::*ClassFunc;
    ClassFunc func_ptr = &TestClass::data;

    // Run invoke and check the return value.
    auto ret =
        ct::can_invoke(func_ptr, std::forward<Functor>(f));
    //assert(ret == 42);
    CT_ASSERT(decltype(ret){});
}
コード例 #15
0
ファイル: SsdQuiesce.cpp プロジェクト: JoeAltmaier/Odyssey
void SSD_Ddm::Process_Quiesce(void *p_context, Status status)
{
	TRACE_ENTRY(SSD_Ddm::Process_Quiesce);

	SSD_Request_Context *p_request_context = (SSD_Request_Context *)p_context;

	SSD_Ddm *p_ddm = p_request_context->m_p_ddm;

	CT_ASSERT((p_ddm->m_num_requests_outstanding == 0), SSD_Ddm::Process_Quiesce);
	CT_ASSERT(p_ddm->m_p_quiesce_message, SSD_Ddm::Process_Quiesce);

	if (status == OK)
		Tracef(EOL "Flash file system quiesced.");
	else
		Tracef(EOL "Flash file system quiesce failed, status = %d.", status);

	// Free all the memory that we allocated.
	delete (p_ddm->m_p_callback_context_memory);
	p_ddm->m_p_callback_context_memory = 0;
	
	delete (p_ddm->m_p_flash_file_system_memory);
	p_ddm->m_p_flash_file_system_memory = 0;

	// Did this quiesce message come from a reset?
	if (p_ddm->m_p_quiesce_message!= p_ddm->m_p_reset_message)

		// Let Chaos know we are quiesced.
		p_ddm->Reply(p_ddm->m_p_quiesce_message);
	else
	{
		// Reset the hardware
		WARM_RESET_REGISTER = 1;

		// Never returns!
	}

	// Zero pointer to quiesce message.
	// This was our mark on the wall to indicate we were processing a quiesce.
	p_ddm->m_p_quiesce_message = 0;

} // SSD_Ddm::Process_Quiesce
コード例 #16
0
void Device_Timer_Expiration_Routine(U32 id)
{
	CT_ASSERT(id < FF_NUM_UNITS_MAX, Device_Timer_Expiration_Routine);
	
	Callback_Context *p_callback_context = timer_context[id];
	if (p_callback_context == 0)
		return;
	timer_context[id] = 0;
	
	p_callback_context->Make_Ready();
	
} // Device_Timer_Expiration_Routine
コード例 #17
0
ファイル: CmValidate.cpp プロジェクト: JoeAltmaier/Odyssey
void CM_Cache::Validate()
{
	// Only validate if simulating -- too time-consuming otherwise.
#ifdef SIM
	m_p_frame_table->Validate();

	if (m_p_frame_table_2)
		m_p_frame_table_2->Validate();

	// Validate page numbers
	CM_Frame	*p_frame;
	U32 index;
	U32 num_page_frames = m_p_frame_table->Num_Page_Frames();
	for (index = 0; index < num_page_frames; index++)
	{
		p_frame = Get_Frame(index + 1); // frame indexes start with 1

		U32 frame_index;
		U32 frame_index1;
		frame_index = p_frame->Get_Frame_Index();

		// This page number must be present.
		CT_ASSERT(frame_index == (index + 1), Validate);

		I64	page_number = p_frame->Get_Page_Number();
		if (page_number != -1)
		{
			frame_index1 = Get_Frame_Index(page_number);
			CT_ASSERT((frame_index1 == frame_index), Validate);
		}
		else
		{
			CT_ASSERT((p_frame->Is_Page_Clean()), Validate);
			CT_ASSERT((!p_frame->Is_Page_Locked()), Validate);
		}
	}
#endif // SIM
}
コード例 #18
0
void test_b12(Functor&& f) {
    // Create the callable object.
    typedef Signature TestClass::*ClassFunc;
    ClassFunc func_ptr = &TestClass::operator();

    // Create the dummy arg.
    NonCopyable arg;

    // Run invoke and check the return value.
    auto ret =
        ct::can_invoke(func_ptr, std::forward<Functor>(f), std::move(arg));
    //assert(ret == 42);
    CT_ASSERT(decltype(ret){});
}
コード例 #19
0
int main() {

    {
        using f = sig<N<0>, N<1>, N<2>, N<3>, N<4>>;
        using test = ct::replace_args_t<0, f, int, char>;
        using expect = sig<int, char, N<2>, N<3>, N<4>>;
        CT_ASSERT(std::is_same<test, expect>::value);
    }

    {
        using f = sig<N<0>, N<1>, N<2>, N<3>, N<4>>;
        using test = ct::replace_args_t<1, f, int, char>;
        using expect = sig<N<0>, int, char, N<3>, N<4>>;
        CT_ASSERT(std::is_same<test, expect>::value);
    }

    {
        using f = sig<N<0>, N<1>, N<2>, N<3>, N<4>>;
        using test = ct::replace_args_t<2, f, int, char>;
        using expect = sig<N<0>, N<1>, int, char, N<4>>;
        CT_ASSERT(std::is_same<test, expect>::value);
    }

    {
        using f = sig<N<0>, N<1>, N<2>, N<3>, N<4>>;
        using test = ct::replace_args_t<3, f, int, char>;
        using expect = sig<N<0>, N<1>, N<2>, int, char>;
        CT_ASSERT(std::is_same<test, expect>::value);
    }

    {
        using f = sig<N<0>, N<1>, N<2>, N<3>, N<4>>;
        using test = ct::replace_args_t<4, f, int, char, short, void*>;
        using expect = sig<N<0>, N<1>, N<2>, N<3>, int, char, short, void*>;
        CT_ASSERT(std::is_same<test, expect>::value);
    }
}
コード例 #20
0
ファイル: CmCache.cpp プロジェクト: JoeAltmaier/Odyssey
Status CM_Get_Event_Data(CM_CACHE_HANDLE cache_handle,
	CM_EVENT_DATA *p_event_data_buffer, 
	U32 size_buffer) 
{
#ifndef _WINDOWS
	CT_ASSERT(IS_ALIGNED_8(p_event_data_buffer), CM_Get_Event_Data);
#endif
	CM_Cache *p_cache = CM_Cache::Validate_Cache_Handle(cache_handle);
	if (p_cache == 0)
		return CM_ERROR(INVALID_CACHE_HANDLE);

	p_cache->Get_Event_Data(p_event_data_buffer, size_buffer);
	return OK;

} // CM_Get_Event_Data
コード例 #21
0
STATUS Create_Bad_Sector(
	U32 device,
	UNSIGNED offset, // offset in file 
	UNSIGNED num_bytes // number of bytes 
	)
{
	char *p_data = p_mem_file + (device * Flash_Address::Pages_Per_Device() 
		* Flash_Address::Bytes_Per_Page()) + offset;
	char *p_data_last = p_data + num_bytes;
	CT_ASSERT((p_data_last <= p_mem_file_last), Create_Bad_Sector);

	memset(p_data, 0X55, num_bytes);

	return OK;

} // Create_Bad_Sector
コード例 #22
0
ファイル: CmCache.cpp プロジェクト: JoeAltmaier/Odyssey
Status CM_Get_Statistics(CM_CACHE_HANDLE cache_handle,
	CM_STATISTICS *p_statistics_buffer, 
	U32 size_buffer) 
{
#ifndef _WINDOWS
	CT_ASSERT(IS_ALIGNED_8(p_statistics_buffer), CM_Get_Statistics);
#endif
	CM_Cache *p_cache = CM_Cache::Validate_Cache_Handle(cache_handle);
	if (p_cache == 0)
		return CM_ERROR(INVALID_CACHE_HANDLE);

	p_cache->Find_Waiting_Contexts();
	p_cache->Find_Open_Pages();

	p_cache->Get_Statistics(p_statistics_buffer, size_buffer);
	return OK;

} // CM_Get_Statistics
コード例 #23
0
ファイル: nv_event.cpp プロジェクト: lwllovewf2010/Crender
const char* NVEventGetEventStr(NVEventType eventType)
{
	switch(eventType)
	{
		case NV_EVENT_KEY:         return "NV_EVENT_KEY";
		case NV_EVENT_CHAR:        return "NV_EVENT_CHAR";
		case NV_EVENT_TOUCH:       return "NV_EVENT_TOUCH";
		case NV_EVENT_MULTITOUCH:  return "NV_EVENT_MULTITOUCH";
		case NV_EVENT_ACCEL:       return "NV_EVENT_ACCEL";
		case NV_EVENT_WINDOW_SIZE: return "NV_EVENT_WINDOW_SIZE";
		case NV_EVENT_QUIT:        return "NV_EVENT_QUIT";
		case NV_EVENT_PAUSE:       return "NV_EVENT_PAUSE";
		case NV_EVENT_RESUME:      return "NV_EVENT_RESUME";
	}
	// update this if you end up having to edit something.
	CT_ASSERT(NEED_TO_ADD_STRING_HERE, NV_EVENT_NUM_EVENTS == 9);
	return "unknown event type!";
}
コード例 #24
0
//得到一个空闲的用户
CCUser* CCUserManager::GetOneFreeUser(CT_DWORD userID, CCNetInterface* pNetInterface)
{
    _AUTOMUTEX(&m_mutex);
    if (Find(pNetInterface))
    {
        UFM_IT it =  m_userFindMap.find(pNetInterface);
        if (it != m_userFindMap.end())
        {
            m_userFindMap.erase(it);
        }
    }

    CCUser* pUser = 0;
    CT_BOOL bFind = Find(userID, &pUser);
    if (bFind)
    {
        pUser->Init();
        pUser->SetUserID(userID);
        pUser->SetNetInterface(pNetInterface);
        pUser->SetHeartBeat();
        m_userFindMap.insert(UserIDFindMap::value_type(pNetInterface, userID));
        return pUser;
    }

    pUser = G_UserPool.NewObj();
    CT_ASSERT(pUser != 0 || "G_UserPool.NewObj();");
    if (pUser == 0)
    {
        return 0;
    }

    if (!bFind && pUser != 0)
    {
        pUser->Init();
        pUser->SetUserID(userID);
        pUser->SetNetInterface(pNetInterface);
        pUser->SetHeartBeat();
        m_userDataMap.insert(UserDataMap::value_type(userID, pUser));
        m_userFindMap.insert(UserIDFindMap::value_type(pNetInterface, userID));
    }
    return pUser;
}
コード例 #25
0
ファイル: SsdQuiesce.cpp プロジェクト: JoeAltmaier/Odyssey
STATUS SSD_Ddm::Quiesce(Message *p_quiesce_message)	// virtual
{
	TRACE_ENTRY(SSD_Ddm::Quiesce);

	// Save pointer to quiesce message.
	// When this pointer is non zero, we are processing a quiesce.
	CT_ASSERT(m_p_quiesce_message == 0, SSD_Ddm::Process_Quiesce);
	m_p_quiesce_message = p_quiesce_message;

	Tracef(EOL "Beginning flash file system quiesce.");

#ifdef PHS_REPORTER
	// Start the Status reporter
	RqDdmReporter *pRqReporter = new RqDdmReporter(PHS_STOP, PHS_SSD_STATUS, MyDid, MyVdn);
	Send(pRqReporter, (ReplyCallback) &DiscardReply);

	// Start the Performance reporter
	RqDdmReporter *pRqReporter = new RqDdmReporter(PHS_STOP, PHS_SSD_PERFORMANCE, MyDid, MyVdn);
	Send(pRqReporter, (ReplyCallback) &DiscardReply);
#endif

#if 0 // TEMPORARY always allow quiesce for debugging
	// Are there any requests outstanding?
	if (m_num_requests_outstanding)
	{
		// If so, Quiesce will be called by Respond_To_BSA_Request
		// when the number of requests goes to zero.
		Tracef(EOL "Waiting for %d outstanding requests to quiesce", m_num_requests_outstanding);
		return OK;
	}
#endif

	// Set up the callback context to call Process_Quiesce
	// when the file system has been closed.
	m_request_context.Set_Callback(&Process_Quiesce);

	// Start the close operation.
	FF_Close(m_flash_handle, &m_request_context);

	return OK;

} // SSD_Ddm::Quiesce
コード例 #26
0
ファイル: CmFrameTable.cpp プロジェクト: JoeAltmaier/Odyssey
void CM_Frame_Table::Inc_Replaceable_Pages(LIST *p_list_waiting_contexts)
{
 	TRACE_ENTRY(CM_Frame_Table::Inc_Replaceable_Pages);

	// Increment number of replaceable pages.
	m_num_pages_replaceable++;
	CT_ASSERT((m_num_pages_replaceable <= m_num_page_frames), CM_Frame_Table::Inc_Replaceable_Pages);
	m_p_stats->Set_Num_Pages_Replaceable(m_num_pages_replaceable);

	// See if any context is waiting for a frame.
	if (LIST_IS_EMPTY(&m_list_wait_frame))
		return;

	// There is a context waiting for a page frame.
	// Remove it from the list and put it on the ready list.
	Callback_Context *p_callback_context = 
		(Callback_Context *)LIST_REMOVE_TAIL(&m_list_wait_frame);
	m_p_stats->Dec_Num_Waits_For_Page_Frame();

	LIST_INSERT_TAIL(p_list_waiting_contexts, &p_callback_context->m_list);

}  // CM_Frame_Table::Inc_Replaceable_Pages
コード例 #27
0
ファイル: FfController.cpp プロジェクト: JoeAltmaier/Odyssey
void FF_Controller::Mark_Buss_Not_Busy(Flash_Address flash_address)
{
	// Turn off the busy flag.
	CT_ASSERT((m_buss_context), FF_Controller::Mark_Buss_Not_Busy);
	m_buss_context = 0;

	// See if another context is waiting for the buss.
	if (!LIST_IS_EMPTY(&m_context_list_wait_buss))
	{
		m_p_flash->m_stats.Dec_Num_Waits_Buss();

		FF_Controller_Context *p_controller_context;
		p_controller_context = (FF_Controller_Context *)LIST_REMOVE_HEAD(
			&m_context_list_wait_buss);
		
 		TRACEF(TRACE_L5, 
			(EOL "Mark_Buss_Not_Busy Making waiting context ready for unit_index = %d", 
			p_controller_context->m_flash_address.Unit_Index()));
 	
		// Queue context back on ready list for execution..
		p_controller_context->Make_Ready();
	}
		
} // FF_Controller::Mark_Buss_Not_Busy
コード例 #28
0
int main() {
    {
        using f   = void(foo::*)();
        using l   = void(foo::*)() &;
        using r   = void(foo::*)() &&;
        using c   = void(foo::*)() const;
        using cl  = void(foo::*)() const &;
        using cr  = void(foo::*)() const &&;
        using v   = void(foo::*)() volatile;
        using vl  = void(foo::*)() volatile &;
        using vr  = void(foo::*)() volatile &&;
        using cv  = void(foo::*)() const volatile;
        using cvl = void(foo::*)() const volatile &;
        using cvr = void(foo::*)() const volatile &&;

        CT_ASSERT(std::is_same<f,    TRAIT(remove_member_reference,  f)>{});
        CT_ASSERT(std::is_same<c,    TRAIT(remove_member_reference,  c)>{});
        CT_ASSERT(std::is_same<v,    TRAIT(remove_member_reference,  v)>{});
        CT_ASSERT(std::is_same<cv,   TRAIT(remove_member_reference,  cv)>{});
        CT_ASSERT(std::is_same<f,    TRAIT(remove_member_reference,  l)>{});
        CT_ASSERT(std::is_same<c,    TRAIT(remove_member_reference,  cl)>{});
        CT_ASSERT(std::is_same<v,    TRAIT(remove_member_reference,  vl)>{});
        CT_ASSERT(std::is_same<cv,   TRAIT(remove_member_reference,  cvl)>{});
        CT_ASSERT(std::is_same<f,    TRAIT(remove_member_reference,  r)>{});
        CT_ASSERT(std::is_same<c,    TRAIT(remove_member_reference,  cr)>{});
        CT_ASSERT(std::is_same<v,    TRAIT(remove_member_reference,  vr)>{});
        CT_ASSERT(std::is_same<cv,   TRAIT(remove_member_reference,  cvr)>{});
    }

    {
        using f   = void();
        using l   = void() &;
        using r   = void() &&;
        using c   = void() const;
        using cl  = void() const &;
        using cr  = void() const &&;
        using v   = void() volatile;
        using vl  = void() volatile &;
        using vr  = void() volatile &&;
        using cv  = void() const volatile;
        using cvl = void() const volatile &;
        using cvr = void() const volatile &&;

        CT_ASSERT(std::is_same<f,    TRAIT(remove_member_reference,  f)>{});
        CT_ASSERT(std::is_same<c,    TRAIT(remove_member_reference,  c)>{});
        CT_ASSERT(std::is_same<v,    TRAIT(remove_member_reference,  v)>{});
        CT_ASSERT(std::is_same<cv,   TRAIT(remove_member_reference,  cv)>{});
        CT_ASSERT(std::is_same<f,    TRAIT(remove_member_reference,  l)>{});
        CT_ASSERT(std::is_same<c,    TRAIT(remove_member_reference,  cl)>{});
        CT_ASSERT(std::is_same<v,    TRAIT(remove_member_reference,  vl)>{});
        CT_ASSERT(std::is_same<cv,   TRAIT(remove_member_reference,  cvl)>{});
        CT_ASSERT(std::is_same<f,    TRAIT(remove_member_reference,  r)>{});
        CT_ASSERT(std::is_same<c,    TRAIT(remove_member_reference,  cr)>{});
        CT_ASSERT(std::is_same<v,    TRAIT(remove_member_reference,  vr)>{});
        CT_ASSERT(std::is_same<cv,   TRAIT(remove_member_reference,  cvr)>{});
    }
}
コード例 #29
0
int
main (int argc, char **argv)
{
    int c;
    int err;
    int nomtab = 0;
    unsigned long flags = MS_NODEV;
    char *host_name;
    char *mount_point;
    struct vbsf_mount_info_new mntinf;
    struct vbsf_mount_opts opts =
    {
        0,     /* uid */
        0,     /* gid */
        0,     /* ttl */
        ~0U,    /* dmode */
        ~0U,    /* fmode*/
        0,     /* dmask */
        0,     /* fmask */
        0,     /* ronly */
        0,     /* noexec */
        0,     /* nodev */
        0,     /* nosuid */
        0,     /* remount */
        "\0",  /* nls_name */
        NULL,  /* convertcp */
    };

    mntinf.nullchar = '\0';
    mntinf.signature[0] = VBSF_MOUNT_SIGNATURE_BYTE_0;
    mntinf.signature[1] = VBSF_MOUNT_SIGNATURE_BYTE_1;
    mntinf.signature[2] = VBSF_MOUNT_SIGNATURE_BYTE_2;
    mntinf.length       = sizeof(mntinf);

    if (getuid())
        panic("Only root can mount shared folders from the host.\n");

    if (!argv[0])
        argv[0] = "mount.vboxsf";

    /* Compile-time assertions */
    CT_ASSERT(sizeof(uid_t) == sizeof(int));
    CT_ASSERT(sizeof(gid_t) == sizeof(int));

    while ((c = getopt(argc, argv, "rwno:h")) != -1)
    {
        switch (c)
        {
        default:
            fprintf(stderr, "unknown option `%c:%#x'\n", c, c);
        case '?':
        case 'h':
            usage(argv[0]);

        case 'r':
            opts.ronly = 1;
            break;

        case 'w':
            opts.ronly = 0;

        case 'o':
            process_mount_opts(optarg, &opts);
            break;

        case 'n':
            nomtab = 1;
            break;
        }
    }

    if (argc - optind < 2)
        usage(argv[0]);

    host_name = argv[optind];
    mount_point = argv[optind + 1];

    if (opts.convertcp)
        convertcp(opts.convertcp, host_name, &mntinf);
    else
    {
        if (strlen(host_name) > MAX_HOST_NAME - 1)
            panic("host name is too big\n");

        strcpy(mntinf.name, host_name);
    }

    if (strlen(opts.nls_name) > MAX_NLS_NAME - 1)
        panic("%s: the character set name for I/O is too long.\n", argv[0]);

    strcpy(mntinf.nls_name, opts.nls_name);

    if (opts.ronly)
        flags |= MS_RDONLY;
    if (opts.noexec)
        flags |= MS_NOEXEC;
    if (opts.nodev)
        flags |= MS_NODEV;

    mntinf.uid   = opts.uid;
    mntinf.gid   = opts.gid;
    mntinf.ttl   = opts.ttl;
    mntinf.dmode = opts.dmode;
    mntinf.fmode = opts.fmode;
    mntinf.dmask = opts.dmask;
    mntinf.fmask = opts.fmask;

    /*
     * Note: When adding and/or modifying parameters of the vboxsf mounting
     *       options you also would have to adjust VBoxServiceAutoMount.cpp
     *       to keep this code here slick without having VbglR3.
     */
    err = mount(NULL, mount_point, "vboxsf", flags, &mntinf);
    if (err == -1 && errno == EPROTO)
    {
        /* Sometimes the mount utility messes up the share name.  Try to
         * un-mangle it again. */
        char szCWD[4096];
        size_t cchCWD;
        if (!getcwd(szCWD, sizeof(szCWD)))
            panic_err("%s: failed to get the current working directory", argv[0]);
        cchCWD = strlen(szCWD);
        if (!strncmp(host_name, szCWD, cchCWD))
        {
            while (host_name[cchCWD] == '/')
                ++cchCWD;
            /* We checked before that we have enough space */
            strcpy(mntinf.name, host_name + cchCWD);
        }
        err = mount(NULL, mount_point, "vboxsf", flags, &mntinf);
    }
    if (err == -1 && errno == EPROTO)
    {
        /* New mount tool with old vboxsf module? Try again using the old
         * vbsf_mount_info_old structure. */
        struct vbsf_mount_info_old mntinf_old;
        memcpy(&mntinf_old.name, &mntinf.name, MAX_HOST_NAME);
        memcpy(&mntinf_old.nls_name, mntinf.nls_name, MAX_NLS_NAME);
        mntinf_old.uid = mntinf.uid;
        mntinf_old.gid = mntinf.gid;
        mntinf_old.ttl = mntinf.ttl;
        err = mount(NULL, mount_point, "vboxsf", flags, &mntinf_old);
    }
    if (err)
        panic_err("%s: mounting failed with the error", argv[0]);

    if (!nomtab)
    {
        err = vbsfmount_complete(host_name, mount_point, flags, &opts);
        switch (err)
        {
        case 0: /* Success. */
            break;

        case 1:
            panic_err("%s: Could not update mount table (failed to create memstream).", argv[0]);
            break;

        case 2:
            panic_err("%s: Could not open mount table for update.", argv[0]);
            break;

        case 3:
            /* panic_err("%s: Could not add an entry to the mount table.", argv[0]); */
            break;

        default:
            panic_err("%s: Unknown error while completing mount operation: %d", argv[0], err);
            break;
        }
    }

    exit(EXIT_SUCCESS);
}
コード例 #30
0
//处理建造					  			
CT_VOID CCCityUserBuildEvent::DisposeUpgradeBuilding(const CMD_G_UpgradeBuild& ubData)
{
	//基本建筑数据关联检测(判断发来的数据是否合法)
	G_Building build = {0};
	G_BuildingType bt = {0};
	if(!CCBuildingScriptSetting::getSingleton().GetBuildingData(ubData.iBuildID, &build))
	{
		CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: CCBuildingScriptSetting::getSingleton().GetBuildingData Can't find user id: %i : buildID=%i", ubData.dwUserID, ubData.iBuildID);
		return;
	}

	if(!CCBuildingScriptSetting::getSingleton().GetBuildTypeWithID(ubData.iBuildID, &bt))
	{
		CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: CCBuildingScriptSetting::getSingleton().GetBuildTypeWithID Can't find user id: %i : buildID=%i", ubData.dwUserID, ubData.iBuildID);
		return;
	}

	//查找是否正在到达升级限制和是否正在升级
	CCUser* pUser = 0;
	if(!CCUserManager::getSingleton().Find(ubData.dwUserID, &pUser))
	{
		CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: Can't find user id: %i", ubData.dwUserID);
		return;
	}

	//vip add 如果建筑是vip特权建筑,判断vip特权
	int iPriID=0;
	if ((iPriID=G_GetVipPriIDByBuildID(ubData.iBuildID))>0)
	{
		if (!pUser->m_userVip.VipHasPrivilege(iPriID))
		{
			CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: build id: %d need vip pri %d \n", ubData.iBuildID,iPriID );
			pUser->CloseNet();
			return;
		}
	}

	//判断建筑所在区域是否解锁
	CT_INT32 iRegionID=0;
	CCRegionScriptSetting::getSingleton().GetRegionIDByBuildID(ubData.iBuildID,&iRegionID);
	if(!pUser->m_userRegion.GetRegionStatus(iRegionID))
	{
		CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: build id: %d the region %d is unlock\n", ubData.iBuildID, iRegionID);
		pUser->CloseNet();
		return;
	}

	//判断任务是否完成
	if(!pUser->m_userTask.ViewCompleteTask(build.iTaskID) && build.iTaskID != 0)
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_TASK_FAIL);
		return;
	}

	//判断建筑需要的领主和文明等级
	MasterVariableData mvd = {0};
	pUser->m_userBase.GetMasterData(mvd);
	if (mvd.stCivili.iLevel < build.iCivilGrade)
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_CIVILI_GRADE_LOW_FAIL);		
		return ;
	}

	
	if (mvd.stGrade.iLevel< build.iMasterGrade )
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_MASTER_GRADE_LOW_FAIL);
		return ;
	}

	//得到用户建筑数据
	BuildingData buildData={0};
	if(pUser->m_userBuilding. FindBuildData(ubData.iBuildID, buildData))
	{
		if (buildData.iGrade >= bt.iMaxGrade)
		{
			SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_TOP_GRADE_FAIL);
			return ;
		}
		if (pUser->m_userBuilding. FindUpgradeBuildData(ubData.iBuildID))
		{
			SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_UPGRADING_FAIL);
			return;
		}
	}

	//图腾等级不能超过领主等级,建筑等级不能超过图腾等级
	if (buildData.iID == BUILIDING_ID_TOTEM) 
	{
		MasterLevelInfo mle = {0};
	    pUser->m_userBase.GetMasterGrade(mle);
		if (buildData.iGrade >= mle.iLevel)
		{
			SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_MASTER_FAIL);
			return;
		}
	}else{

		BuildingData totem = {0};
		if(!pUser->m_userBuilding.FindBuildData(BUILIDING_ID_TOTEM, totem))
		{
			CT_ASSERT(false || "CCCityUserBuildEvent::DisposeUpgradeBuilding 致命的错误没有发现图腾建筑");
			CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding 致命的错误没有发现图腾建筑 usid =%i", ubData.dwUserID);
			return;
		}

		if (buildData.iGrade >= totem.iGrade)
		{
			SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_TOTEM_FAIL);
			return;
		}
	}

	//手动生产建筑是否在生产
	if (pUser->m_userBuilding. FindBuildingProduct(ubData.iBuildID))
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_PRODUCTING_FAIL);
		return ;
	}

	if (pUser->m_userEvent.FindBuildingEventByID(ubData.iBuildID))
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_EVENTING_FAIL);
		return ;
	}
	
	//得到升级数据
	G_BuildingUpgrade bu ={0};
	if (! CCBuildingScriptSetting::getSingleton().GetBuildingUpgradeDataWithID( ubData.iBuildID, buildData.iGrade+1, &bu))
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_DATA_FAIL);
		CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: CCBuildingScriptSetting::getSingleton().GetBuildingUpgradeDataWithID Can't find building type id: %i", bt.iID);
		return ;
	}

	//得到建筑信息
	G_Building     buildingInfo = {0};
	if (!CCBuildingScriptSetting::getSingleton().GetBuildingData(ubData.iBuildID, &buildingInfo))
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_DATA_FAIL);
		CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: G_GetBuildingData Can't find building id: %i", ubData.iBuildID );
		return ;
	}

	//检测资源是否满足
	if (!CheckResForUpgrade(pUser, ubData, bu))
	{
		CCLogMeg::getSingleton().WriteError("CCCityUserBuildEvent::DisposeUpgradeBuilding: fail to CanBuildingUpgrade()" );
		return ;
	}


	//自动生产的建筑是否在生产
	if (pUser->m_userBuilding.FindAutoProductingBuilding(ubData.iBuildID))
	{
		SendBuildError(pUser, MAIN_G_APPLY_UPGRADE_CITY, SUB_G_APPLY_UPGRADE_BUILD_FAIL, CBF_PRODUCTING_FAIL);
		return ;
	}

	ProductingBuilding pb = {0};
	if (pUser->m_userBuilding.FindAutoBuilding(ubData.iBuildID, pb))
	{
		pb.llTime = time(0) + bu.iNeedTime;
		pUser->m_userBuilding.UpdateAutoBuilding(ubData.iBuildID, pb);
	}

	UpgradingBuildData  ubd = {0};
	ubd.iID           = build.iID;
	ubd.llBeginTime   = time(0);
	ubd.bSpeedUpTime  = 0;
	ubd.iNeedTime     = bu.iNeedTime;
	memcpy(&(ubd.buildingUpgrade), &bu, sizeof(ubd.buildingUpgrade));
	pUser->m_userBuilding.InsertUpgradeBuildData(ubd);

	DisposeDBUpgadeSuc(pUser, ubd);
}