Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright © 2010-2011 Benjamin Franzke |
| 3 | * Copyright © 2012 Intel Corporation |
| 4 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 5 | * Permission is hereby granted, free of charge, to any person obtaining |
| 6 | * a copy of this software and associated documentation files (the |
| 7 | * "Software"), to deal in the Software without restriction, including |
| 8 | * without limitation the rights to use, copy, modify, merge, publish, |
| 9 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 10 | * permit persons to whom the Software is furnished to do so, subject to |
| 11 | * the following conditions: |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 12 | * |
Bryce Harrington | a0bbfea | 2015-06-11 15:35:43 -0700 | [diff] [blame] | 13 | * The above copyright notice and this permission notice (including the |
| 14 | * next paragraph) shall be included in all copies or substantial |
| 15 | * portions of the Software. |
| 16 | * |
| 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 18 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 20 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
| 21 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
| 22 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
| 23 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 | * SOFTWARE. |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 25 | */ |
| 26 | |
Daniel Stone | c228e23 | 2013-05-22 18:03:19 +0300 | [diff] [blame] | 27 | #include "config.h" |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 28 | |
Jussi Kukkonen | 649bbce | 2016-07-19 14:16:27 +0300 | [diff] [blame] | 29 | #include <stdint.h> |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 30 | #include <stdlib.h> |
| 31 | #include <string.h> |
| 32 | #include <sys/time.h> |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 33 | #include <stdbool.h> |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 34 | |
| 35 | #include "compositor.h" |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 36 | #include "compositor-headless.h" |
| 37 | #include "shared/helpers.h" |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 38 | #include "pixman-renderer.h" |
Pekka Paalanen | b00c79b | 2016-02-18 16:53:27 +0200 | [diff] [blame] | 39 | #include "presentation-time-server-protocol.h" |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 40 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 41 | struct headless_backend { |
| 42 | struct weston_backend base; |
| 43 | struct weston_compositor *compositor; |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 44 | |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 45 | struct weston_seat fake_seat; |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 46 | bool use_pixman; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 47 | }; |
| 48 | |
| 49 | struct headless_output { |
| 50 | struct weston_output base; |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 51 | |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 52 | struct weston_mode mode; |
| 53 | struct wl_event_source *finish_frame_timer; |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 54 | uint32_t *image_buf; |
| 55 | pixman_image_t *image; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 56 | }; |
| 57 | |
Armin Krezović | a8fb5ea | 2016-08-01 19:17:55 +0200 | [diff] [blame^] | 58 | static inline struct headless_output * |
| 59 | to_headless_output(struct weston_output *base) |
| 60 | { |
| 61 | return container_of(base, struct headless_output, base); |
| 62 | } |
| 63 | |
| 64 | static inline struct headless_backend * |
| 65 | to_headless_backend(struct weston_compositor *base) |
| 66 | { |
| 67 | return container_of(base->backend, struct headless_backend, base); |
| 68 | } |
| 69 | |
Jonas Ådahl | e5a1225 | 2013-04-05 23:07:11 +0200 | [diff] [blame] | 70 | static void |
| 71 | headless_output_start_repaint_loop(struct weston_output *output) |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 72 | { |
Pekka Paalanen | b5eedad | 2014-09-23 22:08:45 -0400 | [diff] [blame] | 73 | struct timespec ts; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 74 | |
Pekka Paalanen | 662f384 | 2015-03-18 12:17:26 +0200 | [diff] [blame] | 75 | weston_compositor_read_presentation_clock(output->compositor, &ts); |
Pekka Paalanen | b00c79b | 2016-02-18 16:53:27 +0200 | [diff] [blame] | 76 | weston_output_finish_frame(output, &ts, WP_PRESENTATION_FEEDBACK_INVALID); |
Jonas Ådahl | e5a1225 | 2013-04-05 23:07:11 +0200 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | static int |
| 80 | finish_frame_handler(void *data) |
| 81 | { |
Pekka Paalanen | 363aa7b | 2014-12-17 16:20:40 +0200 | [diff] [blame] | 82 | struct headless_output *output = data; |
| 83 | struct timespec ts; |
| 84 | |
Pekka Paalanen | 662f384 | 2015-03-18 12:17:26 +0200 | [diff] [blame] | 85 | weston_compositor_read_presentation_clock(output->base.compositor, &ts); |
Pekka Paalanen | 363aa7b | 2014-12-17 16:20:40 +0200 | [diff] [blame] | 86 | weston_output_finish_frame(&output->base, &ts, 0); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 87 | |
| 88 | return 1; |
| 89 | } |
| 90 | |
David Herrmann | 1edf44c | 2013-10-22 17:11:26 +0200 | [diff] [blame] | 91 | static int |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 92 | headless_output_repaint(struct weston_output *output_base, |
| 93 | pixman_region32_t *damage) |
| 94 | { |
Armin Krezović | a8fb5ea | 2016-08-01 19:17:55 +0200 | [diff] [blame^] | 95 | struct headless_output *output = to_headless_output(output_base); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 96 | struct weston_compositor *ec = output->base.compositor; |
| 97 | |
| 98 | ec->renderer->repaint_output(&output->base, damage); |
| 99 | |
Ander Conselvan de Oliveira | 0a88772 | 2012-11-22 15:57:00 +0200 | [diff] [blame] | 100 | pixman_region32_subtract(&ec->primary_plane.damage, |
| 101 | &ec->primary_plane.damage, damage); |
| 102 | |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 103 | wl_event_source_timer_update(output->finish_frame_timer, 16); |
| 104 | |
David Herrmann | 1edf44c | 2013-10-22 17:11:26 +0200 | [diff] [blame] | 105 | return 0; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | static void |
| 109 | headless_output_destroy(struct weston_output *output_base) |
| 110 | { |
Armin Krezović | a8fb5ea | 2016-08-01 19:17:55 +0200 | [diff] [blame^] | 111 | struct headless_output *output = to_headless_output(output_base); |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 112 | struct headless_backend *b = |
Armin Krezović | a8fb5ea | 2016-08-01 19:17:55 +0200 | [diff] [blame^] | 113 | to_headless_backend(output->base.compositor); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 114 | |
| 115 | wl_event_source_remove(output->finish_frame_timer); |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 116 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 117 | if (b->use_pixman) { |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 118 | pixman_renderer_output_destroy(&output->base); |
| 119 | pixman_image_unref(output->image); |
| 120 | free(output->image_buf); |
| 121 | } |
| 122 | |
| 123 | weston_output_destroy(&output->base); |
| 124 | |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 125 | free(output); |
| 126 | |
| 127 | return; |
| 128 | } |
| 129 | |
| 130 | static int |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 131 | headless_backend_create_output(struct headless_backend *b, |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 132 | struct weston_headless_backend_config *config) |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 133 | { |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 134 | struct weston_compositor *c = b->compositor; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 135 | struct headless_output *output; |
| 136 | struct wl_event_loop *loop; |
| 137 | |
Peter Hutterer | f3d6227 | 2013-08-08 11:57:05 +1000 | [diff] [blame] | 138 | output = zalloc(sizeof *output); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 139 | if (output == NULL) |
| 140 | return -1; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 141 | |
| 142 | output->mode.flags = |
| 143 | WL_OUTPUT_MODE_CURRENT | WL_OUTPUT_MODE_PREFERRED; |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 144 | output->mode.width = config->width; |
| 145 | output->mode.height = config->height; |
Pekka Paalanen | 1879f21 | 2014-05-23 12:48:45 +0300 | [diff] [blame] | 146 | output->mode.refresh = 60000; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 147 | wl_list_init(&output->base.mode_list); |
| 148 | wl_list_insert(&output->base.mode_list, &output->mode.link); |
| 149 | |
Hardening | ff39efa | 2013-09-18 23:56:35 +0200 | [diff] [blame] | 150 | output->base.current_mode = &output->mode; |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 151 | weston_output_init(&output->base, c, 0, 0, config->width, |
| 152 | config->height, config->transform, 1); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 153 | |
| 154 | output->base.make = "weston"; |
| 155 | output->base.model = "headless"; |
| 156 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 157 | loop = wl_display_get_event_loop(c->wl_display); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 158 | output->finish_frame_timer = |
| 159 | wl_event_loop_add_timer(loop, finish_frame_handler, output); |
| 160 | |
Jonas Ådahl | e5a1225 | 2013-04-05 23:07:11 +0200 | [diff] [blame] | 161 | output->base.start_repaint_loop = headless_output_start_repaint_loop; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 162 | output->base.repaint = headless_output_repaint; |
| 163 | output->base.destroy = headless_output_destroy; |
| 164 | output->base.assign_planes = NULL; |
| 165 | output->base.set_backlight = NULL; |
| 166 | output->base.set_dpms = NULL; |
| 167 | output->base.switch_mode = NULL; |
| 168 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 169 | if (b->use_pixman) { |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 170 | output->image_buf = malloc(config->width * config->height * 4); |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 171 | if (!output->image_buf) |
| 172 | return -1; |
| 173 | |
| 174 | output->image = pixman_image_create_bits(PIXMAN_x8r8g8b8, |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 175 | config->width, |
| 176 | config->height, |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 177 | output->image_buf, |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 178 | config->width * 4); |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 179 | |
| 180 | if (pixman_renderer_output_create(&output->base) < 0) |
| 181 | return -1; |
| 182 | |
| 183 | pixman_renderer_output_set_buffer(&output->base, |
| 184 | output->image); |
| 185 | } |
| 186 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 187 | weston_compositor_add_output(c, &output->base); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 188 | |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | static void |
| 193 | headless_restore(struct weston_compositor *ec) |
| 194 | { |
| 195 | } |
| 196 | |
| 197 | static void |
| 198 | headless_destroy(struct weston_compositor *ec) |
| 199 | { |
Armin Krezović | a8fb5ea | 2016-08-01 19:17:55 +0200 | [diff] [blame^] | 200 | struct headless_backend *b = to_headless_backend(ec); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 201 | |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 202 | weston_compositor_shutdown(ec); |
| 203 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 204 | free(b); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 205 | } |
| 206 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 207 | static struct headless_backend * |
| 208 | headless_backend_create(struct weston_compositor *compositor, |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 209 | struct weston_headless_backend_config *config) |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 210 | { |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 211 | struct headless_backend *b; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 212 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 213 | b = zalloc(sizeof *b); |
| 214 | if (b == NULL) |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 215 | return NULL; |
| 216 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 217 | b->compositor = compositor; |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 218 | if (weston_compositor_set_presentation_clock_software(compositor) < 0) |
| 219 | goto err_free; |
Pekka Paalanen | b5eedad | 2014-09-23 22:08:45 -0400 | [diff] [blame] | 220 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 221 | b->base.destroy = headless_destroy; |
| 222 | b->base.restore = headless_restore; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 223 | |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 224 | b->use_pixman = config->use_pixman; |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 225 | if (b->use_pixman) { |
| 226 | pixman_renderer_init(compositor); |
Derek Foreman | a04e913 | 2014-11-19 15:06:17 -0800 | [diff] [blame] | 227 | } |
Armin Krezović | d84deeb | 2016-06-23 11:59:29 +0200 | [diff] [blame] | 228 | |
| 229 | if (!config->no_outputs) { |
| 230 | if (headless_backend_create_output(b, config) < 0) |
| 231 | goto err_input; |
| 232 | } |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 233 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 234 | if (!b->use_pixman && noop_renderer_init(compositor) < 0) |
Emilio Pozuelo Monfort | dd9f6bc | 2014-02-07 09:34:43 +0100 | [diff] [blame] | 235 | goto err_input; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 236 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 237 | compositor->backend = &b->base; |
| 238 | return b; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 239 | |
Emilio Pozuelo Monfort | dd9f6bc | 2014-02-07 09:34:43 +0100 | [diff] [blame] | 240 | err_input: |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 241 | weston_compositor_shutdown(compositor); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 242 | err_free: |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 243 | free(b); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 244 | return NULL; |
| 245 | } |
| 246 | |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 247 | static void |
| 248 | config_init_to_defaults(struct weston_headless_backend_config *config) |
| 249 | { |
| 250 | } |
| 251 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 252 | WL_EXPORT int |
| 253 | backend_init(struct weston_compositor *compositor, |
Giulio Camuffo | 93daabb | 2015-10-17 19:24:14 +0300 | [diff] [blame] | 254 | struct weston_backend_config *config_base) |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 255 | { |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 256 | struct headless_backend *b; |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 257 | struct weston_headless_backend_config config = {{ 0, }}; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 258 | |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 259 | if (config_base == NULL || |
| 260 | config_base->struct_version != WESTON_HEADLESS_BACKEND_CONFIG_VERSION || |
| 261 | config_base->struct_size > sizeof(struct weston_headless_backend_config)) { |
| 262 | weston_log("headless backend config structure is invalid\n"); |
| 263 | return -1; |
| 264 | } |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 265 | |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 266 | config_init_to_defaults(&config); |
| 267 | memcpy(&config, config_base, config_base->struct_size); |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 268 | |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 269 | b = headless_backend_create(compositor, &config); |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 270 | if (b == NULL) |
| 271 | return -1; |
Benoit Gschwind | 3c53094 | 2016-04-15 20:28:32 -0700 | [diff] [blame] | 272 | |
Giulio Camuffo | 954f183 | 2014-10-11 18:27:30 +0300 | [diff] [blame] | 273 | return 0; |
Ander Conselvan de Oliveira | 11f8d40 | 2012-10-29 18:19:24 +0200 | [diff] [blame] | 274 | } |