Initial version checkin
[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
8 enum status {CLEAN, DIRTY};
9
10 typedef struct obj_header {
11         unsigned int oid;
12         unsigned short type;
13         unsigned short version;
14         unsigned short rcount;
15         char status;
16 } obj_header_t;
17
18 typedef struct obj_store {
19         unsigned int id;
20         char *base;
21         unsigned int size;
22         char *top;              //next available location
23         struct obj_store *next;
24 } obj_store_t;
25
26 //use for hash tables, transaction records.
27 //to check oid, do object->oid
28 typedef struct obj_lnode{
29         obj_header_t *object;
30         unsigned int oid;
31         struct obj_lnode *next;
32 } obj_listnode_t;
33
34 typedef struct obj_addr_table {
35         unsigned int size;      //number of elements, not bytes
36         obj_listnode_t *table;  //this should point to an array of object lists, of the specified size
37 } obj_addr_table_t;
38
39 typedef struct trans_record {
40         obj_listnode_t *obj_list;
41         obj_store_t *cache;
42         obj_addr_table_t *lookupTable;
43 } trans_record_t;
44
45 typedef struct obj_location_lnode {
46         unsigned int oid;
47         unsigned int mid;
48         struct obj_location_lnode *next;
49 } obj_location_listnode_t;
50
51 typedef struct {
52         unsigned int size; //number of elements, not bytes
53         obj_location_listnode_t *table; //this should point to an array of object lists, of the specified size
54 } obj_location_table;
55
56 /* Prototypes for object store */
57 void dstm_init(void);
58 void create_objstr(unsigned int);
59 void delete_objstr(int);
60 obj_store_t *get_objstr_begin(void);
61 /* end object store */
62
63
64 /* Prototypes for object header */
65 int get_newID(void);
66 int insertObject(obj_header_t h); 
67 int getObjSize(obj_header_t h);
68 void createObject(unsigned short type); 
69 /* end object header */
70
71
72
73 /*
74 void * allocate_size(unsigned int);
75 void initializeobj(unsigned int);
76 unsigned int getobjSize(obj_header *);
77 int insertAddr(obj_addr_table *, obj_header *);
78 int removeAddr(obj_addr_table *, unsigned int);
79 obj_header *getAddr(obj_addr_table *, unsigned int);
80 trans_record *transStart();
81 obj_header *transRead(trans_record *, unsigned int);
82 int transCommit(trans_record *);
83 int insertLocation(obj_location_table *, unsigned int, unsigned int);
84 int removeLocation(obj_location_table *, unsigned int);
85 unsigned int getLocation(obj_location_table *, unsigned int);
86 */
87
88 #endif