Exemplo n.º 1
0
/*
 * This is called whenever a thread is initialized
 */
int
INFINIBAND_init_thread( hwd_context_t * ctx )
{
	string_list *counter_list = NULL;
	int i;
	int loop;

	/* initialize portid struct of type ib_portid_t to 0 */
	InitStruct( portid, ib_portid_t );

	if ( is_initialized )
		return PAPI_OK;

	is_initialized = 1;

	init_ib_counter(  );

	for ( loop = 0; loop < INFINIBAND_MAX_COUNTERS; loop++ )
		subscriptions[loop] = NULL;

	counter_list = host_listCounter( num_counters );

	for ( i = 0; i < counter_list->count; i++ )
		host_subscribe( counter_list->data[i] );

	( ( INFINIBAND_context_t * ) ctx )->state.ncounter = counter_list->count;

	host_deleteStringList( counter_list );

	return PAPI_OK;
}
Exemplo n.º 2
0
int main(void){
	calculate_s *calculate = NULL;

	calculate = InitStruct();
	if(!calculate)
		return -1;

	GetElementsOfArray(calculate);
	CalculateWrapper(calculate);
	PrintStruct(calculate);

	freeStruct(calculate);
	
	return 0;
}
Exemplo n.º 3
0
void InitSymData( TYPEPTR typ, TYPEPTR ctyp, int level )
{
    TOKEN               token;
    unsigned long       size;

    SKIP_TYPEDEFS( typ );
    if( typ->decl_type == TYPE_ENUM ) typ = typ->object;        /* 07-nov-90 */
    token = CurToken;
    if( CurToken == T_LEFT_BRACE ) {
        NextToken();
        if( CurToken == T_RIGHT_BRACE  ||  CurToken == T_COMMA ) {
            CErr1( ERR_EMPTY_INITIALIZER_LIST );
        }
    }
    size = SizeOfArg( typ );
    switch( typ->decl_type ) {
    case TYPE_ARRAY:
        if( CharArray( typ->object ) ) {
            InitCharArray( typ );
        } else if( WCharArray( typ->object ) ) {
            InitWCharArray( typ );
        } else {
            if( token == T_LEFT_BRACE ) {
                ctyp = typ;
            } else if( level == 0 ) {
                CErr1( ERR_NEED_BRACES );
            }
            if( typ == ctyp ) { /* initialize new current type */
                /* first zero out the whole array; otherwise
                   overlapping fields caused by designated
                   initializers will make life very difficult */
                ZeroBytes( size );
                RelSeekBytes( -size );
            }
            InitArray( typ, ctyp );
        }
        break;
    case TYPE_FCOMPLEX:
    case TYPE_DCOMPLEX:
    case TYPE_LDCOMPLEX:
    case TYPE_STRUCT:
        if( token == T_LEFT_BRACE ) {
            ctyp = typ;
        } else if( level == 0 ) {
            CErr1( ERR_NEED_BRACES );
        }
        if( typ == ctyp ) { /* initialize new current type */
            /* zero out all fields; otherwise overlapping fields caused
               by designated initializers will make life very difficult */
            ZeroBytes( size );
            RelSeekBytes( -size );
        }
        InitStruct( typ, ctyp );
        break;
    case TYPE_UNION:
        if( token == T_LEFT_BRACE ) {
            ctyp = typ;
        } else if( level == 0 ) {
            CErr1( ERR_NEED_BRACES );
        }
        InitUnion( typ, ctyp );
        break;
    case TYPE_CHAR:
    case TYPE_UCHAR:
    case TYPE_BOOL:
    case TYPE_SHORT:
    case TYPE_USHORT:
    case TYPE_INT:
    case TYPE_UINT:
    case TYPE_LONG:
    case TYPE_ULONG:
    case TYPE_POINTER:
        StorePointer( typ, size );
        break;
    case TYPE_LONG64:
    case TYPE_ULONG64:
        StoreInt64( typ );
        break;
    case TYPE_FLOAT:
    case TYPE_DOUBLE:
    case TYPE_FIMAGINARY:
    case TYPE_DIMAGINARY:
        StoreFloat( typ->decl_type, size );
        break;
    case TYPE_LONG_DOUBLE:
    case TYPE_LDIMAGINARY:
        //StoreFloat( typ->decl_type, size );
        StoreFloat( TYPE_DOUBLE, size );
        break;
    default:
        break;
    }
    if( token == T_LEFT_BRACE ) {
        if( CurToken == T_COMMA ) {
            NextToken();
        }
        if( CurToken != T_RIGHT_BRACE ) {
            CErr1( ERR_TOO_MANY_INITS );
        }
        while( CurToken != T_RIGHT_BRACE ) {
          if( CurToken == T_EOF ) break;
          if( CurToken == T_SEMI_COLON )break;
          if( CurToken == T_LEFT_BRACE )break;
           NextToken();
        }
        MustRecog( T_RIGHT_BRACE );
    }
}