Discussion:
[PATCH mesa 1/2] egl: turn boolean `int`s into `bool`s
(too old to reply)
Eric Engestrom
2017-06-18 23:49:10 UTC
Permalink
Raw Message
Signed-off-by: Eric Engestrom <***@engestrom.ch>
---
src/egl/drivers/dri2/egl_dri2.c | 2 +-
src/egl/drivers/dri2/egl_dri2.h | 17 +++++++++--------
src/egl/drivers/dri2/platform_drm.c | 6 +++---
src/egl/drivers/dri2/platform_wayland.c | 20 ++++++++++----------
src/egl/drivers/dri2/platform_x11.c | 4 ++--
5 files changed, 25 insertions(+), 24 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 020a0bc639..fd7584f7ab 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -783,7 +783,7 @@ dri2_create_screen(_EGLDisplay *disp)
return EGL_FALSE;
}

- dri2_dpy->own_dri_screen = 1;
+ dri2_dpy->own_dri_screen = true;
return EGL_TRUE;
}

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index f8c26a9d45..bffc63e1e9 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -28,6 +28,7 @@
#ifndef EGL_DRI2_INCLUDED
#define EGL_DRI2_INCLUDED

+#include <stdbool.h>
#include <stdint.h>

#ifdef HAVE_X11_PLATFORM
@@ -158,7 +159,7 @@ struct dri2_egl_display
int dri2_major;
int dri2_minor;
__DRIscreen *dri_screen;
- int own_dri_screen;
+ bool own_dri_screen;
const __DRIconfig **driver_configs;
void *driver;
const __DRIcoreExtension *core;
@@ -179,8 +180,8 @@ struct dri2_egl_display
* dri2_make_current (tracks if there are active contexts/surfaces). */
int ref_count;

- int own_device;
- int invalidate_available;
+ bool own_device;
+ bool invalidate_available;
int min_swap_interval;
int max_swap_interval;
int default_swap_interval;
@@ -196,7 +197,7 @@ struct dri2_egl_display
#ifdef HAVE_X11_PLATFORM
xcb_connection_t *conn;
xcb_screen_t *screen;
- int swap_available;
+ bool swap_available;
#ifdef HAVE_DRI3
struct loader_dri3_extensions loader_dri3_ext;
#endif
@@ -210,7 +211,7 @@ struct dri2_egl_display
struct wl_drm *wl_drm;
struct wl_shm *wl_shm;
struct wl_event_queue *wl_queue;
- int authenticated;
+ bool authenticated;
int formats;
uint32_t capabilities;
char *device_name;
@@ -220,7 +221,7 @@ struct dri2_egl_display
const gralloc_module_t *gralloc;
#endif

- int is_render_node;
+ bool is_render_node;
int is_different_gpu;
};

@@ -245,7 +246,7 @@ struct dri2_egl_surface
__DRIdrawable *dri_drawable;
__DRIbuffer buffers[5];
int buffer_count;
- int have_fake_front;
+ bool have_fake_front;

#ifdef HAVE_X11_PLATFORM
xcb_drawable_t drawable;
@@ -287,7 +288,7 @@ struct dri2_egl_surface
#ifdef HAVE_DRM_PLATFORM
struct gbm_bo *bo;
#endif
- int locked;
+ bool locked;
int age;
} color_buffers[4], *back, *current;
#endif
diff --git a/src/egl/drivers/dri2/platform_drm.c b/src/egl/drivers/dri2/platform_drm.c
index 8b0562c75d..2cf7106255 100644
--- a/src/egl/drivers/dri2/platform_drm.c
+++ b/src/egl/drivers/dri2/platform_drm.c
@@ -56,7 +56,7 @@ lock_front_buffer(struct gbm_surface *_surf)
bo = dri2_surf->current->bo;

if (device->dri2) {
- dri2_surf->current->locked = 1;
+ dri2_surf->current->locked = true;
dri2_surf->current = NULL;
}

@@ -72,7 +72,7 @@ release_buffer(struct gbm_surface *_surf, struct gbm_bo *bo)

