Revision 3b6edd16

b/configure
2142 2142
  dup3=yes
2143 2143
fi
2144 2144

  
2145
# check for epoll support
2146
epoll=no
2147
cat > $TMPC << EOF
2148
#include <sys/epoll.h>
2149

  
2150
int main(void)
2151
{
2152
    epoll_create(0);
2153
    return 0;
2154
}
2155
EOF
2156
if compile_prog "$ARCH_CFLAGS" "" ; then
2157
  epoll=yes
2158
fi
2159

  
2160
# epoll_create1 and epoll_pwait are later additions
2161
# so we must check separately for their presence
2162
epoll_create1=no
2163
cat > $TMPC << EOF
2164
#include <sys/epoll.h>
2165

  
2166
int main(void)
2167
{
2168
    epoll_create1(0);
2169
    return 0;
2170
}
2171
EOF
2172
if compile_prog "$ARCH_CFLAGS" "" ; then
2173
  epoll_create1=yes
2174
fi
2175

  
2176
epoll_pwait=no
2177
cat > $TMPC << EOF
2178
#include <sys/epoll.h>
2179

  
2180
int main(void)
2181
{
2182
    epoll_pwait(0, 0, 0, 0, 0);
2183
    return 0;
2184
}
2185
EOF
2186
if compile_prog "$ARCH_CFLAGS" "" ; then
2187
  epoll_pwait=yes
2188
fi
2189

  
2145 2190
# Check if tools are available to build documentation.
2146 2191
if test "$docs" != "no" ; then
2147 2192
  if has makeinfo && has pod2man; then
......
2674 2719
if test "$dup3" = "yes" ; then
2675 2720
  echo "CONFIG_DUP3=y" >> $config_host_mak
2676 2721
fi
2722
if test "$epoll" = "yes" ; then
2723
  echo "CONFIG_EPOLL=y" >> $config_host_mak
2724
fi
2725
if test "$epoll_create1" = "yes" ; then
2726
  echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
2727
fi
2728
if test "$epoll_pwait" = "yes" ; then
2729
  echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
2730
fi
2677 2731
if test "$inotify" = "yes" ; then
2678 2732
  echo "CONFIG_INOTIFY=y" >> $config_host_mak
2679 2733
fi
b/linux-user/syscall.c
66 66
#ifdef CONFIG_EVENTFD
67 67
#include <sys/eventfd.h>
68 68
#endif
69
#ifdef CONFIG_EPOLL
70
#include <sys/epoll.h>
71
#endif
69 72

  
70 73
#define termios host_termios
71 74
#define winsize host_winsize
......
7612 7615
        break;
7613 7616
#endif
7614 7617
#endif
7618
#if defined(CONFIG_EPOLL)
7619
#if defined(TARGET_NR_epoll_create)
7620
    case TARGET_NR_epoll_create:
7621
        ret = get_errno(epoll_create(arg1));
7622
        break;
7623
#endif
7624
#if defined(TARGET_NR_epoll_create1) && defined(CONFIG_EPOLL_CREATE1)
7625
    case TARGET_NR_epoll_create1:
7626
        ret = get_errno(epoll_create1(arg1));
7627
        break;
7628
#endif
7629
#if defined(TARGET_NR_epoll_ctl)
7630
    case TARGET_NR_epoll_ctl:
7631
    {
7632
        struct epoll_event ep;
7633
        struct epoll_event *epp = 0;
7634
        if (arg4) {
7635
            struct target_epoll_event *target_ep;
7636
            if (!lock_user_struct(VERIFY_READ, target_ep, arg4, 1)) {
7637
                goto efault;
7638
            }
7639
            ep.events = tswap32(target_ep->events);
7640
            /* The epoll_data_t union is just opaque data to the kernel,
7641
             * so we transfer all 64 bits across and need not worry what
7642
             * actual data type it is.
7643
             */
7644
            ep.data.u64 = tswap64(target_ep->data.u64);
7645
            unlock_user_struct(target_ep, arg4, 0);
7646
            epp = &ep;
7647
        }
7648
        ret = get_errno(epoll_ctl(arg1, arg2, arg3, epp));
7649
        break;
7650
    }
