From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: MPS: Win64 testers? Date: Sat, 27 Jul 2024 20:22:34 +0000 Message-ID: References: <86zfq31cvc.fsf@gnu.org> <86ttgb1186.fsf@gnu.org> <86le1m24tx.fsf@gnu.org> <86jzh622p4.fsf@gnu.org> <86h6ca1xfz.fsf@gnu.org> Mime-Version: 1.0 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="27955"; 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 Sun Jul 28 06:28:21 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 1sXvW9-000768-0k for ged-emacs-devel@m.gmane-mx.org; Sun, 28 Jul 2024 06:28:21 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sXvVe-0005eQ-EU; Sun, 28 Jul 2024 00:27:50 -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 1sXnwA-00018y-6i for emacs-devel@gnu.org; Sat, 27 Jul 2024 16:22:42 -0400 Original-Received: from mail-4322.protonmail.ch ([185.70.43.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sXnw8-0005uQ-7U for emacs-devel@gnu.org; Sat, 27 Jul 2024 16:22:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1722111757; x=1722370957; bh=Ue8Pxs0FI2e44L9KM6FSveVsGxBjCOaL3dBV5UmskJ4=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=jRhet/bCpctaTzwxCPwv7nU619MWZxppQs1we90fM/QsbYswUP6jO3S5jrS7EyF9B vsCRiegmxftWsM8HluiQPnePIXWIruM/APb8NoNO337tN+3smAb42SD4ZEXuQOGrpa FeCJaaAaVn5TLeKJJm8mPu9EzuQmBI3bq5ZI+BnX7yp/F76ICY75NZOcvPPD5q4ev2 kqwnScJ6/LSAo5eBD92TNcevSiP7wiupt6EdEN8w41YXAIpq0FJh+2wHOVd+bwtw8G kGC64ZeTPnqsg3eKe4cMq0F5xrZIh+T57sUB0vlZV9bgT3lJgGXPTh5nDBs86YMIgq ZA8K3sLnKStFg== In-Reply-To: <86h6ca1xfz.fsf@gnu.org> Feedback-ID: 112775352:user:proton X-Pm-Message-ID: ba56e12ce5c871438e56164143c8c80dd40551a8 Received-SPF: pass client-ip=185.70.43.22; envelope-from=pipcet@protonmail.com; helo=mail-4322.protonmail.ch X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sun, 28 Jul 2024 00:27:47 -0400 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:322151 Archived-At: On Saturday, July 27th, 2024 at 18:50, Eli Zaretskii wrote: > > Date: Sat, 27 Jul 2024 18:27:43 +0000 >=20 > > From: Pip Cet pipcet@protonmail.com > > Cc: emacs-devel@gnu.org > >=20 > > On Saturday, July 27th, 2024 at 16:56, Eli Zaretskii eliz@gnu.org wrote= : > >=20 > > > then stepping through this code I see that fd is first assigned zero, > > > then 1, then 2. As expected, because any decent emulation of Posix > > > file descriptors must keep this semantics: file descriptors are reuse= d > > > starting from the lowest available slot. > > >=20 > > > Do you see something different in your build? > >=20 > > _open_osfhandle returns 0 for the first FD, but _fdopen returns 0x7b281= 160, while stdin is 0x7b281100. >=20 >=20 > Not on my system. Here _fdopen returns a pointer to the same FILE > object as the original std* streams. And it is also expected, since > the source code of MSVCRT explicitly shows that _fdopen calls a > routine that looks up a vacant stream slot, and that routine examines > the _iob[] array in the ascending order of indices, from zero to max, > until it finds an unused slot. Wine does the same thing, except it starts at index 3: for (i =3D 3; i < MSVCRT_max_streams; i++) { file =3D msvcrt_get_file(i); if (!file) return NULL; if (file->_flag =3D=3D 0) { if (i =3D=3D MSVCRT_stream_idx) { CRITICAL_SECTION *cs =3D file_get_cs(file); if (cs) { InitializeCriticalSectionEx(cs, 0, RTL_CRITICAL_SECTION_FLAG_= FORCE_DEBUG_INFO); cs->DebugInfo->Spare[0] =3D (DWORD_PTR)(__FILE__ ": file_crit= .crit"); } MSVCRT_stream_idx++; } return file; } } It's been that way since 2004, if the git history is to be believed. Fixing wine (single-character fixes are my favorite) to start at index 0 ma= kes things work. > > I believe that _fdopen (0, "r") returns stdin if it has previously been= closed is an implementation detail of Windows that Emacs relies on, and th= at wine fails to properly emulate. IMHO, this is a wine bug, but Emacs also= shouldn't rely on it unless it's documented as part of the API; I don't kn= ow whether it is. >=20 >=20 > I believe this is how every Posix-like allocation of FILE objects > should behave. I'm astonished that Wine doesn't work like that, since > it's the easiest way. >=20 > Moreover, the MS documentation says about the standard streams: >=20 > These pointers are constants, and can't be assigned new values. >=20 > So you cannot do "stdin =3D _fdopen (...);" and hope for all the > references to stdin in the rest of the program to use the new value of > the stream pointer. IOW, what Emacs does is the only way of doing > that. Well, there's freopen, but no fdreopen, so you're probably right... Pip