Beispiel #1
0
int main(int argc, char *argv[]) {
    el *name, *tmp;

    char linebuf[BUFLEN];
    FILE *file;

    if ( (file = fopen( "test11.dat", "r" )) == NULL ) {
        perror("can't open: "); 
        exit(-1);
    }

    while (fgets(linebuf,BUFLEN,file) != NULL) {
        if ( (name = (el*)malloc(sizeof(el))) == NULL) exit(-1);
        strncpy(name->bname,linebuf,BUFLEN);
        DL_APPEND(head, name);
    }
    DL_SORT(head, namecmp);
    DL_FOREACH(head,tmp) printf("%s", tmp->bname);

    /* now delete the list head */
    printf("deleting head %shead->prev: %s", head->bname, head->prev->bname);
    DL_DELETE(head,head);
    DL_FOREACH(head,tmp) printf("%s", tmp->bname);

    fclose(file);

    return 0;
}
Beispiel #2
0
int main(int argc, char *argv[]) {
    el *name, *elt, *tmp, etmp;
    int i;
    example_user_t *user, *users=NULL;

    char linebuf[BUFLEN];
    FILE *file;

    UT_string *s;
    char binary[] = "\xff\xff";

    if ( (file = fopen( "test11.dat", "r" )) == NULL ) {
        perror("can't open: ");
        exit(-1);
    }

    while (fgets(linebuf,BUFLEN,file) != NULL) {
        if ( (name = (el*)malloc(sizeof(el))) == NULL) exit(-1);
        strncpy(name->bname,linebuf,BUFLEN);
        DL_APPEND(head, name);
    }
    DL_SORT(head, namecmp);
    DL_FOREACH(head,elt) printf("%s", elt->bname);

    memcpy(&etmp.bname, "WES\n", 5);
    DL_SEARCH(head,elt,&etmp,namecmp);
    if (elt) printf("found %s\n", elt->bname);

    /* now delete each element, use the safe iterator */
    DL_FOREACH_SAFE(head,elt,tmp) {
      DL_DELETE(head,elt);
    }
Beispiel #3
0
int main(int argc, char *argv[]) {
    el *name, *elt, *tmp, etmp;
    el *head = NULL; /* important- initialize to NULL! */

    char linebuf[BUFLEN];
    FILE *file;

    file = fopen( "test11.dat", "r" );
    if (file == NULL) {
        perror("can't open: ");
        exit(-1);
    }

    while (fgets(linebuf,BUFLEN,file) != NULL) {
        name = (el*)malloc(sizeof(el));
        if (name == NULL) exit(-1);
        strncpy(name->bname,linebuf,sizeof(name->bname));
        DL_APPEND(head, name);
    }
    DL_SORT(head, namecmp);
    DL_FOREACH(head,elt) printf("%s", elt->bname);

    memcpy(etmp.bname, "WES\n", 5UL);
    DL_SEARCH(head,elt,&etmp,namecmp);
    if (elt != NULL) printf("found %s\n", elt->bname);

    /* now delete each element, use the safe iterator */
    DL_FOREACH_SAFE(head,elt,tmp) {
      DL_DELETE(head,elt);
    }
Beispiel #4
0
int main(int argc, char *argv[])
{
    el *name, *elt, *tmp, etmp;
    int i;
    example_user_t *user, *users=NULL;
    el *head = NULL; /* important- initialize to NULL! */

    char linebuf[BUFLEN];
    FILE *file;

    UT_string *s;
    char binary[] = "\xff\xff";

    file = fopen( "test11.dat", "r" );
    if (file == NULL) {
        perror("can't open: ");
        exit(-1);
    }

    while (fgets(linebuf,BUFLEN,file) != NULL) {
        name = (el*)malloc(sizeof(el));
        if (name == NULL) {
            exit(-1);
        }
        strncpy(name->bname,linebuf,sizeof(name->bname));
        DL_APPEND(head, name);
    }
    DL_SORT(head, namecmp);
    DL_FOREACH(head,elt) {
        printf("%s", elt->bname);
    }
/*
 * Pretty prints the insts (as in program order) stats in TAs format.
 */
inline void
dis_print_inst_stats(struct dis_input *dis)
{
    struct dis_inst_node *iter = NULL;

    /* First, sort and print all instruction entries with timing info. */
    DL_SORT(dis->list_wback->list, dis_cb_cmp);
    DL_FOREACH(dis->list_wback->list, iter)
        dis_print_inst_entry_stats(dis, iter);

    /* Print L1 cache data, if present. */
    if (dis->l1) {
        cache_print_cache_data(dis->l1);

        /* Print L2 cache data, if present. */
        if (dis->l2) {
            dprint("\n");
            cache_print_cache_data(dis->l2);
        }

        dprint("\n");
    }


    /* Now, the scheduler configuration. */
    dprint("CONFIGURATION\n");
    dprint(" superscalar bandwidth (N) = %u\n", dis->n);
    dprint(" dispatch queue size (2*N) = %u\n", (dis->n * 2));
    dprint(" schedule queue size (S)   = %u\n", dis->s);

    /* Finally, some scheduler performance numbers. */
    dprint("RESULTS\n");
    dprint(" number of instructions = %u\n", dis_get_inst_num());
    dprint(" number of cycles       = %u\n", dis_get_cycle_num() + 1);
    dprint(" IPC                    = %.2f\n",
            (double) ((double) dis_get_inst_num() /
                        (double) (dis_get_cycle_num() + 1)));

    return;
}