From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Eggert Newsgroups: gmane.emacs.bugs Subject: bug#12116: merge from gnulib for extern-inline Date: Thu, 02 Aug 2012 11:02:59 -0700 Organization: UCLA Computer Science Department Message-ID: <501AC0D3.6080300@cs.ucla.edu> References: <5019AB4B.3060607@cs.ucla.edu> <83obmtcoy2.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1343930629 441 80.91.229.3 (2 Aug 2012 18:03:49 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 2 Aug 2012 18:03:49 +0000 (UTC) Cc: lekktu@gmail.com, 12116@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Aug 02 20:03:47 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1SwzkQ-0007z8-1s for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Aug 2012 20:03:46 +0200 Original-Received: from localhost ([::1]:54673 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwzkP-0003v0-76 for geb-bug-gnu-emacs@m.gmane.org; Thu, 02 Aug 2012 14:03:45 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53303) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwzkJ-0003un-Ag for bug-gnu-emacs@gnu.org; Thu, 02 Aug 2012 14:03:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SwzkB-00078N-R9 for bug-gnu-emacs@gnu.org; Thu, 02 Aug 2012 14:03:39 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:47822) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SwzkB-00078I-NX for bug-gnu-emacs@gnu.org; Thu, 02 Aug 2012 14:03:31 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SwzrS-0002PS-8y for bug-gnu-emacs@gnu.org; Thu, 02 Aug 2012 14:11:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Eggert Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 02 Aug 2012 18:11:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12116 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 12116-submit@debbugs.gnu.org id=B12116.13439310419236 (code B ref 12116); Thu, 02 Aug 2012 18:11:02 +0000 Original-Received: (at 12116) by debbugs.gnu.org; 2 Aug 2012 18:10:41 +0000 Original-Received: from localhost ([127.0.0.1]:57368 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Swzr6-0002Ou-Ho for submit@debbugs.gnu.org; Thu, 02 Aug 2012 14:10:41 -0400 Original-Received: from smtp.cs.ucla.edu ([131.179.128.62]:40412) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Swzr2-0002Ol-VC for 12116@debbugs.gnu.org; Thu, 02 Aug 2012 14:10:38 -0400 Original-Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id AC4EB39E8014; Thu, 2 Aug 2012 11:03:04 -0700 (PDT) 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 RLBxOOfVkg0W; Thu, 2 Aug 2012 11:03:04 -0700 (PDT) Original-Received: from [192.168.1.4] (pool-108-23-119-2.lsanca.fios.verizon.net [108.23.119.2]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id E52A939E8013; Thu, 2 Aug 2012 11:03:03 -0700 (PDT) User-Agent: Mozilla/5.0 (X11; Linux i686; rv:14.0) Gecko/20120714 Thunderbird/14.0 In-Reply-To: <83obmtcoy2.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:62764 Archived-At: On 08/02/2012 08:07 AM, Eli Zaretskii wrote: > Can you explain what it does? The basic idea is to support globally-used inline functions using the way established by C99 standard. C99 does it by putting this into a .h file: inline foo (int x) { return bar (x); } and by also declaring FOO to be extern in one .c file. In a non-optimizing implementation FOO's machine code is generated for that .c file, and all uses invoke that machine code. In an optimizing implementation, FOO is expanded inline when that makes sense, and FOO's machine code can be optimized away if all calls to FOO are inlined. The way it's done in gnulib and Emacs is to use the above scheme when C99 style extern inline works, and to fall back on 'static inline' for older compilers, or even to plain 'static' if the compiler is so ancient that it doesn't even grok 'inline'. In Emacs we have the macros: e x p a n s i o n i n : macro C99 older compilers ancient compilers INLINE inline static inline static EXTERN_INLINE extern inline static inline static and the Emacs include file charset.h does this: #ifndef CHARSET_INLINE # define CHARSET_INLINE INLINE #endif CHARSET_INLINE void set_charset_attr (struct charset *charset, enum charset_attr_index idx, Lisp_Object val) { ASET (CHARSET_ATTRIBUTES (charset), idx, val); } so in C99 most users of charset.h see the function as being 'inline void'. charset.c does this before including charset.h: #define CHARSET_INLINE EXTERN_INLINE so that when it's compiled, the function is 'extern inline void'. In pre-C99 compilers the function is 'static inline' or (if ancient) plain 'static'. Similarly for each .h file that uses inline functions.