diff src/lrecord.h @ 996:25e260cb7994

[xemacs-hg @ 2002-09-10 15:27:02 by james] Enable unloading of dynamic modules. Create the first two internal XEmacs modules: LDAP and postgreSQL. Update the sample directory to contain a sample internal XEmacs module and a sample external XEmacs module. Improve support for autoloading modules. Make internal module code compile into the XEmacs binary if XEmacs is configured without module support. Make the internal module directories self-contained so that they can be distributed separately from XEmacs.
author james
date Tue, 10 Sep 2002 15:27:39 +0000
parents c925bacdda60
children e22b0213b713
line wrap: on
line diff
--- a/src/lrecord.h	Mon Sep 09 21:53:43 2002 +0000
+++ b/src/lrecord.h	Tue Sep 10 15:27:39 2002 +0000
@@ -770,6 +770,24 @@
   INIT_LRECORD_IMPLEMENTATION(type);					\
 } while (0)
 
+#ifdef HAVE_SHLIB
+/* Allow undefining types in order to support module unloading. */
+
+#define UNDEF_LRECORD_IMPLEMENTATION(type) do {				\
+  lrecord_implementations_table[lrecord_type_##type] = NULL;		\
+  lrecord_markers[lrecord_type_##type] = NULL;				\
+} while (0)
+
+#define UNDEF_EXTERNAL_LRECORD_IMPLEMENTATION(type) do {		\
+  if (lrecord_##type.lrecord_type_index == lrecord_type_count - 1) {	\
+    /* This is the most recently defined type.  Clean up nicely. */	\
+    lrecord_type_##type = lrecord_type_count--;				\
+  } /* Else we can't help leaving a hole with this implementation. */	\
+  UNDEF_LRECORD_IMPLEMENTATION(type);					\
+} while (0)
+
+#endif /* HAVE_SHLIB */
+
 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record)
 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))