From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.devel Subject: Re: How to add pseudo vector types Date: Sat, 24 Jul 2021 13:40:28 -0400 Message-ID: References: <83h7gw6pyj.fsf@gnu.org> <45EBF16A-C953-42C7-97D1-3A2BFEF7DD01@gmail.com> <83y2a764oy.fsf@gnu.org> <83v95b60fn.fsf@gnu.org> <00DD5BFE-D14E-449A-9319-E7B725DEBFB3@gmail.com> <83r1fz5xr9.fsf@gnu.org> <1AAB1BCC-362B-4249-B785-4E0530E15C60@gmail.com> <83czri67h0.fsf@gnu.org> <46BBFF88-76C3-4818-8805-5437409BEA93@gmail.com> <83wnpq46uk.fsf@gnu.org> <533BD53B-4E85-4E9E-B46A-346A5BBAD0F5@gmail.com> <258CB68D-1CC1-42C8-BDCD-2A8A8099B783@gmail.com> <1a776770-50b7-93cd-6591-c9a5b3a56eb8@gmail.com> <8335s64v10.fsf@gnu.org> <5380C92B-6C15-4490-A1E0-1C3132DBB16A@gmail.com> <83k0li2shw.fsf@gnu.org> <83eebq2mpy.fsf@gnu.org> <83lf5w26e3.fsf@gnu.org> <838s1vzp9i.fsf@gnu.org> <83pmv7y6fx.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Content-Type: multipart/alternative; boundary="Apple-Mail=_0EA8BA73-7E84-4A1C-A7B2-B4A9FE461F1B" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15369"; mail-complaints-to="usenet@ciao.gmane.io" Cc: =?utf-8?Q?Cl=C3=A9ment_Pit-Claudel?= , Stefan Monnier , emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jul 24 19:42:00 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m7Ley-0003iD-Qa for ged-emacs-devel@m.gmane-mx.org; Sat, 24 Jul 2021 19:42:00 +0200 Original-Received: from localhost ([::1]:51190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m7Lex-0002X9-Iv for ged-emacs-devel@m.gmane-mx.org; Sat, 24 Jul 2021 13:41:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m7Lda-0001UE-Hk for emacs-devel@gnu.org; Sat, 24 Jul 2021 13:40:35 -0400 Original-Received: from mail-qk1-x72e.google.com ([2607:f8b0:4864:20::72e]:33542) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m7LdY-0005cn-E6; Sat, 24 Jul 2021 13:40:34 -0400 Original-Received: by mail-qk1-x72e.google.com with SMTP id t66so4742862qkb.0; Sat, 24 Jul 2021 10:40:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=IIlTNRiwk7iGMUa/c6rSCpeOPPWWp2WMuFEdinXxLPI=; b=lBBN7hqAajI51FePkyOW6rLmbTr0Bpxt6np83A1qzzVGDYYGwVi9TcJc6YHfKjD0mR vE5H6ED5ep1J+KsfDjRuxQEMgxsFxRIAoQ6BXimWoi4ORSXjT1bp4+Kr/dcL78A59m6h +p4WK9nu4FMWduEGLZcR2sXnI35EjfNSS3NP4k1w18QZ1ZfK2Ug4pAWIzcRTPetfySKM x2smYLtwQWWitIO+0HwWi9m+HMVIx+ZguiW6uDDq2wewgtBXXvmsmv4V3lHRx73D3GQU egcaCNBzMB4J/gHmdvb+9QCUuaPok/AytvcgogCOM7LI0SI11zwXANI4DwPX0I77Ipng ABfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=IIlTNRiwk7iGMUa/c6rSCpeOPPWWp2WMuFEdinXxLPI=; b=hOtCN68saMqzFcTvFyhNc5OkELutZqyb5bgnp3Sd1ANkWgmuMFlpwSh9sE1ycTIh39 YNCg9OvQqQo9Xn0x5qoyb1YkcjPz4ax3c6H2B6uRQs9R+UwMOQflP3KPS5ctBPujzNAx BGQ1G0vvtMygPqhF8/04gmnbQJS/A7mtmAx4nbnKTYdUhiYTjc8rRFVnhoA35tliT5He kT+QBMOMDj36ugBvk2707Far3peYoYRxj/oHaX3lj+wP5SP1ltq5634eJzgjo8DfyhrG CKvpYAxycyE5nZnxUvA3xUEdteIGmEd84o0Sn7p7XmiHlV+UoqQn1Dihq+J3XL6PzsXz CsTA== X-Gm-Message-State: AOAM533e4ZOHG8OxFeSnGW4NIAtVRwv4w9Cjq+fn//O9bAMrixlRasYN 3jrnmRTr0+tlT7cqLhiS5gGTSZd47ulktQ== X-Google-Smtp-Source: ABdhPJwT34jU1T6Dt441tz5vcKgDPoQ1UNttz+bgPkV/1oCgKcGL9ZaicKwU/VG2svZynCrjvwHBGg== X-Received: by 2002:a05:620a:12d8:: with SMTP id e24mr10227264qkl.354.1627148430628; Sat, 24 Jul 2021 10:40:30 -0700 (PDT) Original-Received: from 2603-7080-0302-635e-d969-6d23-8e5f-2ec1.res6.spectrum.com (2603-7080-0302-635e-d969-6d23-8e5f-2ec1.res6.spectrum.com. [2603:7080:302:635e:d969:6d23:8e5f:2ec1]) by smtp.gmail.com with ESMTPSA id i24sm9810358qki.61.2021.07.24.10.40.29 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 24 Jul 2021 10:40:30 -0700 (PDT) In-Reply-To: <83pmv7y6fx.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.60.0.2.21) Received-SPF: pass client-ip=2607:f8b0:4864:20::72e; envelope-from=casouri@gmail.com; helo=mail-qk1-x72e.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, FREEMAIL_REPLY=1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 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-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:271566 Archived-At: --Apple-Mail=_0EA8BA73-7E84-4A1C-A7B2-B4A9FE461F1B Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jul 24, 2021, at 1:20 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu > >> Date: Sat, 24 Jul 2021 13:14:50 -0400 >> Cc: Stefan Monnier >, >> cpitclaudel@gmail.com , >> emacs-devel@gnu.org >>=20 >> IIUC if we want tree-sitter to use our malloc, we need to build it = with Emacs, where should I put the >> source of tree-sitter? >>=20 >> tree-sitter itself should be a library we link against. If you meant >> the tree-sitter support code, then it should go on a separate file in >> src/. Or did I misunderstand your question? >>=20 >> If we link against libtree-sitter, how do we change its malloc = behavior? Tree-sitter has these kind of things: >>=20 >> #ifndef ts_malloc >> #define ts_malloc ts_malloc_default >> #endif >>=20 >> So I assume we need to define ts_malloc to, say, xmalloc when = compiling libtree-sitter. And if we only link to >> it, we can=E2=80=99t redefine ts_malloc. >=20 > How does TS propose the client projects to do that? Are you saying > that the only way to replace its malloc is to recompile tree-sitter?? Here is the relevant lines in alloc.h in tree-sitter: // Allow clients to override allocation functions #ifndef ts_malloc #define ts_malloc ts_malloc_default #endif #ifndef ts_calloc #define ts_calloc ts_calloc_default #endif #ifndef ts_realloc #define ts_realloc ts_realloc_default #endif #ifndef ts_free #define ts_free ts_free_default #endif I=E2=80=99m not a C expert, does this allow us to replace its malloc in = runtime? Relative discussion found on the issue tracker: = https://github.com/tree-sitter/tree-sitter/issues/739 = Yuan= --Apple-Mail=_0EA8BA73-7E84-4A1C-A7B2-B4A9FE461F1B Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