for (i = 0; i < ARRAY_SIZE(dri2_surf->color_buffers); i++) {
if (dri2_surf->color_buffers[i].bo == bo) {
- dri2_surf->color_buffers[i].locked = 0;
+ dri2_surf->color_buffers[i].locked = false;
}
}
}
@@ -696,7 +696,7 @@ dri2_initialize_drm(_EGLDriver *drv, _EGLDisplay *disp)
err = "DRI2: failed to create gbm device";
goto cleanup;
}
- dri2_dpy->own_device = 1;
+ dri2_dpy->own_device = true;
} else {
dri2_dpy->fd = fcntl(gbm_device_get_fd(gbm), F_DUPFD_CLOEXEC, 3);
if (dri2_dpy->fd < 0) {
diff --git a/src/egl/drivers/dri2/platform_wayland.c b/src/egl/drivers/dri2/platform_wayland.c
index f746f0bfd1..1444449e8c 100644
--- a/src/egl/drivers/dri2/platform_wayland.c
+++ b/src/egl/drivers/dri2/platform_wayland.c
@@ -76,7 +76,7 @@ wl_buffer_release(void *data, struct wl_buffer *buffer)
return;
}

- dri2_surf->color_buffers[i].locked = 0;
+ dri2_surf->color_buffers[i].locked = false;
}

static const struct wl_buffer_listener wl_buffer_listener = {
@@ -314,7 +314,7 @@ dri2_wl_release_buffers(struct dri2_egl_surface *dri2_surf)
dri2_surf->color_buffers[i].dri_image = NULL;
dri2_surf->color_buffers[i].linear_copy = NULL;
dri2_surf->color_buffers[i].data = NULL;
- dri2_surf->color_buffers[i].locked = 0;
+ dri2_surf->color_buffers[i].locked = false;
}

if (dri2_dpy->dri2) {
@@ -410,7 +410,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
if (dri2_surf->back->dri_image == NULL)
return -1;

- dri2_surf->back->locked = 1;
+ dri2_surf->back->locked = true;

return 0;
}
@@ -908,7 +908,7 @@ dri2_wl_authenticate(_EGLDisplay *disp, uint32_t id)
"authenticate for render-nodes");
return 0;
}
- dri2_dpy->authenticated = 0;
+ dri2_dpy->authenticated = false;

wl_drm_authenticate(dri2_dpy->wl_drm, id);
if (roundtrip(dri2_dpy) < 0)
@@ -918,7 +918,7 @@ dri2_wl_authenticate(_EGLDisplay *disp, uint32_t id)
ret = -1;

/* reset authenticated */
- dri2_dpy->authenticated = 1;
+ dri2_dpy->authenticated = true;

return ret;
}
@@ -941,7 +941,7 @@ drm_handle_device(void *data, struct wl_drm *drm, const char *device)
}

if (drmGetNodeTypeFromFd(dri2_dpy->fd) == DRM_NODE_RENDER) {
- dri2_dpy->authenticated = 1;
+ dri2_dpy->authenticated = true;
} else {
drmGetMagic(dri2_dpy->fd, &magic);
wl_drm_authenticate(dri2_dpy->wl_drm, magic);
@@ -979,7 +979,7 @@ drm_handle_authenticated(void *data, struct wl_drm *drm)
{
struct dri2_egl_display *dri2_dpy = data;

- dri2_dpy->authenticated = 1;
+ dri2_dpy->authenticated = true;
}

static const struct wl_drm_listener drm_listener = {
@@ -1164,7 +1164,7 @@ dri2_initialize_wayland_drm(_EGLDriver *drv, _EGLDisplay *disp)
dri2_dpy->wl_dpy = wl_display_connect(NULL);
if (dri2_dpy->wl_dpy == NULL)
goto cleanup;
- dri2_dpy->own_device = 1;
+ dri2_dpy->own_device = true;
} else {
dri2_dpy->wl_dpy = disp->PlatformDisplay;
}
@@ -1526,7 +1526,7 @@ swrast_update_buffers(struct dri2_egl_surface *dri2_surf)
return -1;
}

- dri2_surf->back->locked = 1;
+ dri2_surf->back->locked = true;

