I'm writing code that creates trees and times different methods of creating trees. I can't seem to get rdtsc to function properly, though.
Here's my code:
    #include <stdio.h>
    #include <stdlib.h>
    #define SIZE 10
    struct tnode {
        int val;
        struct tnode *left;
        struct tnode *right;
    };
    struct tnode *addnode(struct tnode *p, long n);
    void treeprint(struct tnode *p);
    main () {
        long data[SIZE]={6, 3, 8, 1, 7, 5, 2, 9, 0, 4};
        int i;
        struct tnode *node, *root;
        unsigned long long rdtsc();
        unsigned long long a, b;
        printf("size of tnode   = %d\n", sizeof(struct tnode));
        printf("size of *node = %d\n", sizeof *node);
        printf("size of &node = %d\n", sizeof &node);
        printf("size of root = %d\n", sizeof root);
        printf("size of *root = %d\n", sizeof *root);
        printf("size of &root = %d\n", sizeof &root);
        a = rdtsc();
        root = NULL;
        for (i = 0; i < SIZE; i++)
            root = addnode(root, data[i]);
        b = rdtsc();
        treeprint(root);
        printf("It took %llu to make this tree.\n", b-a);
    }
Assume that all functions listed above are taken care of (aside from rdtsc, of course).
When I try to compile, I get this error:
/tmp/cccnojMf.o: In function `main':
tree.c:(.text+0xd9): undefined reference to `rdtsc'
tree.c:(.text+0x120): undefined reference to `rdtsc'
collect2: ld returned 1 exit status
Any ideas why I'm getting this undefined reference error?
 
    