summaryrefslogtreecommitdiffstats
path: root/generic/tclInt.h
diff options
context:
space:
mode:
authorapnadkarni <apnmbx-wits@yahoo.com>2022-06-13 16:15:15 (GMT)
committerapnadkarni <apnmbx-wits@yahoo.com>2022-06-13 16:15:15 (GMT)
commit420a7fc15d7b123ff696251d0a67b148edbb4c0a (patch)
tree180f1125eac446cbd3409bf2f3eea394de9327c2 /generic/tclInt.h
parentb5d8216129b152ca5598851d5c71ca121e19698c (diff)
downloadtcl-420a7fc15d7b123ff696251d0a67b148edbb4c0a.zip
tcl-420a7fc15d7b123ff696251d0a67b148edbb4c0a.tar.gz
tcl-420a7fc15d7b123ff696251d0a67b148edbb4c0a.tar.bz2
Start towards Tcl9 support
Diffstat (limited to 'generic/tclInt.h')
-rw-r--r--generic/tclInt.h58
1 files changed, 45 insertions, 13 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 2ac7644..96e5b58 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -2423,6 +2423,29 @@ typedef enum TclEolTranslation {
#define TCL_INVOKE_NO_TRACEBACK (1<<2)
/*
+ * TclListSizeT is the type for holding list element counts. It's defined
+ * simplify sharing source between Tcl8 and Tcl9.
+ */
+#if TCL_MAJOR_VERSION > 8
+
+typedef ptrdiff_t ListSizeT; /* TODO - may need to fix to match Tcl9's API */
+
+/*
+ * SSIZE_MAX, NOT SIZE_MAX as negative differences need to be expressed
+ * between values of the ListSizeT type so limit the range to signed
+ */
+#define ListSizeT_MAX PTRDIFF_MAX
+
+#else
+
+typedef int ListSizeT;
+#define ListSizeT_MAX INT_MAX
+
+#endif
+
+/*
+ * ListStore --
+ *
* A Tcl list's internal representation is defined through three structures.
*
* A ListStore struct is a structure that includes a variable size array that
@@ -2446,32 +2469,41 @@ typedef enum TclEolTranslation {
*
*/
typedef struct ListStore {
- int refCount;
- int firstUsed; /* Index of first slot in use within the slots[] array */
- int numUsed; /* Number of slots in use (starting at index firstUsed) */
- int numAllocated; /* Total number of slots[] array slots. */
- int flags; /* LISTSTORE_* flags */
- Tcl_Obj *slots[1]; /* Variable size array. The struct is grown as needed */
+ ListSizeT firstUsed; /* Index of first slot in use within slots[] */
+ ListSizeT numUsed; /* Number of slots in use (starting firstUsed) */
+ ListSizeT numAllocated; /* Total number of slots[] array slots. */
+ int refCount; /* Number of references to this instance */
+ int flags; /* LISTSTORE_* flags */
+ Tcl_Obj *slots[1]; /* Variable size array. Grown as needed */
} ListStore;
#define LISTSTORE_CANONICAL 0x1 /* All Tcl_Obj's referencing this
store have their string representation
derived from the list representation */
-/* TODO - should the limit not be based on INT_MAX and not UINT_MAX? */
-#define LIST_MAX \
- (1 + (int)(((size_t)UINT_MAX - sizeof(ListStore))/sizeof(Tcl_Obj *)))
+/* Max number of elements that can be contained in a list */
+#define LIST_MAX \
+ (1 \
+ + (ListSizeT)(((size_t)ListSizeT_MAX - sizeof(ListStore)) \
+ / sizeof(Tcl_Obj *)))
+/* Memory size needed for a ListStore to hold numSlots_ elements */
#define LIST_SIZE(numSlots_) \
(unsigned)(sizeof(ListStore) + (((numSlots_) - 1) * sizeof(Tcl_Obj *)))
-/* See comments above */
+/*
+ * ListSpan --
+ * See comments above for ListStore
+ */
typedef struct ListSpan {
+ ListSizeT spanStart; /* Starting index of the span */
+ ListSizeT spanLength; /* Number of elements in the span */
int refCount; /* Count of references to this span record */
- int spanStart; /* Starting index within parentList where the span */
- int spanLength; /* Number of elements in the span */
} ListSpan;
-/* See comments above */
+/*
+ * ListRep --
+ * See comments above for ListStore
+ */
typedef struct ListRep {
ListStore *storePtr;/* element array shared amongst different lists */
ListSpan *spanPtr; /* If not NULL, the span holds the range of slots