/* If we have an extra unlocked buffer at this point, we had to do triple
* buffering for a while, but now can go back to just double buffering.
@@ -1814,7 +1814,7 @@ dri2_initialize_wayland_swrast(_EGLDriver *drv, _EGLDisplay *disp)
dri2_dpy->wl_dpy = wl_display_connect(NULL);
if (dri2_dpy->wl_dpy == NULL)
goto cleanup;
- dri2_dpy->own_device = 1;
+ dri2_dpy->own_device = true;
} else {
dri2_dpy->wl_dpy = disp->PlatformDisplay;
}
diff --git a/src/egl/drivers/dri2/platform_x11.c b/src/egl/drivers/dri2/platform_x11.c
index 74d3a164b6..95e560a32a 100644
--- a/src/egl/drivers/dri2/platform_x11.c
+++ b/src/egl/drivers/dri2/platform_x11.c
@@ -445,7 +445,7 @@ dri2_x11_process_buffers(struct dri2_egl_surface *dri2_surf,
unsigned i;

dri2_surf->buffer_count = count;
- dri2_surf->have_fake_front = 0;
+ dri2_surf->have_fake_front = false;

/* This assumes the DRI2 buffer attachment tokens matches the
* __DRIbuffer tokens. */
@@ -462,7 +462,7 @@ dri2_x11_process_buffers(struct dri2_egl_surface *dri2_surf,
* Note that EGL doesn't require that several clients rendering
* to the same window must see the same aux buffers. */
if (dri2_surf->buffers[i].attachment == __DRI_BUFFER_FAKE_FRONT_LEFT)
- dri2_surf->have_fake_front = 1;
+ dri2_surf->have_fake_front = true;
}

if (dri2_surf->region != XCB_NONE)
--
Cheers,
Eric
Eric Engestrom
2017-06-18 23:49:11 UTC
Permalink
Raw Message
Same as the previous commit, but this one was split out because it's
a bit more complicated: this field is given as a pointer to a function,
so the function had to be changed as well, and the function was use in
a bunch of places, which needed updating as well.

Signed-off-by: Eric Engestrom <***@engestrom.ch>
---
src/egl/drivers/dri2/egl_dri2.h | 2 +-
src/gallium/auxiliary/vl/vl_winsys_dri3.c | 2 +-
src/gallium/targets/d3dadapter9/drm.c | 6 +++---
src/glx/dri3_priv.h | 2 +-
src/loader/loader.c | 10 +++++-----
src/loader/loader.h | 4 +++-
6 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/src/egl/drivers/dri2/egl_dri2.h b/src/egl/drivers/dri2/egl_dri2.h
index bffc63e1e9..3f29e64cdc 100644
--- a/src/egl/drivers/dri2/egl_dri2.h
+++ b/src/egl/drivers/dri2/egl_dri2.h
@@ -222,7 +222,7 @@ struct dri2_egl_display
#endif

bool is_render_node;
- int is_different_gpu;
+ bool is_different_gpu;
};

struct dri2_egl_context
diff --git a/src/gallium/auxiliary/vl/vl_winsys_dri3.c b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
index c7c615b395..8251087f3f 100644
--- a/src/gallium/auxiliary/vl/vl_winsys_dri3.c
+++ b/src/gallium/auxiliary/vl/vl_winsys_dri3.c
@@ -89,7 +89,7 @@ struct vl_dri3_screen
int64_t last_ust, ns_frame, last_msc, next_msc;

bool flushed;
- int is_different_gpu;
+ bool is_different_gpu;
};

