static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,

                          abi_ulong target_addr, socklen_t addrlen)

{

    void *addr;

    void *host_msg;

    abi_long ret;



    if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)

        return -TARGET_EINVAL;



    host_msg = lock_user(VERIFY_READ, msg, len, 1);

    if (!host_msg)

        return -TARGET_EFAULT;

    if (target_addr) {

        addr = alloca(addrlen);

        target_to_host_sockaddr(addr, target_addr, addrlen);

        ret = get_errno(sendto(fd, host_msg, len, flags, addr, addrlen));

    } else {

        ret = get_errno(send(fd, host_msg, len, flags));

    }

    unlock_user(host_msg, msg, 0);

    return ret;

}

static abi_long do_sendto(int fd, abi_ulong msg, size_t len, int flags,

                          abi_ulong target_addr, socklen_t addrlen)

{

    void *addr;

    void *host_msg;

    abi_long ret;



    if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)

        return -TARGET_EINVAL;



    host_msg = lock_user(VERIFY_READ, msg, len, 1);

    if (!host_msg)

        return -TARGET_EFAULT;

    if (target_addr) {

        addr = alloca(addrlen);

        target_to_host_sockaddr(addr, target_addr, addrlen);

        ret = get_errno(sendto(fd, host_msg, len, flags, addr, addrlen));

    } else {

        ret = get_errno(send(fd, host_msg, len, flags));

    }

    unlock_user(host_msg, msg, 0);

    return ret;

}

static abi_long FUNC_0(int fd, abi_ulong msg, size_t len, int flags,

                          abi_ulong target_addr, socklen_t addrlen)

{

    void *VAR_0;

    void *VAR_1;

    abi_long ret;



    if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)

        return -TARGET_EINVAL;



    VAR_1 = lock_user(VERIFY_READ, msg, len, 1);

    if (!VAR_1)

        return -TARGET_EFAULT;

    if (target_addr) {

        VAR_0 = alloca(addrlen);

        target_to_host_sockaddr(VAR_0, target_addr, addrlen);

        ret = get_errno(sendto(fd, VAR_1, len, flags, VAR_0, addrlen));

    } else {

        ret = get_errno(send(fd, VAR_1, len, flags));

    }

    unlock_user(VAR_1, msg, 0);

    return ret;

}

static abi_long FUNC_0(int fd, abi_ulong msg, size_t len, int flags,
abi_ulong target_addr, socklen_t addrlen)
{ void *VAR_0; void *VAR_1; abi_long ret; if (addrlen < 0 || addrlen > MAX_SOCK_ADDR)
return -TARGET_EINVAL; VAR_1 = lock_user(VERIFY_READ, msg, len, 1); if (!VAR_1)
return -TARGET_EFAULT; if (target_addr) { VAR_0 = alloca(addrlen); target_to_host_sockaddr(VAR_0, target_addr, addrlen); ret = get_errno(sendto(fd, VAR_1, len, flags, VAR_0, addrlen)); } else { ret = get_errno(send(fd, VAR_1, len, flags)); } unlock_user(VAR_1, msg, 0); return ret; }