void dfb_surfacemanager_destroy( SurfaceManager *manager ) { Chunk *chunk; D_ASSERT( manager != NULL ); D_ASSERT( manager->chunks != NULL ); D_MAGIC_ASSERT( manager, SurfaceManager ); D_MAGIC_CLEAR( manager ); /* Deallocate all chunks. */ chunk = manager->chunks; while (chunk) { Chunk *next = chunk->next; D_MAGIC_CLEAR( chunk ); SHFREE( chunk ); chunk = next; } /* Destroy manager lock. */ fusion_skirmish_destroy( &manager->lock ); /* Deallocate manager struct. */ SHFREE( manager ); }
static DFBResult dfb_clipboard_core_shutdown( DFBClipboardCore *data, bool emergency ) { DFBClipboardCoreShared *shared; D_DEBUG_AT( Core_Clipboard, "dfb_clipboard_core_shutdown( %p, %semergency )\n", data, emergency ? "" : "no " ); D_MAGIC_ASSERT( data, DFBClipboardCore ); shared = data->shared; D_MAGIC_ASSERT( shared, DFBClipboardCoreShared ); fusion_skirmish_destroy( &shared->lock ); if (shared->data) SHFREE( shared->shmpool, shared->data ); if (shared->mime_type) SHFREE( shared->shmpool, shared->mime_type ); D_MAGIC_CLEAR( data ); D_MAGIC_CLEAR( shared ); return DFB_OK; }
DirectResult fusion_shm_deinit( FusionWorld *world ) { int i; DirectResult ret; FusionSHM *shm; FusionSHMShared *shared; D_MAGIC_ASSERT( world, FusionWorld ); shm = &world->shm; D_MAGIC_ASSERT( shm, FusionSHM ); shared = shm->shared; D_MAGIC_ASSERT( shared, FusionSHMShared ); ret = fusion_skirmish_prevail( &shared->lock ); if (ret) return ret; /* Deinitialize shared data. */ if (fusion_master( world )) { D_ASSUME( shared->num_pools == 0 ); for (i=0; i<FUSION_SHM_MAX_POOLS; i++) { if (shared->pools[i].active) { D_MAGIC_ASSERT( &shared->pools[i], FusionSHMPoolShared ); D_MAGIC_ASSERT( &shm->pools[i], FusionSHMPool ); D_WARN( "destroying remaining '%s'", shared->pools[i].name ); fusion_shm_pool_destroy( world, &shared->pools[i] ); } } /* Destroy shared lock. */ fusion_skirmish_destroy( &shared->lock ); D_MAGIC_CLEAR( shared ); } else { for (i=0; i<FUSION_SHM_MAX_POOLS; i++) { if (shared->pools[i].active) { D_MAGIC_ASSERT( &shared->pools[i], FusionSHMPoolShared ); D_MAGIC_ASSERT( &shm->pools[i], FusionSHMPool ); fusion_shm_pool_detach( shm, &shared->pools[i] ); } } fusion_skirmish_dismiss( &shared->lock ); } D_MAGIC_CLEAR( shm ); return DR_OK; }
static Chunk* free_chunk( SurfaceManager *manager, Chunk *chunk ) { D_MAGIC_ASSERT( manager, SurfaceManager ); D_MAGIC_ASSERT( chunk, _Chunk_ ); if (!chunk->buffer) { D_BUG( "freeing free chunk" ); return chunk; } else { D_DEBUG_AT( Core_SM, "Deallocating %d bytes at offset %d.\n", chunk->length, chunk->offset ); } if (chunk->buffer->policy == CSP_VIDEOONLY) manager->available += chunk->length; chunk->buffer = NULL; manager->min_toleration--; if (chunk->prev && !chunk->prev->buffer) { Chunk *prev = chunk->prev; //D_DEBUG_AT( Core_SM, " -> merging with previous chunk at %d\n", prev->offset ); prev->length += chunk->length; prev->next = chunk->next; if (prev->next) prev->next->prev = prev; //D_DEBUG_AT( Core_SM, " -> freeing %p (prev %p, next %p)\n", chunk, chunk->prev, chunk->next); D_MAGIC_CLEAR( chunk ); SHFREE( chunk ); chunk = prev; } if (chunk->next && !chunk->next->buffer) { Chunk *next = chunk->next; //D_DEBUG_AT( Core_SM, " -> merging with next chunk at %d\n", next->offset ); chunk->length += next->length; chunk->next = next->next; if (chunk->next) chunk->next->prev = chunk; D_MAGIC_CLEAR( next ); SHFREE( next ); } return chunk; }
static void call_handlers( int num, void *addr ) { DirectLink *l, *n; if (num == SIG_DUMP_STACK) num = DIRECT_SIGNAL_DUMP_STACK; /* Loop through all handlers. */ direct_mutex_lock( &handlers_lock ); direct_list_foreach_safe (l, n, handlers) { DirectSignalHandler *handler = (DirectSignalHandler*) l; if (handler->removed) { direct_list_remove( &handlers, &handler->link ); D_MAGIC_CLEAR( handler ); D_FREE( handler ); continue; } D_LOG( Direct_Signals, FATAL, " --> %d\n", handler->num ); if (handler->num != num && handler->num != DIRECT_SIGNAL_ANY) continue; if (handler->num == DIRECT_SIGNAL_ANY && num == DIRECT_SIGNAL_DUMP_STACK) continue; switch (handler->func( num, addr, handler->ctx )) { case DSHR_OK: break; case DSHR_REMOVE: direct_list_remove( &handlers, &handler->link ); D_MAGIC_CLEAR( handler ); D_FREE( handler ); break; case DSHR_RESUME: D_LOG( Direct_Signals, FATAL, " '-> cured!\n" ); direct_mutex_unlock( &handlers_lock ); return; default: D_BUG( "unknown result" ); break; } }
void dfb_font_destroy( CoreFont *font ) { int i; D_MAGIC_ASSERT( font, CoreFont ); D_MAGIC_CLEAR( font ); pthread_mutex_lock( &font->lock ); dfb_state_set_destination( &font->state, NULL ); dfb_state_set_source( &font->state, NULL ); dfb_state_destroy( &font->state ); direct_tree_destroy( font->glyph_infos ); if (font->surfaces) { for (i = 0; i < font->rows; i++) dfb_surface_unref( font->surfaces[i] ); D_FREE( font->surfaces ); } pthread_mutex_unlock( &font->lock ); pthread_mutex_destroy( &font->lock ); D_FREE( font ); }
static DFBResult fbdevDeallocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { FBDevPoolData *data = pool_data; FBDevAllocationData *alloc = alloc_data; D_DEBUG_AT( FBDev_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, FBDevPoolData ); D_MAGIC_ASSERT( buffer, CoreSurfaceBuffer ); D_MAGIC_ASSERT( alloc, FBDevAllocationData ); if (alloc->chunk) dfb_surfacemanager_deallocate( data->manager, alloc->chunk ); D_MAGIC_CLEAR( alloc ); return DFB_OK; }
static DFBResult stmfbdevDeallocateBuffer (CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data) { STMfbdevPoolData * const data = pool_data; const STMfbdevPoolLocalData * const local = pool_local; STMfbdevPoolAllocationData * const alloc = alloc_data; D_DEBUG_AT (STMfbdev_Surfaces, "%s (%p)\n", __FUNCTION__, buffer); D_MAGIC_ASSERT (pool, CoreSurfacePool); D_MAGIC_ASSERT (data, STMfbdevPoolData); D_MAGIC_ASSERT (local, STMfbdevPoolLocalData); D_MAGIC_ASSERT (buffer, CoreSurfaceBuffer); D_MAGIC_ASSERT (allocation, CoreSurfaceAllocation); D_MAGIC_ASSERT (alloc, STMfbdevPoolAllocationData); (void) local; D_ASSERT (alloc->chunk != NULL); dfb_surfacemanager_deallocate (data->manager, alloc->chunk); D_MAGIC_CLEAR (alloc); return DFB_OK; }
static DFBResult mesaDeallocateBuffer( CoreSurfacePool *pool, void *pool_data, void *pool_local, CoreSurfaceBuffer *buffer, CoreSurfaceAllocation *allocation, void *alloc_data ) { MesaPoolData *data = pool_data; MesaAllocationData *alloc = alloc_data; MesaPoolLocalData *local = pool_local; (void)data; D_DEBUG_AT( Mesa_Surfaces, "%s( %p )\n", __FUNCTION__, buffer ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, MesaPoolData ); D_MAGIC_ASSERT( alloc, MesaAllocationData ); drmModeRmFB( local->mesa->fd, alloc->fb_id ); eglDestroyImageKHR( local->mesa->dpy, alloc->image ); gbm_bo_destroy( alloc->bo ); D_MAGIC_CLEAR( alloc ); return DFB_OK; }
static DFBResult wm_remove_window( CoreWindowStack *stack, void *wm_data, void *stack_data, CoreWindow *window, void *window_data ) { WindowData *data = window_data; D_ASSERT( stack != NULL ); D_ASSERT( wm_data != NULL ); D_ASSERT( stack_data != NULL ); D_ASSERT( window != NULL ); D_ASSERT( window_data != NULL ); D_MAGIC_ASSERT( data, WindowData ); // D_ASSUME( data->window == NULL ); if (data->window) unique_window_detach_global( data->window, &data->window_reaction ); D_MAGIC_CLEAR( data ); return DFB_OK; }
static void palette_destructor( FusionObject *object, bool zombie, void *ctx ) { CorePaletteNotification notification; CorePalette *palette = (CorePalette*) object; D_MAGIC_ASSERT( palette, CorePalette ); D_DEBUG_AT( Core_Palette, "destroying %p (%d)%s\n", palette, palette->num_entries, zombie ? " (ZOMBIE)" : ""); D_ASSERT( palette->entries != NULL ); D_ASSERT( palette->entries_yuv != NULL ); notification.flags = CPNF_DESTROY; notification.palette = palette; dfb_palette_dispatch( palette, ¬ification, dfb_palette_globals ); if (palette->hash_attached) { dfb_colorhash_invalidate( NULL, palette ); dfb_colorhash_detach( NULL, palette ); } SHFREE( palette->shmpool, palette->entries_yuv ); SHFREE( palette->shmpool, palette->entries ); D_MAGIC_CLEAR( palette ); fusion_object_destroy( object ); }
static void surface_client_destructor( FusionObject *object, bool zombie, void *ctx ) { CoreSurfaceClient *client = (CoreSurfaceClient*) object; CoreSurface *surface; int index; D_MAGIC_ASSERT( client, CoreSurfaceClient ); surface = client->surface; CORE_SURFACE_ASSERT( surface ); D_DEBUG_AT( Core_SurfClient, "destroying %p (%dx%d%s)\n", client, surface->config.size.w, surface->config.size.h, zombie ? " ZOMBIE" : ""); CoreSurfaceClient_Deinit_Dispatch( &client->call ); dfb_surface_lock( surface ); index = fusion_vector_index_of( &surface->clients, client ); D_ASSERT( index >= 0 ); fusion_vector_remove( &surface->clients, index ); dfb_surface_check_acks( surface ); dfb_surface_unlock( surface ); dfb_surface_unlink( &client->surface ); D_MAGIC_CLEAR( client ); fusion_object_destroy( object ); }
static void leave_pool( FusionSHM *shm, FusionSHMPool *pool, FusionSHMPoolShared *shared ) { FusionWorld *world; D_DEBUG_AT( Fusion_SHMPool, "%s( %p, %p, %p )\n", __FUNCTION__, shm, pool, shared ); D_MAGIC_ASSERT( shm, FusionSHM ); D_MAGIC_ASSERT( pool, FusionSHMPool ); D_MAGIC_ASSERT( shared, FusionSHMPoolShared ); world = shm->world; D_MAGIC_ASSERT( world, FusionWorld ); if (munmap( shared->addr_base, shared->max_size )) D_PERROR( "Fusion/SHM: Could not munmap shared memory file '%s'!\n", pool->filename ); pool->attached = false; D_FREE( pool->filename ); D_MAGIC_CLEAR( pool ); }
VoodooInstance::~VoodooInstance() { D_DEBUG_AT( Voodoo_Instance, "VoodooInstance::%s( %p )\n", __func__, this ); D_MAGIC_ASSERT( this, VoodooInstance ); D_MAGIC_CLEAR( this ); }
void one_core_wq_deinit( OneCore *core, OneWaitQueue *queue ) { D_MAGIC_ASSERT( core, OneCore ); D_MAGIC_ASSERT( queue, OneWaitQueue ); D_MAGIC_CLEAR( queue ); }
static DFBResult mesaDestroyPool( CoreSurfacePool *pool, void *pool_data, void *pool_local ) { MesaPoolData *data = pool_data; MesaPoolLocalData *local = pool_local; D_DEBUG_AT( Mesa_Surfaces, "%s()\n", __FUNCTION__ ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, MesaPoolData ); D_MAGIC_ASSERT( local, MesaPoolLocalData ); D_MAGIC_CLEAR( data ); D_MAGIC_CLEAR( local ); return DFB_OK; }
VoodooConnection::~VoodooConnection() { D_DEBUG_AT( Voodoo_Connection, "VoodooConnection::%s( %p )\n", __func__, this ); D_MAGIC_ASSERT( this, VoodooConnection ); link->Close( link ); D_MAGIC_CLEAR( this ); }
DFBResult x11ImageInit( DFBX11 *x11, x11Image *image, int width, int height, DFBSurfacePixelFormat format ) { int ret; Visual *visual; DFBX11Shared *shared = x11->shared; if (!x11->use_shm) return DFB_UNSUPPORTED; /* Lookup visual. */ visual = x11->visuals[DFB_PIXELFORMAT_INDEX(format)]; if (!visual) return DFB_UNSUPPORTED; /* For probing. */ if (!image) return DFB_OK; image->width = width; image->height = height; image->format = format; image->depth = DFB_COLOR_BITS_PER_PIXEL( format ); D_MAGIC_SET( image, x11Image ); if (fusion_call_execute( &shared->call, FCEF_NONE, X11_IMAGE_INIT, image, &ret )) { D_MAGIC_CLEAR( image ); return DFB_FUSION; } if (ret) { D_DERROR( ret, "X11/Image: X11_IMAGE_INIT call failed!\n" ); D_MAGIC_CLEAR( image ); return ret; } return DFB_OK; }
static void shutdown_pool( FusionSHM *shm, FusionSHMPool *pool, FusionSHMPoolShared *shared ) { FusionWorld *world; D_DEBUG_AT( Fusion_SHMPool, "%s( %p, %p, %p )\n", __FUNCTION__, shm, pool, shared ); D_MAGIC_ASSERT( shm, FusionSHM ); D_MAGIC_ASSERT( pool, FusionSHMPool ); D_MAGIC_ASSERT( shared, FusionSHMPoolShared ); world = shm->world; D_MAGIC_ASSERT( world, FusionWorld ); SHFREE( shared, shared->name ); fusion_dbg_print_memleaks( shared ); if (munmap( shared->addr_base, shared->max_size )) D_PERROR( "Fusion/SHM: Could not munmap shared memory file '%s'!\n", pool->filename ); if (pool->fd != -1 && close( pool->fd )) D_PERROR( "Fusion/SHM: Could not close shared memory file '%s'!\n", pool->filename ); if (unlink( pool->filename )) D_PERROR( "Fusion/SHM: Could not unlink shared memory file '%s'!\n", pool->filename ); shared->active = false; pool->attached = false; D_FREE( pool->filename ); D_MAGIC_CLEAR( pool ); fusion_skirmish_destroy( &shared->lock ); D_MAGIC_CLEAR( shared ); }
void CoreGraphicsStateClient_Deinit( CoreGraphicsStateClient *client ) { D_DEBUG_AT( Core_GraphicsStateClient, "%s( client %p )\n", __FUNCTION__, client ); D_MAGIC_ASSERT( client, CoreGraphicsStateClient ); dfb_graphics_state_unref( client->gfx_state ); D_MAGIC_CLEAR( client ); }
static DFBResult dfb_colorhash_core_shutdown( DFBColorHashCore *data, bool emergency ) { DFBColorHashCoreShared *shared; D_DEBUG_AT( Core_ColorHash, "dfb_colorhash_core_shutdown( %p, %semergency )\n", data, emergency ? "" : "no " ); D_MAGIC_ASSERT( data, DFBColorHashCore ); D_MAGIC_ASSERT( data->shared, DFBColorHashCoreShared ); shared = data->shared; fusion_skirmish_destroy( &shared->hash_lock ); D_MAGIC_CLEAR( data ); D_MAGIC_CLEAR( shared ); return DFB_OK; }
static DFBResult fbdevDestroyPool( CoreSurfacePool *pool, void *pool_data, void *pool_local ) { FBDevPoolData *data = pool_data; FBDevPoolLocalData *local = pool_local; D_DEBUG_AT( FBDev_Surfaces, "%s()\n", __FUNCTION__ ); D_MAGIC_ASSERT( pool, CoreSurfacePool ); D_MAGIC_ASSERT( data, FBDevPoolData ); D_MAGIC_ASSERT( local, FBDevPoolLocalData ); dfb_surfacemanager_destroy( data->manager ); D_MAGIC_CLEAR( data ); D_MAGIC_CLEAR( local ); return DFB_OK; }
void direct_map_destroy( DirectMap *map ) { D_DEBUG_AT( Direct_Map, "%s()\n", __func__ ); DIRECT_MAP_ASSERT( map ); D_MAGIC_CLEAR( map ); D_FREE( map->entries ); D_FREE( map ); }
void one_core_exit( OneCore *core ) { ONE_DEBUG( "%s()\n", __FUNCTION__ ); D_MAGIC_ASSERT( core, OneCore ); D_MAGIC_CLEAR( core ); kfree( core ); }
void OneTarget_Destroy( OneTarget *target ) { ONE_DEBUG( "%s( %p )\n", __FUNCTION__, target ); D_MAGIC_ASSERT( target, OneTarget ); D_MAGIC_CLEAR( target ); one_core_free( one_core, target ); }
static int dfb_core_arena_initialize( FusionArena *arena, void *ctx ) { DFBResult ret; CoreDFB *core = ctx; CoreDFBShared *shared; FusionSHMPoolShared *pool; D_MAGIC_ASSERT( core, CoreDFB ); D_DEBUG_AT( DirectFB_Core, "Initializing...\n" ); /* Create the shared memory pool first! */ ret = fusion_shm_pool_create( core->world, "DirectFB Main Pool", 0x400000, fusion_config->debugshm, &pool ); if (ret) return ret; /* Allocate shared structure in the new pool. */ shared = SHCALLOC( pool, 1, sizeof(CoreDFBShared) ); if (!shared) { fusion_shm_pool_destroy( core->world, pool ); return D_OOSHM(); } core->shared = shared; core->master = true; shared->shmpool = pool; D_MAGIC_SET( shared, CoreDFBShared ); /* Initialize. */ ret = dfb_core_initialize( core ); if (ret) { D_MAGIC_CLEAR( shared ); SHFREE( pool, shared ); fusion_shm_pool_destroy( core->world, pool ); return ret; } fusion_skirmish_init( &shared->lock, "DirectFB Core", core->world ); CoreDFB_Init_Dispatch( core, core, &shared->call ); fusion_call_add_permissions( &shared->call, 0, FUSION_CALL_PERMIT_EXECUTE ); /* Register shared data. */ fusion_arena_add_shared_field( arena, "Core/Shared", shared ); return DFB_OK; }
DirectResult fusion_shm_pool_destroy( FusionWorld *world, FusionSHMPoolShared *pool ) { D_MAGIC_ASSERT( pool, FusionSHMPoolShared ); D_MAGIC_CLEAR( pool ); D_FREE( pool ); return DR_OK; }
static void surface_destructor( FusionObject *object, bool zombie, void *ctx ) { int i; CoreSurface *surface = (CoreSurface*) object; D_MAGIC_ASSERT( surface, CoreSurface ); D_DEBUG_AT( Core_Surface, "destroying %p (%dx%d%s)\n", surface, surface->config.size.w, surface->config.size.h, zombie ? " ZOMBIE" : ""); Core_Resource_RemoveSurface( surface ); CoreSurface_Deinit_Dispatch( &surface->call ); dfb_surface_lock( surface ); surface->state |= CSSF_DESTROYED; /* announce surface destruction */ dfb_surface_notify( surface, CSNF_DESTROY ); /* unlink palette */ if (surface->palette) { dfb_palette_detach_global( surface->palette, &surface->palette_reaction ); dfb_palette_unlink( &surface->palette ); } /* destroy buffers */ for (i=0; i<MAX_SURFACE_BUFFERS; i++) { if (surface->buffers[i]) dfb_surface_buffer_decouple( surface->buffers[i] ); } dfb_system_surface_data_destroy( surface, surface->data ); /* release the system driver specific surface data */ if (surface->data) { SHFREE( surface->shmpool, surface->data ); surface->data = NULL; } direct_serial_deinit( &surface->serial ); dfb_surface_unlock( surface ); fusion_skirmish_destroy( &surface->lock ); D_MAGIC_CLEAR( surface ); fusion_object_destroy( object ); }
static void call_tls_destroy( void *arg ) { CallTLS *call_tls = arg; D_MAGIC_ASSERT( call_tls, CallTLS ); fusion_world_flush_calls( call_tls->world, 0 ); D_MAGIC_CLEAR( call_tls ); D_FREE( call_tls ); }
static DFBResult dfb_clipboard_core_leave( DFBClipboardCore *data, bool emergency ) { D_DEBUG_AT( Core_Clipboard, "dfb_clipboard_core_leave( %p, %semergency )\n", data, emergency ? "" : "no " ); D_MAGIC_ASSERT( data, DFBClipboardCore ); D_MAGIC_ASSERT( data->shared, DFBClipboardCoreShared ); D_MAGIC_CLEAR( data ); return DFB_OK; }