static inline abi_long do_msgsnd(int msqid, abi_long msgp,

                                 unsigned int msgsz, int msgflg)

{

    struct target_msgbuf *target_mb;

    struct msgbuf *host_mb;

    abi_long ret = 0;



    if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))

        return -TARGET_EFAULT;

    host_mb = malloc(msgsz+sizeof(long));

    host_mb->mtype = (abi_long) tswapal(target_mb->mtype);

    memcpy(host_mb->mtext, target_mb->mtext, msgsz);

    ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));

    free(host_mb);

    unlock_user_struct(target_mb, msgp, 0);



    return ret;

}

static inline abi_long do_msgsnd(int msqid, abi_long msgp,

                                 unsigned int msgsz, int msgflg)

{

    struct target_msgbuf *target_mb;

    struct msgbuf *host_mb;

    abi_long ret = 0;



    if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))

        return -TARGET_EFAULT;

    host_mb = malloc(msgsz+sizeof(long));

    host_mb->mtype = (abi_long) tswapal(target_mb->mtype);

    memcpy(host_mb->mtext, target_mb->mtext, msgsz);

    ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));

    free(host_mb);

    unlock_user_struct(target_mb, msgp, 0);



    return ret;

}

static inline abi_long FUNC_0(int msqid, abi_long msgp,

                                 unsigned int msgsz, int msgflg)

{

    struct target_msgbuf *VAR_0;

    struct msgbuf *VAR_1;

    abi_long ret = 0;



    if (!lock_user_struct(VERIFY_READ, VAR_0, msgp, 0))

        return -TARGET_EFAULT;

    VAR_1 = malloc(msgsz+sizeof(long));

    VAR_1->mtype = (abi_long) tswapal(VAR_0->mtype);

    memcpy(VAR_1->mtext, VAR_0->mtext, msgsz);

    ret = get_errno(msgsnd(msqid, VAR_1, msgsz, msgflg));

    free(VAR_1);

    unlock_user_struct(VAR_0, msgp, 0);



    return ret;

}

static inline abi_long FUNC_0(int msqid, abi_long msgp,
unsigned int msgsz, int msgflg)
{ struct target_msgbuf *VAR_0; struct msgbuf *VAR_1; abi_long ret = 0; if (!lock_user_struct(VERIFY_READ, VAR_0, msgp, 0))
return -TARGET_EFAULT; VAR_1 = malloc(msgsz+sizeof(long)); VAR_1->mtype = (abi_long) tswapal(VAR_0->mtype); memcpy(VAR_1->mtext, VAR_0->mtext, msgsz); ret = get_errno(msgsnd(msqid, VAR_1, msgsz, msgflg)); free(VAR_1); unlock_user_struct(VAR_0, msgp, 0); return ret; }