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: Re: Dynamic loading progress Date: Wed, 9 Jul 2014 23:02:52 +0200 Message-ID: References: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1404939788 1392 80.91.229.3 (9 Jul 2014 21:03:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 9 Jul 2014 21:03:08 +0000 (UTC) Cc: Emacs development discussions To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 09 23:03:02 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 1X4z14-0000ei-4l for ged-emacs-devel@m.gmane.org; Wed, 09 Jul 2014 23:03:02 +0200 Original-Received: from localhost ([::1]:33733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4z13-0008Qs-8f for ged-emacs-devel@m.gmane.org; Wed, 09 Jul 2014 17:03:01 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44450) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4z0x-0008QT-TW for emacs-devel@gnu.org; Wed, 09 Jul 2014 17:02:57 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X4z0w-00017A-LS for emacs-devel@gnu.org; Wed, 09 Jul 2014 17:02:55 -0400 Original-Received: from mail-lb0-x22b.google.com ([2a00:1450:4010:c04::22b]:35345) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X4z0w-00016d-Cp for emacs-devel@gnu.org; Wed, 09 Jul 2014 17:02:54 -0400 Original-Received: by mail-lb0-f171.google.com with SMTP id s7so5460985lbd.16 for ; Wed, 09 Jul 2014 14:02:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=RPCdidB8mQNl/yA0627L/COCoHmajPBNMkPUdINgfec=; b=ZVVtKgdIRc8ppPwosY2528KJqAKyaT7Zk/NAT02iA8YETumtITSEj+dQoGY1zekssL d4iUyw9TbrYzyA271NhNgQO0+PJwuLz8Ob/dTjZvwku1Vn0lJ70orLojco4QJoxpoQQ9 sLi8oscinGZoB//5fmAhBKiofEvE63OdjUPgmXdgqnedNh37C4ZOYiEYHad6VYzTWOAy RxUH9t/JmSrp4ncxcHS1aG66s0tswlSWv2NMRqSRncKI2gOwpII92nSftYd4CIREGQCt BNXTi3YEFeeM6dbiM3H2wk7p4O3RaecTUd5uufIGneAs+uB8k34nU7t4C4pFkF1QBDxi ncJQ== X-Received: by 10.152.36.169 with SMTP id r9mr35131802laj.14.1404939772514; Wed, 09 Jul 2014 14:02:52 -0700 (PDT) Original-Received: by 10.114.77.202 with HTTP; Wed, 9 Jul 2014 14:02:52 -0700 (PDT) In-Reply-To: X-Google-Sender-Auth: fUv5-y9BB1dhzpNH3Xbz4B0SBUA X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22b 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:172913 Archived-At: I've made a github repo of my work so far: https://github.com/aaptel/emacs-dynamic-module On Mon, Jul 7, 2014 at 3:19 AM, Stefan Monnier wrote: > The `doc' field could simply be changed to be of type Lisp_Object and > then follow the usual representation used for lambda expressions I've followed your advice. a) I've updated the type of the doc field. I'm initializing it to 0 in the DEFUN macro and I set it to Qnil in defsubr(). I'm not initializing the field directly to Qnil because the docs reads: You must not use C initializers for static or global variables unless the variables are never written once Emacs is dumped. These variables with initializers are allocated in an area of memory that becomes read-only (on certain operating systems) as a result of dumping Emacs. See Pure Storage. Instead of duplicating the Fsnarf_documentation code for handling modules I've added a boolean 'module' parameter. If the function snarfs a module documentation, don't overwrite the global DOC file path and store a (FILE . OFFSET) cons instead of a simple offset. This part works correctly. b) Now, when fetching a function docstring with Fdocumentation, I check the types and let the existing get_doc_string() handle the field itself. It should work but I've ran into a strange problem: the doc field is set correctly in step a) but the field becomes either an invalid lisp object or garbage at step b). I've added debug print statement (using safe_debug_print): # this is after calling load-module --- fmod ("/home/knarf/prog/c/emacs/dyn/modules/fmod.doc" . -16) --- --- fmod-test1 ("/home/knarf/prog/c/emacs/dyn/modules/fmod.doc" . -98) --- --- fmod-test2 ("/home/knarf/prog/c/emacs/dyn/modules/fmod.doc" . -125) --- --- fmod-test3 ("/home/knarf/prog/c/emacs/dyn/modules/fmod.doc" . -152) --- # now calling (documentation 'fmod...) --Fdocumentation fmod # --- --Fdocumentation fmod-test1 # --- --Fdocumentation fmod-test2 ((keymap #^[nil nil keymap #^^[3 0 set-mark-comma... # [garbage] --- It suspect it has to do with garbage collecting since I have not done anything special to protect the doc field. I'm not sure how to proceed.