#define MAXARRAYSIZE 2147483647
#define GETLOCKPTR(lock, array, byteindex) { \
- lock=(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)); \
+ lock=(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)-2*sizeof(int)); \
}
#define GETLOCKVAL(lock, array, byteindex) { \
- lock=*(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)); \
+ lock=*(unsigned int *)((char *)array-sizeof(objheader_t)-sizeof(int)*2*(byteindex>>INDEXSHIFT)-2*sizeof(int)); \
}
#define GETVERSIONVAL(version, array, byteindex) { \
int *status; \
if (array!=array->___objlocation___) { \
GETLOCKPTR(status, array, byteindex); \
- if ((*status)==STMNONE) { \
+ if ((*status)==STMNONE&&!(array->___objstatus___&NEW)) { \
arraycopy(array, byteindex); \
*status=STMCLEAN;}; \
} \
int byteindex=index*sizeof(type); \
int * lengthoff=&array->___length___; \
int *status; \
- GETLOCKPTR(status, array); \
- if (*status==STMNONE) \
+ GETLOCKPTR(status, array, byteindex); \
+ if (*status==STMNONE&&!(array->___objstatus___&NEW)) \
arraycopy(array, byteindex, sizeof(type)*(*lengthoff)); \
*status=STMDIRTY; \
((type *)(((char *) lengthoff)+sizeof(int)))[index]=src; \
int j; \
int addwrobject=0, addrdobject=0; \
for(j=lowoffset; j<=highoffset;j++) { \
- int status; \
+ unsigned int status; \
GETLOCKVAL(status, transao, j); \
if (status==STMDIRTY) { \
unsigned int * lockptr; \
int highoffset=(transao->highindex)>>INDEXSHIFT; \
int j; \
for(j=lowoffset; j<=highoffset;j++) { \
- int locallock;GETLOCKVAL(locallock,transao,j); \
+ unsigned int locallock;GETLOCKVAL(locallock,transao,j); \
if (locallock==STMCLEAN) { \
/* do read check */ \
- int mainlock; GETLOCKVAL(mainlock, mainao, j); \
+ unsigned int mainlock; GETLOCKVAL(mainlock, mainao, j); \
if (mainlock>0) { \
CFENCE; \
unsigned int localversion; \
int j;
int addwrobject=0, addrdobject=0;
for(j=lowoffset; j<=highoffset;j++) {
- int status;
+ unsigned int status;
GETLOCKVAL(status, src, j);
if (status==STMDIRTY) {
- int *lockptr;
+ unsigned int *lockptr;
GETLOCKPTR(lockptr, ((struct ArrayObject *)dst), j);
write_unlock(lockptr);
}
int j;
int addwrobject=0, addrdobject=0;
int elementsize=classsize[type];
- int baseoffset=(lowoffset*elementsize)&HIGHMASK;
- for(j=lowoffset; j<=highoffset;j++, baseoffset+=elementsize) {
- int status;
+ int baseoffset=((lowoffset*elementsize)&HIGHMASK)+sizeof(struct ArrayObject);
+ char *dstptr=((char *)dst)+baseoffset;
+ char *srcptr=((char *)src)+baseoffset;
+ for(j=lowoffset; j<=highoffset;j++, srcptr+=INDEXLENGTH,dstptr+=INDEXLENGTH) {
+ unsigned int status;
GETLOCKVAL(status, ((struct ArrayObject *)src), j);
if (status==STMDIRTY) {
- A_memcpy(((char *)&oid[1])+baseoffset, ((char *)&orig[1])+baseoffset, INDEXLENGTH);
+ A_memcpy(dstptr, srcptr, INDEXLENGTH);
}
}
} else
int j;
int addwrobject=0, addrdobject=0;
for(j=lowoffset; j<=highoffset;j++) {
- int status;
+ unsigned int status;
GETLOCKVAL(status, src, j);
if (status==STMDIRTY) {
- int *ptr;
+ unsigned int *intptr;
GETVERSIONPTR(intptr, ((struct ArrayObject *)dst), j);
(*intptr)++;
GETLOCKPTR(intptr, ((struct ArrayObject *)dst), j);
*/
#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);
+ char *tmpchar = mygcmalloc(ptr, (sizeof(objheader_t) + size));
+ objheader_t *tmp = (objheader_t *) (tmpchar+bytelength);
#else
objheader_t *transCreateObj(void * ptr, unsigned int size) {
objheader_t *tmp = mygcmalloc(ptr, (sizeof(objheader_t) + size));
int basesize=((struct ArrayObject *)oid)->___length___*classsize[type];
basesize=(basesize+LOWMASK)&HIGHMASK;
int metasize=sizeof(int)*2*(basesize>>INDEXSHIFT);
- size = basesize + sizeof(objheader_t)+metasize;
+ size = basesize + sizeof(objheader_t)+metasize+sizeof(struct ArrayObject);
char *tmpptr = (char *) objstrAlloc(size);
- bzero(objcopy, metasize);//clear out stm data
+ bzero(tmpptr, metasize);//clear out stm data
objcopy=(objheader_t *) (tmpptr+metasize);
A_memcpy(objcopy, header, sizeof(objheader_t)+sizeof(struct ArrayObject)); //copy the metadata and base array info
} else {