I am working on a software implementation of OpenGL, and OpenGL seems to require that I return 32-bit pointers. To save time, I am putting this into a C equivalent of map with 64-bit systems in order to retrieve 64-bit pointers from 32-bit psuedo-addresses. However, on 32-bit systems, this would cause a hassle, and so I should just use the pointer verbatim.
Here is basically what I want to do in my shared header:
#if <64-bit>
    #include <search.h>
    extern void * pointerTable;
    typedef struct {
          int key;
          void* value;
    } intPtrMap;
    inline int compar(const void *l, const void *r) {
        const intPtrMap *lm = l;
        const intPtrMap *lr = r;
        return lm->key - lr->key;
    }
    inline uint32_t allocate(size) {
        void* result = malloc(size);
        intPtrMap *a = malloc(sizeof(intStrMap));
        a->key = (uint32_t) result;
        a->value = result;
        tsearch(a, &pointerTable, compar);
        return (uint32_t) result;
    }
    inline int getPtr(ptr) {
        intPtrMap *find_a = malloc(sizeof(intPtrMap));
        find_a->key = ptr;
        void *r = tfind(find_a, &root, compar);
        return (*(intPtrMap**)r)->value;
    }
#else
    inline uint32_t allocate(size) {
        return (uint32_t) malloc(size);
    }
    inline uint32_t getPtr(ptr) {
        return (uint32_t) ptr;
    }
#endif
Any suggestions on how to do the first if?
 
    