From unknown Thu Sep 11 16:39:30 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#13419 <13419@debbugs.gnu.org> To: bug#13419 <13419@debbugs.gnu.org> Subject: Status: make 'eabs' act more like a function Reply-To: bug#13419 <13419@debbugs.gnu.org> Date: Thu, 11 Sep 2025 23:39:30 +0000 retitle 13419 make 'eabs' act more like a function reassign 13419 emacs submitter 13419 Paul Eggert severity 13419 minor tag 13419 patch thanks From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 12 01:50:16 2013 Received: (at submit) by debbugs.gnu.org; 12 Jan 2013 06:50:16 +0000 Received: from localhost ([127.0.0.1]:56148 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ttuv0-0004Iq-AD for submit@debbugs.gnu.org; Sat, 12 Jan 2013 01:50:16 -0500 Received: from eggs.gnu.org ([208.118.235.92]:48687) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ttuuv-0004Ib-Fn for submit@debbugs.gnu.org; Sat, 12 Jan 2013 01:50:11 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Ttuua-00016B-W9 for submit@debbugs.gnu.org; Sat, 12 Jan 2013 01:49:53 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-104.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD,USER_IN_WHITELIST autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:39283) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Ttuua-000167-Se for submit@debbugs.gnu.org; Sat, 12 Jan 2013 01:49:48 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60044) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtuuS-00073a-Ll for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2013 01:49:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TtuuL-00012Z-BS for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2013 01:49:40 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:57444) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TtuuK-00012Q-US for bug-gnu-emacs@gnu.org; Sat, 12 Jan 2013 01:49:33 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 5B0A5A60001 for ; Fri, 11 Jan 2013 22:44:22 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu 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 hzAxTIr7GuX4 for ; Fri, 11 Jan 2013 22:44:20 -0800 (PST) Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id A258339E8008 for ; Fri, 11 Jan 2013 22:44:20 -0800 (PST) Message-ID: <50F10643.8000408@cs.ucla.edu> Date: Fri, 11 Jan 2013 22:44:19 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: bug-gnu-emacs@gnu.org Subject: make 'eabs' act more like a function Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -6.2 (------) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.2 (------) Tags: patch Severity: minor This patch doesn't fix any bugs, it's just a code cleanup. It fixes 'eabs (X)' so that it evaluates X just once instead of twice. As Emacs is currently written this shouldn't affect efficiency or behavior, but it is a nicety. The key part of this patch is to lisp.h; most of the rest is pulled in from gnulib automatically. I'm guessing about the change to nt/inc/inttypes.h, as I don't use Windows. === modified file 'ChangeLog' --- ChangeLog 2013-01-12 05:21:06 +0000 +++ ChangeLog 2013-01-12 06:31:32 +0000 @@ -1,5 +1,10 @@ 2013-01-12 Paul Eggert + Make eabs act more like a function. + * configure.ac: Invoke AC_C_TYPEOF. + * lib/imaxabs.c, m4/imaxabs.m4, m4/_Generic.m4: New files, from gnulib. + * lib/gnulib.mk, m4/gnulib-comp.m4: Regenerate. + Enable conservative stack scanning for all architectures. Suggested by Stefan Monnier in . === modified file 'admin/ChangeLog' --- admin/ChangeLog 2013-01-10 03:43:02 +0000 +++ admin/ChangeLog 2013-01-12 01:03:44 +0000 @@ -1,3 +1,8 @@ +2013-01-12 Paul Eggert + + Make eabs act more like a function. + * merge-gnulib (GNULIB_MODULES): Add _Generic, imaxabs. + 2013-01-03 Glenn Morris * check-doc-strings: Update for CVS->bzr, moved lispref/ directory. === modified file 'admin/merge-gnulib' --- admin/merge-gnulib 2013-01-02 16:13:04 +0000 +++ admin/merge-gnulib 2013-01-12 01:03:44 +0000 @@ -26,11 +26,11 @@ GNULIB_URL=git://git.savannah.gnu.org/gnulib.git GNULIB_MODULES=' - alloca-opt c-ctype c-strcase + _Generic alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday - ignore-value intprops largefile lstat + ignore-value imaxabs intprops largefile lstat manywarnings mktime pselect pthread_sigmask putenv readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat === modified file 'configure.ac' --- configure.ac 2013-01-12 05:21:06 +0000 +++ configure.ac 2013-01-12 06:31:32 +0000 @@ -3350,6 +3350,8 @@ AC_TYPE_MBSTATE_T +AC_C_TYPEOF + AC_CACHE_CHECK([for C restricted array declarations], emacs_cv_c_restrict_arr, [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[void fred (int x[__restrict]);]], [[]])], emacs_cv_c_restrict_arr=yes, emacs_cv_c_restrict_arr=no)]) === modified file 'lib/gnulib.mk' --- lib/gnulib.mk 2013-01-04 02:17:49 +0000 +++ lib/gnulib.mk 2013-01-12 01:03:44 +0000 @@ -21,7 +21,7 @@ # the same distribution terms as the rest of that program. # # Generated by gnulib-tool. -# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value intprops largefile lstat manywarnings mktime pselect pthread_sigmask putenv readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec-sub uns etenv uti mens warnings +# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu --source-base=lib --m4-base=m4 --doc-base=doc --tests-base=tests --aux-dir=build-aux --avoid=at-internal --avoid=errno --avoid=fchdir --avoid=fcntl --avoid=fstat --avoid=malloc-posix --avoid=msvc-inval --avoid=msvc-nothrow --avoid=openat-die --avoid=openat-h --avoid=raise --avoid=save-cwd --avoid=select --avoid=sigprocmask --avoid=sys_types --avoid=threadlib --makefile-name=gnulib.mk --conditional-dependencies --no-libtool --macro-prefix=gl --no-vc-files _Generic alloca-opt c-ctype c-strcase careadlinkat close-stream crypto/md5 crypto/sha1 crypto/sha256 crypto/sha512 dtoastr dtotimespec dup2 environ execinfo faccessat fcntl-h filemode getloadavg getopt-gnu gettime gettimeofday ignore-value imaxabs intprops largefile lstat manywarnings mktime pselect pthread_sigmask putenv readlink sig2str socklen stat-time stdalign stdarg stdbool stdio strftime strtoimax strtoumax symlink sys_stat sys_time time timer-time timespec-add timespec -sub unsetenv utimens warnings MOSTLYCLEANFILES += core *.stackdump @@ -343,6 +343,15 @@ ## end gnulib module ignore-value +## begin gnulib module imaxabs + + +EXTRA_DIST += imaxabs.c + +EXTRA_libgnu_a_SOURCES += imaxabs.c + +## end gnulib module imaxabs + ## begin gnulib module intprops === added file 'lib/imaxabs.c' --- lib/imaxabs.c 1970-01-01 00:00:00 +0000 +++ lib/imaxabs.c 2013-01-10 08:23:32 +0000 @@ -0,0 +1,26 @@ +/* imaxabs() function: absolute value of 'intmax_t'. + Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include + +/* Specification. */ +#include + +intmax_t +imaxabs (intmax_t x) +{ + return (x >= 0 ? x : - x); +} === added file 'm4/_Generic.m4' --- m4/_Generic.m4 1970-01-01 00:00:00 +0000 +++ m4/_Generic.m4 2013-01-12 01:03:44 +0000 @@ -0,0 +1,34 @@ +# Test for C11-style _Generic +dnl Copyright 2012-2013 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Paul Eggert. + +# Backport of autoconf-2.70's macro. +# Remove this macro when we can assume autoconf >= 2.70. +m4_ifndef([AC_C__GENERIC], +[AC_DEFUN([AC_C__GENERIC], +[AC_CACHE_CHECK([for _Generic], ac_cv_c__Generic, +[AC_COMPILE_IFELSE( + [AC_LANG_SOURCE( + [[int + main (int argc, char **argv) + { + int a = _Generic (argc, int: argc = 1); + int *b = &_Generic (argc, default: argc); + char ***c = _Generic (argv, int: argc, default: argv ? &argv : 0); + _Generic (1 ? 0 : b, int: a, default: b) = &argc; + _Generic (a = 1, default: a) = 3; + return a + !b + !c; + } + ]])], + [ac_cv_c__Generic=yes], + [ac_cv_c__Generic=no])]) +if test $ac_cv_c__Generic = yes; then + AC_DEFINE([HAVE_C__GENERIC], 1, + [Define to 1 if C11-style _Generic works.]) +fi +]) +]) === modified file 'm4/gnulib-comp.m4' --- m4/gnulib-comp.m4 2013-01-04 02:17:49 +0000 +++ m4/gnulib-comp.m4 2013-01-12 01:03:44 +0000 @@ -38,6 +38,7 @@ m4_pattern_allow([^gl_LIBOBJS$])dnl a variable m4_pattern_allow([^gl_LTLIBOBJS$])dnl a variable AC_REQUIRE([gl_PROG_AR_RANLIB]) + # Code from module _Generic: # Code from module alloca-opt: # Code from module allocator: # Code from module c-ctype: @@ -72,6 +73,7 @@ # Code from module gettimeofday: # Code from module group-member: # Code from module ignore-value: + # Code from module imaxabs: # Code from module include_next: # Code from module intprops: # Code from module inttypes-incomplete: @@ -150,6 +152,7 @@ m4_pushdef([gl_LIBSOURCES_DIR], []) gl_COMMON gl_source_base='lib' + AC_C__GENERIC gl_FUNC_ALLOCA AC_CHECK_FUNCS_ONCE([readlinkat]) gl_CLOCK_TIME @@ -216,6 +219,12 @@ gl_PREREQ_GETTIMEOFDAY fi gl_SYS_TIME_MODULE_INDICATOR([gettimeofday]) + gl_FUNC_IMAXABS + if test $ac_cv_func_imaxabs = no; then + AC_LIBOBJ([imaxabs]) + gl_PREREQ_IMAXABS + fi + gl_INTTYPES_MODULE_INDICATOR([imaxabs]) gl_INTTYPES_INCOMPLETE AC_REQUIRE([gl_LARGEFILE]) gl_FUNC_LSTAT @@ -682,6 +691,7 @@ lib/gettimeofday.c lib/group-member.c lib/ignore-value.h + lib/imaxabs.c lib/intprops.h lib/inttypes.in.h lib/lstat.c @@ -742,6 +752,7 @@ lib/verify.h lib/xalloc-oversized.h m4/00gnulib.m4 + m4/_Generic.m4 m4/alloca.m4 m4/c-strtod.m4 m4/clock_time.m4 @@ -764,6 +775,7 @@ m4/gettimeofday.m4 m4/gnulib-common.m4 m4/group-member.m4 + m4/imaxabs.m4 m4/include_next.m4 m4/inttypes.m4 m4/largefile.m4 === added file 'm4/imaxabs.m4' --- m4/imaxabs.m4 1970-01-01 00:00:00 +0000 +++ m4/imaxabs.m4 2013-01-10 08:23:32 +0000 @@ -0,0 +1,20 @@ +# imaxabs.m4 serial 4 +dnl Copyright (C) 2006, 2009-2013 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_IMAXABS], +[ + AC_REQUIRE([gl_INTTYPES_H_DEFAULTS]) + + dnl On OSF/1 5.1 with cc, this function is declared but not defined. + AC_CHECK_FUNCS_ONCE([imaxabs]) + AC_CHECK_DECLS_ONCE([imaxabs]) + if test "$ac_cv_have_decl_imaxabs" != yes; then + HAVE_DECL_IMAXABS=0 + fi +]) + +# Prerequisites of lib/imaxabs.c. +AC_DEFUN([gl_PREREQ_IMAXABS], [:]) === modified file 'nt/ChangeLog' --- nt/ChangeLog 2013-01-11 09:33:54 +0000 +++ nt/ChangeLog 2013-01-12 01:04:47 +0000 @@ -1,3 +1,8 @@ +2013-01-12 Paul Eggert + + Make eabs act more like a function. + * inc/inttypes.h (imaxabs) [!__MINGW32__]: New macro. + 2013-01-11 Eli Zaretskii * inc/unistd.h (O_IGNORE_CTTY): Define, as it is unconditionally === modified file 'nt/inc/inttypes.h' --- nt/inc/inttypes.h 2013-01-01 09:11:05 +0000 +++ nt/inc/inttypes.h 2013-01-11 23:37:49 +0000 @@ -25,9 +25,11 @@ #else /* !__MINGW32__ */ #include "stdint.h" #ifdef _WIN64 +#define imaxabs _abs64 #define strtoumax _strtoui64 #define strtoimax _strtoi64 #else +#define imaxabs labs #define strtoumax strtoul #define strtoimax strtol #endif === modified file 'src/ChangeLog' --- src/ChangeLog 2013-01-12 06:15:12 +0000 +++ src/ChangeLog 2013-01-12 06:31:32 +0000 @@ -1,3 +1,8 @@ +2013-01-12 Paul Eggert + + Make eabs act more like a function. + * lisp.h (eabs): Evaluate arg just once. + 2013-01-12 Dmitry Antipov * indent.c (Fvertical_motion): Remove now-incorrect GCPROs === modified file 'src/lisp.h' --- src/lisp.h 2013-01-12 05:21:06 +0000 +++ src/lisp.h 2013-01-12 06:31:32 +0000 @@ -3626,11 +3626,21 @@ /* Set up the name of the machine we're running on. */ extern void init_system_name (void); -/* We used to use `abs', but that clashes with system headers on some - platforms, and using a name reserved by Standard C is a bad idea - anyway. */ -#if !defined (eabs) -#define eabs(x) ((x) < 0 ? -(x) : (x)) +/* Return the absolute value of X, without evaluating X more than once. + X should be a signed integer, and X's absolute value should not + exceed the maximum for its promoted type. + + If _Generic or typeof works, speed things up a bit by avoiding the + conversion to intmax_t. The "~" promotes X's type, and checks that + X is an integer. */ +#if HAVE_C__GENERIC +# define eabs(x) \ + (_Generic (~ (x), int: abs, long: labs, long long: llabs, default: imaxabs) \ + (x)) +#elif HAVE_TYPEOF +# define eabs(x) ({ typeof (~ (x)) eabsx = x; eabsx < 0 ? -eabsx : eabsx; }) +#else +# define eabs(x) imaxabs (x) #endif /* Return a fixnum or float, depending on whether VAL fits in a Lisp From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 12 04:11:49 2013 Received: (at 13419) by debbugs.gnu.org; 12 Jan 2013 09:11:49 +0000 Received: from localhost ([127.0.0.1]:56229 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ttx80-0007ht-TW for submit@debbugs.gnu.org; Sat, 12 Jan 2013 04:11:49 -0500 Received: from mtaout20.012.net.il ([80.179.55.166]:54512) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Ttx7y-0007hg-GQ for 13419@debbugs.gnu.org; Sat, 12 Jan 2013 04:11:47 -0500 Received: from conversion-daemon.a-mtaout20.012.net.il by a-mtaout20.012.net.il (HyperSendmail v2007.08) id <0MGI00J009I5BM00@a-mtaout20.012.net.il> for 13419@debbugs.gnu.org; Sat, 12 Jan 2013 11:11:05 +0200 (IST) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout20.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MGI00IS09IHZ180@a-mtaout20.012.net.il>; Sat, 12 Jan 2013 11:11:05 +0200 (IST) Date: Sat, 12 Jan 2013 11:11:28 +0200 From: Eli Zaretskii Subject: Re: bug#13419: make 'eabs' act more like a function In-reply-to: <50F10643.8000408@cs.ucla.edu> X-012-Sender: halo1@inter.net.il To: Paul Eggert Message-id: <83bocuu5of.fsf@gnu.org> References: <50F10643.8000408@cs.ucla.edu> X-Spam-Score: 1.5 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: > Date: Fri, 11 Jan 2013 22:44:19 -0800 > From: Paul Eggert > > The key part of this patch is to lisp.h; most of the rest > is pulled in from gnulib automatically. I'm guessing about > the change to nt/inc/inttypes.h, as I don't use Windows. [...] Content analysis details: (1.5 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [80.179.55.166 listed in list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% [score: 0.4123] X-Debbugs-Envelope-To: 13419 Cc: 13419@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 0.2 (/) > Date: Fri, 11 Jan 2013 22:44:19 -0800 > From: Paul Eggert > > The key part of this patch is to lisp.h; most of the rest > is pulled in from gnulib automatically. I'm guessing about > the change to nt/inc/inttypes.h, as I don't use Windows. Thanks. The change to nt/inc/inttypes.h should be OK for the MS compiler, I think, with one gotcha: > +#define imaxabs labs This should be just "abs". There's no 'labs' in the MS compiler, according to the MS documentation, and 'long' is 32-bit wide, so 'abs' is fine. The _abs64 definition for the 64-bit build is OK, AFAIU. Given these macros, the Windows build doesn't need lib/imaxabs.c, right (since MinGW defines imaxabs in its inttypes.h)? Because if it does, lib/makefile.w32-in needs a suitable change. From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 12 08:25:33 2013 Received: (at 13419) by debbugs.gnu.org; 12 Jan 2013 13:25:33 +0000 Received: from localhost ([127.0.0.1]:56409 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tu15X-0006Lu-TQ for submit@debbugs.gnu.org; Sat, 12 Jan 2013 08:25:33 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:17824) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tu15Q-0006Ld-Oh for 13419@debbugs.gnu.org; Sat, 12 Jan 2013 08:25:28 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtkGAG6Zu09FpZpV/2dsb2JhbABEDoFtshaBCIIVAQEEAVYjBQsLNBIUGA0kiBwFugmQRAOIQppxgViCMFc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="212360118" Received: from 69-165-154-85.dsl.teksavvy.com (HELO pastel.home) ([69.165.154.85]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 12 Jan 2013 08:25:06 -0500 Received: by pastel.home (Postfix, from userid 20848) id 90F10592A5; Sat, 12 Jan 2013 08:25:06 -0500 (EST) From: Stefan Monnier To: Paul Eggert Subject: Re: bug#13419: make 'eabs' act more like a function Message-ID: References: <50F10643.8000408@cs.ucla.edu> Date: Sat, 12 Jan 2013 08:25:06 -0500 In-Reply-To: <50F10643.8000408@cs.ucla.edu> (Paul Eggert's message of "Fri, 11 Jan 2013 22:44:19 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13419 Cc: 13419@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) > This patch doesn't fix any bugs, it's just a code cleanup. [...] > -/* We used to use `abs', but that clashes with system headers on some > - platforms, and using a name reserved by Standard C is a bad idea > - anyway. */ > -#if !defined (eabs) > -#define eabs(x) ((x) < 0 ? -(x) : (x)) > +/* Return the absolute value of X, without evaluating X more than once. > + X should be a signed integer, and X's absolute value should not > + exceed the maximum for its promoted type. > + > + If _Generic or typeof works, speed things up a bit by avoiding the > + conversion to intmax_t. The "~" promotes X's type, and checks that > + X is an integer. */ > +#if HAVE_C__GENERIC > +# define eabs(x) \ > + (_Generic (~ (x), int: abs, long: labs, long long: llabs, default: imaxabs) \ > + (x)) > +#elif HAVE_TYPEOF > +# define eabs(x) ({ typeof (~ (x)) eabsx = x; eabsx < 0 ? -eabsx : eabsx; }) > +#else > +# define eabs(x) imaxabs (x) > #endif Huh? Do you really consider this code cleaner? It's hideous and impenetrable. Not cool! Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 12 18:07:04 2013 Received: (at 13419) by debbugs.gnu.org; 12 Jan 2013 23:07:05 +0000 Received: from localhost ([127.0.0.1]:57361 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuAAK-0004CV-1u for submit@debbugs.gnu.org; Sat, 12 Jan 2013 18:07:04 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:41870) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuAAF-0004Bz-V8 for 13419@debbugs.gnu.org; Sat, 12 Jan 2013 18:07:02 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 345E4A60001; Sat, 12 Jan 2013 15:06:39 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu 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 lAOwiz4FTBiX; Sat, 12 Jan 2013 15:06:38 -0800 (PST) Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 237EE39E8008; Sat, 12 Jan 2013 15:06:38 -0800 (PST) Message-ID: <50F1EC7D.6050609@cs.ucla.edu> Date: Sat, 12 Jan 2013 15:06:37 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Stefan Monnier Subject: Re: bug#13419: make 'eabs' act more like a function References: <50F10643.8000408@cs.ucla.edu> In-Reply-To: Content-Type: multipart/mixed; boundary="------------020309010805080105070404" X-Spam-Score: -4.2 (----) X-Debbugs-Envelope-To: 13419 Cc: 13419@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -4.2 (----) This is a multi-part message in MIME format. --------------020309010805080105070404 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 01/12/2013 05:25 AM, Stefan Monnier wrote: > Do you really consider this code cleaner? The implementation's worse, but the use is nicer, since eabs is guaranteed to evaluate its argument just once. Anyway, here's a simpler implementation that also evaluates its argument just once: would you prefer this? #define eabs(x) imaxabs (x) (This is shorter and simpler than what's in Emacs now.) I've attached a complete patch based on this idea. It incorporates Eli's suggestion to implement imaxabs via abs rather than labs on 32-bit MS-Windows. (The idea is to avoid the need to build imaxabs.o on Windows.) --------------020309010805080105070404 Content-Type: text/plain; charset=UTF-8; name="eabs-imaxabs.txt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="eabs-imaxabs.txt" PT09IG1vZGlmaWVkIGZpbGUgJ0NoYW5nZUxvZycKLS0tIENoYW5nZUxvZwkyMDEzLTAxLTEy IDA1OjIxOjA2ICswMDAwCisrKyBDaGFuZ2VMb2cJMjAxMy0wMS0xMiAyMzowMjowMCArMDAw MApAQCAtMSw1ICsxLDkgQEAKIDIwMTMtMDEtMTIgIFBhdWwgRWdnZXJ0ICA8ZWdnZXJ0QGNz LnVjbGEuZWR1PgogCisJTWFrZSBlYWJzIGFjdCBtb3JlIGxpa2UgYSBmdW5jdGlvbi4KKwkq IGxpYi9pbWF4YWJzLmMsIG00L2ltYXhhYnMubTQ6IE5ldyBmaWxlcywgZnJvbSBnb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yogU2V0IHVwIHRoZSBuYW1lIG9mIHRoZSBtYWNoaW5lIHdlJ3JlIHJ1bm5pbmcgb24uICAq LwogZXh0ZXJuIHZvaWQgaW5pdF9zeXN0ZW1fbmFtZSAodm9pZCk7CiAKLS8qIFdlIHVzZWQg dG8gdXNlIGBhYnMnLCBidXQgdGhhdCBjbGFzaGVzIHdpdGggc3lzdGVtIGhlYWRlcnMgb24g c29tZQotICAgcGxhdGZvcm1zLCBhbmQgdXNpbmcgYSBuYW1lIHJlc2VydmVkIGJ5IFN0YW5k YXJkIEMgaXMgYSBiYWQgaWRlYQotICAgYW55d2F5LiAgKi8KLSNpZiAhZGVmaW5lZCAoZWFi cykKLSNkZWZpbmUgZWFicyh4KSAgICAgICAgICgoeCkgPCAwID8gLSh4KSA6ICh4KSkKLSNl bmRpZgorLyogUmV0dXJuIHRoZSBhYnNvbHV0ZSB2YWx1ZSBvZiBYLCB3aXRob3V0IGV2YWx1 YXRpbmcgWCBtb3JlIHRoYW4gb25jZS4KKyAgIFggc2hvdWxkIGJlIGEgc2lnbmVkIGludGVn ZXIsIGFuZCBYJ3MgYWJzb2x1dGUgdmFsdWUgc2hvdWxkIG5vdAorICAgZXhjZWVkIHRoZSBt YXhpbXVtIGZvciBpdHMgcHJvbW90ZWQgdHlwZS4gICovCisjZGVmaW5lIGVhYnMoeCkgaW1h eGFicyAoeCkKIAogLyogUmV0dXJuIGEgZml4bnVtIG9yIGZsb2F0LCBkZXBlbmRpbmcgb24g d2hldGhlciBWQUwgZml0cyBpbiBhIExpc3AKICAgIGZpeG51bS4gICovCgo= --------------020309010805080105070404-- From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 12 19:27:19 2013 Received: (at 13419) by debbugs.gnu.org; 13 Jan 2013 00:27:19 +0000 Received: from localhost ([127.0.0.1]:57396 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuBPy-00065X-Mk for submit@debbugs.gnu.org; Sat, 12 Jan 2013 19:27:19 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.182]:53866) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuBPw-00065K-DV for 13419@debbugs.gnu.org; Sat, 12 Jan 2013 19:27:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AtkGAG6Zu09FpZpV/2dsb2JhbABEDoFtshaBCIIVAQEEAVYjBQsLNBIUGA0kiBwFugmQRAOIQppxgViCMFc X-IronPort-AV: E=Sophos;i="4.75,637,1330923600"; d="scan'208";a="212392905" Received: from 69-165-154-85.dsl.teksavvy.com (HELO fmsmemgm.homelinux.net) ([69.165.154.85]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 12 Jan 2013 19:26:55 -0500 Received: by fmsmemgm.homelinux.net (Postfix, from userid 20848) id 5D7A7AE0B8; Sat, 12 Jan 2013 19:26:55 -0500 (EST) From: Stefan Monnier To: Paul Eggert Subject: Re: bug#13419: make 'eabs' act more like a function Message-ID: References: <50F10643.8000408@cs.ucla.edu> <50F1EC7D.6050609@cs.ucla.edu> Date: Sat, 12 Jan 2013 19:26:55 -0500 In-Reply-To: <50F1EC7D.6050609@cs.ucla.edu> (Paul Eggert's message of "Sat, 12 Jan 2013 15:06:37 -0800") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.8 (/) X-Debbugs-Envelope-To: 13419 Cc: 13419@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -0.0 (/) >> Do you really consider this code cleaner? > The implementation's worse, but the use is nicer, > since eabs is guaranteed to evaluate its argument just once. I understand this, but I think the price is too high. > Anyway, here's a simpler implementation that also evaluates > its argument just once: would you prefer this? > #define eabs(x) imaxabs (x) But then it's not inlined, right? I think this is trying to fix something that's not broken and C simply does not offer a good enough alternative. Stefan From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 12 20:41:36 2013 Received: (at 13419) by debbugs.gnu.org; 13 Jan 2013 01:41:37 +0000 Received: from localhost ([127.0.0.1]:57416 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuCZs-0007qW-9S for submit@debbugs.gnu.org; Sat, 12 Jan 2013 20:41:36 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:45762) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuCZp-0007qI-L0 for 13419@debbugs.gnu.org; Sat, 12 Jan 2013 20:41:34 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 3F57439E8100; Sat, 12 Jan 2013 17:41:12 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu 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 OvJFhtvZWBYL; Sat, 12 Jan 2013 17:41:12 -0800 (PST) Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id E3BE039E8008; Sat, 12 Jan 2013 17:41:11 -0800 (PST) Message-ID: <50F210B7.80708@cs.ucla.edu> Date: Sat, 12 Jan 2013 17:41:11 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: Stefan Monnier Subject: Re: bug#13419: make 'eabs' act more like a function References: <50F10643.8000408@cs.ucla.edu> <50F1EC7D.6050609@cs.ucla.edu> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 13419 Cc: 13419@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) On 01/12/2013 04:26 PM, Stefan Monnier wrote: >> #define eabs(x) imaxabs (x) > But then it's not inlined, right? No, it's inlined, if the compiler's any good. GCC inlines it, for example. So it is a cleaner and efficient replacement for what Emacs has now. From debbugs-submit-bounces@debbugs.gnu.org Sat Jan 19 17:37:06 2013 Received: (at 13419-done) by debbugs.gnu.org; 19 Jan 2013 22:37:06 +0000 Received: from localhost ([127.0.0.1]:40684 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Twh2A-0002yi-3N for submit@debbugs.gnu.org; Sat, 19 Jan 2013 17:37:06 -0500 Received: from smtp.cs.ucla.edu ([131.179.128.62]:34095) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Twh28-0002yb-Aj for 13419-done@debbugs.gnu.org; Sat, 19 Jan 2013 17:37:04 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id 907B339E810A for <13419-done@debbugs.gnu.org>; Sat, 19 Jan 2013 14:36:09 -0800 (PST) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu 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 E6hkdV+d1Eea for <13419-done@debbugs.gnu.org>; Sat, 19 Jan 2013 14:36:09 -0800 (PST) Received: from [192.168.1.9] (pool-71-189-154-249.lsanca.fios.verizon.net [71.189.154.249]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 4973539E8106 for <13419-done@debbugs.gnu.org>; Sat, 19 Jan 2013 14:36:09 -0800 (PST) Message-ID: <50FB1FD9.4070402@cs.ucla.edu> Date: Sat, 19 Jan 2013 14:36:09 -0800 From: Paul Eggert Organization: UCLA Computer Science Department User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130106 Thunderbird/17.0.2 MIME-Version: 1.0 To: 13419-done@debbugs.gnu.org Subject: Re: bug#13419: make 'eabs' act more like a function References: <50F10643.8000408@cs.ucla.edu> <50F1EC7D.6050609@cs.ucla.edu> <50F210B7.80708@cs.ucla.edu> In-Reply-To: <50F210B7.80708@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Score: -1.5 (-) X-Debbugs-Envelope-To: 13419-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.3 (--) No further comment, and as this was a low-priority refactoring that doesn't have consensus I am marking this bug as done without installing the patch. I did patch the comment that describes 'eabs', and removed an unnecessary "#if", as trunk bzr 111566. From unknown Thu Sep 11 16:39:30 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sun, 17 Feb 2013 12:24:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator