static int compare_fd(void *key1, void *key2) { int fd1 = pointer_to_intptr(key1); int fd2 = pointer_to_intptr(key2); struct stat stat1, stat2; fstat(fd1, &stat1); fstat(fd2, &stat2); return stat1.st_dev != stat2.st_dev || stat1.st_ino != stat2.st_ino || stat1.st_rdev != stat2.st_rdev; }
static struct native_display * native_create_display(void *dpy, boolean use_sw) { struct native_display *ndpy; int fd; /* well, this makes fd 0 being ignored */ if (!dpy) { const char *device_name="/dev/fb0"; #ifdef O_CLOEXEC fd = open(device_name, O_RDWR | O_CLOEXEC); if (fd == -1 && errno == EINVAL) #endif { fd = open(device_name, O_RDWR); if (fd != -1) fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); } } else { fd = dup((int) pointer_to_intptr(dpy)); } if (fd < 0) return NULL; ndpy = fbdev_display_create(fd, fbdev_event_handler); if (!ndpy) close(fd); return ndpy; }
static unsigned hash_fd(void *key) { int fd = pointer_to_intptr(key); struct stat stat; fstat(fd, &stat); return stat.st_dev ^ stat.st_ino ^ stat.st_rdev; }
/** * Save the command parser state for rewind. * * Note that this cannot rewind a flush, and the caller must make sure * that does not happend. */ void ilo_cp_setjmp(struct ilo_cp *cp, struct ilo_cp_jmp_buf *jmp) { jmp->id = pointer_to_intptr(cp->bo); jmp->size = cp->size; jmp->used = cp->used; jmp->stolen = cp->stolen; /* save reloc count to rewind ilo_cp_write_bo() */ jmp->reloc_count = intel_bo_get_reloc_count(cp->bo); }
/** * Rewind to the saved state. */ void ilo_cp_longjmp(struct ilo_cp *cp, const struct ilo_cp_jmp_buf *jmp) { if (jmp->id != pointer_to_intptr(cp->bo)) { assert(!"invalid use of CP longjmp"); return; } cp->size = jmp->size; cp->used = jmp->used; cp->stolen = jmp->stolen; intel_bo_clear_relocs(cp->bo, jmp->reloc_count); }
_EGLImage * egl_g3d_create_image(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attribs) { struct pipe_resource *ptex; struct egl_g3d_image *gimg; unsigned level = 0, layer = 0; gimg = CALLOC_STRUCT(egl_g3d_image); if (!gimg) { _eglError(EGL_BAD_ALLOC, "eglCreateEGLImageKHR"); return NULL; } if (!_eglInitImage(&gimg->base, dpy)) { FREE(gimg); return NULL; } switch (target) { case EGL_NATIVE_PIXMAP_KHR: ptex = egl_g3d_reference_native_pixmap(dpy, (EGLNativePixmapType) buffer); break; #ifdef EGL_MESA_drm_image case EGL_DRM_BUFFER_MESA: ptex = egl_g3d_reference_drm_buffer(dpy, (EGLint) pointer_to_intptr(buffer), &gimg->base, attribs); break; #endif #ifdef EGL_WL_bind_wayland_display case EGL_WAYLAND_BUFFER_WL: ptex = egl_g3d_reference_wl_buffer(dpy, (struct wl_buffer *) buffer, &gimg->base, attribs); break; #endif #ifdef EGL_ANDROID_image_native_buffer case EGL_NATIVE_BUFFER_ANDROID: ptex = egl_g3d_reference_android_native_buffer(dpy, (struct ANativeWindowBuffer *) buffer); break; #endif default: ptex = NULL; break; } if (!ptex) { FREE(gimg); return NULL; } if (level > ptex->last_level) { _eglError(EGL_BAD_MATCH, "eglCreateEGLImageKHR"); pipe_resource_reference(&gimg->texture, NULL); FREE(gimg); return NULL; } if (layer >= (u_minify(ptex->depth0, level) + ptex->array_size - 1)) { _eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR"); pipe_resource_reference(&gimg->texture, NULL); FREE(gimg); return NULL; } /* transfer the ownership to the image */ gimg->texture = ptex; gimg->level = level; gimg->layer = layer; return &gimg->base; }
static int compare_fd(void *key1, void *key2) { return pointer_to_intptr(key1) != pointer_to_intptr(key2); }
static unsigned hash_fd(void *key) { return pointer_to_intptr(key); }