Program Listing for File allocm.h

Return to documentation for file (rcsw/ds/allocm.h)

#pragma once

/*******************************************************************************
 * Includes
 ******************************************************************************/
#include "rcsw/rcsw.h"

/*******************************************************************************
 * Structure Definitions
 ******************************************************************************/
struct RCSW_ATTR(packed, aligned (sizeof(dptr_t))) allocm_entry {
  int32_t value;
};

/*******************************************************************************
 * API Functions
 ******************************************************************************/
static inline void allocm_mark_free(struct allocm_entry* entry) {
  entry->value = -1;
}

static inline void allocm_mark_inuse(struct allocm_entry* entry) {
  entry->value = 0;
}

int allocm_probe(struct allocm_entry *map,
                 size_t max_elts,
                 size_t index) RCSW_PURE;

void allocm_init(struct allocm_entry* map, size_t max_elts);