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: Calling Lisp in C functions Date: Fri, 24 Sep 2021 10:55:00 -0700 Message-ID: References: <83y27pw4c3.fsf@gnu.org> <87357FA2-4AF8-4E7E-BD26-1852D9C8CE6F@gmail.com> <83r1dfvktm.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11904"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Sep 24 20:08:26 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 1mTpcW-0002s4-Ud for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Sep 2021 20:08:24 +0200 Original-Received: from localhost ([::1]:45784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mTpcV-0003H4-UM for ged-emacs-devel@m.gmane-mx.org; Fri, 24 Sep 2021 14:08:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:57420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mTpPi-0001lX-QG for emacs-devel@gnu.org; Fri, 24 Sep 2021 13:55:10 -0400 Original-Received: from mail-qk1-x730.google.com ([2607:f8b0:4864:20::730]:33749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mTpPd-0002ox-Ol; Fri, 24 Sep 2021 13:55:10 -0400 Original-Received: by mail-qk1-x730.google.com with SMTP id d207so29301906qkg.0; Fri, 24 Sep 2021 10:55:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=lu/8PnNRuhXY95n7EbdfolQM6n7jhcIr0GegqPFfbz0=; b=c7Vzr7d9ACDA66CqeblyJE+u6UesdMT+h7hz6vzNPX8BB0/q/g2/pfVFce61RSW8N6 I0h0J+YLjLAiKF1Ljo8DexGcZCN0Vy9RQaxMuIpbnYHnQ1PmgDLrNR2rDgSV4W9139qF bVxfiCvlfubLQF0xfbGB+EcyLk57aYxkJAQGQGVG6YRMHIFBECqfbLV61vDDHl52O8GG zesAePmsSyImm+iRg0HEbeKfLb64aupAGcYFq2fydZhiRB/F6rd0qk2z+z7Enn3KZL9x 9d0ud3ZBoqa1aaMkJsX1MyoSpaT48mUFoSY5wgCrGQQnS5bn69ve/dtQR16qszBPOcYq NLMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=lu/8PnNRuhXY95n7EbdfolQM6n7jhcIr0GegqPFfbz0=; b=0/AFvh+tDkfJH9WMZyS0eDIwkYflO4CNaPxz53/nwlQP48fjmEluRTZcQdUZMNfZYe mk2YyVoVb+f7wq+4b1oYGQMYHrgkAmQYmVdPnmf1dOBleyI2qWpWBz48upLxPmnTjCKH T7ucu9jscg9G/Kw1DtKBG8MbduvfO/igtgrg0nvVRf96RR0CqGxZ+LSPs68AlVndGgFC vx0LKuSpAVqtmKzzBPxEGUT08cvUzKG1/4/O34xbSF1FtQwp09O8N4D9O27D6+NMxXGF CO5Mj0hLxS0uuSE8Hcl8Ou/rdUfT/0YInUYmSNu6xNYiQ55WAYKgsO7EEOcYpTwBvQj4 T4eg== X-Gm-Message-State: AOAM5311yENsTagsui8xN+AO0Iq0LR+JpeSZ9cxDz4uGORvn2Vm3BziU eGrQSvntXXrdkuqym3he5USkCj3ejrvkNQ== X-Google-Smtp-Source: ABdhPJxXhg9wyNM5F6kySpYUSdrVRAQEvySQcddl/oZBK5hHrO7Enjben7Ml9d1aK3heDiJsru+9aA== X-Received: by 2002:a37:746:: with SMTP id 67mr11866930qkh.465.1632506103601; Fri, 24 Sep 2021 10:55:03 -0700 (PDT) Original-Received: from smtpclient.apple ([2600:1700:2ec7:8c9f:985d:2b51:33e2:edd4]) by smtp.gmail.com with ESMTPSA id p15sm5931205qti.70.2021.09.24.10.55.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 Sep 2021 10:55:03 -0700 (PDT) In-Reply-To: <83r1dfvktm.fsf@gnu.org> X-Mailer: Apple Mail (2.3654.120.0.1.13) Received-SPF: pass client-ip=2607:f8b0:4864:20::730; envelope-from=casouri@gmail.com; helo=mail-qk1-x730.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.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, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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:275412 Archived-At: > On Sep 22, 2021, at 11:59 PM, Eli Zaretskii wrote: >=20 >> From: Yuan Fu >> Date: Wed, 22 Sep 2021 20:59:00 -0700 >> Cc: Emacs developers >>=20 >> I tried to write >>=20 >> ptrdiff_t count =3D SPECPDL_INDEX (); >> record_unwind_protect_ptr (ts_delete_cursor, cursor); >> ... >> return unbind_to (count, xxx); >>=20 >> But it give a type error, because ts_delete_cursor doesn=E2=80=99t = take a void*. I guess I need to define a wrapper function to avoid that = error? >=20 > Yes, see for example directory_files_internal_unwind and its usage in > dired.c. >=20 >> Can I use record_unwind_protect_ptr more than once? >=20 > Yes. >=20 >> What does that count mean? >=20 > It tells unbind_to how much of the unwind-protect stack to unwind. > See the definition of unbind_to in eval.c. >=20 >> What is specpdl? >=20 > It's an array used for manually managed stack for tracking unwinds and > other stuff by the Emacs Lisp machine. See the comments for 'union > specbinding', starting at line 3135 of lisp.h. Thanks, I think I know how it works now. Yuan