Revision 949d31e6 osdep.c

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