summaryrefslogtreecommitdiff
path: root/apl9.h
diff options
context:
space:
mode:
authorglenda <glenda@9front>2022-10-22 16:45:32 +0000
committerglenda <glenda@9front>2022-10-22 16:45:32 +0000
commita82186dab48c234c507693b166acd7c13433864a (patch)
treeeb6db255c93b1e6278e0e833e915c4c85372c84f /apl9.h
parenta3b635de1753ed4ce73dabdc7e2c24dfdf77891e (diff)
Atomic reference counting
Diffstat (limited to 'apl9.h')
-rw-r--r--apl9.h33
1 files changed, 14 insertions, 19 deletions
diff --git a/apl9.h b/apl9.h
index bfb4d99..08c4d00 100644
--- a/apl9.h
+++ b/apl9.h
@@ -83,20 +83,16 @@ struct Mixed
};
};
-#define GetSize(a) ((u32int)(a->info & 0x00000000FFFFFFFF))
-#define GetRank(a) ((u8int)((a->info & 0x0000000F00000000) >> 32))
-#define GetType(a) ((u8int)((a->info & 0x000000F000000000) >> 36))
-#define GetStrand(a) ((u8int)((a->info & 0x0000010000000000) >> 40))
-#define GetRefs(a) ((u32int)((a->info & 0xFFFFFE0000000000) >> 41))
-#define SetSize(a,v) (a->info ^= ((u64int)GetSize(a)^v))
-#define SetRank(a,v) (a->info ^= ((u64int)(GetRank(a)^v) << 32))
-#define SetType(a,v) (a->info ^= ((u64int)(GetType(a)^v) << 36))
-#define SetStrand(a,v) (a->info ^= ((u64int)(GetStrand(a)^v) << 40))
-#define SetRefs(a,v) (a->info ^= ((u64int)(GetRefs(a)^v) << 41))
+#define GetRank(a) ((u8int)((a->info & 0x000000000000000F) >> 0))
+#define GetType(a) ((u8int)((a->info & 0x000000000000000F) >> 4))
+#define GetStrand(a) ((u8int)((a->info & 0x0000000000000010) >> 8))
+#define SetRank(a,v) (a->info ^= ((u64int)(GetRank(a)^v) << 0))
+#define SetType(a,v) (a->info ^= ((u64int)(GetType(a)^v) << 4))
+#define SetStrand(a,v) (a->info ^= ((u64int)(GetStrand(a)^v) << 8))
struct Array
{
- u32int *shape;
+ u64int *shape;
union {
char *rawdata;
vlong *intdata;
@@ -106,13 +102,14 @@ struct Array
Array **arraydata;
Array *prototype; /* only in use when size == 0 and type == AtypeArray */
};
+ uvlong size;
+ Ref; /* Reference count */
u64int info;
/* info is a bitmap of information, divided as follows:
- * 0-31: 32 bits for size (max size = 4294967296)
- * 32-35: 4 bits for the rank (max rank 15)
- * 36-39: 4 bits for the type (16 options)
- * 40: 1 bit for stranding
- * 41-63: 23 bits for reference counting (max refs = 8388608)
+ * 0-3: 4 bits for the rank (max rank 15)
+ * 4-7: 4 bits for the type (16 options)
+ * 8: 1 bit for stranding
+ * 9-63: unused
* NOTE: should only be modified through the macros defined above
*/
};
@@ -163,7 +160,6 @@ struct Datum
{
datumTag tag;
int shy;
- int refs;
union {
Array *array;
Statement stmt;
@@ -173,6 +169,7 @@ struct Datum
Rune *name;
Statement names;
};
+ Ref; /* reference count*/
};
struct Symbol
@@ -314,10 +311,8 @@ void *erealloc(void *, ulong);
void checkmem(char *);
Array *allocarray(int, int, int);
void freearray(Array *);
-void incarrayref(Array *);
Datum *allocdatum(int, int);
void freedatum(Datum *);
-void incdatumref(Datum *);
void freefunction(Function);
void freeoperator(Operator);
void freestatement(Statement);