#define MAXARRAYSIZE 2147483647
#define GETLOCKPTR(lock, array, byteindex) { \
- lock=(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)-2*sizeof(int)); \
+ lock=(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex)-2*sizeof(int)); \
}
#define GETLOCKVAL(lock, array, byteindex) { \
- lock=*(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)-2*sizeof(int)); \
+ lock=*(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex)-2*sizeof(int)); \
}
#define GETVERSIONVAL(version, array, byteindex) { \
- version=*(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)-sizeof(int)); \
+ version=*(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex)-sizeof(int)); \
+ }
+
+#define SETVERSION(array, byteindex, version) { \
+ *(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex)-sizeof(int))=version; \
}
#define GETVERSIONPTR(version, array, byteindex) { \
- version=(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)-sizeof(int)); \
+ version=(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex)-sizeof(int)); \
}
#define STMGETARRAY(dst, array, index, type) { \
int byteindex=index*sizeof(type); \
int * lengthoff=&array->___length___; \
- int *status; \
if (array!=array->___objlocation___) { \
- GETLOCKPTR(status, array, byteindex); \
- if ((*status)==STMNONE&&!(array->___objstatus___&NEW)) { \
- arraycopy(array, byteindex); \
- *status=STMCLEAN;}; \
+ if(!(array->___objstatus___&NEW)) { \
+ int *status; \
+ GETLOCKPTR(status, array, byteindex>>INDEXSHIFT); \
+ if ((*status)==STMNONE) { \
+ arraycopy(array, byteindex); \
+ *status=STMCLEAN;} \
+ } \
} \
dst=((type *)(((char *) lengthoff)+sizeof(int)))[index]; \
}
#define STMSETARRAY(array, index, src, type) { \
int byteindex=index*sizeof(type); \
int * lengthoff=&array->___length___; \
- int *status; \
- GETLOCKPTR(status, array, byteindex); \
- if (*status==STMNONE&&!(array->___objstatus___&NEW)) \
- arraycopy(array, byteindex, sizeof(type)*(*lengthoff)); \
- *status=STMDIRTY; \
+ if (!(array->___objstatus___&NEW)) { \
+ int *status; \
+ GETLOCKPTR(status, array, byteindex>>INDEXSHIFT); \
+ if ((*status)==STMNONE) \
+ arraycopy(array, byteindex); \
+ *status=STMDIRTY; \
+ } \
((type *)(((char *) lengthoff)+sizeof(int)))[index]=src; \
}
#endif
} \
} else
-#define READARRAYS \
+#define READARRAYS \
for(i=0; i<numoidrdlockedarray; i++) { \
objheader_t * transheader=oidrdlockedarray[i]; \
struct ArrayObject * transao=(struct ArrayObject *)&transheader[1]; \
void *objptr=curr->key;
objheader_t *header=(objheader_t *)(((char *)objptr)-sizeof(objheader_t));
unsigned int version = headeraddr->version;
-
+
PROCESSARRAY;
if(STATUS(headeraddr) & DIRTY) {
int j;
int addwrobject=0, addrdobject=0;
int elementsize=classsize[type];
- int baseoffset=((lowoffset*elementsize)&HIGHMASK)+sizeof(struct ArrayObject);
+ int baseoffset=(lowoffset<<INDEXSHIFT)+sizeof(int)+((int)&(((struct ArrayObject *)0)->___length___));
char *dstptr=((char *)dst)+baseoffset;
char *srcptr=((char *)src)+baseoffset;
for(j=lowoffset; j<=highoffset;j++, srcptr+=INDEXLENGTH,dstptr+=INDEXLENGTH) {
void arraycopy(struct ArrayObject *oid, int byteindex) {
struct ArrayObject * orig=(struct ArrayObject *) oid->___objlocation___;
int baseoffset=byteindex&HIGHMASK;
+ unsigned int mainversion;
+ int baseindex=baseoffset>>INDEXSHIFT;
+ GETVERSIONVAL(mainversion, orig, baseindex);
+ SETVERSION(oid, baseindex, mainversion);
A_memcpy(((char *)&oid[1])+baseoffset, ((char *)&orig[1])+baseoffset, INDEXLENGTH);
if (oid->lowindex>baseoffset)
oid->lowindex=baseoffset;
int basesize=length*classsize[type];
//round the base size up
basesize=(basesize+LOWMASK)&HIGHMASK;
- int bookkeepsize=(basesize>>INDEXSHIFT)*2*sizeof(int);
+ int numlocks=basesize>>INDEXSHIFT;
+ int bookkeepsize=numlocks*2*sizeof(int);
struct ArrayObject * v=(struct ArrayObject *)transCreateObj(ptr, sizeof(struct ArrayObject)+basesize+bookkeepsize, bookkeepsize);
+ unsigned int *intptr=(unsigned int *)(((char *)v)-sizeof(objheader_t));
+ for(;numlocks>0;numlocks--) {
+ intptr-=2;
+ intptr[0]=1;
+ }
v->highindex=-1;
v->lowindex=MAXARRAYSIZE;
#else
int basesize=length*classsize[type];
//round the base size up
basesize=(basesize+LOWMASK)&HIGHMASK;
- int bookkeepsize=(basesize>>INDEXSHIFT)*2*sizeof(int);
+ int numlocks=basesize>>INDEXSHIFT;
+ int bookkeepsize=(numlocks)*2*sizeof(int);
int *tmpint=mygcmalloc((struct garbagelist *) ptr, sizeof(struct ArrayObject)+basesize+sizeof(objheader_t)+bookkeepsize);
- objheader_t *tmp=(objheader_t *)(tmpint+bookkeepsize);
+ for(;numlocks>0;numlocks--) {
+ tmpint[0]=1;
+ tmpint+=2;
+ }
+ objheader_t *tmp=(objheader_t *)tmpint;
struct ArrayObject * v=(struct ArrayObject *) &tmp[1];
v->highindex=-1;
v->lowindex=MAXARRAYSIZE;