+void SymConDes (const char* Name, unsigned Type, unsigned Prio)
+/* Mark the given symbol as a module constructor/destructor. This will also
+ * mark the symbol as an export. Initializers may never be zero page symbols.
+ */
+{
+ SymEntry* S;
+
+ /* Check the parameters */
+#if (CD_TYPE_MIN != 0)
+ CHECK (Type >= CD_TYPE_MIN && Type <= CD_TYPE_MAX);
+#else
+ CHECK (Type <= CD_TYPE_MAX);
+#endif
+ CHECK (Prio >= CD_PRIO_MIN && Prio <= CD_PRIO_MAX);
+
+ /* Don't accept local symbols */
+ if (IsLocal (Name)) {
+ Error (ERR_ILLEGAL_LOCAL_USE);
+ return;
+ }
+
+ /* Do we have such a symbol? */
+ S = SymFind (SymTab, Name, SF_ALLOC_NEW);
+ if (S->Flags & SF_IMPORT) {
+ /* The symbol is already marked as imported external symbol */
+ Error (ERR_SYM_ALREADY_IMPORT, Name);
+ return;
+ }
+
+ /* If the symbol is marked as global, silently remove the global flag */
+ if (S->Flags & SF_GLOBAL) {
+ S->Flags &= ~SF_GLOBAL;
+ }
+
+ /* Check if the symbol was not already defined as ZP symbol */
+ if ((S->Flags & SF_ZP) != 0) {
+ Error (ERR_SYM_REDECL_MISMATCH);
+ }
+
+ /* If the symbol was already declared as a condes, check if the new
+ * priority value is the same as the old one.
+ */
+ if (S->ConDesPrio[Type] != CD_PRIO_NONE) {
+ if (S->ConDesPrio[Type] != Prio) {
+ Error (ERR_SYM_REDECL_MISMATCH);
+ }
+ }
+ S->ConDesPrio[Type] = Prio;
+
+ /* Set the symbol data */
+ S->Flags |= SF_EXPORT | SF_REFERENCED;
+}
+
+
+