From 2688f6163f5cce95302bb40ae35ff855ee1ccb1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Wed, 21 Feb 2018 10:22:58 +0100 Subject: [PATCH 1/3] Rename _strip_path to wlr_strip_path since it's a public function --- include/render/gles2.h | 2 +- include/wlr/util/log.h | 6 +++--- util/log.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/render/gles2.h b/include/render/gles2.h index 797c5293..e015160d 100644 --- a/include/render/gles2.h +++ b/include/render/gles2.h @@ -62,7 +62,7 @@ extern const GLchar fragment_src_external[]; bool _gles2_flush_errors(const char *file, int line); #define gles2_flush_errors(...) \ - _gles2_flush_errors(_strip_path(__FILE__), __LINE__) + _gles2_flush_errors(wlr_strip_path(__FILE__), __LINE__) #define GL_CALL(func) func; gles2_flush_errors() diff --git a/include/wlr/util/log.h b/include/wlr/util/log.h index 3d3f25f9..5528664b 100644 --- a/include/wlr/util/log.h +++ b/include/wlr/util/log.h @@ -28,13 +28,13 @@ void wlr_log_init(log_importance_t verbosity, log_callback_t callback); void _wlr_log(log_importance_t verbosity, const char *format, ...) ATTRIB_PRINTF(2, 3); void _wlr_vlog(log_importance_t verbosity, const char *format, va_list args) ATTRIB_PRINTF(2, 0); -const char *_strip_path(const char *filepath); +const char *wlr_strip_path(const char *filepath); #define wlr_log(verb, fmt, ...) \ - _wlr_log(verb, "[%s:%d] " fmt, _strip_path(__FILE__), __LINE__, ##__VA_ARGS__) + _wlr_log(verb, "[%s:%d] " fmt, wlr_strip_path(__FILE__), __LINE__, ##__VA_ARGS__) #define wlr_vlog(verb, fmt, args) \ - _wlr_vlog(verb, "[%s:%d] " fmt, _strip_path(__FILE__), __LINE__, args) + _wlr_vlog(verb, "[%s:%d] " fmt, wlr_strip_path(__FILE__), __LINE__, args) #define wlr_log_errno(verb, fmt, ...) \ wlr_log(verb, fmt ": %s", ##__VA_ARGS__, strerror(errno)) diff --git a/util/log.c b/util/log.c index 327402e6..2adcae2d 100644 --- a/util/log.c +++ b/util/log.c @@ -73,7 +73,7 @@ void _wlr_log(log_importance_t verbosity, const char *fmt, ...) { // e.g. '/src/build/wlroots/backend/wayland/backend.c' and // '../backend/wayland/backend.c' will both be stripped to // 'backend/wayland/backend.c' -const char *_strip_path(const char *filepath) { +const char *wlr_strip_path(const char *filepath) { static int srclen = sizeof(WLR_SRC_DIR); if (strstr(filepath, WLR_SRC_DIR) == filepath) { filepath += srclen; From b13f9fcfdee3028e8966a45295c12c818f9bc4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Thu, 22 Feb 2018 12:04:32 +0100 Subject: [PATCH 2/3] Don't use os_create_anonymous_file outside of wlroots Use a stripped down version for the backing file in the screenshot example. --- examples/screenshot.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/examples/screenshot.c b/examples/screenshot.c index c163df75..7edb7327 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -121,12 +121,32 @@ static const struct wl_registry_listener registry_listener = { .global_remove = handle_global_remove, }; +static int backingfile(off_t size) { + static char template[] = "/tmp/wlroots-shared-XXXXXX"; + int fd, ret; + + fd = mkstemp(template); + if (fd < 0) { + return -1; + } + + while ((ret = ftruncate(fd, size)) == EINTR) {} + if (ret < 0) { + close(fd); + return -1; + } + + unlink(template); + return fd; +} + + static struct wl_buffer *create_shm_buffer(int width, int height, void **data_out) { int stride = width * 4; int size = stride * height; - int fd = os_create_anonymous_file(size); + int fd = backingfile(size); if (fd < 0) { fprintf(stderr, "creating a buffer file for %d B failed: %m\n", size); return NULL; From 6ba1128a72c3779affd82719a19be643a33490a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Guido=20G=C3=BCnther?= Date: Tue, 20 Feb 2018 08:06:51 +0100 Subject: [PATCH 3/3] Add symbols file to only export symbols matching wlr_* from the wlroots library --- meson.build | 3 +++ wlroots.syms | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 wlroots.syms diff --git a/meson.build b/meson.build index 2fc78d33..d5ae7863 100644 --- a/meson.build +++ b/meson.build @@ -140,6 +140,8 @@ wlr_deps += [ math, ] +symbols_file = 'wlroots.syms' +symbols_flag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), symbols_file) lib_wlr = library( meson.project_name(), version: '.'.join(so_version), @@ -147,6 +149,7 @@ lib_wlr = library( dependencies: wlr_deps, include_directories: wlr_inc, install: true, + link_args : symbols_flag, ) wlroots = declare_dependency( diff --git a/wlroots.syms b/wlroots.syms new file mode 100644 index 00000000..93d6fe51 --- /dev/null +++ b/wlroots.syms @@ -0,0 +1,49 @@ +WLROOTS_0_0_0 { + global: + wlr_*; + _wlr_log; + local: + wlr_data_device_keyboard_drag_interface; + wlr_data_device_pointer_drag_interface; + wlr_data_device_touch_drag_interface; + wlr_drm_backend_get_session; + wlr_drm_check_features; + wlr_drm_connector_cleanup; + wlr_drm_connector_start_renderer; + wlr_drm_event; + wlr_drm_get_connector_props; + wlr_drm_get_crtc_props; + wlr_drm_get_plane_props; + wlr_drm_get_prop; + wlr_drm_get_prop_blob; + wlr_drm_plane_surfaces_init; + wlr_drm_renderer_finish; + wlr_drm_renderer_init; + wlr_drm_resources_free; + wlr_drm_resources_init; + wlr_drm_restore_outputs; + wlr_drm_scan_connectors; + wlr_drm_surface_finish; + wlr_drm_surface_get_front; + wlr_drm_surface_init; + wlr_drm_surface_make_current; + wlr_drm_surface_mgpu_copy; + wlr_drm_surface_post; + wlr_drm_surface_swap_buffers; + wlr_egl_get_buffer_age; + wlr_libinput_event; + wlr_libinput_keyboard_create; + wlr_libinput_pointer_create; + wlr_libinput_tablet_pad_create; + wlr_libinput_tablet_tool_create; + wlr_libinput_touch_create; + wlr_log_stderr; + wlr_signal_emit_safe; + wlr_subsurface_destroy; + wlr_wl_output_for_surface; + wlr_wl_output_layout_get_box; + wlr_wl_output_move_cursor; + wlr_wl_output_update_cursor; + wlr_wl_registry_poll; + *; +};