1856339728ff84ac560354d44ac555aaecc20a30
[IRC.git] / Robust / src / Runtime / DSTM / interface / dstm.h
1 #ifndef _DSTM_H_
2 #define _DSTM_H_
3
4 #include <stdlib.h>
5 #include <stdio.h>
6 #include <string.h>
7 #include "hashtable.h"
8
9 enum status {CLEAN, DIRTY};
10
11 typedef struct objheader {
12         unsigned int oid;
13         unsigned short type;
14         unsigned short version;
15         unsigned short rcount;
16         char status;
17 } objheader_t;
18
19 typedef struct objstr {
20         void *base;
21         unsigned int size;
22         void *top;
23         struct objstr *next;
24 } objstr_t;
25
26 typedef struct transrecord {
27         objstr_t *cache;
28         hashtable_t *lookupTable;
29 } transrecord_t;
30
31 /* Initialize main object store and lookup tables, start server thread. */
32 void dstmInit(void);
33
34 /* Prototypes for object header */
35 unsigned int getNewOID(void);
36 unsigned int objSize(objheader_t *object);
37 void objInsert(objheader_t *object); //copies object to main object store
38 unsigned int objCreate(unsigned short type); //returns oid
39 /* end object header */
40
41 /* Prototypes for object store */
42 objstr_t *objstrCreate(unsigned int size); //size in bytes
43 void objstrDelete(objstr_t *store); //traverse and free entire list
44 void *objstrAlloc(objstr_t *store, unsigned int size); //size in bytes
45 /* end object store */
46
47 /* Prototypes for server portion */
48 void *dstmListen();
49 void *dstmAccept(void *);
50 /* end server portion */
51
52 /* Prototypes for transactions */
53 transrecord_t *transStart();
54 objheader_t *transRead(transrecord_t *record, unsigned int oid);
55 int transCommit(transrecord_t *record); //return 0 if successful
56 /* end transactions */
57
58 #endif
59