From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.devel Subject: Re: Dynamic loading progress Date: Wed, 14 Oct 2015 22:25:05 +0000 Message-ID: References: <87bnl1vmqf.fsf@lifelogs.com> <87vbj8tow4.fsf@lifelogs.com> <87r3twtagf.fsf@lifelogs.com> <85siebl7ws.fsf@stephe-leake.org> <85a90ilwmm.fsf@stephe-leake.org> <83386a6f7z.fsf@gnu.org> <85h9upjz7v.fsf@stephe-leake.org> <83wq3k3kl4.fsf@gnu.org> <85bnkwil1c.fsf@stephe-leake.org> <83pp9cwky8.fsf@gnu.org> <85a90ggf2d.fsf@stephe-leake.org> <54E0A40F.5080603@dancol.org> <83sie7un20.fsf@gnu.org> <54E0D181.2080802@dancol.org> <83r3trulse.fsf@gnu.org> <54E0D7E0.305@87.69.4.28> <83h9unukbg.fsf@gnu.org> <54E0DEF8.7020901@dancol> <83egpruiyp.fsf@gnu.org> <54E0FF93.2000104@dancol.org> <5610ED13.1010406@dancol.org> <56117F37.9060808@dancol.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=001a1134c69c62a8ca0522180995 X-Trace: ger.gmane.org 1444861600 4904 80.91.229.3 (14 Oct 2015 22:26:40 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 14 Oct 2015 22:26:40 +0000 (UTC) Cc: Eli Zaretskii , Daniel Colascione , Stephen Leake , Emacs development discussions To: =?UTF-8?Q?Aur=C3=A9lien_Aptel?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 15 00:26:39 2015 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 1ZmUVK-0000WK-CZ for ged-emacs-devel@m.gmane.org; Thu, 15 Oct 2015 00:26:38 +0200 Original-Received: from localhost ([::1]:44783 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmUVJ-0007L3-Fw for ged-emacs-devel@m.gmane.org; Wed, 14 Oct 2015 18:26:37 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:47511) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmUU3-0007KE-Fq for emacs-devel@gnu.org; Wed, 14 Oct 2015 18:25:20 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZmUU2-0005r7-E8 for emacs-devel@gnu.org; Wed, 14 Oct 2015 18:25:19 -0400 Original-Received: from mail-wi0-x236.google.com ([2a00:1450:400c:c05::236]:36165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZmUU0-0005py-Hc; Wed, 14 Oct 2015 18:25:16 -0400 Original-Received: by wicgb1 with SMTP id gb1so248959628wic.1; Wed, 14 Oct 2015 15:25:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-type; bh=qZNNXL8YiRZxaDxO6FcVY3Ys447dIvpoJSaqRw098iI=; b=DpjlIM5BoRuvKVB2Vu7hE9YN3e579nPkaA2oI+RPdLLBPJUbf05KWJVH57HX6NWdfE Gj7AEXMI6liZLjz1cXyFUtgQmEpvqVY6d1JataMhSD/HLd9VHOCxHEXNyQStDprKIKwr cNjGQCa8M+nRma569KSWxguoeRZzSGpvoTh2R2OWQPv/5vhzBzr5z6evNaVA68VyBbCT XH6eRITT9MDh0nFwyIdPrQPe5y0fWb4qSOxT+4tsnwC597aISv/uJWDHAZeNyS9u40C6 Hq5+vDf7nPmNBVUl76t0S65ELJYSyeppgjTBDIfiGdG4s7MlpuJT4myvl+7aP2fX/RPY QGEA== X-Received: by 10.180.216.36 with SMTP id on4mr7087901wic.65.1444861515571; Wed, 14 Oct 2015 15:25:15 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::236 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:191592 Archived-At: --001a1134c69c62a8ca0522180995 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Aur=C3=A9lien Aptel schrieb am So., 4. Okt= . 2015 um 23:12 Uhr: > On Sun, Oct 4, 2015 at 9:47 PM, Philipp Stephani > wrote: > > Aur=C3=A9lien, is that something you agree with and could implement? > > I'm not sure I understood what you wanted.. I've commited this, but it > assumes Lisp_Object are the same size as pointers... > > commit 4c2813950d14fa2348e30ee94a4f3b022263e36d > Author: Aur=C3=A9lien Aptel > Date: Sun Oct 4 23:04:56 2015 +0200 > > use opaque struct emacs_value_tag instead of void* for emacs_value. > > diff --git a/src/emacs_module.h b/src/emacs_module.h > index c5ec347..b055547 100644 > --- a/src/emacs_module.h > +++ b/src/emacs_module.h > @@ -27,7 +27,7 @@ > > /* Current environement */ > typedef struct emacs_env_25 emacs_env; > -typedef void* emacs_value; > +typedef struct emacs_value_tag* emacs_value; > > enum emacs_type { > EMACS_FIXNUM, > diff --git a/src/module.c b/src/module.c > index 9bbb832..ab058bb 100644 > --- a/src/module.c > +++ b/src/module.c > @@ -24,6 +24,8 @@ > #include "dynlib.h" > #include "coding.h" > > +struct emacs_value_tag { Lisp_Object v; }; > + > void syms_of_module (void); > static struct emacs_runtime* module_get_runtime (void); > static emacs_env* module_get_environment (struct emacs_runtime *ert); > This is good (thanks!), but still assumes that sizeof(Lisp_Object) <=3D sizeof(void*) and that (Lisp_Object)((void *)0) is never a valid Lisp object, both of which are not provably true. To implement Daniel's approach you'll also have to change: static Lisp_Object value_to_lisp (emacs_value value) { return value->v; } static emacs_value lisp_to_value (Lisp_Object object) { emacs_value v =3D (emacs_value) malloc(sizeof v); // The allocation needs to be smarter, this example leaks memory. if (!v) return 0; v->v =3D object; return v; } --001a1134c69c62a8ca0522180995 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable


Aur=C3= =A9lien Aptel <aurel= ien.aptel+emacs@gmail.com> schrieb am So., 4. Okt. 2015 um 23:12=C2= =A0Uhr:
On Sun, Oct 4, 2015 at 9:47= PM, Philipp Stephani <p.stephani2@gmail.com> wrote:
> Aur=C3=A9lien, is that something you agree with and could implement?
I'm not sure I understood what you wanted.. I've commited this, but= it
assumes Lisp_Object are the same size as pointers...

commit 4c2813950d14fa2348e30ee94a4f3b022263e36d
Author: Aur=C3=A9lien Aptel <aurelien.aptel@gmail.com>
Date:=C2=A0 =C2=A0Sun Oct 4 23:04:56 2015 +0200

=C2=A0 =C2=A0 use opaque struct emacs_value_tag instead of void* for emacs_= value.

diff --git a/src/emacs_module.h b/src/emacs_module.h
index c5ec347..b055547 100644
--- a/src/emacs_module.h
+++ b/src/emacs_module.h
@@ -27,7 +27,7 @@

=C2=A0/* Current environement */
=C2=A0typedef struct emacs_env_25 emacs_env;
-typedef void* emacs_value;
+typedef struct emacs_value_tag* emacs_value;

=C2=A0enum emacs_type {
=C2=A0 =C2=A0EMACS_FIXNUM,
diff --git a/src/module.c b/src/module.c
index 9bbb832..ab058bb 100644
--- a/src/module.c
+++ b/src/module.c
@@ -24,6 +24,8 @@
=C2=A0#include "dynlib.h"
=C2=A0#include "coding.h"

+struct emacs_value_tag { Lisp_Object v; };
+
=C2=A0void syms_of_module (void);
=C2=A0static struct emacs_runtime* module_get_runtime (void);
=C2=A0static emacs_env* module_get_environment (struct emacs_runtime *ert);=


This is good (thanks!),= but still assumes that sizeof(Lisp_Object) <=3D sizeof(void*) and that = (Lisp_Object)((void *)0) is never a valid Lisp object, both of which are no= t provably true. To implement Daniel's approach you'll also have to= change:

static Lisp_Object value_to_lisp (emacs_v= alue value) {
=C2=A0 return value->v;
}
static emacs_value lisp_to_value (Lisp_Object object) {
<= div>=C2=A0 emacs_value v =3D (emacs_value) malloc(sizeof v);
=C2= =A0 // The allocation needs to be smarter, this example leaks memory.
=
=C2=A0 if (!v) return 0;
=C2=A0 v->v =3D object;
=C2=A0 return v;
}=C2=A0
--001a1134c69c62a8ca0522180995--