Esempio n. 1
0
void *mdb_handle_get_data(mdb_handle_map_t *hmap, mdb_handle_t h)
{
    uint32_t          useid = HANDLE_USEID(h);
    int               index = HANDLE_INDEX(h);
    indextbl_t       *indextbl;
    indextbl_entry_t *entry;

    MDB_CHECKARG(hmap && h != MDB_HANDLE_INVALID, NULL);

    indextbl = &hmap->indextbl;

    if (index >= indextbl->nentry) {
        errno = EKEYREJECTED;
        return NULL;
    }

    entry = indextbl->entries + index;

    if (entry->useid != useid) {
        errno = ENOANO;
        return NULL;
    }

    if (!entry->data)
        errno = ENODATA;

    return entry->data;
}
Esempio n. 2
0
int MPIR_Datatype_init(void)
{
    int i;
    int mpi_errno = MPI_SUCCESS;
    MPID_Datatype *ptr;

    MPIU_Assert(MPID_Datatype_mem.initialized == 0);
    MPIU_Assert(MPID_DATATYPE_PREALLOC >= 5);

    for (i=0; mpi_pairtypes[i] != (MPI_Datatype) -1; ++i) {
        /* types based on 'long long' and 'long double', may be disabled at
           configure time, and their values set to MPI_DATATYPE_NULL.  skip any
           such types. */
        if (mpi_pairtypes[i] == MPI_DATATYPE_NULL) continue;
        /* XXX: this allocation strategy isn't right if one or more of the
           pairtypes is MPI_DATATYPE_NULL.  in fact, the assert below will
           fail if any type other than the las in the list is equal to
           MPI_DATATYPE_NULL.  obviously, this should be fixed, but I need
           to talk to Rob R. first. -- BRT */
        /* XXX DJG it does work, but only because MPI_LONG_DOUBLE_INT is the
         * only one that is ever optional and it comes last */

        /* we use the _unsafe version because we are still in MPI_Init, before
         * multiple threads are permitted and possibly before support for
         * critical sections is entirely setup */
        ptr = (MPID_Datatype *)MPIU_Handle_obj_alloc_unsafe( &MPID_Datatype_mem );

        MPIU_Assert(ptr);
        MPIU_Assert(ptr->handle == mpi_pairtypes[i]);
        /* this is a redundant alternative to the previous statement */
        MPIU_Assert((void *) ptr == (void *) (MPID_Datatype_direct + HANDLE_INDEX(mpi_pairtypes[i])));

        mpi_errno = MPID_Type_create_pairtype(mpi_pairtypes[i], (MPID_Datatype *) ptr);
        if (mpi_errno) MPIU_ERR_POP(mpi_errno);
    }

    MPIR_Add_finalize(MPIR_Datatype_finalize, 0,
                      MPIR_FINALIZE_CALLBACK_PRIO-1);

fn_fail:
    return mpi_errno;
}
Esempio n. 3
0
void *mdb_handle_delete(mdb_handle_map_t *hmap, mdb_handle_t h)
{
    uint32_t  useid = HANDLE_USEID(h);
    int       index = HANDLE_INDEX(h);
    void     *old_data;

    MDB_CHECKARG(hmap && h != MDB_HANDLE_INVALID, NULL);


    if (!(old_data = index_free(&hmap->indextbl, useid,index))) {
        /* errno has been set by index_free() */
        return NULL;
    }

    if (freemap_free(&hmap->freemap, index) < 0) {
        /* errno has been set by freemap_free() */
        return NULL;
    }

    return old_data;
}
Esempio n. 4
0
/* For debugging */
static void MPIU_Print_handle( int handle )
{
    int type, kind, block, index;

    type = HANDLE_GET_MPI_KIND(handle);
    kind = HANDLE_GET_KIND(handle);
    switch (type) {
    case HANDLE_KIND_INVALID:
	printf( "invalid" );
	break;
    case HANDLE_KIND_BUILTIN:
	printf( "builtin" );
	break;
    case HANDLE_KIND_DIRECT:
	index = HANDLE_INDEX(handle);
	printf( "direct: %d", index );
	break;
    case HANDLE_KIND_INDIRECT:
	block = HANDLE_BLOCK(handle);
	index = HANDLE_BLOCK_INDEX(handle);
	printf( "indirect: block %d index %d", block, index );
	break;
    }
}