static inline abi_long target_to_host_semarray(int semid, unsigned short **host_array,

                                               abi_ulong target_addr)

{

    int nsems;

    unsigned short *array;

    union semun semun;

    struct semid_ds semid_ds;

    int i, ret;



    semun.buf = &semid_ds;



    ret = semctl(semid, 0, IPC_STAT, semun);

    if (ret == -1)

        return get_errno(ret);



    nsems = semid_ds.sem_nsems;



    *host_array = malloc(nsems*sizeof(unsigned short));

    array = lock_user(VERIFY_READ, target_addr,

                      nsems*sizeof(unsigned short), 1);

    if (!array)

        return -TARGET_EFAULT;



    for(i=0; i<nsems; i++) {

        __get_user((*host_array)[i], &array[i]);

    }

    unlock_user(array, target_addr, 0);



    return 0;

}

static inline abi_long target_to_host_semarray(int semid, unsigned short **host_array,

                                               abi_ulong target_addr)

{

    int nsems;

    unsigned short *array;

    union semun semun;

    struct semid_ds semid_ds;

    int i, ret;



    semun.buf = &semid_ds;



    ret = semctl(semid, 0, IPC_STAT, semun);

    if (ret == -1)

        return get_errno(ret);



    nsems = semid_ds.sem_nsems;



    *host_array = malloc(nsems*sizeof(unsigned short));

    array = lock_user(VERIFY_READ, target_addr,

                      nsems*sizeof(unsigned short), 1);

    if (!array)

        return -TARGET_EFAULT;



    for(i=0; i<nsems; i++) {

        __get_user((*host_array)[i], &array[i]);

    }

    unlock_user(array, target_addr, 0);



    return 0;

}

    if (!array)
static inline abi_long FUNC_0(int semid, unsigned short **host_array,

                                               abi_ulong target_addr)

{

    int VAR_0;

    unsigned short *VAR_1;

    union VAR_2 VAR_2;

    struct VAR_3 VAR_3;

    int VAR_4, VAR_5;



    VAR_2.buf = &VAR_3;



    VAR_5 = semctl(semid, 0, IPC_STAT, VAR_2);

    if (VAR_5 == -1)

        return get_errno(VAR_5);



    VAR_0 = VAR_3.sem_nsems;



    *host_array = malloc(VAR_0*sizeof(unsigned short));

    VAR_1 = lock_user(VERIFY_READ, target_addr,

                      VAR_0*sizeof(unsigned short), 1);

    if (!VAR_1)

        return -TARGET_EFAULT;



    for(VAR_4=0; VAR_4<VAR_0; VAR_4++) {

        __get_user((*host_array)[VAR_4], &VAR_1[VAR_4]);

    }

    unlock_user(VAR_1, target_addr, 0);



    return 0;

}

static inline abi_long FUNC_0(int semid, unsigned short **host_array,
abi_ulong target_addr)
{ int VAR_0; unsigned short *VAR_1; union VAR_2 VAR_2; struct VAR_3 VAR_3; int VAR_4, VAR_5; VAR_2.buf = &VAR_3; VAR_5 = semctl(semid, 0, IPC_STAT, VAR_2); if (VAR_5 == -1)
return get_errno(VAR_5); VAR_0 = VAR_3.sem_nsems; *host_array = malloc(VAR_0*sizeof(unsigned short)); VAR_1 = lock_user(VERIFY_READ, target_addr,
VAR_0*sizeof(unsigned short), 1); if (!VAR_1)
return -TARGET_EFAULT; for(VAR_4=0; VAR_4<VAR_0; VAR_4++) { __get_user((*host_array)[VAR_4], &VAR_1[VAR_4]); } unlock_user(VAR_1, target_addr, 0); return 0; }