Commit 20dff4db authored by Marek Vavruša's avatar Marek Vavruša

contrib: added mempools from libucw

parent 4d6e2de4
This diff is collapsed.
../licenses/LGPL2
\ No newline at end of file
/*
* UCW Library -- Generic allocators
*
* (c) 2014 Martin Mares <mj@ucw.cz>
*/
#ifndef _UCW_ALLOC_H
#define _UCW_ALLOC_H
/**
* This structure describes a generic allocator. It provides pointers
* to three functions, which handle the actual (re)allocations.
**/
struct ucw_allocator {
void * (*alloc)(struct ucw_allocator *alloc, size_t size);
void * (*realloc)(struct ucw_allocator *alloc, void *ptr, size_t old_size, size_t new_size);
void (*free)(struct ucw_allocator *alloc, void *ptr);
};
/* alloc-std.c */
/**
* [[std]]
* This allocator uses <<basics:xmalloc()>>, <<basics:xrealloc()>> and <<basics:xfree()>>. The memory
* it allocates is left unitialized.
**/
extern struct ucw_allocator ucw_allocator_std;
/**
* [[zeroing]]
* This allocator uses <<basics:xmalloc()>>, <<basics:xrealloc()>> and <<basics:xfree()>>. All memory
* is zeroed upon allocation.
**/
extern struct ucw_allocator ucw_allocator_zeroed;
#endif
/*
* UCW Library -- Configuration-Dependent Definitions
*
* (c) 1997--2012 Martin Mares <mj@ucw.cz>
* (c) 2006 Robert Spalek <robert@ucw.cz>
*
* This software may be freely distributed and used according to the terms
* of the GNU Lesser General Public License.
*/
#ifndef _UCW_CONFIG_H
#define _UCW_CONFIG_H
/* Default page size and pointer alignment */
#ifndef CPU_PAGE_SIZE
#define CPU_PAGE_SIZE 4096
#endif
#define CPU_STRUCT_ALIGN sizeof(void *)
/* Tell libc we're going to use all extensions available */
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
/* Types (based on standard C99 integers) */
#include <stddef.h>
#include <stdint.h>
typedef uint8_t byte; /** Exactly 8 bits, unsigned **/
typedef uint8_t u8; /** Exactly 8 bits, unsigned **/
typedef int8_t s8; /** Exactly 8 bits, signed **/
typedef uint16_t u16; /** Exactly 16 bits, unsigned **/
typedef int16_t s16; /** Exactly 16 bits, signed **/
typedef uint32_t u32; /** Exactly 32 bits, unsigned **/
typedef int32_t s32; /** Exactly 32 bits, signed **/
typedef uint64_t u64; /** Exactly 64 bits, unsigned **/
typedef int64_t s64; /** Exactly 64 bits, signed **/
typedef unsigned int uint; /** A better pronounceable alias for `unsigned int` **/
typedef s64 timestamp_t; /** Milliseconds since an unknown epoch **/
// FIXME: This should be removed soon
typedef uint uns; /** Backwards compatible alias for `uint' ***/
#ifdef CONFIG_UCW_LARGE_FILES
typedef s64 ucw_off_t; /** File position (either 32- or 64-bit, depending on `CONFIG_UCW_LARGE_FILES`). **/
#else
typedef s32 ucw_off_t;
#endif
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment