Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make allocate_shm_file() portable across systems #8

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dtao.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,16 @@ static const struct wl_buffer_listener wl_buffer_listener = {
static int
allocate_shm_file(size_t size)
{
#if defined(__linux__)
int fd = memfd_create("surface", MFD_CLOEXEC);
#elif defined(__FreeBSD__)
int fd = shm_open(SHM_ANON, O_RDWR | O_CLOEXEC, 0600);
#else
char name[] = "/tmp/dtao-shm-buffer-XXXXXX";
int fd = mkostemp(name, O_CLOEXEC);
unlink(name);
#endif

if (fd < 0)
return -1;
int ret;
Expand Down