summaryrefslogtreecommitdiff
path: root/src/module.c
diff options
context:
space:
mode:
authorAurélien Aptel <aurelien.aptel@gmail.com>2015-02-11 02:15:14 +0100
committerAurélien Aptel <aurelien.aptel@gmail.com>2015-02-11 02:15:14 +0100
commitc59f2deaae99ca85b0a4fcdd53a3d8ed41d995cd (patch)
tree455db9967d881b610b400ea53c70f87b08eba496 /src/module.c
parent9dc8a56a4dc27a752186185743c4fc16c8fced45 (diff)
downloademacs-feature/aptel/dynamic-modules-rc3.tar.gz
add new Lisp_Module type (misc subtype)feature/aptel/dynamic-modules-rc3
Lisp_Module is a new subtype of Misc objects. As other Misc types, it re-uses the marker free list. A module must have a custom destructor, which is automatically called by the GC. Previous module object using the Save_Value type still work and they still have to be free explicitely from Lisp. Their use is now discouraged in modules. A simple module example + tests are available in modules/memtest.
Diffstat (limited to 'src/module.c')
-rw-r--r--src/module.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/module.c b/src/module.c
new file mode 100644
index 00000000000..b1aca0fb255
--- /dev/null
+++ b/src/module.c
@@ -0,0 +1,59 @@
+/* Dynamic modules related functions for GNU Emacs
+
+ Copyright (C) 2015 Free Software Foundation, Inc.
+
+ This file is part of GNU Emacs.
+
+ GNU Emacs is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ GNU Emacs is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
+
+
+#include <config.h>
+#include <limits.h>
+#include "lisp.h"
+
+EXFUN (Fmodule_available_p, 0);
+DEFUN ("module-available-p", Fmodule_available_p, Smodule_available_p, 0, 0, 0,
+ doc: "Doc")
+ (void)
+{
+#ifdef HAVE_LTDL
+ return Qt;
+#else
+ return Qnil;
+#endif
+}
+
+/* Module functions */
+#ifdef HAVE_LTDL
+
+/* Return a unique id for a new module opaque type. */
+module_id_t
+module_make_id (void)
+{
+ static module_id_t module_count = 0;
+
+ eassert (module_count < MODULE_ID_MAX);
+ return module_count++;
+}
+
+#endif
+
+void syms_of_module (void)
+{
+#ifdef HAVE_LTDL
+ /* Nothing yet! */
+#endif
+
+ defsubr(&Smodule_available_p);
+}