Add prototypes warnings, use -fvisibility.

dev
Kristian Høgsberg 16 years ago
parent f099fd24a3
commit b7a01928be
  1. 2
      Makefile
  2. 2
      egl-compositor.c
  3. 14
      event-loop.c
  4. 2
      glx-compositor.c
  5. 37
      wayland-client.c
  6. 7
      wayland-client.h
  7. 40
      wayland.c
  8. 22
      wayland.h
  9. 8
      window.c

@ -1,4 +1,4 @@
CFLAGS = -Wall -g CFLAGS = -Wall -g -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden
PKG_CONFIG_PATH ?= $(HOME)/install/lib/pkgconfig PKG_CONFIG_PATH ?= $(HOME)/install/lib/pkgconfig

@ -226,7 +226,7 @@ static const struct wl_compositor_interface interface = {
static const char gem_device[] = "/dev/dri/card0"; static const char gem_device[] = "/dev/dri/card0";
struct wl_compositor * WL_EXPORT struct wl_compositor *
wl_compositor_create(struct wl_display *display) wl_compositor_create(struct wl_display *display)
{ {
EGLConfig configs[64]; EGLConfig configs[64];

@ -21,7 +21,7 @@ struct wl_event_source {
void *data; void *data;
}; };
struct wl_event_source * WL_EXPORT struct wl_event_source *
wl_event_loop_add_fd(struct wl_event_loop *loop, wl_event_loop_add_fd(struct wl_event_loop *loop,
int fd, uint32_t mask, int fd, uint32_t mask,
wl_event_loop_fd_func_t func, 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; struct wl_event_source idle_source;
int WL_EXPORT int
wl_event_loop_remove_source(struct wl_event_loop *loop, wl_event_loop_remove_source(struct wl_event_loop *loop,
struct wl_event_source *source) 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, wl_event_loop_update_source(struct wl_event_loop *loop,
struct wl_event_source *source, struct wl_event_source *source,
uint32_t mask) uint32_t mask)
@ -90,7 +90,7 @@ wl_event_loop_update_source(struct wl_event_loop *loop,
EPOLL_CTL_MOD, source->fd, &ep); EPOLL_CTL_MOD, source->fd, &ep);
} }
struct wl_event_loop * WL_EXPORT struct wl_event_loop *
wl_event_loop_create(void) wl_event_loop_create(void)
{ {
struct wl_event_loop *loop; struct wl_event_loop *loop;
@ -108,14 +108,14 @@ wl_event_loop_create(void)
return loop; return loop;
} }
void WL_EXPORT void
wl_event_loop_destroy(struct wl_event_loop *loop) wl_event_loop_destroy(struct wl_event_loop *loop)
{ {
close(loop->epoll_fd); close(loop->epoll_fd);
free(loop); 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_add_idle(struct wl_event_loop *loop,
wl_event_loop_idle_func_t func, wl_event_loop_idle_func_t func,
void *data) 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]) #define ARRAY_LENGTH(a) (sizeof (a) / sizeof (a)[0])
int WL_EXPORT int
wl_event_loop_wait(struct wl_event_loop *loop) wl_event_loop_wait(struct wl_event_loop *loop)
{ {
struct epoll_event ep[32]; struct epoll_event ep[32];

@ -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) wl_compositor_create(struct wl_display *display)
{ {
static int attribs[] = { static int attribs[] = {

@ -52,7 +52,7 @@ connection_update(struct wl_connection *connection,
return 0; return 0;
} }
struct wl_display * WL_EXPORT struct wl_display *
wl_display_create(const char *address) wl_display_create(const char *address)
{ {
struct wl_display *display; struct wl_display *display;
@ -102,7 +102,7 @@ wl_display_create(const char *address)
return display; return display;
} }
void WL_EXPORT void
wl_display_destroy(struct wl_display *display) wl_display_destroy(struct wl_display *display)
{ {
wl_connection_destroy(display->connection); wl_connection_destroy(display->connection);
@ -110,7 +110,7 @@ wl_display_destroy(struct wl_display *display)
free(display); free(display);
} }
int WL_EXPORT int
wl_display_get_fd(struct wl_display *display, wl_display_get_fd(struct wl_display *display,
wl_display_update_func_t update, void *data) 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); wl_connection_consume(display->connection, size);
} }
void WL_EXPORT void
wl_display_iterate(struct wl_display *display, uint32_t mask) wl_display_iterate(struct wl_display *display, uint32_t mask)
{ {
uint32_t p[2], opcode, size; 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_set_event_handler(struct wl_display *display,
wl_display_event_func_t handler, wl_display_event_func_t handler,
void *data) void *data)
@ -173,7 +173,7 @@ wl_display_set_event_handler(struct wl_display *display,
#define WL_DISPLAY_CREATE_SURFACE 0 #define WL_DISPLAY_CREATE_SURFACE 0
struct wl_surface * WL_EXPORT struct wl_surface *
wl_display_create_surface(struct wl_display *display) wl_display_create_surface(struct wl_display *display)
{ {
struct wl_surface *surface; struct wl_surface *surface;
@ -200,7 +200,8 @@ wl_display_create_surface(struct wl_display *display)
#define WL_SURFACE_COPY 3 #define WL_SURFACE_COPY 3
#define WL_SURFACE_DAMAGE 4 #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]; uint32_t request[2];
@ -211,8 +212,9 @@ void wl_surface_destroy(struct wl_surface *surface)
request, sizeof request); request, sizeof request);
} }
void wl_surface_attach(struct wl_surface *surface, uint32_t name, WL_EXPORT void
int32_t width, int32_t height, uint32_t stride) wl_surface_attach(struct wl_surface *surface, uint32_t name,
int32_t width, int32_t height, uint32_t stride)
{ {
uint32_t request[6]; uint32_t request[6];
@ -227,8 +229,9 @@ void wl_surface_attach(struct wl_surface *surface, uint32_t name,
request, sizeof request); request, sizeof request);
} }
void wl_surface_map(struct wl_surface *surface, WL_EXPORT void
int32_t x, int32_t y, int32_t width, int32_t height) wl_surface_map(struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height)
{ {
uint32_t request[6]; uint32_t request[6];
@ -243,9 +246,10 @@ void wl_surface_map(struct wl_surface *surface,
request, sizeof request); request, sizeof request);
} }
void wl_surface_copy(struct wl_surface *surface, int32_t dst_x, int32_t dst_y, WL_EXPORT void
uint32_t name, uint32_t stride, wl_surface_copy(struct wl_surface *surface, int32_t dst_x, int32_t dst_y,
int32_t x, int32_t y, int32_t width, int32_t height) uint32_t name, uint32_t stride,
int32_t x, int32_t y, int32_t width, int32_t height)
{ {
uint32_t request[10]; 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); request, sizeof request);
} }
void wl_surface_damage(struct wl_surface *surface, WL_EXPORT void
int32_t x, int32_t y, int32_t width, int32_t height) wl_surface_damage(struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height)
{ {
uint32_t request[6]; uint32_t request[6];

@ -1,6 +1,13 @@
#ifndef _WAYLAND_CLIENT_H #ifndef _WAYLAND_CLIENT_H
#define _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_display;
struct wl_surface; struct wl_surface;

@ -13,16 +13,6 @@
#include "wayland.h" #include "wayland.h"
#include "connection.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) void wl_list_init(struct wl_list *list)
{ {
list->prev = list; list->prev = list;
@ -126,7 +116,7 @@ static const struct wl_argument attach_arguments[] = {
{ WL_ARGUMENT_UINT32 }, { WL_ARGUMENT_UINT32 },
}; };
void static void
wl_surface_map(struct wl_client *client, struct wl_surface *surface, wl_surface_map(struct wl_client *client, struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height) 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 }, { WL_ARGUMENT_UINT32 },
}; };
void static void
wl_surface_copy(struct wl_client *client, struct wl_surface *surface, 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 dst_x, int32_t dst_y, uint32_t name, uint32_t stride,
int32_t x, int32_t y, int32_t width, int32_t height) 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 }, { WL_ARGUMENT_UINT32 },
}; };
void static void
wl_surface_damage(struct wl_client *client, struct wl_surface *surface, wl_surface_damage(struct wl_client *client, struct wl_surface *surface,
int32_t x, int32_t y, int32_t width, int32_t height) 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, surface_methods,
}; };
struct wl_surface * static struct wl_surface *
wl_surface_create(struct wl_display *display, uint32_t id) wl_surface_create(struct wl_display *display, uint32_t id)
{ {
struct wl_surface *surface; struct wl_surface *surface;
@ -236,13 +226,13 @@ wl_surface_create(struct wl_display *display, uint32_t id)
return surface; return surface;
} }
void WL_EXPORT void
wl_surface_set_data(struct wl_surface *surface, void *data) wl_surface_set_data(struct wl_surface *surface, void *data)
{ {
surface->compositor_data = data; surface->compositor_data = data;
} }
void * WL_EXPORT void *
wl_surface_get_data(struct wl_surface *surface) wl_surface_get_data(struct wl_surface *surface)
{ {
return surface->compositor_data; 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); wl_connection_write(client->connection, pad, -length & 3);
} }
struct wl_client * static struct wl_client *
wl_client_create(struct wl_display *display, int fd) wl_client_create(struct wl_display *display, int fd)
{ {
struct wl_client *client; struct wl_client *client;
@ -548,7 +538,7 @@ wl_display_create_input_devices(struct wl_display *display)
display->pointer_y = 100; display->pointer_y = 100;
} }
struct wl_display * static struct wl_display *
wl_display_create(void) wl_display_create(void)
{ {
struct wl_display *display; struct wl_display *display;
@ -576,7 +566,7 @@ wl_display_create(void)
return display; return display;
} }
void static void
wl_display_send_event(struct wl_display *display, uint32_t *data, size_t size) wl_display_send_event(struct wl_display *display, uint32_t *data, size_t size)
{ {
struct wl_client *client; struct wl_client *client;
@ -649,13 +639,13 @@ wl_display_set_compositor(struct wl_display *display,
display->compositor = compositor; display->compositor = compositor;
} }
struct wl_event_loop * WL_EXPORT struct wl_event_loop *
wl_display_get_event_loop(struct wl_display *display) wl_display_get_event_loop(struct wl_display *display)
{ {
return display->loop; return display->loop;
} }
void static void
wl_display_run(struct wl_display *display) wl_display_run(struct wl_display *display)
{ {
while (1) while (1)
@ -683,7 +673,7 @@ socket_data(int fd, uint32_t mask, void *data)
wl_client_create(display, client_fd); wl_client_create(display, client_fd);
} }
int static int
wl_display_add_socket(struct wl_display *display) wl_display_add_socket(struct wl_display *display)
{ {
struct sockaddr_un name; struct sockaddr_un name;
@ -718,7 +708,7 @@ struct wl_surface_iterator {
uint32_t mask; uint32_t mask;
}; };
struct wl_surface_iterator * WL_EXPORT struct wl_surface_iterator *
wl_surface_iterator_create(struct wl_display *display, uint32_t mask) wl_surface_iterator_create(struct wl_display *display, uint32_t mask)
{ {
struct wl_surface_iterator *iterator; struct wl_surface_iterator *iterator;
@ -735,7 +725,7 @@ wl_surface_iterator_create(struct wl_display *display, uint32_t mask)
return iterator; return iterator;
} }
int WL_EXPORT int
wl_surface_iterator_next(struct wl_surface_iterator *iterator, wl_surface_iterator_next(struct wl_surface_iterator *iterator,
struct wl_surface **surface) struct wl_surface **surface)
{ {
@ -749,7 +739,7 @@ wl_surface_iterator_next(struct wl_surface_iterator *iterator,
return 1; return 1;
} }
void WL_EXPORT void
wl_surface_iterator_destroy(struct wl_surface_iterator *iterator) wl_surface_iterator_destroy(struct wl_surface_iterator *iterator)
{ {
free(iterator); free(iterator);

@ -3,8 +3,28 @@
#include <stdint.h> #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 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 { enum {
WL_EVENT_READABLE = 0x01, WL_EVENT_READABLE = 0x01,
WL_EVENT_WRITEABLE = 0x02 WL_EVENT_WRITEABLE = 0x02
@ -144,5 +164,7 @@ struct wl_compositor_interface {
void wl_display_set_compositor(struct wl_display *display, void wl_display_set_compositor(struct wl_display *display,
struct wl_compositor *compositor); struct wl_compositor *compositor);
struct wl_compositor *
wl_compositor_create(struct wl_display *display);
#endif #endif

@ -197,6 +197,10 @@ draw_window(void *data)
wl_surface_attach(window->surface, buffer->name, wl_surface_attach(window->surface, buffer->name,
buffer->width, buffer->height, buffer->stride); 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. */ /* FIXME: Free window->buffer when we receive the ack event. */
buffer = window->egl_buffer; buffer = window->egl_buffer;
@ -205,10 +209,6 @@ draw_window(void *data)
buffer->name, buffer->stride, buffer->name, buffer->stride,
0, 0, buffer->width, buffer->height); 0, 0, buffer->width, buffer->height);
wl_surface_map(window->surface,
window->x, window->y,
buffer->width, buffer->height);
window->redraw_scheduled = 0; window->redraw_scheduled = 0;
return FALSE; return FALSE;

Loading…
Cancel
Save