From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.devel Subject: Re: MPS image cache Date: Fri, 03 May 2024 17:02:20 +0200 Message-ID: <87jzkb0whv.fsf@gmail.com> References: <875xvvp3fo.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40914"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , Emacs Devel To: Gerd =?utf-8?Q?M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 03 17:03:17 2024 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 1s2uRQ-000ANI-Mx for ged-emacs-devel@m.gmane-mx.org; Fri, 03 May 2024 17:03:16 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s2uQf-0000Vp-Jy; Fri, 03 May 2024 11:02:29 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1s2uQc-0000Od-Sc for emacs-devel@gnu.org; Fri, 03 May 2024 11:02:27 -0400 Original-Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s2uQa-0004mk-NG; Fri, 03 May 2024 11:02:26 -0400 Original-Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-a597de5a715so335845566b.2; Fri, 03 May 2024 08:02:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714748542; x=1715353342; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=m4mi07HH4RaS5oMT9HM3uPAL2tGeiBmT8SxI6HlU+4k=; b=JSF52MHZeh/OcZjS+d2NpdYFhgn0VKEdDRrM4Oy/lkvsJXAVehQrWZfctGyAfHD9UC sBRoXdccuosTvXfR7uf4S0cj4etVXiX6PNy+D0DINAbez33RlKrc6+X9OxH4X70E7ZU9 /g8mijP9jytT41IVV8WzADBBTgWBzI6it0XyI6AxYkQE6tb7AArYPPEEY3uojuaCdXt+ vXJqsjrAkMWFvtOQ3b+YHufWJiudjCslNPVp3QtSotXgrbzNR+8AugYTwPZnwje/S1yq rRv3HlM7pf1Pfo6aiKp5ASyozckh6i0oqIPYcjMNM6UR+SuJYTB7MuwpB2RUVy7uURM9 e9dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714748542; x=1715353342; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=m4mi07HH4RaS5oMT9HM3uPAL2tGeiBmT8SxI6HlU+4k=; b=rIxu6Ezia3Qj0l+KouVI/TAxZfQHr3fXrcjbOuhFVibbkivpbS5wHH2XGXK1QGqaLa DYSgSnECRLwfWopwJUIiE+UxaN+mJGSAHNq7NMwyw40E5/OrbvEnXs5C2yl5rxFM83bC yogK++Pp16oR4XlVObFOxhyr2DCvcxDuK5HGUOlY2wyhj3EcA+zBPDqf2XzRUkJ16n+u UPp5qH005KnM+XoETB57Scc6OBY1VS753R9MVfAYNr4B0akpttBSvPf4HE3ltuwo7WMk dSj0aXAavM7Mlu9I/qY+ykMyS3VQ2U1hXsYPhJ2KE9URyOOgi6UuB6Ow9uU+f7/qn6np bvZQ== X-Forwarded-Encrypted: i=1; AJvYcCUvCUGN61asiXScxmSjwXvRs4eRHh52T9bLHiBcqZzf809CXbUujy/BNgvzquicaBAm8s7zgF0YkplZboFMXyIeV7ey X-Gm-Message-State: AOJu0YzPfzldqBPOgDX5vrsLPuVkcr5NaLZ1E0HDYUHO2dl01b0oQPNZ ppjVji1FibKs8ueCKNBerwQ1hKCRr9IY5wSKA4CmFvoUHjEErExfFhoO1g== X-Google-Smtp-Source: AGHT+IG+B/S2NxTl0o5WzmAZ5Alg/XRFjfqH08E3d08ax3J45gO/jjDxcjU7WuWhaFkwOZXmrtSJ1w== X-Received: by 2002:a50:a6de:0:b0:572:a158:8a7c with SMTP id f30-20020a50a6de000000b00572a1588a7cmr1484298edc.42.1714748541436; Fri, 03 May 2024 08:02:21 -0700 (PDT) Original-Received: from caladan (dial-184253.pool.broadband44.net. [212.46.184.253]) by smtp.gmail.com with ESMTPSA id m22-20020aa7d356000000b00571bde3b0a4sm1759349edr.34.2024.05.03.08.02.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 08:02:21 -0700 (PDT) In-Reply-To: ("Gerd =?utf-8?Q?M=C3=B6llman?= =?utf-8?Q?n=22's?= message of "Fri, 03 May 2024 13:22:15 +0200") Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=eller.helmut@gmail.com; helo=mail-ej1-x634.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.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:318692 Archived-At: --=-=-= Content-Type: text/plain >> There is a bit of an issue with proper initialization of the structs >> pointed to by those roots. E.g. x_term_init uses xzalloc, puts pointers >> into the struct, and only then stores the pointer to the struct in >> x_display_list. So what should be the root, the struct (registred >> immediately after the call to xzalloc) or the global variable >> x_display_list? > > Hm. For my case, the troublesome field was xi_device_t.name. I decided to make x_display_info and xi_device_t amigous roots, because there is usually only one x_display_info and dozen of xi_device_t. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Make-x_display_info-and-xi_device_t-amig-roots.patch >From 497b5c900e1a4746c214af7be6242d0bc456cdc7 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Fri, 3 May 2024 16:47:51 +0200 Subject: [PATCH] Make x_display_info and xi_device_t amig roots * src/xterm.c (x_cache_xi_devices, xi_disable_devices): Use igc_xzalloc_ambig for xi_disable_t. (handle_one_xevent): For the XI_HierarchyChanged event igc_realloc_ambig if needed. (x_term_init): Use igc_xzalloc_ambig for dpyinfo. * src/igc.h (igc_realloc_ambig): New. * src/igc.c (igc_realloc_ambig): Not implemented yet; scetch of an implementation as comment. --- src/igc.c | 24 ++++++++++++++++++++++-- src/igc.h | 1 + src/xterm.c | 29 +++++++++++++++++++++++++---- 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/src/igc.c b/src/igc.c index 648f2bbc44d..6d553bc316d 100644 --- a/src/igc.c +++ b/src/igc.c @@ -1389,10 +1389,10 @@ fix_frame (mps_ss_t ss, struct frame *f) struct font **font_ptr = &FRAME_FONT (f); if (*font_ptr) IGC_FIX12_RAW (ss, font_ptr); - Lisp_Object *nle = &FRAME_DISPLAY_INFO(f)->name_list_element; + Lisp_Object *nle = &FRAME_DISPLAY_INFO (f)->name_list_element; IGC_FIX12_OBJ (ss, nle); } -#endif +#endif // HAVE_WINDOW_SYSTEM } MPS_SCAN_END (ss); return MPS_RES_OK; @@ -2157,6 +2157,26 @@ igc_xzalloc_ambig (size_t size) return p; } +void * +igc_realloc_ambig (void *block, size_t size) +{ +#if 0 // non tested code: + struct igc_root_list *r = root_find (block); + igc_assert (r != NULL); + destroy_root (&r); + + /* Can't make a root that has zero length. Want one to be able to + detect calling igc_free on something not having a root. */ + size_t new_size = (size == 0 ? IGC_ALIGN_DFLT : size); + void *p = xrealloc (block, new_size); + void *end = (char *)p + new_size; + root_create_ambig (global_igc, p, end); + return p; +#endif + emacs_abort (); +} + + void igc_xfree (void *p) { diff --git a/src/igc.h b/src/igc.h index 84e4ff8f13a..b1d09700a78 100644 --- a/src/igc.h +++ b/src/igc.h @@ -51,6 +51,7 @@ #define EMACS_IGC_H struct Lisp_Buffer_Local_Value *igc_alloc_blv (void); void *igc_xzalloc_ambig (size_t size); +void *igc_realloc_ambig (void *block, size_t size); void igc_xfree (void *p); Lisp_Object *igc_xalloc_lisp_objs_exact (size_t n); void *igc_xpalloc_ambig (void *pa, ptrdiff_t *nitems, ptrdiff_t nitems_incr_min, diff --git a/src/xterm.c b/src/xterm.c index 36f83a33244..c47c7b0534d 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -787,6 +787,9 @@ #define XtNinitialState "initialState" #ifdef HAVE_XKB #include #endif +#ifdef HAVE_MPS +#include "igc.h" +#endif /* Although X11/Xlib.h commonly defines the types XErrorHandler and XIOErrorHandler, they are not in the Xlib spec, so for portability @@ -5744,7 +5747,11 @@ x_cache_xi_devices (struct x_display_info *dpyinfo) return; } +#ifdef HAVE_MPS + dpyinfo->devices = igc_xzalloc_ambig (sizeof *dpyinfo->devices * ndevices); +#else dpyinfo->devices = xzalloc (sizeof *dpyinfo->devices * ndevices); +#endif for (i = 0; i < ndevices; ++i) { @@ -13774,7 +13781,11 @@ xi_disable_devices (struct x_display_info *dpyinfo, return; ndevices = 0; +#ifdef HAVE_MPS + devices = igc_xzalloc_ambig (sizeof *devices * dpyinfo->num_devices); +#else devices = xzalloc (sizeof *devices * dpyinfo->num_devices); +#endif /* Loop through every device currently in DPYINFO, and copy it to DEVICES if it is not in TO_DISABLE. Note that this function @@ -24600,10 +24611,15 @@ handle_one_xevent (struct x_display_info *dpyinfo, if (info && info->enabled) { - dpyinfo->devices - = xrealloc (dpyinfo->devices, - (sizeof *dpyinfo->devices - * ++dpyinfo->num_devices)); + size_t new_size = (sizeof *dpyinfo->devices + * ++dpyinfo->num_devices); +#ifdef HAVE_MPS + dpyinfo->devices = + igc_realloc_ambig (dpyinfo->devices, new_size); +#else + dpyinfo->devices = + xrealloc (dpyinfo->devices, new_size); +#endif memset (dpyinfo->devices + dpyinfo->num_devices - 1, 0, sizeof *dpyinfo->devices); device = &dpyinfo->devices[dpyinfo->num_devices - 1]; @@ -30676,7 +30692,12 @@ #define NUM_ARGV 10 /* We have definitely succeeded. Record the new connection. */ +#ifdef HAVE_MPS + dpyinfo = igc_xzalloc_ambig (sizeof *dpyinfo); +#else dpyinfo = xzalloc (sizeof *dpyinfo); +#endif + terminal = x_create_terminal (dpyinfo); if (!NILP (Vx_detect_server_trust)) -- 2.39.2 --=-=-=--