--- /dev/null
+2006-02-20 Adam Jackson <ajax@freedesktop.org>
+
+ * ChangeLog:
+ * Makefile.am:
+ Created.
+
+ * TODO:
+ * xf86drm.c:
+ * xf86drm.h:
+ * xf86drmHash.c:
+ * xf86drmRandom.c:
+ * xf86drmSL.c:
+ Formatting cleanup, dead code removal. Remove N() namespacing macro,
+ useless. Remove SIGIO handling functions as they're server-only and
+ properly belong in libdri.
libdrmincludedir = ${includedir}
libdrminclude_HEADERS = xf86drm.h
+
+EXTRA_DIST = ChangeLog TODO
- drmMsg, xf86DrvMsgVerb versus vfprintf
- drmOpenDevice tries chmod/chown if in server
- drmOpen{,ByName} tries to load kernel module if in server
- - drm*SIGIOHandler only exists in server
- All but the last three should probably be factored out into libdri.
+ All but the last two should probably be factored out into libdri.
* DEALINGS IN THE SOFTWARE.
*/
-/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drm.c,v 1.36 2003/08/24 17:35:35 tsi Exp $ */
-
#ifdef HAVE_XORG_CONFIG_H
#include <xorg-config.h>
#endif
# include "drm.h"
#endif
-/* No longer needed with CVS kernel modules on alpha
-#if defined(__alpha__) && defined(__linux__)
-extern unsigned long _bus_base(void);
-#define BUS_BASE _bus_base()
-#endif
-*/
-
/* Not all systems have MAP_FAILED defined */
#ifndef MAP_FAILED
#define MAP_FAILED ((void *)-1)
#define DRM_MAX_MINOR 16
#endif
+/*
+ * This definition needs to be changed on some systems if dev_t is a structure.
+ * If there is a header file we can get it from, there would be best.
+ */
#ifndef makedev
- /* This definition needs to be changed on
- some systems if dev_t is a structure.
- If there is a header file we can get it
- from, there would be best. */
#define makedev(x,y) ((dev_t)(((x) << 8) | (y)))
#endif
if ((fd = drmOpenMinor(0, 1)) < 0) {
#ifdef __linux__
- /* Try proc for backward Linux compatibility */
+ /* Try proc for backward Linux compatibility */
if (!access("/proc/dri/0", R_OK)) return 1;
#endif
return 0;
id = drmGetBusid(fd);
drmMsg("drmGetBusid returned '%s'\n", id ? id : "NULL");
if (!id || !*id) {
- if (id) {
+ if (id)
drmFreeBusid(id);
- }
return fd;
} else {
drmFreeBusid(id);
}
#ifdef __linux__
- /* Backward-compatibility /proc support */
+ /* Backward-compatibility /proc support */
for (i = 0; i < 8; i++) {
char proc_name[64], buf[512];
char *driver, *pt, *devstring;
buf[retcode-1] = '\0';
for (driver = pt = buf; *pt && *pt != ' '; ++pt)
;
- if (*pt) { /* Device is next */
+ if (*pt) { /* Device is next */
*pt = '\0';
if (!strcmp(driver, name)) { /* Match */
for (devstring = ++pt; *pt && *pt != ' '; ++pt)
;
if (*pt) { /* Found busid */
return drmOpenByBusid(++pt);
- } else { /* No busid */
+ } else { /* No busid */
return drmOpenDevice(strtol(devstring, NULL, 0),i);
}
}
if (fd >= 0)
return fd;
}
+
if (name)
return drmOpenByName(name);
+
return -1;
}
drmVersionPtr retval;
drm_version_t *version = drmMalloc(sizeof(*version));
- /* First, get the lengths */
version->name_len = 0;
version->name = NULL;
version->date_len = 0;
return NULL;
}
- /* Now, allocate space and get the data */
if (version->name_len)
version->name = drmMalloc(version->name_len + 1);
if (version->date_len)
return NULL;
}
- /* The results might not be null-terminated
- strings, so terminate them. */
-
+ /* The results might not be null-terminated strings, so terminate them. */
if (version->name_len) version->name[version->name_len] = '\0';
if (version->date_len) version->date[version->date_len] = '\0';
if (version->desc_len) version->desc[version->desc_len] = '\0';
- /* Now, copy it all back into the
- client-visible data structure... */
retval = drmMalloc(sizeof(*retval));
drmCopyVersion(retval, version);
drmFreeKernelVersion(version);
* This function is a wrapper around the DRM_IOCTL_ADD_MAP ioctl, passing
* the arguments in a drm_map structure.
*/
-int drmAddMap(int fd,
- drm_handle_t offset,
- drmSize size,
- drmMapType type,
- drmMapFlags flags,
- drm_handle_t * handle)
+int drmAddMap(int fd, drm_handle_t offset, drmSize size, drmMapType type,
+ drmMapFlags flags, drm_handle_t *handle)
{
drm_map_t map;
map.offset = offset;
-/* No longer needed with CVS kernel modules on alpha
-#ifdef __alpha__
- if (type != DRM_SHM)
- map.offset += BUS_BASE;
-#endif
-*/
map.size = size;
map.handle = 0;
map.type = type;
* \internal
* This function is a wrapper for mmap().
*/
-int drmMap(int fd,
- drm_handle_t handle,
- drmSize size,
- drmAddressPtr address)
+int drmMap(int fd, drm_handle_t handle, drmSize size, drmAddressPtr address)
{
static unsigned long pagesize_mask = 0;
* \return zero on success, or a negative value on failure.
*
* \internal
- * This function is a wrapper for unmap().
+ * This function is a wrapper for munmap().
*/
int drmUnmap(drmAddress address, drmSize size)
{
drmFree(info.list);
return NULL;
}
- /* Now, copy it all back into the
- client-visible data structure... */
+
retval = drmMalloc(sizeof(*retval));
retval->count = info.count;
retval->list = drmMalloc(info.count * sizeof(*retval->list));
drmFree(bufs.list);
return NULL;
}
- /* Now, copy it all back into the
- client-visible data structure... */
+
retval = drmMalloc(sizeof(*retval));
retval->count = bufs.count;
retval->list = drmMalloc(bufs.count * sizeof(*retval->list));
drm_dma_t dma;
int ret, i = 0;
- /* Copy to hidden structure */
dma.context = request->context;
dma.send_count = request->send_count;
dma.send_indices = request->send_list;
return ioctl(fd, DRM_IOCTL_UNLOCK, &lock);
}
-drm_context_t * drmGetReservedContextList(int fd, int *count)
+drm_context_t *drmGetReservedContextList(int fd, int *count)
{
drm_ctx_res_t res;
drm_ctx_t *list;
return retval;
}
-void drmFreeReservedContextList(drm_context_t * pt)
+void drmFreeReservedContextList(drm_context_t *pt)
{
drmFree(pt);
}
* This function is a wrapper around the DRM_IOCTL_ADD_CTX ioctl, passing the
* argument in a drm_ctx structure.
*/
-int drmCreateContext(int fd, drm_context_t * handle)
+int drmCreateContext(int fd, drm_context_t *handle)
{
drm_ctx_t ctx;
{
drm_ctx_t ctx;
- /* Context preserving means that no context
- switched are done between DMA buffers
- from one context and the next. This is
- suitable for use in the X server (which
- promises to maintain hardware context,
- or in the client-side library when
- buffers are swapped on behalf of two
- threads. */
+ /*
+ * Context preserving means that no context switches are done between DMA
+ * buffers from one context and the next. This is suitable for use in the
+ * X server (which promises to maintain hardware context), or in the
+ * client-side library when buffers are swapped on behalf of two threads.
+ */
ctx.handle = context;
ctx.flags = 0;
if (flags & DRM_CONTEXT_PRESERVED) ctx.flags |= _DRM_CONTEXT_PRESERVED;
return 0;
}
-int drmGetContextFlags(int fd, drm_context_t context, drm_context_tFlagsPtr flags)
+int drmGetContextFlags(int fd, drm_context_t context,
+ drm_context_tFlagsPtr flags)
{
drm_ctx_t ctx;
return 0;
}
-int drmCreateDrawable(int fd, drm_drawable_t * handle)
+int drmCreateDrawable(int fd, drm_drawable_t *handle)
{
drm_draw_t draw;
if (ioctl(fd, DRM_IOCTL_ADD_DRAW, &draw)) return -errno;
return value;
}
-int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id, drm_handle_t handle)
+int drmAddContextPrivateMapping(int fd, drm_context_t ctx_id,
+ drm_handle_t handle)
{
drm_ctx_priv_map_t map;
return 0;
}
-int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id, drm_handle_t * handle)
+int drmGetContextPrivateMapping(int fd, drm_context_t ctx_id,
+ drm_handle_t *handle)
{
drm_ctx_priv_map_t map;
* It issues a read-write ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
-int drmSetInterfaceVersion(int fd, drmSetVersion *version )
+int drmSetInterfaceVersion(int fd, drmSetVersion *version)
{
int retcode = 0;
drm_set_version_t sv;
* It issues a read ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
-int drmCommandRead(int fd, unsigned long drmCommandIndex,
- void *data, unsigned long size )
+int drmCommandRead(int fd, unsigned long drmCommandIndex, void *data,
+ unsigned long size)
{
unsigned long request;
* It issues a write ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
-int drmCommandWrite(int fd, unsigned long drmCommandIndex,
- void *data, unsigned long size )
+int drmCommandWrite(int fd, unsigned long drmCommandIndex, void *data,
+ unsigned long size)
{
unsigned long request;
* It issues a read-write ioctl given by
* \code DRM_COMMAND_BASE + drmCommandIndex \endcode.
*/
-int drmCommandWriteRead(int fd, unsigned long drmCommandIndex,
- void *data, unsigned long size )
+int drmCommandWriteRead(int fd, unsigned long drmCommandIndex, void *data,
+ unsigned long size)
{
unsigned long request;
}
return 0;
}
-
-#if defined(XFree86Server)
-static void drmSIGIOHandler(int interrupt, void *closure)
-{
- unsigned long key;
- void *value;
- ssize_t count;
- drm_ctx_t ctx;
- typedef void (*_drmCallback)(int, void *, void *);
- char buf[256];
- drm_context_t old;
- drm_context_t new;
- void *oldctx;
- void *newctx;
- char *pt;
- drmHashEntry *entry;
-
- if (!drmHashTable) return;
- if (drmHashFirst(drmHashTable, &key, &value)) {
- entry = value;
- do {
-#if 0
- fprintf(stderr, "Trying %d\n", entry->fd);
-#endif
- if ((count = read(entry->fd, buf, sizeof(buf))) > 0) {
- buf[count] = '\0';
-#if 0
- fprintf(stderr, "Got %s\n", buf);
-#endif
-
- for (pt = buf; *pt != ' '; ++pt); /* Find first space */
- ++pt;
- old = strtol(pt, &pt, 0);
- new = strtol(pt, NULL, 0);
- oldctx = drmGetContextTag(entry->fd, old);
- newctx = drmGetContextTag(entry->fd, new);
-#if 0
- fprintf(stderr, "%d %d %p %p\n", old, new, oldctx, newctx);
-#endif
- ((_drmCallback)entry->f)(entry->fd, oldctx, newctx);
- ctx.handle = new;
- ioctl(entry->fd, DRM_IOCTL_NEW_CTX, &ctx);
- }
- } while (drmHashNext(drmHashTable, &key, &value));
- }
-}
-
-int drmInstallSIGIOHandler(int fd, void (*f)(int, void *, void *))
-{
- drmHashEntry *entry;
-
- entry = drmGetEntry(fd);
- entry->f = f;
-
- return xf86InstallSIGIOHandler(fd, drmSIGIOHandler, 0);
-}
-
-int drmRemoveSIGIOHandler(int fd)
-{
- drmHashEntry *entry = drmGetEntry(fd);
-
- entry->f = NULL;
-
- return xf86RemoveSIGIOHandler(fd);
-}
-#endif
extern int drmDestroyDrawable(int fd, drm_drawable_t handle);
extern int drmCtlInstHandler(int fd, int irq);
extern int drmCtlUninstHandler(int fd);
-extern int drmInstallSIGIOHandler(int fd,
- void (*f)(int fd,
- void *oldctx,
- void *newctx));
-extern int drmRemoveSIGIOHandler(int fd);
/* General user-level programmer's API: authenticated client and/or X */
extern int drmMap(int fd,
# endif
#endif
-#define N(x) drm##x
-
#define HASH_MAGIC 0xdeadbeef
#define HASH_DEBUG 0
#define HASH_SIZE 512 /* Good for about 100 entries */
} HashTable, *HashTablePtr;
#if HASH_MAIN
-extern void *N(HashCreate)(void);
-extern int N(HashDestroy)(void *t);
-extern int N(HashLookup)(void *t, unsigned long key, unsigned long *value);
-extern int N(HashInsert)(void *t, unsigned long key, unsigned long value);
-extern int N(HashDelete)(void *t, unsigned long key);
+extern void *drmHashCreate(void);
+extern int drmHashDestroy(void *t);
+extern int drmHashLookup(void *t, unsigned long key, unsigned long *value);
+extern int drmHashInsert(void *t, unsigned long key, unsigned long value);
+extern int drmHashDelete(void *t, unsigned long key);
#endif
static unsigned long HashHash(unsigned long key)
return hash;
}
-void *N(HashCreate)(void)
+void *drmHashCreate(void)
{
HashTablePtr table;
int i;
return table;
}
-int N(HashDestroy)(void *t)
+int drmHashDestroy(void *t)
{
HashTablePtr table = (HashTablePtr)t;
HashBucketPtr bucket;
return NULL;
}
-int N(HashLookup)(void *t, unsigned long key, void **value)
+int drmHashLookup(void *t, unsigned long key, void **value)
{
HashTablePtr table = (HashTablePtr)t;
HashBucketPtr bucket;
return 0; /* Found */
}
-int N(HashInsert)(void *t, unsigned long key, void *value)
+int drmHashInsert(void *t, unsigned long key, void *value)
{
HashTablePtr table = (HashTablePtr)t;
HashBucketPtr bucket;
return 0; /* Added to table */
}
-int N(HashDelete)(void *t, unsigned long key)
+int drmHashDelete(void *t, unsigned long key)
{
HashTablePtr table = (HashTablePtr)t;
unsigned long hash;
return 0;
}
-int N(HashNext)(void *t, unsigned long *key, void **value)
+int drmHashNext(void *t, unsigned long *key, void **value)
{
HashTablePtr table = (HashTablePtr)t;
return 0;
}
-int N(HashFirst)(void *t, unsigned long *key, void **value)
+int drmHashFirst(void *t, unsigned long *key, void **value)
{
HashTablePtr table = (HashTablePtr)t;
table->p0 = 0;
table->p1 = table->buckets[0];
- return N(HashNext)(table, key, value);
+ return drmHashNext(table, key, value);
}
#if HASH_MAIN
unsigned long key, unsigned long value)
{
unsigned long retval = 0;
- int retcode = N(HashLookup)(table, key, &retval);
+ int retcode = drmHashLookup(table, key, &retval);
switch (retcode) {
case -1:
int i;
printf("\n***** 256 consecutive integers ****\n");
- table = N(HashCreate)();
- for (i = 0; i < 256; i++) N(HashInsert)(table, i, i);
+ table = drmHashCreate();
+ for (i = 0; i < 256; i++) drmHashInsert(table, i, i);
for (i = 0; i < 256; i++) check_table(table, i, i);
for (i = 256; i >= 0; i--) check_table(table, i, i);
compute_dist(table);
- N(HashDestroy)(table);
+ drmHashDestroy(table);
printf("\n***** 1024 consecutive integers ****\n");
- table = N(HashCreate)();
- for (i = 0; i < 1024; i++) N(HashInsert)(table, i, i);
+ table = drmHashCreate();
+ for (i = 0; i < 1024; i++) drmHashInsert(table, i, i);
for (i = 0; i < 1024; i++) check_table(table, i, i);
for (i = 1024; i >= 0; i--) check_table(table, i, i);
compute_dist(table);
- N(HashDestroy)(table);
+ drmHashDestroy(table);
printf("\n***** 1024 consecutive page addresses (4k pages) ****\n");
- table = N(HashCreate)();
- for (i = 0; i < 1024; i++) N(HashInsert)(table, i*4096, i);
+ table = drmHashCreate();
+ for (i = 0; i < 1024; i++) drmHashInsert(table, i*4096, i);
for (i = 0; i < 1024; i++) check_table(table, i*4096, i);
for (i = 1024; i >= 0; i--) check_table(table, i*4096, i);
compute_dist(table);
- N(HashDestroy)(table);
+ drmHashDestroy(table);
printf("\n***** 1024 random integers ****\n");
- table = N(HashCreate)();
+ table = drmHashCreate();
srandom(0xbeefbeef);
- for (i = 0; i < 1024; i++) N(HashInsert)(table, random(), i);
+ for (i = 0; i < 1024; i++) drmHashInsert(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++) check_table(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 1024; i++) check_table(table, random(), i);
compute_dist(table);
- N(HashDestroy)(table);
+ drmHashDestroy(table);
printf("\n***** 5000 random integers ****\n");
- table = N(HashCreate)();
+ table = drmHashCreate();
srandom(0xbeefbeef);
- for (i = 0; i < 5000; i++) N(HashInsert)(table, random(), i);
+ for (i = 0; i < 5000; i++) drmHashInsert(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++) check_table(table, random(), i);
srandom(0xbeefbeef);
for (i = 0; i < 5000; i++) check_table(table, random(), i);
compute_dist(table);
- N(HashDestroy)(table);
+ drmHashDestroy(table);
return 0;
}
# endif
#endif
-#define N(x) drm##x
-
#define RANDOM_MAGIC 0xfeedbeef
#define RANDOM_DEBUG 0
} RandomState;
#if RANDOM_MAIN
-extern void *N(RandomCreate)(unsigned long seed);
-extern int N(RandomDestroy)(void *state);
-extern unsigned long N(Random)(void *state);
-extern double N(RandomDouble)(void *state);
+extern void *drmRandomCreate(unsigned long seed);
+extern int drmRandomDestroy(void *state);
+extern unsigned long drmRandom(void *state);
+extern double drmRandomDouble(void *state);
#endif
-void *N(RandomCreate)(unsigned long seed)
+void *drmRandomCreate(unsigned long seed)
{
RandomState *state;
return state;
}
-int N(RandomDestroy)(void *state)
+int drmRandomDestroy(void *state)
{
RANDOM_FREE(state);
return 0;
}
-unsigned long N(Random)(void *state)
+unsigned long drmRandom(void *state)
{
RandomState *s = (RandomState *)state;
long hi;
return s->seed;
}
-double N(RandomDouble)(void *state)
+double drmRandomDouble(void *state)
{
RandomState *s = (RandomState *)state;
- return (double)N(Random)(state)/(double)s->m;
+ return (double)drmRandom(state)/(double)s->m;
}
#if RANDOM_MAIN
unsigned long initial;
void *state;
- state = N(RandomCreate)(seed);
- initial = N(Random)(state);
+ state = drmRandomCreate(seed);
+ initial = drmRandom(state);
++count;
- while (initial != N(Random)(state)) {
+ while (initial != drmRandom(state)) {
if (!++count) break;
}
printf("With seed of %10ld, period = %10lu (0x%08lx)\n",
seed, count, count);
- N(RandomDestroy)(state);
+ drmRandomDestroy(state);
}
int main(void)
int i;
unsigned long rand;
- state = N(RandomCreate)(1);
+ state = drmRandomCreate(1);
for (i = 0; i < 10000; i++) {
- rand = N(Random)(state);
+ rand = drmRandom(state);
}
printf("After 10000 iterations: %lu (%lu expected): %s\n",
rand, state->check,
rand - state->check ? "*INCORRECT*" : "CORRECT");
- N(RandomDestroy)(state);
+ drmRandomDestroy(state);
printf("Checking periods...\n");
check_period(1);
# endif
#endif
-#define N(x) drm##x
-
#define SL_LIST_MAGIC 0xfacade00LU
#define SL_ENTRY_MAGIC 0x00fab1edLU
#define SL_FREED_MAGIC 0xdecea5edLU
} SkipList, *SkipListPtr;
#if SL_MAIN
-extern void *N(SLCreate)(void);
-extern int N(SLDestroy)(void *l);
-extern int N(SLLookup)(void *l, unsigned long key, void **value);
-extern int N(SLInsert)(void *l, unsigned long key, void *value);
-extern int N(SLDelete)(void *l, unsigned long key);
-extern int N(SLNext)(void *l, unsigned long *key, void **value);
-extern int N(SLFirst)(void *l, unsigned long *key, void **value);
-extern void N(SLDump)(void *l);
-extern int N(SLLookupNeighbors)(void *l, unsigned long key,
+extern void *drmSLCreate(void);
+extern int drmSLDestroy(void *l);
+extern int drmSLLookup(void *l, unsigned long key, void **value);
+extern int drmSLInsert(void *l, unsigned long key, void *value);
+extern int drmSLDelete(void *l, unsigned long key);
+extern int drmSLNext(void *l, unsigned long *key, void **value);
+extern int drmSLFirst(void *l, unsigned long *key, void **value);
+extern void drmSLDump(void *l);
+extern int drmSLLookupNeighbors(void *l, unsigned long key,
unsigned long *prev_key, void **prev_value,
unsigned long *next_key, void **next_value);
#endif
return level;
}
-void *N(SLCreate)(void)
+void *drmSLCreate(void)
{
SkipListPtr list;
int i;
return list;
}
-int N(SLDestroy)(void *l)
+int drmSLDestroy(void *l)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
return entry->forward[0];
}
-int N(SLInsert)(void *l, unsigned long key, void *value)
+int drmSLInsert(void *l, unsigned long key, void *value)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
return 0; /* Added to table */
}
-int N(SLDelete)(void *l, unsigned long key)
+int drmSLDelete(void *l, unsigned long key)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr update[SL_MAX_LEVEL + 1];
return 0;
}
-int N(SLLookup)(void *l, unsigned long key, void **value)
+int drmSLLookup(void *l, unsigned long key, void **value)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr update[SL_MAX_LEVEL + 1];
return -1;
}
-int N(SLLookupNeighbors)(void *l, unsigned long key,
+int drmSLLookupNeighbors(void *l, unsigned long key,
unsigned long *prev_key, void **prev_value,
unsigned long *next_key, void **next_value)
{
return retcode;
}
-int N(SLNext)(void *l, unsigned long *key, void **value)
+int drmSLNext(void *l, unsigned long *key, void **value)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
return 0;
}
-int N(SLFirst)(void *l, unsigned long *key, void **value)
+int drmSLFirst(void *l, unsigned long *key, void **value)
{
SkipListPtr list = (SkipListPtr)l;
if (list->magic != SL_LIST_MAGIC) return -1; /* Bad magic */
list->p0 = list->head->forward[0];
- return N(SLNext)(list, key, value);
+ return drmSLNext(list, key, value);
}
/* Dump internal data structures for debugging. */
-void N(SLDump)(void *l)
+void drmSLDump(void *l)
{
SkipListPtr list = (SkipListPtr)l;
SLEntryPtr entry;
unsigned long key;
void *value;
- if (N(SLFirst)(list, &key, &value)) {
+ if (drmSLFirst(list, &key, &value)) {
do {
printf("key = %5lu, value = %p\n", key, value);
- } while (N(SLNext)(list, &key, &value));
+ } while (drmSLNext(list, &key, &value));
}
}
SL_RANDOM_INIT(12345);
- list = N(SLCreate)();
+ list = drmSLCreate();
for (i = 0; i < size; i++) {
keys[i] = SL_RANDOM;
- N(SLInsert)(list, keys[i], NULL);
+ drmSLInsert(list, keys[i], NULL);
}
previous = 0;
- if (N(SLFirst)(list, &key, &value)) {
+ if (drmSLFirst(list, &key, &value)) {
do {
if (key <= previous) {
printf( "%lu !< %lu\n", previous, key);
}
previous = key;
- } while (N(SLNext)(list, &key, &value));
+ } while (drmSLNext(list, &key, &value));
}
gettimeofday(&start, NULL);
for (j = 0; j < iter; j++) {
for (i = 0; i < size; i++) {
- if (N(SLLookup)(list, keys[i], &value))
+ if (drmSLLookup(list, keys[i], &value))
printf("Error %lu %d\n", keys[i], i);
}
}
printf("%0.2f microseconds for list length %d\n", usec, size);
- N(SLDestroy)(list);
+ drmSLDestroy(list);
return usec;
}
SkipListPtr list;
double usec, usec2, usec3, usec4;
- list = N(SLCreate)();
+ list = drmSLCreate();
printf( "list at %p\n", list);
print(list);
printf("\n==============================\n\n");
- N(SLInsert)(list, 123, NULL);
- N(SLInsert)(list, 213, NULL);
- N(SLInsert)(list, 50, NULL);
+ drmSLInsert(list, 123, NULL);
+ drmSLInsert(list, 213, NULL);
+ drmSLInsert(list, 50, NULL);
print(list);
printf("\n==============================\n\n");
print_neighbors(list, 256);
printf("\n==============================\n\n");
- N(SLDelete)(list, 50);
+ drmSLDelete(list, 50);
print(list);
printf("\n==============================\n\n");
- N(SLDump)(list);
- N(SLDestroy)(list);
+ drmSLDump(list);
+ drmSLDestroy(list);
printf("\n==============================\n\n");
usec = do_time(100, 10000);