Add prototypes warnings, use -fvisibility.
authorKristian Høgsberg <krh@redhat.com>
Sat, 8 Nov 2008 20:39:41 +0000 (15:39 -0500)
committerKristian Høgsberg <krh@redhat.com>
Sat, 8 Nov 2008 20:49:49 +0000 (15:49 -0500)
Makefile
egl-compositor.c
event-loop.c
glx-compositor.c
wayland-client.c
wayland-client.h
wayland.c
wayland.h
window.c

index 05f7229..68da5f6 100644 (file)
--- 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
 
index b4c5630..2f65f9e 100644 (file)
@@ -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];
index 40f1c86..bef1d35 100644 (file)
@@ -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];
index 2c3e7e3..2665f81 100644 (file)
@@ -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[] = {
index 005954b..3e9ed42 100644 (file)
@@ -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];
 
index d96e59c..138b045 100644 (file)
@@ -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;
 
index 65dd870..d2b0036 100644 (file)
--- a/wayland.c
+++ b/wayland.c
 #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);
index 69128cb..64a1c36 100644 (file)
--- a/wayland.h
+++ b/wayland.h
@@ -3,8 +3,28 @@
 
 #include <stdint.h>
 
+/* 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
index b423f4c..4ded97f 100644 (file)
--- 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;