From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "Jan D." Newsgroups: gmane.emacs.devel Subject: Re: Question about GC in C code. Date: Tue, 12 Nov 2002 13:49:56 +0100 (MET) Sender: emacs-devel-admin@gnu.org Message-ID: <200211121246.gACCk0MU030988@stubby.bodenonline.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: main.gmane.org 1037200742 18308 80.91.224.249 (13 Nov 2002 15:19:02 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Wed, 13 Nov 2002 15:19:02 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 18BzCU-00046k-00 for ; Wed, 13 Nov 2002 16:13:06 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 18BzOR-00066k-01 for ; Wed, 13 Nov 2002 16:25:27 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.10) id 18BagU-00028Q-00; Tue, 12 Nov 2002 08:02:26 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.10) id 18BaUk-0006tT-00 for emacs-devel@gnu.org; Tue, 12 Nov 2002 07:50:18 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.10) id 18BaUh-0006sZ-00 for emacs-devel@gnu.org; Tue, 12 Nov 2002 07:50:17 -0500 Original-Received: from stubby.bodenonline.com ([193.201.16.94]) by monty-python.gnu.org with esmtp (Exim 4.10) id 18BaUc-0006rc-00; Tue, 12 Nov 2002 07:50:10 -0500 Original-Received: from pc35.bodenonline.com (IDENT:root@[193.201.16.44]) by stubby.bodenonline.com (8.12.1/8.12.1) with ESMTP id gACCk0MU030988; Tue, 12 Nov 2002 13:46:00 +0100 Original-To: rms@gnu.org In-Reply-To: from "Richard Stallman" at nov 11, 2002 05:20:05 X-Mailer: ELM [version 2.5 PL0pre8] Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.11 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:9316 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:9316 > > But I confess that I have no clue as how GC works in the C code. > Will this approach work? Will menu_bar_vector be safe from GC? > > You have to modify the GC code in alloc.c to explicitly find these > C data structures in the menus and mark them the vectors by calling > mark_object. > I think now I got it. But instead of adding a Gtk-specific solution I would like to propose a more generic variant. How about if alloc.c was modified so other code could register a function to be called when GC occurs? That function could then mark lisp objects as needed. That way we can keep alloc.c free from knowing all the details of data structures, and changes to those data structures can be localized in just one file. Something like this: typedef void (*mark_function) (Lisp_Object *argptr); typedef void (*gc_function) (mark_function func); void register_gc_function (gc_function func); Then in the Gtk code I can do: static void mark_gtk_data (mark_function func) { /* find menu data and mark */ ... func(&data->menu_bar_vector); ... } ... register_gc_function (mark_gtk_data); The reason for mark_function is that mark_object is static in alloc.c, so I pass it as an argument to gc_function. Is this feasible? Jan D.