From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?Aur=C3=A9lien_Aptel?= Newsgroups: gmane.emacs.devel Subject: Dynamic loading progress Date: Wed, 2 Jul 2014 22:54:27 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=001a11c3c6d216407d04fd3c19b2 X-Trace: ger.gmane.org 1404334480 31858 80.91.229.3 (2 Jul 2014 20:54:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 2 Jul 2014 20:54:40 +0000 (UTC) To: Emacs development discussions Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 02 22:54:36 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1X2RY4-00075h-Cd for ged-emacs-devel@m.gmane.org; Wed, 02 Jul 2014 22:54:36 +0200 Original-Received: from localhost ([::1]:56438 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2RY4-0008RQ-1Y for ged-emacs-devel@m.gmane.org; Wed, 02 Jul 2014 16:54:36 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2RY0-0008R5-7Y for emacs-devel@gnu.org; Wed, 02 Jul 2014 16:54:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X2RXy-0003Lf-8h for emacs-devel@gnu.org; Wed, 02 Jul 2014 16:54:32 -0400 Original-Received: from mail-lb0-x231.google.com ([2a00:1450:4010:c04::231]:47052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X2RXx-0003LS-Q8 for emacs-devel@gnu.org; Wed, 02 Jul 2014 16:54:30 -0400 Original-Received: by mail-lb0-f177.google.com with SMTP id u10so8224077lbd.8 for ; Wed, 02 Jul 2014 13:54:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:date:message-id:subject:from:to:content-type; bh=tHKERepOL3cF0JpW1Qg9grFgx5rfDm+hC6HJkLACLMQ=; b=wmad8oZohmXLIG/nye4ACGm7lJj8wRUccmxFVbQeFFhZQ5ylyepzRgtJvpjjHIAs4z 3dXexd0ej3vC71U0tlHZ8zsf9Pptaw7bJ9yAE5TYLrNQILAfPvBEkQodQ2kKSgtxt1EB 5fO9QPHuRgfWN9D7L/X0I+drmaUA4TDtqdlyqo2CjAe5rUXLZaVJJmhqN9AW4fqZleBQ /Ah4Co2rscV60graABGhc5Kdha5kd+ZsBOpBvURymGGCt5nHzRDNyUyEoP/cx0w5m7mp ppA2JUYqZN4yYEkkXGPnKt/A/ovuBSuE7YP5ROaKKfgaMmldlwpPm+BBtQ7RJoTdnCJu pTyg== X-Received: by 10.112.16.230 with SMTP id j6mr153571lbd.90.1404334467586; Wed, 02 Jul 2014 13:54:27 -0700 (PDT) Original-Received: by 10.114.77.202 with HTTP; Wed, 2 Jul 2014 13:54:27 -0700 (PDT) X-Google-Sender-Auth: C8Vk7z1PeCu0Nr4UFl2Z1C32n4U X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::231 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:172855 Archived-At: --001a11c3c6d216407d04fd3c19b2 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, I've tried to test Dave Love's patch [1] but it's now bitrotten, I was not able to make it work. So I've started my own thing (drawn from Dave's initial work): * Use of libtool (ltdl) - add configure option for ltdl - update dependency in configure.ac / Makefile.in - add HAVE_LTDL test macro * New Lisp function `load-module' which takes a compiled module file path and loads it - check for plugin_is_GPL_compatible symbol - check presence of `init' symbol - run it as a void (*) () call (no return value/arg). At first I was calling the libtool init function (lt_dlinit) in syms_of_lread() but it made every subsequent call to lt_dlopen segfault. I think the problem was coming from calling it before dumping because as soon as I moved it to the body of `load-module' it started working. It works for very simple stuff so far. If I put a printf in the module init function it is called successfully. But as soon as I try to use DEFUN, gcc complains: In file included from fmod.c:17:0: fmod.c:30:16: error: =E2=80=98Ffmod=E2=80=99 undeclared here (not in a func= tion) DEFUN ("fmod", Ffmod, Sfmod, 2, 2, 0, ^ emacs-master/src/lisp.h:2688:26: note: in definition of macro =E2=80=98DEFU= N=E2=80=99 { .a ## maxargs =3D fnname }, \ ^ So I'm stuck here for now... Any help/feedback welcome :) I've attached a patch and an example module (compilation/loading instructions in comments). ltdl is enabled by default in the configure script, you just need libtool in order to try it. I know it is not as polished as Dave's patch, I'm just trying to get it to work before making it clean. 1: http://www.loveshack.ukfsn.org/emacs/dynamic-loading/ --001a11c3c6d216407d04fd3c19b2 Content-Type: text/plain; charset=US-ASCII; name="dynamic-loading.diff" Content-Disposition: attachment; filename="dynamic-loading.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hx54c2bm0 ZGlmZiAtcnUgb2xkL2NvbmZpZ3VyZS5hYyBuZXcvY29uZmlndXJlLmFjCi0tLSBvbGQvY29uZmln dXJlLmFjCTIwMTQtMDctMDEgMTY6MDY6MTEuMDAwMDAwMDAwICswMjAwCisrKyBuZXcvY29uZmln dXJlLmFjCTIwMTQtMDctMDEgMTk6Mjg6MDguMDMwNTIwNTAwICswMjAwCkBAIC0zMjMsNiArMzIz LDggQEAKIE9QVElPTl9ERUZBVUxUX09OKFtzZWxpbnV4XSxbZG9uJ3QgY29tcGlsZSB3aXRoIFNF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0 X2luaXRfZG9uZSkKKyAgICAgIHsKKyAgICAgICAgaW50IHJldCA9IGx0X2RsaW5pdCAoKTsKKyAg ICAgICAgaWYgKHJldCkKKyAgICAgICAgICB7CisgICAgICAgICAgICBjb25zdCBjaGFyKiBzID0g bHRfZGxlcnJvciAoKTsKKyAgICAgICAgICAgIGVycm9yICgibHRkbCBpbml0IGZhaWw6ICVzIiwg cyk7CisgICAgICAgICAgfQorICAgICAgICBsdF9pbml0X2RvbmUgPSAxOworICAgICAgfQorCisg ICAgQ0hFQ0tfU1RSSU5HIChmaWxlKTsKKworICAgIGhhbmRsZSA9IGx0X2Rsb3BlbiAoU0RBVEEg KGZpbGUpKTsKKyAgICBpZiAoIWhhbmRsZSkKKyAgICAgIGVycm9yICgiQ2Fubm90IGxvYWQgZmls ZSAlcyIsIFNEQVRBIChmaWxlKSk7CisKKyAgICBncGxfc3ltID0gbHRfZGxzeW0gKGhhbmRsZSwg InBsdWdpbl9pc19HUExfY29tcGF0aWJsZSIpOworICAgIGlmICghZ3BsX3N5bSkKKyAgICAgIGVy cm9yICgiTW9kdWxlICVzIGlzIG5vdCBHUEwgY29tcGF0aWJsZSIsIFNEQVRBIChmaWxlKSk7CisK KyAgICBtb2R1bGVfaW5pdCA9ICh2b2lkICgqKSAoKSkgbHRfZGxzeW0gKGhhbmRsZSwgImluaXQi KTsKKyAgICBpZiAoIW1vZHVsZV9pbml0KQorICAgICAgZXJyb3IgKCJNb2R1bGUgJXMgZG9lcyBu b3QgaGF2ZSBhbiBpbml0IGZ1bmN0aW9uLiIsIFNEQVRBIChmaWxlKSk7CisKKyAgICBtb2R1bGVf aW5pdCAoKTsKKworICAgIHJldHVybiBRdDsKKyNlbHNlCisgICAgcmV0dXJuIFFuaWw7CisjZW5k aWYKK30KKwogREVGVU4gKCJsb2FkIiwgRmxvYWQsIFNsb2FkLCAxLCA1LCAwLAogICAgICAgIGRv YzogLyogRXhlY3V0ZSBhIGZpbGUgb2YgTGlzcCBjb2RlIG5hb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09ORklHX0xJQlMpICQo TElCT1RGX0xJQlMpICQoTTE3Tl9GTFRfTElCUykgXAogICAgJChMSUJHTlVUTFNfTElCUykgJChM SUJfUFRIUkVBRCkgXAotICAgJChHRklMRU5PVElGWV9MSUJTKSAkKExJQl9NQVRIKSAkKExJQlop CisgICAkKEdGSUxFTk9USUZZX0xJQlMpICQoTElCX01BVEgpICQoTElCWikgJChMSUJMVERMKQoK IGFsbDogZW1hY3MkKEVYRUVYVCkgJChPVEhFUl9GSUxFUykKIC5QSE9OWTogYWxsCg== --001a11c3c6d216407d04fd3c19b2 Content-Type: text/x-csrc; charset=US-ASCII; name="fmod.c" Content-Disposition: attachment; filename="fmod.c" Content-Transfer-Encoding: base64 X-Attachment-Id: f_hx54c82d1 LyoKICBleGFtcGxlIG1vZHVsZQoKICBjb21waWxhdGlvbjoKCiAgICAkIGdjYyAtV2FsbCAtSWVt YWNzL3NyYyAtSWVtYWNzL2xpYiAtZlBJQyAtYyBmbW9kLmMKICAgICQgZ2NjIC1zaGFyZWQgLW8g Zm1vZC5zbyBmbW9kLm8KCiAgbG9hZGluZzoKCiAgICAkIC4vZW1hY3MgLVEgLS1iYXRjaCAtLWV2 YWwgJyhsb2FkLW1vZHVsZSAiLi4vLi4vZm1vZC5zbyIpJwogICAgaGVsbG8gd29ybGQKCiovCgoj aW5jbHVkZSA8Y29uZmlnLmg+CiNpbmNsdWRlIDxsaXNwLmg+CgojaW5jbHVkZSA8bWF0aC5oPgoj aW5jbHVkZSA8c3RkaW8uaD4KCi8qIGVtYWNzIGNoZWNrcyBmb3IgdGhpcyBzeW1ib2wgYmVmb3Jl IHJ1bm5pbmcgdGhlIG1vZHVsZSAqLwppbnQgcGx1Z2luX2lzX0dQTF9jb21wYXRpYmxlOwoKLyog WFhYOiBERUZVTiBkb2Vzbid0IHdvcmsgeWV0Li4uIDooICovCgojaWYgMAoKLyogZGVmaW5lIGEg bmV3IGxpc3AgZnVuY3Rpb24gKi8KREVGVU4gKCJmbW9kIiw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