static void
diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c
index 6163734185..0434d8e4c1 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -204,7 +204,7 @@ drm_create_adapter( int fd,
{
struct d3dadapter9drm_context *ctx = CALLOC_STRUCT(d3dadapter9drm_context);
HRESULT hr;
- int different_device;
+ bool different_device;
const struct drm_conf_ret *throttle_ret = NULL;
const struct drm_conf_ret *dmabuf_ret = NULL;
driOptionCache defaultInitOptions;
@@ -220,7 +220,7 @@ drm_create_adapter( int fd,
* takes ownership of it. */
fd = loader_get_user_preferred_fd(fd, &different_device);
ctx->fd = fd;
- ctx->base.linear_framebuffer = !!different_device;
+ ctx->base.linear_framebuffer = different_device;

if (!pipe_loader_drm_probe_fd(&ctx->dev, fd)) {
ERR("Failed to probe drm fd %d.\n", fd);
@@ -271,7 +271,7 @@ drm_create_adapter( int fd,
if (driCheckOption(&userInitOptions, "thread_submit", DRI_BOOL))
ctx->base.thread_submit = driQueryOptionb(&userInitOptions, "thread_submit");
else
- ctx->base.thread_submit = !!different_device;
+ ctx->base.thread_submit = different_device;

if (ctx->base.thread_submit && (throttling_value_user == -2 || throttling_value_user == 0)) {
ctx->base.throttling_value = 0;
diff --git a/src/glx/dri3_priv.h b/src/glx/dri3_priv.h
index 082237781c..1d3c03f999 100644
--- a/src/glx/dri3_priv.h
+++ b/src/glx/dri3_priv.h
@@ -101,7 +101,7 @@ struct dri3_screen {

void *driver;
int fd;
- int is_different_gpu;
+ bool is_different_gpu;

int show_fps_interval;

diff --git a/src/loader/loader.c b/src/loader/loader.c
index 5541ccc2a7..c3fc961be5 100644
--- a/src/loader/loader.c
+++ b/src/loader/loader.c
@@ -153,7 +153,7 @@ static char *drm_get_id_path_tag_for_fd(int fd)
return tag;
}

-int loader_get_user_preferred_fd(int default_fd, int *different_device)
+int loader_get_user_preferred_fd(int default_fd, bool *different_device)
{
/* Arbitrary "maximum" value of drm devices. */
#define MAX_DRM_DEVICES 32
@@ -171,7 +171,7 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
#endif

if (prime == NULL) {
- *different_device = 0;
+ *different_device = false;
return default_fd;
}

@@ -230,16 +230,16 @@ int loader_get_user_preferred_fd(int default_fd, int *different_device)
return fd;

err:
- *different_device = 0;
+ *different_device = false;

free(default_tag);
free(prime);
return default_fd;
}
#else
-int loader_get_user_preferred_fd(int default_fd, int *different_device)
+int loader_get_user_preferred_fd(int default_fd, bool *different_device)
{
- *different_device = 0;
+ *different_device = false;
return default_fd;
}
#endif
diff --git a/src/loader/loader.h b/src/loader/loader.h
index 84314a4fc0..3859b45dc4 100644
--- a/src/loader/loader.h
+++ b/src/loader/loader.h
@@ -27,6 +27,8 @@
#ifndef LOADER_H
#define LOADER_H

+#include <stdbool.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -51,7 +53,7 @@ loader_get_device_name_for_fd(int fd);
*/

int
-loader_get_user_preferred_fd(int default_fd, int *different_device);
+loader_get_user_preferred_fd(int default_fd, bool *different_device);

/* for logging.. keep this aligned with egllog.h so we can just use
* _eglLog directly.
--
Cheers,
Eric
Emil Velikov
2017-06-20 07:38:17 UTC
Permalink
Raw Message
Post by Eric Engestrom
Same as the previous commit, but this one was split out because it's
a bit more complicated: this field is given as a pointer to a function,
so the function had to be changed as well, and the function was use in
a bunch of places, which needed updating as well.
Agreed. Thank you for this.
Post by Eric Engestrom
@@ -220,7 +220,7 @@ drm_create_adapter( int fd,
* takes ownership of it. */
fd = loader_get_user_preferred_fd(fd, &different_device);
ctx->fd = fd;
- ctx->base.linear_framebuffer = !!different_device;
+ ctx->base.linear_framebuffer = different_device;
if (!pipe_loader_drm_probe_fd(&ctx->dev, fd)) {
ERR("Failed to probe drm fd %d.\n", fd);
@@ -271,7 +271,7 @@ drm_create_adapter( int fd,
if (driCheckOption(&userInitOptions, "thread_submit", DRI_BOOL))
ctx->base.thread_submit = driQueryOptionb(&userInitOptions, "thread_submit");
else
- ctx->base.thread_submit = !!different_device;
+ ctx->base.thread_submit = different_device;
thread_submit and linear_framebuffer are BOOL aka int, although
everything should be fine.

Reviewed-by: Emil Velikov <***@collabora.com>

-Emil

Emil Velikov
2017-06-20 07:27:15 UTC
Permalink
Raw Message
Reviewed-by: Emil Velikov <***@collabora.com>

Couple of random thoughts below.
Post by Eric Engestrom
+ bool invalidate_available;
+ bool swap_available;
These two could be nuked since X and all the xf86-video-foo drivers
have been supporting dri2_minor >= 3 for many years.
Need to check the exact dates/releases.
Post by Eric Engestrom
+ bool authenticated;
IIRC platform_wayland was [attempting to] do double-auth, which we
might want to untangle or at least document.

-Emil
Loading...