From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: x-display-pixel-width/height inconsistency Date: Fri, 10 May 2013 11:41:38 +0300 Message-ID: <8338tvcjlp.fsf@gnu.org> References: <514A5DE1.10009@gmx.de> <831ub767wf.fsf@gnu.org> <83mwtu4p7c.fsf@gnu.org> <83vc8h313t.fsf@gnu.org> <5073D6B8-95E4-4012-AA74-106F428379DC@swipnet.se> <8BD4B041-5A3F-4D7C-AFD3-E997E194AA9D@swipnet.se> <02B98FCD-71DB-47EC-B58B-41A2539FF61A@swipnet.se> <83vc6tcqss.fsf@gnu.org> <83haibdipo.fsf@gnu.org> <837gj7co0l.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1368175358 28792 80.91.229.3 (10 May 2013 08:42:38 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 10 May 2013 08:42:38 +0000 (UTC) Cc: emacs-devel@gnu.org To: YAMAMOTO Mitsuharu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri May 10 10:42:36 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UaiuS-0003AM-21 for ged-emacs-devel@m.gmane.org; Fri, 10 May 2013 10:42:36 +0200 Original-Received: from localhost ([::1]:46402 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UaiuR-0002GK-Lx for ged-emacs-devel@m.gmane.org; Fri, 10 May 2013 04:42:35 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:42140) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UaiuO-0002G4-4H for emacs-devel@gnu.org; Fri, 10 May 2013 04:42:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UaiuM-0001wR-K5 for emacs-devel@gnu.org; Fri, 10 May 2013 04:42:32 -0400 Original-Received: from mtaout22.012.net.il ([80.179.55.172]:65462) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UaiuM-0001wE-Cz for emacs-devel@gnu.org; Fri, 10 May 2013 04:42:30 -0400 Original-Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MMK00500QSPWP00@a-mtaout22.012.net.il> for emacs-devel@gnu.org; Fri, 10 May 2013 11:41:53 +0300 (IDT) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MMK004O7QTTWUR0@a-mtaout22.012.net.il>; Fri, 10 May 2013 11:41:53 +0300 (IDT) In-reply-to: X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.172 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:159473 Archived-At: > Date: Fri, 10 May 2013 16:47:36 +0900 > From: YAMAMOTO Mitsuharu > Cc: emacs-devel@gnu.org > > Even if the callback is called in another thread (though I don't think > there is a particular reason to do so), that is indistinguishable for > Fcons from the call in the same thread if memory is properly > synchronized before the call among different processors/cores. We don't know if this is the case, and probably never will. (I tried to search the net for any additional information about this API, but came up empty-handed.) > If not properly synchronized, use of other data structures such as a > simple linked list does not solve the problem either (you can't even > count the number of monitors without explicit synchronization by > mutex). You can count monitors with EnumDisplayMonitors if you pass to the callback a pointer to a static int variable, which the callback will increment. You can then allocate an array of a suitable size and call EnumDisplayMonitors again, this time filling the array with HMONITOR handles, one at a time. This makes sure we don't cons and don't otherwise allocate memory inside a callback.