Revision 949d31e6 os-posix.c

b/os-posix.c
43 43
#include <sys/prctl.h>
44 44
#endif
45 45

  
46
#ifdef CONFIG_EVENTFD
47
#include <sys/eventfd.h>
48
#endif
49

  
46 50
static struct passwd *user_pwd;
47 51
static const char *chroot_dir;
48 52
static int daemonize;
......
329 333
{
330 334
    setvbuf(stdout, NULL, _IOLBF, 0);
331 335
}
336

  
337
/*
338
 * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set.
339
 */
340
int qemu_eventfd(int fds[2])
341
{
342
#ifdef CONFIG_EVENTFD
343
    int ret;
344

  
345
    ret = eventfd(0, 0);
346
    if (ret >= 0) {
347
        fds[0] = ret;
348
        qemu_set_cloexec(ret);
349
        if ((fds[1] = dup(ret)) == -1) {
350
            close(ret);
351
            return -1;
352
        }
353
        qemu_set_cloexec(fds[1]);
354
        return 0;
355
    }
356

  
357
    if (errno != ENOSYS) {
358
        return -1;
359
    }
360
#endif
361

  
362
    return qemu_pipe(fds);
363
}

Also available in: Unified diff