summaryrefslogtreecommitdiffstats
path: root/lpsm.h
blob: 3612c4cd67e84fb7d6a0e9f60ba0f60e9ed8b228 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* ----------------------------------------------------------------------- *
 *   
 *   Copyright 2000-2008 H. Peter Anvin - All Rights Reserved
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Lesser General Public License as
 *   published by the Free Software Foundation, Inc.,
 *   59 Temple Place Ste 330, Boston MA 02111-1307, USA, version 2.1,
 *   incorporated herein by reference.
 *
 * ----------------------------------------------------------------------- */

/*
 * lpsm.h
 *
 * Public header file for the Linux Persistent Memory
 */

#ifndef LPSM_H
#define LPSM_H

#include <stdlib.h>
#include <signal.h>
#include <inttypes.h>
#include <sys/types.h>

#ifdef __cplusplus
extern "C" {
#endif

/* Low-level core routines */

/* When checkpointing, specify the level of synchronicity required */
enum psmsync {
  PSMSYNC_NONE,			/* No synchronicity */
  PSMSYNC_SKIP,			/* Skip if previous writeback still running */
  PSMSYNC_WAIT,			/* Wait if previous writeback still running */
  PSMSYNC_SYNC			/* Wait until this writeback finishes */
};
  
void *lpsm_arena_init(const char *, const char *, size_t *, void *);
pid_t lpsm_checkpoint(double, enum psmsync);
int lpsm_extend(size_t);
void lpsm_shutdown(void);
int lpsm_recover(const char *, const char *);
extern sig_atomic_t lpsm_need_checkpoint;

/* Arena management routines */

/* The allocator gives us this many "root pointers" for our own use.  They
   are initialized to NULL when a new arena is created, and are intended
   to be used to find all the data structures.  lpsm_arena_init()
   returns a pointer to this array (if successful). */
#define LPSM_ROOT_POINTERS	32

void **lpsm_init(const char *, const char *);
void *lpsm_malloc(size_t);
void lpsm_free(void *);
void *lpsm_realloc(void *, size_t);
struct lpsm_alloc_stats {
  size_t size;
  size_t free;
  size_t alloc;
};
void *lpsm_zalloc(size_t);
#ifdef __GNUC__
extern inline void *lpsm_calloc(size_t __nmemb, size_t __size)
{
  return lpsm_zalloc(__nmemb * __size);
}
#else
#define lpsm_calloc(__nmemb, __size) lpsm_zalloc((size_t)(__nmemb)*(size_t)(__size))
#endif

struct lpsm_alloc_stats *lpsm_alloc_stats(void);

#ifdef __cplusplus
}
#endif

#endif /* LPSM_H */