本文整理汇总了C++中D_ASSUME函数的典型用法代码示例。如果您正苦于以下问题:C++ D_ASSUME函数的具体用法?C++ D_ASSUME怎么用?C++ D_ASSUME使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了D_ASSUME函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: direct_thread_join
void
direct_thread_join( DirectThread *thread )
{
D_MAGIC_ASSERT( thread, DirectThread );
D_ASSERT( thread->handle.thread != -1 );
D_ASSUME( !pthread_equal( thread->handle.thread, pthread_self() ) );
D_ASSUME( !thread->joining );
D_ASSUME( !thread->joined );
D_ASSUME( !thread->detached );
D_DEBUG_AT( Direct_Thread, "%s( %p, '%s' %d )\n", __FUNCTION__, thread->main, thread->name, thread->tid );
if (thread->detached) {
D_DEBUG_AT( Direct_Thread, " -> DETACHED!\n" );
return;
}
if (!thread->joining && !pthread_equal( thread->handle.thread, pthread_self() )) {
thread->joining = true;
D_DEBUG_AT( Direct_Thread, " -> joining...\n" );
pthread_join( thread->handle.thread, NULL );
thread->joined = true;
D_DEBUG_AT( Direct_Thread, " -> joined.\n" );
}
}
示例2: direct_thread_deinit
void
direct_thread_deinit( DirectThread *thread )
{
D_MAGIC_ASSERT( thread, DirectThread );
D_ASSUME( !pthread_equal( thread->handle.thread, pthread_self() ) );
D_ASSUME( !thread->detached );
D_DEBUG_AT( Direct_Thread, "%s( %p, '%s' %d )\n", __FUNCTION__, thread->main, thread->name, thread->tid );
if (thread->detached) {
D_DEBUG_AT( Direct_Thread, " -> DETACHED!\n" );
return;
}
if (!thread->joined && !pthread_equal( thread->handle.thread, pthread_self() )) {
if (thread->canceled)
D_DEBUG_AT( Direct_Thread, " -> cancled but not joined!\n" );
else {
D_DEBUG_AT( Direct_Thread, " -> still running!\n" );
if (thread->name)
D_ERROR( "Direct/Thread: Canceling '%s' (%d)!\n", thread->name, thread->tid );
else
D_ERROR( "Direct/Thread: Canceling %d!\n", thread->tid );
#ifndef DIRECT_BUILD_NO_PTHREAD_CANCEL
pthread_cancel( thread->handle.thread );
#endif
}
pthread_join( thread->handle.thread, NULL );
}
}
示例3: direct_thread_terminate
void
direct_thread_terminate( DirectThread *thread )
{
D_MAGIC_ASSERT( thread, DirectThread );
D_ASSERT( thread->thread != -1 );
D_ASSUME( !pthread_equal( thread->thread, pthread_self() ) );
D_ASSUME( !thread->canceled );
D_DEBUG_AT( Direct_Thread, "%s( %p, '%s' %d )\n", __FUNCTION__, thread->main, thread->name, thread->tid );
thread->terminated = true;
direct_thread_notify( thread );
}
示例4: voodoo_manager_quit
DirectResult
voodoo_manager_quit( VoodooManager *manager )
{
D_MAGIC_ASSERT( manager, VoodooManager );
D_ASSUME( !manager->quit );
if (manager->quit)
return DR_OK;
D_DEBUG( "Voodoo/Manager: Quitting manager at %p!\n", manager );
/* Have all threads quit upon this. */
manager->quit = true;
/* Acquire locks and wake up waiters. */
pthread_mutex_lock( &manager->input.lock );
pthread_cond_broadcast( &manager->input.wait );
pthread_mutex_unlock( &manager->input.lock );
pthread_mutex_lock( &manager->response.lock );
pthread_cond_broadcast( &manager->response.wait );
pthread_mutex_unlock( &manager->response.lock );
pthread_mutex_lock( &manager->output.lock );
pthread_cond_broadcast( &manager->output.wait );
pthread_mutex_unlock( &manager->output.lock );
return DR_OK;
}
示例5: dfb_core_get_graphics_state
DFBResult
dfb_core_get_graphics_state( CoreDFB *core,
u32 object_id,
CoreGraphicsState **ret_state )
{
DFBResult ret;
FusionObject *object;
CoreDFBShared *shared;
D_ASSUME( core != NULL );
D_ASSERT( ret_state != NULL );
if (!core)
core = core_dfb;
D_MAGIC_ASSERT( core, CoreDFB );
shared = core->shared;
D_MAGIC_ASSERT( shared, CoreDFBShared );
D_ASSERT( core->shared->graphics_state_pool != NULL );
ret = fusion_object_get( core->shared->graphics_state_pool, object_id, &object );
if (ret)
return ret;
*ret_state = (CoreGraphicsState*) object;
return DFB_OK;
}
示例6: dfb_core_cleanup_add
CoreCleanup *
dfb_core_cleanup_add( CoreDFB *core,
CoreCleanupFunc func,
void *data,
bool emergency )
{
CoreCleanup *cleanup;
D_ASSUME( core != NULL );
if (!core)
core = core_dfb;
D_MAGIC_ASSERT( core, CoreDFB );
cleanup = D_CALLOC( 1, sizeof(CoreCleanup) );
cleanup->func = func;
cleanup->data = data;
cleanup->emergency = emergency;
direct_list_prepend( &core->cleanups, &cleanup->link );
return cleanup;
}
示例7: dfb_core_get_layer_region
DFBResult
dfb_core_get_layer_region( CoreDFB *core,
u32 object_id,
CoreLayerRegion **ret_region )
{
DFBResult ret;
FusionObject *object;
CoreDFBShared *shared;
D_ASSUME( core != NULL );
D_ASSERT( ret_region != NULL );
if (!core)
core = core_dfb;
D_MAGIC_ASSERT( core, CoreDFB );
shared = core->shared;
D_MAGIC_ASSERT( shared, CoreDFBShared );
D_ASSERT( core->shared->layer_region_pool != NULL );
ret = fusion_object_get( core->shared->layer_region_pool, object_id, &object );
if (ret)
return ret;
*ret_region = (CoreLayerRegion*) object;
return DFB_OK;
}
示例8: dfb_layer_region_disable
DFBResult
dfb_layer_region_disable( CoreLayerRegion *region )
{
DFBResult ret;
D_ASSERT( region != NULL );
/* Lock the region. */
if (dfb_layer_region_lock( region ))
return DFB_FUSION;
D_ASSUME( D_FLAGS_IS_SET( region->state, CLRSF_ENABLED ) );
if (! D_FLAGS_IS_SET( region->state, CLRSF_ENABLED )) {
dfb_layer_region_unlock( region );
return DFB_OK;
}
/* Unrealize the region if it's active. */
if (D_FLAGS_IS_SET( region->state, CLRSF_ACTIVE )) {
ret = unrealize_region( region );
if (ret)
return ret;
}
/* Update the region's state. */
D_FLAGS_CLEAR( region->state, CLRSF_ENABLED );
/* Unlock the region. */
dfb_layer_region_unlock( region );
return DFB_OK;
}
示例9: dfb_layer_region_get_surface
DFBResult
dfb_layer_region_get_surface( CoreLayerRegion *region,
CoreSurface **ret_surface )
{
D_ASSERT( region != NULL );
D_ASSERT( ret_surface != NULL );
/* Lock the region. */
if (dfb_layer_region_lock( region ))
return DFB_FUSION;
D_ASSUME( region->surface != NULL );
/* Check for NULL surface. */
if (!region->surface) {
dfb_layer_region_unlock( region );
return DFB_UNSUPPORTED;
}
/* Increase the surface's reference counter. */
if (dfb_surface_ref( region->surface )) {
dfb_layer_region_unlock( region );
return DFB_FUSION;
}
/* Return the surface. */
*ret_surface = region->surface;
/* Unlock the region. */
dfb_layer_region_unlock( region );
return DFB_OK;
}
示例10: dfb_colorhash_attach
void
dfb_colorhash_attach( DFBColorHashCore *core,
CorePalette *palette )
{
DFBColorHashCoreShared *shared;
D_ASSUME( core != NULL );
if (core) {
D_MAGIC_ASSERT( core, DFBColorHashCore );
D_MAGIC_ASSERT( core->shared, DFBColorHashCoreShared );
}
else
core = core_colorhash;
shared = core->shared;
fusion_skirmish_prevail( &shared->hash_lock );
if (!shared->hash) {
D_ASSERT( shared->hash_users == 0 );
shared->hash = SHCALLOC( shared->shmpool, HASH_SIZE, sizeof (Colorhash) );
}
shared->hash_users++;
fusion_skirmish_dismiss( &shared->hash_lock );
}
示例11: dfb_colorhash_detach
void
dfb_colorhash_detach( DFBColorHashCore *core,
CorePalette *palette )
{
DFBColorHashCoreShared *shared;
D_ASSUME( core != NULL );
if (core) {
D_MAGIC_ASSERT( core, DFBColorHashCore );
D_MAGIC_ASSERT( core->shared, DFBColorHashCoreShared );
}
else
core = core_colorhash;
shared = core->shared;
D_ASSERT( shared->hash_users > 0 );
D_ASSERT( shared->hash != NULL );
fusion_skirmish_prevail( &shared->hash_lock );
shared->hash_users--;
if (!shared->hash_users) {
/* no more users, free allocated resources */
SHFREE( shared->shmpool, shared->hash );
shared->hash = NULL;
}
fusion_skirmish_dismiss( &shared->hash_lock );
}
示例12: D_DEBUG_AT
void
VoodooConnectionLink::Stop()
{
D_DEBUG_AT( Voodoo_Connection, "VoodooConnectionLink::%s( %p )\n", __func__, this );
D_MAGIC_ASSERT( this, VoodooConnection );
direct_mutex_lock( &output.lock );
while (output.packets) {
VoodooPacket *packet = (VoodooPacket*) output.packets;
D_DEBUG_AT( Voodoo_Connection, " -> discarding output packet %p\n", packet );
D_ASSUME( packet->sending );
packet->sending = false;
direct_list_remove( &output.packets, &packet->link );
}
direct_mutex_unlock( &output.lock );
direct_waitqueue_broadcast( &output.wait );
}
示例13: direct_serial_notify
DirectResult
direct_serial_notify( DirectSerial *serial, const DirectSerial *source )
{
D_ASSERT( serial != NULL );
D_ASSERT( source != NULL );
D_DEBUG_AT( Direct_Serial_Notify, " ###### %s( %p, %p ) ### %lu <-= %lu ### ### ###\n", __FUNCTION__,
serial, source, serial->value, source->value );
D_MAGIC_ASSERT( serial, DirectSerial );
D_MAGIC_ASSERT( source, DirectSerial );
D_ASSERT( serial->overflow <= source->overflow );
D_ASSERT( serial->overflow == source->overflow || serial->value != source->value );
if (serial->overflow < source->overflow) {
serial->overflow = source->overflow;
serial->value = source->value;
}
else if (serial->overflow == source->overflow && serial->value < source->value)
serial->value = source->value;
else {
D_ASSUME( serial->value == source->value );
return DR_OK;
}
if (serial->waiting > 0) {
D_SYNC_ADD( &serial->wakeup, 1 );
return direct_futex_wake( &serial->wakeup, 1024 );
}
return DR_OK;
}
示例14: dfb_core_get_window
DFBResult
dfb_core_get_window( CoreDFB *core,
u32 object_id,
CoreWindow **ret_window )
{
DFBResult ret;
FusionObject *object;
CoreDFBShared *shared;
D_ASSUME( core != NULL );
D_ASSERT( ret_window != NULL );
if (!core)
core = core_dfb;
D_MAGIC_ASSERT( core, CoreDFB );
shared = core->shared;
D_MAGIC_ASSERT( shared, CoreDFBShared );
D_ASSERT( core->shared->window_pool != NULL );
ret = fusion_object_get( core->shared->window_pool, object_id, &object );
if (ret)
return ret;
*ret_window = (CoreWindow*) object;
return DFB_OK;
}
示例15: dfb_screen_test_output_config
DFBResult
dfb_screen_test_output_config( CoreScreen *screen,
int output,
const DFBScreenOutputConfig *config,
DFBScreenOutputConfigFlags *ret_failed )
{
DFBResult ret;
DFBScreenOutputConfigFlags failed = DSOCONF_NONE;
D_ASSERT( screen != NULL );
D_ASSERT( screen->shared != NULL );
D_ASSERT( screen->funcs != NULL );
D_ASSERT( screen->funcs->TestOutputConfig != NULL );
D_ASSERT( output >= 0 );
D_ASSERT( output < screen->shared->description.outputs );
D_ASSERT( config != NULL );
D_ASSERT( config->flags == screen->shared->outputs[output].configuration.flags );
/* Test the output configuration. */
ret = screen->funcs->TestOutputConfig( screen,
screen->driver_data,
screen->screen_data,
output, config, &failed );
D_ASSUME( (ret == DFB_OK && !failed) || (ret != DFB_OK && failed) );
if (ret_failed)
*ret_failed = failed;
return ret;
}