src/components/io/linux-io.c
// Code to read values; returns PAPI_OK or an error.
// We presume the number of counters and order of them
// will not change from our initialization read.
Code to read values; returns PAPI_OK or an error.
We presume the number of counters and order of them
will not change from our initialization read.
Code to read values ; returns PAPI_OK or an error . We presume the number of counters and order of them will not change from our initialization read .
static int 
io_hardware_read(_io_context_t *ctx, _io_control_state_t *ctl)
{
    ctx->pFile = fopen(IO_FILENAME, "r");
    if (ctx->pFile == NULL) return(PAPI_ENOCNTR); 
    int idx;
    for (idx=0; idx<gEventCount; idx++) {
        if (fgets(ctx->line, FILE_LINE_SIZE-1, ctx->pFile)) {
            char dummy[FILE_LINE_SIZE] = {0};
            long long tmplong = 0LL;
            int nf = sscanf(ctx->line, "%s %lld\n", dummy, &tmplong);
            if (nf != 2 || strlen(dummy)<2 || dummy[strlen(dummy)-1] != ':') {
                return PAPI_ENOCNTR;
            }
            ctl->EventSetVal[idx] = tmplong;
        } else {                            
            return(PAPI_EMISC);
        }
    }
    fclose(ctx->pFile);
    return(PAPI_OK);
}
static int io_hardware_read ( _io_context_t * ctx , _io_control_state_t * ctl ) { ctx -> pFile = fopen ( IO_FILENAME , " " ) ; if ( ctx -> pFile == NULL ) return ( PAPI_ENOCNTR ) ; int idx ; for ( idx = 0 ; idx < gEventCount ; idx ++ ) { if ( fgets ( ctx -> line , FILE_LINE_SIZE - 1 , ctx -> pFile ) ) { char dummy [ FILE_LINE_SIZE ] = { 0 } ; long long tmplong = 0LL ; int nf = sscanf ( ctx -> line , " \n " , dummy , & tmplong ) ; if ( nf != 2 || strlen ( dummy ) < 2 || dummy [ strlen ( dummy ) - 1 ] != ' ' ) { return PAPI_ENOCNTR ; } ctl -> EventSetVal [ idx ] = tmplong ; } else { return ( PAPI_EMISC ) ; } } fclose ( ctx -> pFile ) ; return ( PAPI_OK ) ; }
Code to read values; returns PAPI_OK or an error.
Code to read values ; returns PAPI_OK or an error .
/* No counters */ /* Read each line */ /* Did not read ALL counters. */