You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1016 B

/* this header file comes from libowfat, */
#ifndef IARRAY_H
#define IARRAY_H
/* This header defines an indirect array for use with the io_* routines.
* Assumptions:
* - the elements are small (many fit on one page),
* - the platform has an atomic compare-and-swap instruction
* - the compiler supports it via __sync_val_compare_and_swap
#include "uint64.h"
#include <stddef.h>
#ifdef __MINGW32__
#include <windows.h>
#include <pthread.h>
typedef struct _iarray_page {
struct _iarray_page* next;
char data[];
} iarray_page;
typedef struct {
iarray_page* pages[16];
size_t elemsize,elemperpage,bytesperpage;
} iarray;
void iarray_init(iarray* ia,size_t elemsize);
void* iarray_get(iarray* ia,size_t pos);
void* iarray_allocate(iarray* ia,size_t pos);
/* WARNING: do not use the array during or after iarray_free, make sure
* no threads are potentially doing anything with the iarray while it is
* being freed! */
void iarray_free(iarray* ia);