Re: [PATCH] wayland: use wl_log instead of printf
Anyone has any further comment on this? On Sep 13, 2013 10:47 PM, Jason Ekstrand ja...@jlekstrand.net wrote: I think this is probably pretty good. most of those just look like the programmer being lazy and not remembering wl_log exists. We may want to keep it as printf in the cases where it immediately aborts or calls assert(0). That way it guarantees a message gets printed in the case where it causes the program to die. That said, we may want to make another log function called wl_error or wl_fatal for actual fatal errors that internally does an assert(0). If we did add such a function it might want to have it's own log handler. Kristian, Do you have any thoughts? Thanks, --Jason Ekstrand On Sep 12, 2013 9:36 PM, Chang Liu cl9...@gmail.com wrote: use wl_log instead of printf and fprintf in core library --- I'm pretty sure these printf usages should be avoided since libraries should not print to stdout. But I'm not sure if there is any reason for favoring a fprintf to stderr over wl_log. Please enlighten me if there is any. src/connection.c | 36 ++-- src/event-loop.c | 8 src/wayland-client.c | 14 ++ 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/connection.c b/src/connection.c index 451b93e..40b7fbd 100644 --- a/src/connection.c +++ b/src/connection.c @@ -512,7 +512,7 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode, count = arg_count_for_signature(message-signature); if (count WL_CLOSURE_MAX_ARGS) { - printf(too many args (%d)\n, count); + wl_log(too many args (%d)\n, count); errno = EINVAL; return NULL; } @@ -557,14 +557,14 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode, fd = args[i].h; dup_fd = wl_os_dupfd_cloexec(fd, 0); if (dup_fd 0) { - fprintf(stderr, dup failed: %m); + wl_log(dup failed: %m); abort(); } closure-args[i].h = dup_fd; break; default: - fprintf(stderr, unhandled format code: '%c'\n, - arg.type); + wl_log(unhandled format code: '%c'\n, + arg.type); assert(0); break; } @@ -615,7 +615,7 @@ wl_connection_demarshal(struct wl_connection *connection, count = arg_count_for_signature(message-signature); if (count WL_CLOSURE_MAX_ARGS) { - printf(too many args (%d)\n, count); + wl_log(too many args (%d)\n, count); errno = EINVAL; wl_connection_consume(connection, size); return NULL; @@ -642,7 +642,7 @@ wl_connection_demarshal(struct wl_connection *connection, signature = get_next_argument(signature, arg); if (arg.type != 'h' p + 1 end) { - printf(message too short, + wl_log(message too short, object (%d), message %s(%s)\n, *p, message-name, message-signature); errno = EINVAL; @@ -669,7 +669,7 @@ wl_connection_demarshal(struct wl_connection *connection, next = p + DIV_ROUNDUP(length, sizeof *p); if (next end) { - printf(message too short, + wl_log(message too short, object (%d), message %s(%s)\n, closure-sender_id, message-name, message-signature); @@ -680,7 +680,7 @@ wl_connection_demarshal(struct wl_connection *connection, s = (char *) p; if (length 0 s[length - 1] != '\0') { - printf(string not nul-terminated, + wl_log(string not nul-terminated, message %s(%s)\n, message-name, message-signature); errno = EINVAL; @@ -695,7 +695,7 @@ wl_connection_demarshal(struct wl_connection *connection, closure-args[i].n = id; if (id == 0 !arg.nullable) { - printf(NULL object received on non-nullable + wl_log(NULL object received on non-nullable type, message %s(%s)\n, message-name, message-signature
[PATCH] client: fix an inconsistency in documentation
The errno is set to EAGAIN when there are undispatched events, according to L1066 of wayland-client.c. --- src/wayland-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wayland-client.c b/src/wayland-client.c index 04d988b..d043459 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -1087,7 +1087,7 @@ wl_display_prepare_read_queue(struct wl_display *display, * calls wl_display_read_events(), no other thread will read from the * file descriptor. This only succeeds if the event queue is empty * though, and if there are undispatched events in the queue, -1 is - * returned and errno set to EBUSY. + * returned and errno set to EAGAIN. * * If a thread successfully calls wl_display_prepare_read(), it must * either call wl_display_read_events() when it's ready or cancel the -- 1.8.3.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH] client: fix an inconsistency in documentation
The errno is set to EAGAIN when there are undispatched events, according to L1066 of wayland-client.c. --- src/wayland-client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wayland-client.c b/src/wayland-client.c index 04d988b..d043459 100644 --- a/src/wayland-client.c +++ b/src/wayland-client.c @@ -1087,7 +1087,7 @@ wl_display_prepare_read_queue(struct wl_display *display, * calls wl_display_read_events(), no other thread will read from the * file descriptor. This only succeeds if the event queue is empty * though, and if there are undispatched events in the queue, -1 is - * returned and errno set to EBUSY. + * returned and errno set to EAGAIN. * * If a thread successfully calls wl_display_prepare_read(), it must * either call wl_display_read_events() when it's ready or cancel the -- 1.8.3.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH] protocol: fix an extra underscore
remove the unnecessary extra underscore in the name of the argument of wl_shell_surface::set_class --- The identifier class_ only appears in the generated code, in function declarations. Changing it shouldn't cause any backward incompatibilities. protocol/wayland.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protocol/wayland.xml b/protocol/wayland.xml index aeb0412..28caf61 100644 --- a/protocol/wayland.xml +++ b/protocol/wayland.xml @@ -913,7 +913,7 @@ file name (or the full path if it is a non-standard location) of the application's .desktop file as the class. /description - arg name=class_ type=string/ + arg name=class type=string/ /request event name=ping -- 1.8.3.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH] wayland: use wl_log instead of printf
use wl_log instead of printf and fprintf in core library --- I'm pretty sure these printf usages should be avoided since libraries should not print to stdout. But I'm not sure if there is any reason for favoring a fprintf to stderr over wl_log. Please enlighten me if there is any. src/connection.c | 36 ++-- src/event-loop.c | 8 src/wayland-client.c | 14 ++ 3 files changed, 28 insertions(+), 30 deletions(-) diff --git a/src/connection.c b/src/connection.c index 451b93e..40b7fbd 100644 --- a/src/connection.c +++ b/src/connection.c @@ -512,7 +512,7 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode, count = arg_count_for_signature(message-signature); if (count WL_CLOSURE_MAX_ARGS) { - printf(too many args (%d)\n, count); + wl_log(too many args (%d)\n, count); errno = EINVAL; return NULL; } @@ -557,14 +557,14 @@ wl_closure_marshal(struct wl_object *sender, uint32_t opcode, fd = args[i].h; dup_fd = wl_os_dupfd_cloexec(fd, 0); if (dup_fd 0) { - fprintf(stderr, dup failed: %m); + wl_log(dup failed: %m); abort(); } closure-args[i].h = dup_fd; break; default: - fprintf(stderr, unhandled format code: '%c'\n, - arg.type); + wl_log(unhandled format code: '%c'\n, + arg.type); assert(0); break; } @@ -615,7 +615,7 @@ wl_connection_demarshal(struct wl_connection *connection, count = arg_count_for_signature(message-signature); if (count WL_CLOSURE_MAX_ARGS) { - printf(too many args (%d)\n, count); + wl_log(too many args (%d)\n, count); errno = EINVAL; wl_connection_consume(connection, size); return NULL; @@ -642,7 +642,7 @@ wl_connection_demarshal(struct wl_connection *connection, signature = get_next_argument(signature, arg); if (arg.type != 'h' p + 1 end) { - printf(message too short, + wl_log(message too short, object (%d), message %s(%s)\n, *p, message-name, message-signature); errno = EINVAL; @@ -669,7 +669,7 @@ wl_connection_demarshal(struct wl_connection *connection, next = p + DIV_ROUNDUP(length, sizeof *p); if (next end) { - printf(message too short, + wl_log(message too short, object (%d), message %s(%s)\n, closure-sender_id, message-name, message-signature); @@ -680,7 +680,7 @@ wl_connection_demarshal(struct wl_connection *connection, s = (char *) p; if (length 0 s[length - 1] != '\0') { - printf(string not nul-terminated, + wl_log(string not nul-terminated, message %s(%s)\n, message-name, message-signature); errno = EINVAL; @@ -695,7 +695,7 @@ wl_connection_demarshal(struct wl_connection *connection, closure-args[i].n = id; if (id == 0 !arg.nullable) { - printf(NULL object received on non-nullable + wl_log(NULL object received on non-nullable type, message %s(%s)\n, message-name, message-signature); errno = EINVAL; @@ -707,7 +707,7 @@ wl_connection_demarshal(struct wl_connection *connection, closure-args[i].n = id; if (id == 0 !arg.nullable) { - printf(NULL new ID received on non-nullable + wl_log(NULL new ID received on non-nullable type, message %s(%s)\n, message-name, message-signature); errno = EINVAL; @@ -715,7 +715,7 @@ wl_connection_demarshal(struct wl_connection *connection, } if (wl_map_reserve_new(objects, id) 0) { - printf(not a valid new object id (%d), + wl_log(not a
[PATCH] wayland-util: fix wrap-back of wl_map-free_list when client id = 0x80000000
The current implementation of wl_map uses uint32_t for free_list. When removing client id = 0x8000, shifting said id by 1 bit left will cause free_list to wrap back to 0x0. Bump both wl_map-free_list and union_entry-next to uint64_t to fix this problem. --- The relavent lines are: In wl_map_remove: start[i].next = map-free_list; map-free_list = (i 1) | 1; If we are removing a client id i = 0x8000, the MSB of i will be lost when we perform i 1, and this causes free_list to wrap back to 0x0. In wl_map_insert_new: if (map-free_list) { entry = start[map-free_list 1]; map-free_list = entry-next; } With free_list wrapped back to 0x0, we are longer able to recover the missing MSB in the client id even if we perform a right-shift to free_list. src/wayland-private.h | 2 +- src/wayland-util.c| 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/wayland-private.h b/src/wayland-private.h index 67e8783..5b3715d 100644 --- a/src/wayland-private.h +++ b/src/wayland-private.h @@ -63,7 +63,7 @@ struct wl_map { struct wl_array client_entries; struct wl_array server_entries; uint32_t side; - uint32_t free_list; + uint64_t free_list; }; typedef void (*wl_iterator_func_t)(void *element, void *data); diff --git a/src/wayland-util.c b/src/wayland-util.c index 4fe9c81..1798fd6 100644 --- a/src/wayland-util.c +++ b/src/wayland-util.c @@ -149,12 +149,12 @@ wl_array_copy(struct wl_array *array, struct wl_array *source) } union map_entry { - uintptr_t next; + uint64_t next; void *data; }; #define map_entry_is_free(entry) ((entry).next 0x1) -#define map_entry_get_data(entry) ((void *)((entry).next ~(uintptr_t)0x3)) +#define map_entry_get_data(entry) ((void *)((entry).next ~0x3)) #define map_entry_get_flags(entry) (((entry).next 1) 0x1) WL_EXPORT void @@ -291,7 +291,7 @@ wl_map_remove(struct wl_map *map, uint32_t i) start = entries-data; start[i].next = map-free_list; - map-free_list = (i 1) | 1; + map-free_list = ((uint64_t)i 1) | 1; } WL_EXPORT void * -- 1.8.3.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH] wayland-util: merge {client, server}_entries in wl_map into one variable
Since a wl_map can be either client side or server side (but not both) and we have the side field to indicate this, we can merge client_entries and server_entries into one variable to reduce clutter. --- src/wayland-private.h | 3 +-- src/wayland-util.c| 43 +++ 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/wayland-private.h b/src/wayland-private.h index 5b3715d..68f4ee4 100644 --- a/src/wayland-private.h +++ b/src/wayland-private.h @@ -60,8 +60,7 @@ enum wl_map_entry_flags { }; struct wl_map { - struct wl_array client_entries; - struct wl_array server_entries; + struct wl_array entries; uint32_t side; uint64_t free_list; }; diff --git a/src/wayland-util.c b/src/wayland-util.c index 1798fd6..2fc8b17 100644 --- a/src/wayland-util.c +++ b/src/wayland-util.c @@ -167,22 +167,19 @@ wl_map_init(struct wl_map *map, uint32_t side) WL_EXPORT void wl_map_release(struct wl_map *map) { - wl_array_release(map-client_entries); - wl_array_release(map-server_entries); + wl_array_release(map-entries); } WL_EXPORT uint32_t wl_map_insert_new(struct wl_map *map, uint32_t flags, void *data) { union map_entry *start, *entry; - struct wl_array *entries; + struct wl_array *entries = map-entries; uint32_t base; if (map-side == WL_MAP_CLIENT_SIDE) { - entries = map-client_entries; base = 0; } else { - entries = map-server_entries; base = WL_SERVER_ID_START; } @@ -208,12 +205,9 @@ wl_map_insert_at(struct wl_map *map, uint32_t flags, uint32_t i, void *data) { union map_entry *start; uint32_t count; - struct wl_array *entries; + struct wl_array *entries = map-entries; - if (i WL_SERVER_ID_START) { - entries = map-client_entries; - } else { - entries = map-server_entries; + if (i = WL_SERVER_ID_START) { i -= WL_SERVER_ID_START; } @@ -236,18 +230,14 @@ wl_map_reserve_new(struct wl_map *map, uint32_t i) { union map_entry *start; uint32_t count; - struct wl_array *entries; + struct wl_array *entries = map-entries; if (i WL_SERVER_ID_START) { if (map-side == WL_MAP_CLIENT_SIDE) return -1; - - entries = map-client_entries; } else { if (map-side == WL_MAP_SERVER_SIDE) return -1; - - entries = map-server_entries; i -= WL_SERVER_ID_START; } @@ -274,18 +264,14 @@ WL_EXPORT void wl_map_remove(struct wl_map *map, uint32_t i) { union map_entry *start; - struct wl_array *entries; + struct wl_array *entries = map-entries; if (i WL_SERVER_ID_START) { if (map-side == WL_MAP_SERVER_SIDE) return; - - entries = map-client_entries; } else { if (map-side == WL_MAP_CLIENT_SIDE) return; - - entries = map-server_entries; i -= WL_SERVER_ID_START; } @@ -299,12 +285,9 @@ wl_map_lookup(struct wl_map *map, uint32_t i) { union map_entry *start; uint32_t count; - struct wl_array *entries; + struct wl_array *entries = map-entries; - if (i WL_SERVER_ID_START) { - entries = map-client_entries; - } else { - entries = map-server_entries; + if (i = WL_SERVER_ID_START) { i -= WL_SERVER_ID_START; } @@ -322,12 +305,9 @@ wl_map_lookup_flags(struct wl_map *map, uint32_t i) { union map_entry *start; uint32_t count; - struct wl_array *entries; + struct wl_array *entries = map-entries; - if (i WL_SERVER_ID_START) { - entries = map-client_entries; - } else { - entries = map-server_entries; + if (i = WL_SERVER_ID_START) { i -= WL_SERVER_ID_START; } @@ -356,8 +336,7 @@ for_each_helper(struct wl_array *entries, wl_iterator_func_t func, void *data) WL_EXPORT void wl_map_for_each(struct wl_map *map, wl_iterator_func_t func, void *data) { - for_each_helper(map-client_entries, func, data); - for_each_helper(map-server_entries, func, data); + for_each_helper(map-entries, func, data); } static void -- 1.8.3.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
[PATCH] gitignore: add ./compile
./compile is a GNU autotools helper script and should be ignored by git --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 99b7089..f243100 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,7 @@ ctags /aclocal.m4 /wayland-scanner.m4 /autom4te.cache +/compile /config.guess /config.h /config.h.in -- 1.8.3.4 ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel
Re: Midori browser should now work on Wayland
Sorry I CC'ed wayland-devel-request. I have to resend the mail. I tried this morning. Midori crashed on start. Both midori and libunique are latest git version. Backtrace: Launching command: '/usr/bin/gdb' --batch -ex 'set print thread-events off' -ex run -ex 'set logging on /run/user/1000/midori/gdb.bt' -ex 'bt' --return-child-result --args midori [Thread debugging using libthread_db enabled] Using host libthread_db library /usr/lib/libthread_db.so.1. Program received signal SIGSEGV, Segmentation fault. slowly_and_stupidly_obtain_ timestamp (display=display@entry=0x71a060) at ./uniqueapp.c:129 129 xwindow = XCreateWindow (xdisplay, RootWindow (xdisplay, 0), #0 slowly_and_stupidly_obtain_timestamp (display=display@entry=0x71a060) at ./uniqueapp.c:129 #1 0x773870b8 in set_startup_id (startup_id=optimized out, backend=0x71b4c0) at ./uniqueapp.c:198 #2 unique_app_set_property (gobject=0x7142d0, prop_id=optimized out, value=0x7fffdd60, pspec=0x78bcf0) at ./uniqueapp.c:300 #3 0x77ba10d2 in ?? () from /usr/lib/libgobject-2.0.so.0 #4 0x773870f8 in unique_app_constructor (gtype=7863568, n_params=3, params=0x77fd80) at ./uniqueapp.c:271 #5 0x77ba2509 in g_object_newv () from /usr/lib/libgobject-2.0.so.0 #6 0x77ba2cd6 in g_object_new_valist () from /usr/lib/libgobject-2.0.so.0 #7 0x77ba3044 in g_object_new () from /usr/lib/libgobject-2.0.so.0 #8 0x0042ccfc in midori_app_instance_is_running () #9 0x0043ffa5 in midori_normal_app_new () #10 0x0042924c in main () Looks like libunique still has reference to Xlib functions. Or am I doing things wrong? (Is there a build-time switch for libunique to change this?) 2013/4/25 dar...@chaosreigns.com: I just noticed the bug for preliminary wayland support was just closed. I haven't tried it. http://twotoasts.de/index.php/midori/ http://en.wikipedia.org/wiki/Midori_%28web_browser%29 Bug: https://bugs.launchpad.net/midori/+bug/975355 It's based on WebKitGTK+, so maybe that should work now as well? - Forwarded message - Date: Thu, 25 Apr 2013 22:16:49 - Subject: [Bug 975355] Re: Preliminary Wayland support ** Summary changed: - Wayland support + Preliminary Wayland support ** Changed in: midori Status: In Progress = Fix Released ** Changed in: midori Importance: Undecided = Low -- You received this bug notification because you are subscribed to the bug report. https://bugs.launchpad.net/bugs/975355 Title: Preliminary Wayland support Status in Midori: Webkit Web browser: Fix Released Bug description: To work with wayland, gdk_x11_ calls and Xlib calls need to be wrapped in build-time and run-time backend checks: http://developer.gnome.org/gtk3/3.3/ch24s02.html#id1502079 $ grep -r gdk_x11 . ./midori/sokoke.c:Atom save_mode_atom = gdk_x11_get_xatom_by_name_for_display ( ./midori/midori-browser.c: gdk_x11_xatom_to_atom (XA_INTEGER), $ grep -r Xlib . ./midori/main.c:#include X11/Xlib.h http://wayland.freedesktop.org/gtk.html The wayland backend in GTK+ 3.4 works, so as soon as these are done midori should be usable with wayland. To manage notifications about this bug go to: https://bugs.launchpad.net/midori/+bug/975355/+subscriptions - End forwarded message - -- Will I ever learn? I hope not, I'm having too much fun. - Brent Minime Avis, motorcycle.com http://www.ChaosReigns.com ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel ___ wayland-devel mailing list wayland-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/wayland-devel