From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.devel Subject: Re: External inline functions Date: Sun, 06 Nov 2011 13:20:07 -0800 Organization: UCLA Computer Science Department Message-ID: <4EB6FA07.9000602@cs.ucla.edu> References: <83zkg9hzdg.fsf@gnu.org> <87fwi1asti.fsf@wanadoo.es> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1320614425 21867 80.91.229.12 (6 Nov 2011 21:20:25 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 6 Nov 2011 21:20:25 +0000 (UTC) Cc: Eli Zaretskii , Andreas Schwab , emacs-devel@gnu.org To: =?UTF-8?B?w5NzY2FyIEZ1ZW50ZXM=?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Nov 06 22:20:19 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1RNA8Y-0005M5-GO for ged-emacs-devel@m.gmane.org; Sun, 06 Nov 2011 22:20:18 +0100 Original-Received: from localhost ([::1]:37841 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNA8X-0006n3-Ry for ged-emacs-devel@m.gmane.org; Sun, 06 Nov 2011 16:20:17 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]:53183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNA8U-0006ms-Vl for emacs-devel@gnu.org; Sun, 06 Nov 2011 16:20:16 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RNA8R-0000cH-Ms for emacs-devel@gnu.org; Sun, 06 Nov 2011 16:20:14 -0500 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:60143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RNA8P-0000b2-Ua; Sun, 06 Nov 2011 16:20:10 -0500 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id A4FA239E800A; Sun, 6 Nov 2011 13:20:07 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Original-Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EFgEkg6LKnkU; Sun, 6 Nov 2011 13:20:06 -0800 (PST) Original-Received: from [192.168.1.10] (pool-71-189-109-235.lsanca.fios.verizon.net [71.189.109.235]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 91B6139E8007; Sun, 6 Nov 2011 13:20:06 -0800 (PST) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: <87fwi1asti.fsf@wanadoo.es> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 131.179.128.62 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:145913 Archived-At: Yes, that's right: pre-C99 'inline' is a portability minefield, and GNU Emacs isn't portable even to C99's tricky semantics for extern inline (among other things, extern inline functions cannot call static functions). I installed the following to work around the problems in this area that I found. But as this issue keeps coming up, how about if we simply stop using extern inline functions? They do not buy us significant performance, and they are a hassle that is causing portability problems, so this should be an easy call. ==== Fix some portability problems with 'inline'. * dispextern.h (window_box, window_box_height, window_text_bottom_y) (window_box_width, window_box_left, window_box_left_offset) (window_box_right, window_box_right_offset): Declare extern. Otherwise, these inline functions do not conform to C99 and are miscompiled by Microsoft compilers. Reported by Eli Zaretskii in . * intervals.c (adjust_intervals_for_insertion) (adjust_intervals_for_deletion): Now extern, because otherwise the extern inline functions 'offset_intervals' couldn't refer to it. (static_offset_intervals): Remove. (offset_intervals): Rewrite using the old contents of static_offset_intervals. The old version didn't conform to C99 because an extern inline function contained a reference to an identifier with static linkage. === modified file 'src/dispextern.h' --- src/dispextern.h 2011-10-25 16:36:20 +0000 +++ src/dispextern.h 2011-11-06 21:03:15 +0000 @@ -3006,14 +3006,14 @@ void set_vertical_scroll_bar (struct window *); #endif int try_window (Lisp_Object, struct text_pos, int); -void window_box (struct window *, int, int *, int *, int *, int *); -int window_box_height (struct window *); -int window_text_bottom_y (struct window *); -int window_box_width (struct window *, int); -int window_box_left (struct window *, int); -int window_box_left_offset (struct window *, int); -int window_box_right (struct window *, int); -int window_box_right_offset (struct window *, int); +extern void window_box (struct window *, int, int *, int *, int *, int *); +extern int window_box_height (struct window *); +extern int window_text_bottom_y (struct window *); +extern int window_box_width (struct window *, int); +extern int window_box_left (struct window *, int); +extern int window_box_left_offset (struct window *, int); +extern int window_box_right (struct window *, int); +extern int window_box_right_offset (struct window *, int); int estimate_mode_line_height (struct frame *, enum face_id); void pixel_to_glyph_coords (struct frame *, int, int, int *, int *, NativeRectangle *, int); === modified file 'src/intervals.c' --- src/intervals.c 2011-10-26 01:18:13 +0000 +++ src/intervals.c 2011-11-06 21:03:14 +0000 @@ -52,6 +52,11 @@ #define TMEM(sym, set) (CONSP (set) ? ! NILP (Fmemq (sym, set)) : ! NILP (set)) +extern INTERVAL adjust_intervals_for_insertion (INTERVAL, + EMACS_INT, EMACS_INT); +extern void adjust_intervals_for_deletion (struct buffer *, + EMACS_INT, EMACS_INT); + static Lisp_Object merge_properties_sticky (Lisp_Object, Lisp_Object); static INTERVAL merge_interval_right (INTERVAL); static INTERVAL reproduce_tree (INTERVAL, INTERVAL); @@ -798,7 +803,7 @@ and check the hungry bits of both. Then add the length going back up to the root. */ -static INTERVAL +INTERVAL adjust_intervals_for_insertion (INTERVAL tree, EMACS_INT position, EMACS_INT length) { @@ -859,7 +864,7 @@ interval. Another possibility would be to create a new interval for this text, and make it have the merged properties of both ends. */ -static INTERVAL +INTERVAL adjust_intervals_for_insertion (INTERVAL tree, EMACS_INT position, EMACS_INT length) { @@ -1369,7 +1374,7 @@ text. The deletion is effected at position START (which is a buffer position, i.e. origin 1). */ -static void +void adjust_intervals_for_deletion (struct buffer *buffer, EMACS_INT start, EMACS_INT length) { @@ -1425,9 +1430,8 @@ compiler that does not allow calling a static function (here, adjust_intervals_for_deletion) from a non-static inline function. */ -static inline void -static_offset_intervals (struct buffer *buffer, EMACS_INT start, - EMACS_INT length) +inline void +offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length) { if (NULL_INTERVAL_P (BUF_INTERVALS (buffer)) || length == 0) return; @@ -1440,12 +1444,6 @@ adjust_intervals_for_deletion (buffer, start, -length); } } - -inline void -offset_intervals (struct buffer *buffer, EMACS_INT start, EMACS_INT length) -{ - static_offset_intervals (buffer, start, length); -} /* Merge interval I with its lexicographic successor. The resulting interval is returned, and has the properties of the original