On Jul 24, 2021, at 1:20 PM, Eli Zaretskii <eliz@gnu.org> = wrote:

From: Yuan Fu <casouri@gmail.com>
Date: Sat, 24 Jul 2021 13:14:50 -0400
Cc: = Stefan Monnier <monnier@iro.umontreal.ca>,
cpitclaudel@gmail.com,
emacs-devel@gnu.org

IIUC if we want tree-sitter to use our malloc, = we need to build it with Emacs, where should I put the
source of tree-sitter?

tree-sitter= itself should be a library we link against.  If you meant
the tree-sitter support code, then it should go on a separate = file in
src/.  Or did I misunderstand your = question?

If we link against = libtree-sitter, how do we change its malloc behavior? Tree-sitter has = these kind of things:

#ifndef ts_malloc
#define ts_malloc  ts_malloc_default
#endif

So I assume we need to = define ts_malloc to, say, xmalloc when compiling libtree-sitter. And if = we only link to
it, we can=E2=80=99t redefine = ts_malloc.

How does TS propose the client projects to do that?  Are = you saying
that the only = way to replace its malloc is to recompile = tree-sitter??

Here is = the relevant lines in alloc.h in tree-sitter:

// Allow clients to override allocation = functions

#ifndef = ts_malloc
#define ts_malloc =  ts_malloc_default
#endif
#ifndef = ts_calloc
#define ts_calloc =  ts_calloc_default
#endif
#ifndef = ts_realloc
#define ts_realloc = ts_realloc_default
#endif
#ifndef = ts_free
#define ts_free   =  ts_free_default
#endif

I=E2=80=99m not a C expert, does this allow us to = replace its malloc in runtime?

Relative discussion found on the issue tracker: https://github.com/tree-sitter/tree-sitter/issues/739
=

Yuan
= --Apple-Mail=_0EA8BA73-7E84-4A1C-A7B2-B4A9FE461F1B--