Revision 949d31e6

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
}
b/osdep.c
44 44
extern int madvise(caddr_t, size_t, int);
45 45
#endif
46 46

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

  
51 47
#ifdef _WIN32
52 48
#include <windows.h>
53 49
#elif defined(CONFIG_BSD)
......
207 203
    return total;
208 204
}
209 205

  
210
#ifndef _WIN32
211
/*
212
 * Creates an eventfd that looks like a pipe and has EFD_CLOEXEC set.
213
 */
214
int qemu_eventfd(int fds[2])
215
{
216
#ifdef CONFIG_EVENTFD
217
    int ret;
218

  
219
    ret = eventfd(0, 0);
220
    if (ret >= 0) {
221
        fds[0] = ret;
222
        qemu_set_cloexec(ret);
223
        if ((fds[1] = dup(ret)) == -1) {
224
            close(ret);
225
            return -1;
226
        }
227
        qemu_set_cloexec(fds[1]);
228
        return 0;
229
    }
230

  
231
    if (errno != ENOSYS) {
232
        return -1;
233
    }
234
#endif
235

  
236
    return qemu_pipe(fds);
237
}
238
#endif
239

  
240 206
/*
241 207
 * Opens a socket with FD_CLOEXEC set
242 208
 */

Also available in: Unified diff