Lines Matching full:pool
92 struct wl_shm_pool *pool; member
102 shm_pool_grow_mapping(struct wl_shm_pool *pool) in shm_pool_grow_mapping() argument
107 data = mremap(pool->data, pool->size, pool->new_size, MREMAP_MAYMOVE); in shm_pool_grow_mapping()
109 data = wl_os_mremap_maymove(pool->mmap_fd, pool->data, &pool->size, in shm_pool_grow_mapping()
110 pool->new_size, pool->mmap_prot, in shm_pool_grow_mapping()
111 pool->mmap_flags); in shm_pool_grow_mapping()
112 if (pool->size != 0 && pool->resource != NULL) { in shm_pool_grow_mapping()
113 wl_resource_post_error(pool->resource, in shm_pool_grow_mapping()
122 shm_pool_finish_resize(struct wl_shm_pool *pool) in shm_pool_finish_resize() argument
126 if (pool->size == pool->new_size) in shm_pool_finish_resize()
129 data = shm_pool_grow_mapping(pool); in shm_pool_finish_resize()
131 if (pool->resource != NULL) in shm_pool_finish_resize()
132 wl_resource_post_error(pool->resource, in shm_pool_finish_resize()
138 pool->data = data; in shm_pool_finish_resize()
139 pool->size = pool->new_size; in shm_pool_finish_resize()
143 shm_pool_unref(struct wl_shm_pool *pool, bool external) in shm_pool_unref() argument
146 pool->external_refcount--; in shm_pool_unref()
147 assert(pool->external_refcount >= 0); in shm_pool_unref()
148 if (pool->external_refcount == 0) in shm_pool_unref()
149 shm_pool_finish_resize(pool); in shm_pool_unref()
151 pool->internal_refcount--; in shm_pool_unref()
152 assert(pool->internal_refcount >= 0); in shm_pool_unref()
155 if (pool->internal_refcount + pool->external_refcount > 0) in shm_pool_unref()
158 munmap(pool->data, pool->size); in shm_pool_unref()
160 close(pool->mmap_fd); in shm_pool_unref()
162 free(pool); in shm_pool_unref()
170 shm_pool_unref(buffer->pool, false); in destroy_buffer()
211 struct wl_shm_pool *pool = wl_resource_get_user_data(resource); in shm_pool_create_buffer() local
223 offset > pool->size - stride * height) { in shm_pool_create_buffer()
242 buffer->pool = pool; in shm_pool_create_buffer()
243 pool->internal_refcount++; in shm_pool_create_buffer()
249 shm_pool_unref(pool, false); in shm_pool_create_buffer()
262 struct wl_shm_pool *pool = wl_resource_get_user_data(resource); in destroy_pool() local
264 pool->resource = NULL; in destroy_pool()
265 shm_pool_unref(pool, false); in destroy_pool()
278 struct wl_shm_pool *pool = wl_resource_get_user_data(resource); in shm_pool_resize() local
280 if (size < pool->size) { in shm_pool_resize()
283 "shrinking pool invalid"); in shm_pool_resize()
287 pool->new_size = size; in shm_pool_resize()
289 /* If the compositor has taken references on this pool it in shm_pool_resize()
292 * until the compositor finishes dereferencing the pool. in shm_pool_resize()
294 if (pool->external_refcount == 0) in shm_pool_resize()
295 shm_pool_finish_resize(pool); in shm_pool_resize()
308 struct wl_shm_pool *pool; in shm_create_pool() local
321 pool = zalloc(sizeof *pool); in shm_create_pool()
322 if (pool == NULL) { in shm_create_pool()
333 pool->sigbus_is_impossible = statbuf.st_size >= size; in shm_create_pool()
335 pool->sigbus_is_impossible = false; in shm_create_pool()
337 pool->sigbus_is_impossible = false; in shm_create_pool()
340 pool->internal_refcount = 1; in shm_create_pool()
341 pool->external_refcount = 0; in shm_create_pool()
342 pool->size = size; in shm_create_pool()
343 pool->new_size = size; in shm_create_pool()
346 pool->data = mmap(NULL, size, prot, flags, fd, 0); in shm_create_pool()
347 if (pool->data == MAP_FAILED) { in shm_create_pool()
355 pool->mmap_fd = fd; in shm_create_pool()
356 pool->mmap_prot = prot; in shm_create_pool()
357 pool->mmap_flags = flags; in shm_create_pool()
361 pool->resource = in shm_create_pool()
363 if (!pool->resource) { in shm_create_pool()
365 munmap(pool->data, pool->size); in shm_create_pool()
366 free(pool); in shm_create_pool()
370 wl_resource_set_implementation(pool->resource, in shm_create_pool()
372 pool, destroy_pool); in shm_create_pool()
377 free(pool); in shm_create_pool()
459 if (buffer->pool->external_refcount && in wl_shm_buffer_get_data()
460 (buffer->pool->size != buffer->pool->new_size)) in wl_shm_buffer_get_data()
461 wl_log("Buffer address requested when its parent pool " in wl_shm_buffer_get_data()
464 return buffer->pool->data + buffer->offset; in wl_shm_buffer_get_data()
494 * of the pool.
502 assert(buffer->pool->internal_refcount + in wl_shm_buffer_ref_pool()
503 buffer->pool->external_refcount); in wl_shm_buffer_ref_pool()
505 buffer->pool->external_refcount++; in wl_shm_buffer_ref_pool()
506 return buffer->pool; in wl_shm_buffer_ref_pool()
511 * \param pool The pool object
517 * the pool will be automatically destroyed when appropriate.
523 wl_shm_pool_unref(struct wl_shm_pool *pool) in wl_shm_pool_unref() argument
525 shm_pool_unref(pool, true); in wl_shm_pool_unref()
532 * the pool then we'll uninstall the signal handler so we can in reraise_sigbus()
543 struct wl_shm_pool *pool; in sigbus_handler() local
550 pool = sigbus_data->current_pool; in sigbus_handler()
553 * the pool then the error is a real problem so we'll reraise in sigbus_handler()
555 if (pool == NULL || in sigbus_handler()
556 (char *) info->si_addr < pool->data || in sigbus_handler()
557 (char *) info->si_addr >= pool->data + pool->size) { in sigbus_handler()
565 if (mmap(pool->data, pool->size, PROT_READ | PROT_WRITE, in sigbus_handler()
616 * the SHM pool of the given buffer then the client will be sent an
634 struct wl_shm_pool *pool = buffer->pool; in wl_shm_buffer_begin_access() local
637 if (pool->sigbus_is_impossible) in wl_shm_buffer_begin_access()
652 sigbus_data->current_pool == pool); in wl_shm_buffer_begin_access()
654 sigbus_data->current_pool = pool; in wl_shm_buffer_begin_access()
672 struct wl_shm_pool *pool = buffer->pool; in wl_shm_buffer_end_access() local
675 if (pool->sigbus_is_impossible) in wl_shm_buffer_end_access()