DirectResult direct_signal_handler_add( int num, DirectSignalHandlerFunc func, void *ctx, DirectSignalHandler **ret_handler ) { DirectSignalHandler *handler; D_ASSERT( func != NULL ); D_ASSERT( ret_handler != NULL ); D_DEBUG_AT( Direct_Signals, "Adding handler %p for signal %d with context %p...\n", func, num, ctx ); handler = D_CALLOC( 1, sizeof(DirectSignalHandler) ); if (!handler) { D_WARN( "out of memory" ); return DR_NOLOCALMEMORY; } handler->num = num; handler->func = func; handler->ctx = ctx; D_MAGIC_SET( handler, DirectSignalHandler ); direct_mutex_lock( &handlers_lock ); direct_list_append( &handlers, &handler->link ); direct_mutex_unlock( &handlers_lock ); *ret_handler = handler; return DR_OK; }
static void DecoupleCall( ComaTestInstance *instance, ComaMethodID method, void *data, unsigned int serial ) { DecoupledCall *call; IComaComponent *component = instance->component; call = D_CALLOC( 1, sizeof(DecoupledCall) ); if (!call) { D_OOM(); component->Return( component, DR_NOLOCALMEMORY, call->serial ); return; } call->instance = instance; call->method = method; call->data = data; call->serial = serial; direct_mutex_lock( &decoupled_calls_lock ); direct_list_append( &decoupled_calls, &call->link ); direct_mutex_unlock( &decoupled_calls_lock ); direct_waitqueue_broadcast( &decoupled_calls_wq ); }
DirectThreadInitHandler * direct_thread_add_init_handler( DirectThreadInitFunc func, void *arg ) { DirectThreadInitHandler *handler; handler = D_CALLOC( 1, sizeof(DirectThreadInitHandler) ); if (!handler) { D_WARN( "out of memory" ); return NULL; } handler->func = func; handler->arg = arg; D_MAGIC_SET( handler, DirectThreadInitHandler ); pthread_mutex_lock( &handler_lock ); direct_list_append( &handlers, &handler->link ); pthread_mutex_unlock( &handler_lock ); return handler; }
void VoodooDispatcher::PutPacket( VoodooPacket *packet ) { D_DEBUG_AT( Voodoo_Dispatcher, "VoodooDispatcher::%s( %p, packet %p )\n", __func__, this, packet ); D_MAGIC_ASSERT( this, VoodooDispatcher ); direct_mutex_lock( &lock ); direct_list_append( &packets, &packet->link ); direct_waitqueue_broadcast( &queue ); direct_mutex_unlock( &lock ); }
// Implement stack_containers_XXX function family to maintain the connections // between windowstacks and input devices. static void stack_containers_add(CoreWindowStack *p) { Stack_Container *stack_cntr; D_DEBUG_AT( Core_WindowStack, "Enter:%s()\n", __FUNCTION__); pthread_mutex_lock( &stack_containers_lock ); stack_cntr = (Stack_Container *) D_CALLOC(1, sizeof(Stack_Container)); if (stack_cntr != NULL) { stack_cntr->ctx = (void *)p; direct_list_append(&stack_containers, &stack_cntr->link); } else{ D_ERROR( "Core/WindowStack: stack_cntr = NULL\n"); } pthread_mutex_unlock( &stack_containers_lock ); }
void VoodooConnectionLink::Flush( VoodooPacket *packet ) { D_DEBUG_AT( Voodoo_Connection, "VoodooConnectionLink::%s( %p, packet %p )\n", __func__, this, packet ); D_MAGIC_ASSERT( this, VoodooConnection ); direct_mutex_lock( &output.lock ); D_ASSERT( !direct_list_contains_element_EXPENSIVE( output.packets, &packet->link ) ); D_ASSERT( !packet->sending ); packet->sending = true; direct_list_append( &output.packets, &packet->link ); direct_mutex_unlock( &output.lock ); link->WakeUp( link ); }