--- /dev/null
+#ifndef ARRAY_H
+#define ARRAY_H
+
+/* Array layout */
+#define INDEXSHIFT 4 //must be at least 3 for doubles
+#define DBLINDEXSHIFT INDEXSHIFT-1 //must be at least 3 for doubles
+
+#define GETLOCKPTR(lock, array, byteindex) { \
+ lock=(int *)((char *)array-sizeof(objheader_t)-sizeof(int)*(byteindex>>DBLINDEXSHIFT)); \
+ }
+
+#define GETVERSIONPTR(version, array, byteindex) { \
+ version=(int *)((char *)array-sizeof(objheader_t)-sizeof(int)*(byteindex>>DBLINDEXSHIFT)-sizeof(int)); \
+ }
+#endif
* This function creates objects in the transaction record
* =======================================================
*/
+#ifdef STMARRAY
+objheader_t *transCreateObj(void * ptr, unsigned int size, int bytelength) {
+ int *tmpint = mygcmalloc(ptr, (sizeof(objheader_t) + size));
+ objheader_t *tmp = (objheader_t *) (tmpint+(bytelength>>DBLINDEXSHIFT));
+#else
objheader_t *transCreateObj(void * ptr, unsigned int size) {
objheader_t *tmp = mygcmalloc(ptr, (sizeof(objheader_t) + size));
- objheader_t *retval=&tmp[1];
+#endif
+ objheader_t *retval=tmp+1;
tmp->lock=RW_LOCK_BIAS;
tmp->version = 1;
//initialize obj lock to the header
/* Array allocation function */
__attribute__((malloc)) struct ArrayObject * allocate_newarraytrans(void * ptr, int type, int length) {
+#ifdef STMARRAY
+ struct ArrayObject * v=(struct ArrayObject *)transCreateObj(ptr, sizeof(struct ArrayObject)+length*classsize[type]+sizeof(int)*(((length*classsize[type])>>DBLINDEXSHIFT)), (length*classsize[type])>>DBLINDEXSHIFT);
+#else
struct ArrayObject * v=(struct ArrayObject *)transCreateObj(ptr, sizeof(struct ArrayObject)+length*classsize[type]);
+#endif
if (length<0) {
printf("ERROR: negative array\n");
return NULL;
v->___length___=length;
return v;
}
+
__attribute__((malloc)) void * allocate_new(void * ptr, int type) {
objheader_t *tmp=mygcmalloc((struct garbagelist *) ptr, classsize[type]+sizeof(objheader_t));
struct ___Object___ * v=(struct ___Object___ *) &tmp[1];
/* Array allocation function */
__attribute__((malloc)) struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
+#ifdef STMARRAY
+ int *tmpint=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]+sizeof(objheader_t)+sizeof(int)*(((length*classsize[type])>>DBLINDEXSHIFT)));
+ objheader_t *tmp=(objheader_t *)(tmpint+((length*classsize[type])>>DBLINDEXSHIFT));
+#else
objheader_t *tmp=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+length*classsize[type]+sizeof(objheader_t));
+#endif
struct ArrayObject * v=(struct ArrayObject *) &tmp[1];
initdsmlocks(&tmp->lock);
tmp->version=1;