The ROme OpTimistic Simulator  2.0.0
A General-Purpose Multithreaded Parallel/Distributed Simulation Platform
slab.c File Reference

a Slab Allocator More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdint.h>
#include <stddef.h>
#include <sys/mman.h>
#include <math.h>
#include <assert.h>
#include <core/core.h>
#include <mm/mm.h>
+ Include dependency graph for slab.c:

Go to the source code of this file.

Macros

#define SLOTS_ALL_ZERO   ((uint64_t) 0)
 
#define SLOTS_FIRST   ((uint64_t) 1)
 
#define FIRST_FREE_SLOT(s)   ((size_t) __builtin_ctzll(s))
 
#define FREE_SLOTS(s)   ((size_t) __builtin_popcountll(s))
 
#define ONE_USED_SLOT(slots, empty_slotmask)
 

Functions

static int slab_is_valid (const struct slab_chain *const sch)
 
struct slab_chainslab_init (const size_t itemsize)
 
void * slab_alloc (struct slab_chain *const sch)
 
void slab_free (struct slab_chain *const sch, const void *const addr)
 
void slab_destroy (const struct slab_chain *const sch)
 

Detailed Description

a Slab Allocator

Slab Allocator

This file is part of ROOT-Sim (ROme OpTimistic Simulator).

ROOT-Sim is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; only version 3 of the License applies.

ROOT-Sim is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with ROOT-Sim; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

Author
Blagovest Buyukliev - https://github.com/bbu/userland-slab-allocator

Definition in file slab.c.

Macro Definition Documentation

#define ONE_USED_SLOT (   slots,
  empty_slotmask 
)
Value:
( \
( \
(~(slots) & (empty_slotmask)) & \
((~(slots) & (empty_slotmask)) - 1) \
) == SLOTS_ALL_ZERO \
)

Definition at line 45 of file slab.c.