From cef6d7549131cfee7cd60ada0388a2766335c70a Mon Sep 17 00:00:00 2001 From: Moritz Date: Thu, 30 Nov 2017 15:00:36 +0100 Subject: [PATCH] Moved os-compatibility and added header * Moved os-compatibility.c to util * Added header under util * Removed static since it isn't needed (i think so) * Adjusted meson.build to include lib_wlr Improved some codestyle * Added guard to os-compatibility.h * Fixed typo in include statment Adjusted Guard * Changed guard to _WLR_UTIL_OS_COMPATIBILITY --- backend/meson.build | 1 - examples/meson.build | 3 ++- examples/screenshot.c | 2 +- include/util/os-compatibility.h | 12 ++++++++++++ util/meson.build | 1 + {backend/wayland => util}/os-compatibility.c | 16 +++++----------- 6 files changed, 21 insertions(+), 14 deletions(-) create mode 100644 include/util/os-compatibility.h rename {backend/wayland => util}/os-compatibility.c (94%) diff --git a/backend/meson.build b/backend/meson.build index 5ed7b227..c9d47317 100644 --- a/backend/meson.build +++ b/backend/meson.build @@ -21,7 +21,6 @@ backend_files = files( 'wayland/output.c', 'wayland/registry.c', 'wayland/wl_seat.c', - 'wayland/os-compatibility.c', 'x11/backend.c', ) diff --git a/examples/meson.build b/examples/meson.build index 89fc6211..af0f5a18 100644 --- a/examples/meson.build +++ b/examples/meson.build @@ -29,5 +29,6 @@ executable( executable( 'screenshot', 'screenshot.c', - dependencies: [wayland_client, wlr_protos], + dependencies: [wayland_client, wlr_protos, wlroots], + link_with: lib_shared, ) diff --git a/examples/screenshot.c b/examples/screenshot.c index fc7f3cb3..a887d1d7 100644 --- a/examples/screenshot.c +++ b/examples/screenshot.c @@ -35,7 +35,7 @@ #include #include #include -#include "../backend/wayland/os-compatibility.c" +#include "util/os-compatibility.h" static struct wl_shm *shm = NULL; static struct orbital_screenshooter *screenshooter = NULL; diff --git a/include/util/os-compatibility.h b/include/util/os-compatibility.h new file mode 100644 index 00000000..b2ec2db9 --- /dev/null +++ b/include/util/os-compatibility.h @@ -0,0 +1,12 @@ +#ifndef _WLR_UTIL_OS_COMPATIBILITY_H +#define _WLR_UTIL_OS_COMPATIBILITY_H + +int os_fd_set_cloexec(int fd); + +int set_cloexec_or_close(int fd); + +int create_tmpfile_cloexec(char *tmpname); + +int os_create_anonymous_file(off_t size); + +#endif diff --git a/util/meson.build b/util/meson.build index dd620818..21930693 100644 --- a/util/meson.build +++ b/util/meson.build @@ -2,6 +2,7 @@ lib_wlr_util = static_library( 'wlr_util', files( 'log.c', + 'os-compatibility.c', ), include_directories: wlr_inc, ) diff --git a/backend/wayland/os-compatibility.c b/util/os-compatibility.c similarity index 94% rename from backend/wayland/os-compatibility.c rename to util/os-compatibility.c index cbd7988d..98aeab3d 100644 --- a/backend/wayland/os-compatibility.c +++ b/util/os-compatibility.c @@ -31,10 +31,9 @@ #include #include #include +#include "util/os-compatibility.h" -int -os_fd_set_cloexec(int fd) -{ +int os_fd_set_cloexec(int fd) { long flags; if (fd == -1) @@ -50,9 +49,7 @@ os_fd_set_cloexec(int fd) return 0; } -static int -set_cloexec_or_close(int fd) -{ +int set_cloexec_or_close(int fd) { if (os_fd_set_cloexec(fd) != 0) { close(fd); return -1; @@ -60,8 +57,7 @@ set_cloexec_or_close(int fd) return fd; } -static int -create_tmpfile_cloexec(char *tmpname) +int create_tmpfile_cloexec(char *tmpname) { int fd; @@ -101,9 +97,7 @@ create_tmpfile_cloexec(char *tmpname) * If posix_fallocate() is not supported, program may receive * SIGBUS on accessing mmap()'ed file contents instead. */ -int -os_create_anonymous_file(off_t size) -{ +int os_create_anonymous_file(off_t size) { static const char template[] = "/wlroots-shared-XXXXXX"; const char *path; char *name;