From b7a01928beda1f9ada42e6a32c5d8ab0400d1069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kristian=20H=C3=B8gsberg?= Date: Sat, 8 Nov 2008 15:39:41 -0500 Subject: [PATCH] Add prototypes warnings, use -fvisibility. --- Makefile | 2 +- egl-compositor.c | 2 +- event-loop.c | 14 +++++++------- glx-compositor.c | 2 +- wayland-client.c | 37 +++++++++++++++++++++---------------- wayland-client.h | 7 +++++++ wayland.c | 40 +++++++++++++++------------------------- wayland.h | 22 ++++++++++++++++++++++ window.c | 8 ++++---- 9 files changed, 79 insertions(+), 55 deletions(-) diff --git a/Makefile b/Makefile index 05f72296..68da5f69 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -CFLAGS = -Wall -g +CFLAGS = -Wall -g -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden PKG_CONFIG_PATH ?= $(HOME)/install/lib/pkgconfig diff --git a/egl-compositor.c b/egl-compositor.c index b4c56306..2f65f9e3 100644 --- a/egl-compositor.c +++ b/egl-compositor.c @@ -226,7 +226,7 @@ static const struct wl_compositor_interface interface = { static const char gem_device[] = "/dev/dri/card0"; -struct wl_compositor * +WL_EXPORT struct wl_compositor * wl_compositor_create(struct wl_display *display) { EGLConfig configs[64]; diff --git a/event-loop.c b/event-loop.c index 40f1c86a..bef1d35a 100644 --- a/event-loop.c +++ b/event-loop.c @@ -21,7 +21,7 @@ struct wl_event_source { void *data; }; -struct wl_event_source * +WL_EXPORT struct wl_event_source * wl_event_loop_add_fd(struct wl_event_loop *loop, int fd, uint32_t mask, wl_event_loop_fd_func_t func, @@ -55,7 +55,7 @@ wl_event_loop_add_fd(struct wl_event_loop *loop, struct wl_event_source idle_source; -int +WL_EXPORT int wl_event_loop_remove_source(struct wl_event_loop *loop, struct wl_event_source *source) { @@ -72,7 +72,7 @@ wl_event_loop_remove_source(struct wl_event_loop *loop, }; } -int +WL_EXPORT int wl_event_loop_update_source(struct wl_event_loop *loop, struct wl_event_source *source, uint32_t mask) @@ -90,7 +90,7 @@ wl_event_loop_update_source(struct wl_event_loop *loop, EPOLL_CTL_MOD, source->fd, &ep); } -struct wl_event_loop * +WL_EXPORT struct wl_event_loop * wl_event_loop_create(void) { struct wl_event_loop *loop; @@ -108,14 +108,14 @@ wl_event_loop_create(void) return loop; } -void +WL_EXPORT void wl_event_loop_destroy(struct wl_event_loop *loop) { close(loop->epoll_fd); free(loop); } -struct wl_event_source * +WL_EXPORT struct wl_event_source * wl_event_loop_add_idle(struct wl_event_loop *loop, wl_event_loop_idle_func_t func, void *data) @@ -128,7 +128,7 @@ wl_event_loop_add_idle(struct wl_event_loop *loop, #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) -int +WL_EXPORT int wl_event_loop_wait(struct wl_event_loop *loop) { struct epoll_event ep[32]; diff --git a/glx-compositor.c b/glx-compositor.c index 2c3e7e3d..2665f819 100644 --- a/glx-compositor.c +++ b/glx-compositor.c @@ -249,7 +249,7 @@ display_data(int fd, uint32_t mask, void *data) } } -struct wl_compositor * +WL_EXPORT struct wl_compositor * wl_compositor_create(struct wl_display *display) { static int attribs[] = { diff --git a/wayland-client.c b/wayland-client.c index 005954b8..3e9ed424 100644 --- a/wayland-client.c +++ b/wayland-client.c @@ -52,7 +52,7 @@ connection_update(struct wl_connection *connection, return 0; } -struct wl_display * +WL_EXPORT struct wl_display * wl_display_create(const char *address) { struct wl_display *display; @@ -102,7 +102,7 @@ wl_display_create(const char *address) return display; } -void +WL_EXPORT void wl_display_destroy(struct wl_display *display) { wl_connection_destroy(display->connection); @@ -110,7 +110,7 @@ wl_display_destroy(struct wl_display *display) free(display); } -int +WL_EXPORT int wl_display_get_fd(struct wl_display *display, wl_display_update_func_t update, void *data) { @@ -134,7 +134,7 @@ handle_event(struct wl_display *display, uint32_t opcode, uint32_t size) wl_connection_consume(display->connection, size); } -void +WL_EXPORT void wl_display_iterate(struct wl_display *display, uint32_t mask) { uint32_t p[2], opcode, size; @@ -161,7 +161,7 @@ wl_display_iterate(struct wl_display *display, uint32_t mask) } } -void +WL_EXPORT void wl_display_set_event_handler(struct wl_display *display, wl_display_event_func_t handler, void *data) @@ -173,7 +173,7 @@ wl_display_set_event_handler(struct wl_display *display, #define WL_DISPLAY_CREATE_SURFACE 0 -struct wl_surface * +WL_EXPORT struct wl_surface * wl_display_create_surface(struct wl_display *display) { struct wl_surface *surface; @@ -200,7 +200,8 @@ wl_display_create_surface(struct wl_display *display) #define WL_SURFACE_COPY 3 #define WL_SURFACE_DAMAGE 4 -void wl_surface_destroy(struct wl_surface *surface) +WL_EXPORT void +wl_surface_destroy(struct wl_surface *surface) { uint32_t request[2]; @@ -211,8 +212,9 @@ void wl_surface_destroy(struct wl_surface *surface) request, sizeof request); } -void wl_surface_attach(struct wl_surface *surface, uint32_t name, - int32_t width, int32_t height, uint32_t stride) +WL_EXPORT void +wl_surface_attach(struct wl_surface *surface, uint32_t name, + int32_t width, int32_t height, uint32_t stride) { uint32_t request[6]; @@ -227,8 +229,9 @@ void wl_surface_attach(struct wl_surface *surface, uint32_t name, request, sizeof request); } -void wl_surface_map(struct wl_surface *surface, - int32_t x, int32_t y, int32_t width, int32_t height) +WL_EXPORT void +wl_surface_map(struct wl_surface *surface, + int32_t x, int32_t y, int32_t width, int32_t height) { uint32_t request[6]; @@ -243,9 +246,10 @@ void wl_surface_map(struct wl_surface *surface, request, sizeof request); } -void wl_surface_copy(struct wl_surface *surface, int32_t dst_x, int32_t dst_y, - uint32_t name, uint32_t stride, - int32_t x, int32_t y, int32_t width, int32_t height) +WL_EXPORT void +wl_surface_copy(struct wl_surface *surface, int32_t dst_x, int32_t dst_y, + uint32_t name, uint32_t stride, + int32_t x, int32_t y, int32_t width, int32_t height) { uint32_t request[10]; @@ -264,8 +268,9 @@ void wl_surface_copy(struct wl_surface *surface, int32_t dst_x, int32_t dst_y, request, sizeof request); } -void wl_surface_damage(struct wl_surface *surface, - int32_t x, int32_t y, int32_t width, int32_t height) +WL_EXPORT void +wl_surface_damage(struct wl_surface *surface, + int32_t x, int32_t y, int32_t width, int32_t height) { uint32_t request[6]; diff --git a/wayland-client.h b/wayland-client.h index d96e59c2..138b0456 100644 --- a/wayland-client.h +++ b/wayland-client.h @@ -1,6 +1,13 @@ #ifndef _WAYLAND_CLIENT_H #define _WAYLAND_CLIENT_H +/* GCC visibility */ +#if defined(__GNUC__) && __GNUC__ >= 4 +#define WL_EXPORT __attribute__ ((visibility("default"))) +#else +#define WL_EXPORT +#endif + struct wl_display; struct wl_surface; diff --git a/wayland.c b/wayland.c index 65dd870f..d2b00366 100644 --- a/wayland.c +++ b/wayland.c @@ -13,16 +13,6 @@ #include "wayland.h" #include "connection.h" -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) - - -struct wl_list { - struct wl_list *prev; - struct wl_list *next; -}; - void wl_list_init(struct wl_list *list) { list->prev = list; @@ -126,7 +116,7 @@ static const struct wl_argument attach_arguments[] = { { WL_ARGUMENT_UINT32 }, }; -void +static void wl_surface_map(struct wl_client *client, struct wl_surface *surface, int32_t x, int32_t y, int32_t width, int32_t height) { @@ -152,7 +142,7 @@ static const struct wl_argument map_arguments[] = { { WL_ARGUMENT_UINT32 }, }; -void +static void wl_surface_copy(struct wl_client *client, struct wl_surface *surface, int32_t dst_x, int32_t dst_y, uint32_t name, uint32_t stride, int32_t x, int32_t y, int32_t width, int32_t height) @@ -178,7 +168,7 @@ static const struct wl_argument copy_arguments[] = { { WL_ARGUMENT_UINT32 }, }; -void +static void wl_surface_damage(struct wl_client *client, struct wl_surface *surface, int32_t x, int32_t y, int32_t width, int32_t height) { @@ -215,7 +205,7 @@ static const struct wl_interface surface_interface = { surface_methods, }; -struct wl_surface * +static struct wl_surface * wl_surface_create(struct wl_display *display, uint32_t id) { struct wl_surface *surface; @@ -236,13 +226,13 @@ wl_surface_create(struct wl_display *display, uint32_t id) return surface; } -void +WL_EXPORT void wl_surface_set_data(struct wl_surface *surface, void *data) { surface->compositor_data = data; } -void * +WL_EXPORT void * wl_surface_get_data(struct wl_surface *surface) { return surface->compositor_data; @@ -431,7 +421,7 @@ advertise_object(struct wl_client *client, struct wl_object *object) wl_connection_write(client->connection, pad, -length & 3); } -struct wl_client * +static struct wl_client * wl_client_create(struct wl_display *display, int fd) { struct wl_client *client; @@ -548,7 +538,7 @@ wl_display_create_input_devices(struct wl_display *display) display->pointer_y = 100; } -struct wl_display * +static struct wl_display * wl_display_create(void) { struct wl_display *display; @@ -576,7 +566,7 @@ wl_display_create(void) return display; } -void +static void wl_display_send_event(struct wl_display *display, uint32_t *data, size_t size) { struct wl_client *client; @@ -649,13 +639,13 @@ wl_display_set_compositor(struct wl_display *display, display->compositor = compositor; } -struct wl_event_loop * +WL_EXPORT struct wl_event_loop * wl_display_get_event_loop(struct wl_display *display) { return display->loop; } -void +static void wl_display_run(struct wl_display *display) { while (1) @@ -683,7 +673,7 @@ socket_data(int fd, uint32_t mask, void *data) wl_client_create(display, client_fd); } -int +static int wl_display_add_socket(struct wl_display *display) { struct sockaddr_un name; @@ -718,7 +708,7 @@ struct wl_surface_iterator { uint32_t mask; }; -struct wl_surface_iterator * +WL_EXPORT struct wl_surface_iterator * wl_surface_iterator_create(struct wl_display *display, uint32_t mask) { struct wl_surface_iterator *iterator; @@ -735,7 +725,7 @@ wl_surface_iterator_create(struct wl_display *display, uint32_t mask) return iterator; } -int +WL_EXPORT int wl_surface_iterator_next(struct wl_surface_iterator *iterator, struct wl_surface **surface) { @@ -749,7 +739,7 @@ wl_surface_iterator_next(struct wl_surface_iterator *iterator, return 1; } -void +WL_EXPORT void wl_surface_iterator_destroy(struct wl_surface_iterator *iterator) { free(iterator); diff --git a/wayland.h b/wayland.h index 69128cbc..64a1c360 100644 --- a/wayland.h +++ b/wayland.h @@ -3,8 +3,28 @@ #include +/* GCC visibility */ +#if defined(__GNUC__) && __GNUC__ >= 4 +#define WL_EXPORT __attribute__ ((visibility("default"))) +#else +#define WL_EXPORT +#endif + #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0]) +#define container_of(ptr, type, member) ({ \ + const typeof( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) + +struct wl_list { + struct wl_list *prev; + struct wl_list *next; +}; + +void wl_list_init(struct wl_list *list); +void wl_list_insert(struct wl_list *list, struct wl_list *elm); +void wl_list_remove(struct wl_list *elm); + enum { WL_EVENT_READABLE = 0x01, WL_EVENT_WRITEABLE = 0x02 @@ -144,5 +164,7 @@ struct wl_compositor_interface { void wl_display_set_compositor(struct wl_display *display, struct wl_compositor *compositor); +struct wl_compositor * +wl_compositor_create(struct wl_display *display); #endif diff --git a/window.c b/window.c index b423f4ca..4ded97f3 100644 --- a/window.c +++ b/window.c @@ -197,6 +197,10 @@ draw_window(void *data) wl_surface_attach(window->surface, buffer->name, buffer->width, buffer->height, buffer->stride); + wl_surface_map(window->surface, + window->x, window->y, + buffer->width, buffer->height); + /* FIXME: Free window->buffer when we receive the ack event. */ buffer = window->egl_buffer; @@ -205,10 +209,6 @@ draw_window(void *data) buffer->name, buffer->stride, 0, 0, buffer->width, buffer->height); - wl_surface_map(window->surface, - window->x, window->y, - buffer->width, buffer->height); - window->redraw_scheduled = 0; return FALSE;