+#if defined(HAVE_INLINE)
+INLINE unsigned CS_GetEntryCount (const CodeSeg* S)
+/* Return the number of entries for the given code segment */
+{
+ return CollCount (&S->Entries);
+}
+#else
+# define CS_GetEntryCount(S) CollCount (&(S)->Entries)
+#endif
+
+void CS_InsertEntry (CodeSeg* S, struct CodeEntry* E, unsigned Index);
+/* Insert the code entry at the index given. Following code entries will be
+ * moved to slots with higher indices.
+ */
+
+void CS_DelEntry (CodeSeg* S, unsigned Index);
+/* Delete an entry from the code segment. This includes moving any associated
+ * labels, removing references to labels and even removing the referenced labels
+ * if the reference count drops to zero.
+ * Note: Labels are moved forward if possible, that is, they are moved to the
+ * next insn (not the preceeding one).
+ */
+
+void CS_DelEntries (CodeSeg* S, unsigned Start, unsigned Count);
+/* Delete a range of code entries. This includes removing references to labels,
+ * labels attached to the entries and so on.
+ */
+
+void CS_MoveEntries (CodeSeg* S, unsigned Start, unsigned Count, unsigned NewPos);
+/* Move a range of entries from one position to another. Start is the index
+ * of the first entry to move, Count is the number of entries and NewPos is
+ * the index of the target entry. The entry with the index Start will later
+ * have the index NewPos. All entries with indices NewPos and above are
+ * moved to higher indices. If the code block is moved to the end of the
+ * current code, and if pending labels exist, these labels will get attached
+ * to the first instruction of the moved block (the first one after the
+ * current code end)
+ */
+
+#if defined(HAVE_INLINE)
+INLINE void CS_MoveEntry (CodeSeg* S, unsigned OldPos, unsigned NewPos)
+/* Move an entry from one position to another. OldPos is the current position
+ * of the entry, NewPos is the new position of the entry.
+ */
+{
+ CollMove (&S->Entries, OldPos, NewPos);
+}
+#else
+# define CS_MoveEntry(S, OldPos, NewPos) CollMove (&(S)->Entries, OldPos, NewPos)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE struct CodeEntry* CS_GetEntry (CodeSeg* S, unsigned Index)
+/* Get an entry from the given code segment */
+{
+ return CollAt (&S->Entries, Index);
+}
+#else
+# define CS_GetEntry(S, Index) ((struct CodeEntry*) CollAt(&(S)->Entries, (Index)))
+#endif
+
+struct CodeEntry* CS_GetPrevEntry (CodeSeg* S, unsigned Index);
+/* Get the code entry preceeding the one with the index Index. If there is no
+ * preceeding code entry, return NULL.
+ */
+
+struct CodeEntry* CS_GetNextEntry (CodeSeg* S, unsigned Index);
+/* Get the code entry following the one with the index Index. If there is no
+ * following code entry, return NULL.
+ */
+
+int CS_GetEntries (CodeSeg* S, struct CodeEntry** List,
+ unsigned Start, unsigned Count);
+/* Get Count code entries into List starting at index start. Return true if
+ * we got the lines, return false if not enough lines were available.
+ */
+
+unsigned CS_GetEntryIndex (CodeSeg* S, struct CodeEntry* E);
+/* Return the index of a code entry */
+
+int CS_RangeHasLabel (CodeSeg* S, unsigned Start, unsigned Count);
+/* Return true if any of the code entries in the given range has a label
+ * attached. If the code segment does not span the given range, check the
+ * possible span instead.
+ */
+
+#if defined(HAVE_INLINE)
+INLINE int CS_HavePendingLabel (const CodeSeg* S)
+/* Return true if there are open labels that will get attached to the next
+ * instruction that is added.
+ */
+{
+ return (CollCount (&S->Labels) > 0);
+}
+#else
+# define CS_HavePendingLabel(S) (CollCount (&(S)->Labels) > 0)
+#endif
+
+CodeLabel* CS_AddLabel (CodeSeg* S, const char* Name);