7651
#endif
7652

  
7653
#if defined(TARGET_NR_epoll_pwait) && defined(CONFIG_EPOLL_PWAIT)
7654
#define IMPLEMENT_EPOLL_PWAIT
7655
#endif
7656
#if defined(TARGET_NR_epoll_wait) || defined(IMPLEMENT_EPOLL_PWAIT)
7657
#if defined(TARGET_NR_epoll_wait)
7658
    case TARGET_NR_epoll_wait:
7659
#endif
7660
#if defined(IMPLEMENT_EPOLL_PWAIT)
7661
    case TARGET_NR_epoll_pwait:
7662
#endif
7663
    {
7664
        struct target_epoll_event *target_ep;
7665
        struct epoll_event *ep;
7666
        int epfd = arg1;
7667
        int maxevents = arg3;
7668
        int timeout = arg4;
7669

  
7670
        target_ep = lock_user(VERIFY_WRITE, arg2,
7671
                              maxevents * sizeof(struct target_epoll_event), 1);
7672
        if (!target_ep) {
7673
            goto efault;
7674
        }
7675

  
7676
        ep = alloca(maxevents * sizeof(struct epoll_event));
7677

  
7678
        switch (num) {
7679
#if defined(IMPLEMENT_EPOLL_PWAIT)
7680
        case TARGET_NR_epoll_pwait:
7681
        {
7682
            target_sigset_t *target_set;
7683
            sigset_t _set, *set = &_set;
7684

  
7685
            if (arg5) {
7686
                target_set = lock_user(VERIFY_READ, arg5,
7687
                                       sizeof(target_sigset_t), 1);
7688
                if (!target_set) {
7689
                    unlock_user(target_ep, arg2, 0);
7690
                    goto efault;
7691
                }
7692
                target_to_host_sigset(set, target_set);
7693
                unlock_user(target_set, arg5, 0);
7694
            } else {
7695
                set = NULL;
7696
            }
7697

  
7698
            ret = get_errno(epoll_pwait(epfd, ep, maxevents, timeout, set));
7699
            break;
7700
        }
7701
#endif
7702
#if defined(TARGET_NR_epoll_wait)
7703
        case TARGET_NR_epoll_wait:
7704
            ret = get_errno(epoll_wait(epfd, ep, maxevents, timeout));
7705
            break;
7706
#endif
7707
        default:
7708
            ret = -TARGET_ENOSYS;
7709
        }
7710
        if (!is_error(ret)) {
7711
            int i;
7712
            for (i = 0; i < ret; i++) {
7713
                target_ep[i].events = tswap32(ep[i].events);
7714
                target_ep[i].data.u64 = tswap64(ep[i].data.u64);
7715
            }
7716
        }
7717
        unlock_user(target_ep, arg2, ret * sizeof(struct target_epoll_event));
7718
        break;
7719
    }
7720
#endif
7721
#endif
7615 7722
    default:
7616 7723
    unimplemented:
7617 7724
        gemu_log("qemu: Unsupported syscall: %d\n", num);
b/linux-user/syscall_defs.h
2206 2206
#define FUTEX_CLOCK_REALTIME    256
2207 2207
#define FUTEX_CMD_MASK          ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
2208 2208

  
2209
#ifdef CONFIG_EPOLL
2210
typedef union target_epoll_data {
2211
    abi_ulong ptr;
2212
    abi_ulong fd;
2213
    uint32_t u32;
2214
    uint64_t u64;
2215
} target_epoll_data_t;
2216

  
2217
struct target_epoll_event {
2218
    uint32_t events;
2219
    target_epoll_data_t data;
2220
};
2221
#endif

Also available in: Unified diff