Changeset aa67e26


Ignore:
Timestamp:
04/08/06 13:46:28 (16 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
5da3315
Parents:
67a14d4
Message:

Fix namespace issues with fifo.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lib/fifo.c

    re4e1635 raa67e26  
    5656
    5757
    58 enum which_t { IN, OUT, ACK };
     58enum which_t { FIFO_PTR_IN, FIFO_PTR_OUT, FIFO_PTR_ACK };
    5959
    6060struct tracefifo_t {
     
    8989        }
    9090
    91         fifo->datamap[IN] = 0;
    92         fifo->datamap[OUT] = 0;
    93         fifo->datamap[ACK] = 0;
     91        fifo->datamap[FIFO_PTR_IN] = 0;
     92        fifo->datamap[FIFO_PTR_OUT] = 0;
     93        fifo->datamap[FIFO_PTR_ACK] = 0;
    9494        return fifo;
    9595}
     
    104104static void increment_pointer(struct tracefifo_t *fifo, enum which_t which, int amount) {
    105105        assert(fifo);
    106         assert(which == IN || which == OUT || which == ACK);
     106        assert(which == FIFO_PTR_IN || which == FIFO_PTR_OUT || which == FIFO_PTR_ACK);
    107107        assert(amount >= 0);
    108108
     
    121121static void set_pointer(struct tracefifo_t *fifo, enum which_t which, unsigned int location) {
    122122        assert(fifo);
    123         assert(which == IN || which == OUT || which == ACK);
     123        assert(which == FIFO_PTR_IN || which == FIFO_PTR_OUT || which == FIFO_PTR_ACK);
    124124
    125125        assert(location <= fifo->length);
     
    130130static size_t tracefifo_compare(struct tracefifo_t *fifo, enum which_t first, enum which_t second) {
    131131        assert(fifo);
    132         assert(first == IN || first == OUT || first == ACK);
    133         assert(second == IN || second == OUT || second == ACK);
     132        assert(first == FIFO_PTR_IN || first == FIFO_PTR_OUT || first == FIFO_PTR_ACK);
     133        assert(second == FIFO_PTR_IN || second == FIFO_PTR_OUT || second == FIFO_PTR_ACK);
    134134
    135135        if (fifo->datamap[first] == fifo->datamap[second]) {
     
    145145size_t tracefifo_free(struct tracefifo_t *fifo) {
    146146        assert(fifo);
    147         return (fifo->length - tracefifo_compare(fifo,IN,ACK));
     147        return (fifo->length - tracefifo_compare(fifo,FIFO_PTR_IN,FIFO_PTR_ACK));
    148148}
    149149
     
    155155size_t tracefifo_out_available(struct tracefifo_t *fifo) {
    156156        assert(fifo);
    157         return tracefifo_compare(fifo,IN,OUT);
     157        return tracefifo_compare(fifo,FIFO_PTR_IN,FIFO_PTR_OUT);
    158158}
    159159
    160160size_t tracefifo_ack_available(struct tracefifo_t *fifo) {
    161161        assert(fifo);
    162         return tracefifo_compare(fifo,OUT,ACK);
     162        return tracefifo_compare(fifo,FIFO_PTR_OUT,FIFO_PTR_ACK);
    163163}
    164164
     
    168168        assert(state);
    169169
    170         state->in = fifo->datamap[IN];
    171         state->out = fifo->datamap[OUT];
    172         state->ack = fifo->datamap[ACK];
     170        state->in = fifo->datamap[FIFO_PTR_IN];
     171        state->out = fifo->datamap[FIFO_PTR_OUT];
     172        state->ack = fifo->datamap[FIFO_PTR_ACK];
    173173        state->length = fifo->length;
    174         state->used = tracefifo_compare(fifo,IN,ACK);
     174        state->used = tracefifo_compare(fifo,FIFO_PTR_IN,FIFO_PTR_ACK);
    175175
    176176}
     
    187187        if (desc)
    188188                scan += sprintf(scan,"%s\t",desc);
    189         scan += sprintf(scan,"in:   %d \t",fifo->datamap[IN]);
    190         scan += sprintf(scan,"sent: %d\t", fifo->datamap[OUT]);
    191         scan += sprintf(scan,"ack:  %d\t", fifo->datamap[ACK]);
     189        scan += sprintf(scan,"in:   %d \t",fifo->datamap[FIFO_PTR_IN]);
     190        scan += sprintf(scan,"sent: %d\t", fifo->datamap[FIFO_PTR_OUT]);
     191        scan += sprintf(scan,"ack:  %d\t", fifo->datamap[FIFO_PTR_ACK]);
    192192        if (delta > 0)
    193193                scan += sprintf(scan,"delta: %d\t", delta);
    194         scan += sprintf(scan,"Size: %d", tracefifo_compare(fifo,IN,ACK));
     194        scan += sprintf(scan,"Size: %d", tracefifo_compare(fifo,FIFO_PTR_IN,FIFO_PTR_ACK));
    195195        scan += sprintf(scan,"\n");
    196196        return tracefifo_stat_buffer;
     
    244244        lenleft = len;
    245245        while (lenleft > 0) {
    246                 size = MIN((fifo->length - fifo->datamap[IN]), lenleft );
    247                 memcpy((char *)((ptrdiff_t)fifo->base + fifo->datamap[IN]),
     246                size = MIN((fifo->length - fifo->datamap[FIFO_PTR_IN]), lenleft );
     247                memcpy((char *)((ptrdiff_t)fifo->base + fifo->datamap[FIFO_PTR_IN]),
    248248                                buffer,
    249249                                size);
    250                 increment_pointer(fifo,IN,size);
     250                increment_pointer(fifo,FIFO_PTR_IN,size);
    251251                buffer = (char*)buffer+size;
    252252                lenleft -= size;
     
    259259        assert(fifo);
    260260        assert(buffer);
    261         if (tracefifo_compare(fifo,IN,OUT) < len) {
    262                 return 0;
    263         }
    264         return tracefifo_read_generic(fifo,buffer,len,OUT,0);
     261        if (tracefifo_compare(fifo,FIFO_PTR_IN,FIFO_PTR_OUT) < len) {
     262                return 0;
     263        }
     264        return tracefifo_read_generic(fifo,buffer,len,FIFO_PTR_OUT,0);
    265265}
    266266
     
    268268        assert(fifo);
    269269        assert(buffer);
    270         if (tracefifo_compare(fifo,OUT,ACK) < len) {
    271                 return 0;
    272         }
    273         return tracefifo_read_generic(fifo,buffer,len,ACK,0);
     270        if (tracefifo_compare(fifo,FIFO_PTR_OUT,FIFO_PTR_ACK) < len) {
     271                return 0;
     272        }
     273        return tracefifo_read_generic(fifo,buffer,len,FIFO_PTR_ACK,0);
    274274}
    275275
    276276int tracefifo_out_update(struct tracefifo_t *fifo, size_t len){
    277277        assert(fifo);
    278         if (tracefifo_compare(fifo,IN,OUT) < len) {
    279                 return 0;
    280         }
    281         increment_pointer(fifo,OUT,len);
     278        if (tracefifo_compare(fifo,FIFO_PTR_IN,FIFO_PTR_OUT) < len) {
     279                return 0;
     280        }
     281        increment_pointer(fifo,FIFO_PTR_OUT,len);
    282282        return len;
    283283}
     
    285285int tracefifo_ack_update(struct tracefifo_t *fifo, size_t len){
    286286        assert(fifo);
    287         if (tracefifo_compare(fifo,OUT,ACK) < len) {
    288                 return 0;
    289         }
    290         increment_pointer(fifo,ACK,len);
     287        if (tracefifo_compare(fifo,FIFO_PTR_OUT,FIFO_PTR_ACK) < len) {
     288                return 0;
     289        }
     290        increment_pointer(fifo,FIFO_PTR_ACK,len);
    291291        return len;
    292292}
     
    299299         */
    300300        assert(fifo);
    301         fifo->datamap[OUT] = fifo->datamap[ACK];
    302 }
    303 
     301        fifo->datamap[FIFO_PTR_OUT] = fifo->datamap[FIFO_PTR_ACK];
     302}
     303
Note: See TracChangeset for help on using the changeset viewer.