From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "carlo\.bramix" Newsgroups: gmane.lisp.guile.devel Subject: Re: `SCM_MAKE_CHAR ()' signedness issue Date: Mon, 17 Aug 2009 20:52:59 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1250535200 29094 80.91.229.12 (17 Aug 2009 18:53:20 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 17 Aug 2009 18:53:20 +0000 (UTC) To: "guile-devel" Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Aug 17 20:53:13 2009 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Md7KR-0006TF-N4 for guile-devel@m.gmane.org; Mon, 17 Aug 2009 20:53:12 +0200 Original-Received: from localhost ([127.0.0.1]:49322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Md7KR-0006bZ-1l for guile-devel@m.gmane.org; Mon, 17 Aug 2009 14:53:11 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Md7KL-0006b3-H2 for guile-devel@gnu.org; Mon, 17 Aug 2009 14:53:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Md7KH-0006Wf-UC for guile-devel@gnu.org; Mon, 17 Aug 2009 14:53:05 -0400 Original-Received: from [199.232.76.173] (port=45408 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Md7KH-0006WZ-Rj for guile-devel@gnu.org; Mon, 17 Aug 2009 14:53:01 -0400 Original-Received: from cp-out4.libero.it ([212.52.84.104]:59024) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Md7KH-0001M8-09 for guile-devel@gnu.org; Mon, 17 Aug 2009 14:53:01 -0400 Original-Received: from libero.it (192.168.17.14) by cp-out4.libero.it (8.5.107) id 4A89688D0001BB34 for guile-devel@gnu.org; Mon, 17 Aug 2009 20:52:59 +0200 X-Sensitivity: 3 X-XaM3-API-Version: 4.3 (R1) (B3pl25) X-SenderIP: 213.203.169.135 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:9140 Archived-At: Hello, if I understood the problem, I think it can be easily fixed without using= an inline function. For example: #ifdef __GNUC__ #define SCM_MAKE_CHAR(__x) \ ({ scm_t_int32 __t =3D (scm_t_int32)(__x); \= (__t < 0) \ ? SCM_MAKE_ITAG8 ((scm_t_bits) (unsigned char) (__x), scm_tc8_char) \ : SCM_MAKE_ITAG8 ((scm_t_bits) (__x), scm_tc8_char); \ __t; \ }) #else #define SCM_MAKE_CHAR(x) \ ((scm_t_int32) (x) < 0 \ ? SCM_MAKE_ITAG8 ((scm_t_bits) (unsigned char) (x), scm_tc8_char) \ : SCM_MAKE_ITAG8 ((scm_t_bits) (x), scm_tc8_char)) #endif solves the problem. Actually a much more efficient solution specifically designed for GCC may= use __builtin_types_compatible_p() and __builtin_choose_expr() intrinsic= functions, but this will force you to support GCC 3.x or newer. Something like: #if defined __GNUC__ && __GNUC__ >=3D 3 ... #elif ... will need to be written. Sincerely, Carlo Bramini. ---------- Initial Header ----------- >From : guile-devel-bounces+carlo.bramix=3Dlibero.it@gnu.org To : guile-devel@gnu.org Cc : Date : Mon, 17 Aug 2009 17:33:03 +0200 Subject : Re: `SCM_MAKE_CHAR ()' signedness issue > Mike Gran writes: > > > On my system I ran a test with SCM_MAKE_CHAR as a macro, an an inline= , > > and as a never inlined function. I ran ./check-guile twice for each.= > > You're cheating! ;-) > > The test suite does lots of things besides calling `SCM_MAKE_CHAR ()', > so I'm not sure if it's a good benchmark. > > I'm fairly confident that for such a small piece of code inlining is > always a good idea. > > Thanks, > Ludo'. >