mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-29 06:46:35 -04:00
changes requested by code review
This commit is contained in:
parent
a8da30c437
commit
39e226e923
7 changed files with 16 additions and 25 deletions
4
client.c
4
client.c
|
|
@ -10,11 +10,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#if __linux__
|
|
||||||
#include <linux/un.h>
|
|
||||||
#elif __FreeBSD__
|
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#define LOG_MODULE "foot-client"
|
#define LOG_MODULE "foot-client"
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
|
|
|
||||||
2
fdm.c
2
fdm.c
|
|
@ -98,7 +98,7 @@ bool
|
||||||
fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
|
fdm_add(struct fdm *fdm, int fd, int events, fdm_handler_t handler, void *data)
|
||||||
{
|
{
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#ifdef __FreeBSD__
|
#ifndef __FreeBSD__
|
||||||
int flags = fcntl(fd, F_GETFL);
|
int flags = fcntl(fd, F_GETFL);
|
||||||
if (!(flags & O_NONBLOCK)) {
|
if (!(flags & O_NONBLOCK)) {
|
||||||
LOG_ERR("FD=%d is in blocking mode", fd);
|
LOG_ERR("FD=%d is in blocking mode", fd);
|
||||||
|
|
|
||||||
4
main.c
4
main.c
|
|
@ -10,11 +10,7 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#if __linux__
|
|
||||||
#include <sys/sysinfo.h>
|
|
||||||
#elif __FreeBSD__
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#endif
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#include <fcft/fcft.h>
|
#include <fcft/fcft.h>
|
||||||
|
|
|
||||||
4
server.c
4
server.c
|
|
@ -8,11 +8,7 @@
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
|
|
||||||
#if __linux__
|
|
||||||
#include <linux/un.h>
|
|
||||||
#elif __FreeBSD__
|
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <tllist.h>
|
#include <tllist.h>
|
||||||
|
|
||||||
|
|
|
||||||
18
shm.c
18
shm.c
|
|
@ -53,9 +53,7 @@ static off_t max_pool_size = 512 * 1024 * 1024;
|
||||||
static tll(struct buffer) buffers;
|
static tll(struct buffer) buffers;
|
||||||
|
|
||||||
static bool can_punch_hole = false;
|
static bool can_punch_hole = false;
|
||||||
#ifdef __linux__
|
|
||||||
static bool can_punch_hole_initialized = false;
|
static bool can_punch_hole_initialized = false;
|
||||||
#endif
|
|
||||||
|
|
||||||
#undef MEASURE_SHM_ALLOCS
|
#undef MEASURE_SHM_ALLOCS
|
||||||
#if defined(MEASURE_SHM_ALLOCS)
|
#if defined(MEASURE_SHM_ALLOCS)
|
||||||
|
|
@ -280,9 +278,11 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
|
||||||
if (!can_punch_hole_initialized) {
|
if (!can_punch_hole_initialized) {
|
||||||
can_punch_hole_initialized = true;
|
can_punch_hole_initialized = true;
|
||||||
|
#ifdef __FreeBSD__
|
||||||
|
can_punch_hole = false;
|
||||||
|
#else
|
||||||
can_punch_hole = fallocate(
|
can_punch_hole = fallocate(
|
||||||
pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0;
|
pool_fd, FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE, 0, 1) == 0;
|
||||||
|
|
||||||
|
|
@ -291,10 +291,8 @@ shm_get_buffer(struct wl_shm *shm, int width, int height, unsigned long cookie,
|
||||||
"fallocate(FALLOC_FL_PUNCH_HOLE) not "
|
"fallocate(FALLOC_FL_PUNCH_HOLE) not "
|
||||||
"supported (%s): expect lower performance", strerror(errno));
|
"supported (%s): expect lower performance", strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#elif __FreeBSD__
|
|
||||||
can_punch_hole = false;
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (scrollable && !can_punch_hole) {
|
if (scrollable && !can_punch_hole) {
|
||||||
initial_offset = 0;
|
initial_offset = 0;
|
||||||
|
|
@ -395,7 +393,7 @@ shm_can_scroll(const struct buffer *buf)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifndef __FreeBSD__
|
||||||
static bool
|
static bool
|
||||||
wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
||||||
{
|
{
|
||||||
|
|
@ -432,7 +430,7 @@ wrap_buffer(struct wl_shm *shm, struct buffer *buf, off_t new_offset)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifndef __FreeBSD__
|
||||||
static bool
|
static bool
|
||||||
shm_scroll_forward(struct wl_shm *shm, struct buffer *buf, int rows,
|
shm_scroll_forward(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
int top_margin, int top_keep_rows,
|
int top_margin, int top_keep_rows,
|
||||||
|
|
@ -538,7 +536,7 @@ err:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifndef __FreeBSD__
|
||||||
static bool
|
static bool
|
||||||
shm_scroll_reverse(struct wl_shm *shm, struct buffer *buf, int rows,
|
shm_scroll_reverse(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
int top_margin, int top_keep_rows,
|
int top_margin, int top_keep_rows,
|
||||||
|
|
@ -641,7 +639,7 @@ shm_scroll(struct wl_shm *shm, struct buffer *buf, int rows,
|
||||||
{
|
{
|
||||||
#ifdef __FreeBSD__
|
#ifdef __FreeBSD__
|
||||||
return false;
|
return false;
|
||||||
#elif __linux__
|
#else
|
||||||
if (!shm_can_scroll(buf))
|
if (!shm_can_scroll(buf))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|
|
||||||
6
slave.c
6
slave.c
|
|
@ -10,6 +10,7 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
#define LOG_MODULE "slave"
|
#define LOG_MODULE "slave"
|
||||||
|
|
@ -93,6 +94,11 @@ slave_exec(int ptmx, char *argv[], int err_fd, bool login_shell)
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ioctl(pts, TIOCSCTTY, 0) < 0) {
|
||||||
|
LOG_ERRNO("failed to configure controlling terminal");
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
if (dup2(pts, STDIN_FILENO) == -1 ||
|
if (dup2(pts, STDIN_FILENO) == -1 ||
|
||||||
dup2(pts, STDOUT_FILENO) == -1 ||
|
dup2(pts, STDOUT_FILENO) == -1 ||
|
||||||
dup2(pts, STDERR_FILENO) == -1)
|
dup2(pts, STDERR_FILENO) == -1)
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@
|
||||||
|
|
||||||
#if __linux__
|
#if __linux__
|
||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#elif __FreeBSD__
|
#endif
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#endif
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue