Merge pull request #452 from moritz31/move-os-compatibility
Moved os-compatibility and added header
This commit is contained in:
commit
779cccf8b4
|
@ -21,7 +21,6 @@ backend_files = files(
|
||||||
'wayland/output.c',
|
'wayland/output.c',
|
||||||
'wayland/registry.c',
|
'wayland/registry.c',
|
||||||
'wayland/wl_seat.c',
|
'wayland/wl_seat.c',
|
||||||
'wayland/os-compatibility.c',
|
|
||||||
'x11/backend.c',
|
'x11/backend.c',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -29,5 +29,6 @@ executable(
|
||||||
executable(
|
executable(
|
||||||
'screenshot',
|
'screenshot',
|
||||||
'screenshot.c',
|
'screenshot.c',
|
||||||
dependencies: [wayland_client, wlr_protos],
|
dependencies: [wayland_client, wlr_protos, wlroots],
|
||||||
|
link_with: lib_shared,
|
||||||
)
|
)
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <screenshooter-client-protocol.h>
|
#include <screenshooter-client-protocol.h>
|
||||||
#include "../backend/wayland/os-compatibility.c"
|
#include "util/os-compatibility.h"
|
||||||
|
|
||||||
static struct wl_shm *shm = NULL;
|
static struct wl_shm *shm = NULL;
|
||||||
static struct orbital_screenshooter *screenshooter = NULL;
|
static struct orbital_screenshooter *screenshooter = NULL;
|
||||||
|
|
|
@ -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
|
|
@ -2,6 +2,7 @@ lib_wlr_util = static_library(
|
||||||
'wlr_util',
|
'wlr_util',
|
||||||
files(
|
files(
|
||||||
'log.c',
|
'log.c',
|
||||||
|
'os-compatibility.c',
|
||||||
),
|
),
|
||||||
include_directories: wlr_inc,
|
include_directories: wlr_inc,
|
||||||
)
|
)
|
||||||
|
|
|
@ -31,10 +31,9 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "util/os-compatibility.h"
|
||||||
|
|
||||||
int
|
int os_fd_set_cloexec(int fd) {
|
||||||
os_fd_set_cloexec(int fd)
|
|
||||||
{
|
|
||||||
long flags;
|
long flags;
|
||||||
|
|
||||||
if (fd == -1)
|
if (fd == -1)
|
||||||
|
@ -50,9 +49,7 @@ os_fd_set_cloexec(int fd)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int set_cloexec_or_close(int fd) {
|
||||||
set_cloexec_or_close(int fd)
|
|
||||||
{
|
|
||||||
if (os_fd_set_cloexec(fd) != 0) {
|
if (os_fd_set_cloexec(fd) != 0) {
|
||||||
close(fd);
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -60,8 +57,7 @@ set_cloexec_or_close(int fd)
|
||||||
return fd;
|
return fd;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int create_tmpfile_cloexec(char *tmpname)
|
||||||
create_tmpfile_cloexec(char *tmpname)
|
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
|
@ -101,9 +97,7 @@ create_tmpfile_cloexec(char *tmpname)
|
||||||
* If posix_fallocate() is not supported, program may receive
|
* If posix_fallocate() is not supported, program may receive
|
||||||
* SIGBUS on accessing mmap()'ed file contents instead.
|
* SIGBUS on accessing mmap()'ed file contents instead.
|
||||||
*/
|
*/
|
||||||
int
|
int os_create_anonymous_file(off_t size) {
|
||||||
os_create_anonymous_file(off_t size)
|
|
||||||
{
|
|
||||||
static const char template[] = "/wlroots-shared-XXXXXX";
|
static const char template[] = "/wlroots-shared-XXXXXX";
|
||||||
const char *path;
|
const char *path;
|
||||||
char *name;
|
char *name;
|
Loading…
Reference in New Issue