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: _setjmp woes in image.c Date: Mon, 13 Jan 2014 22:43:22 +0200 Message-ID: <83ob3f62ad.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: plane.gmane.org X-Trace: ger.gmane.org 1389645826 27521 80.91.229.3 (13 Jan 2014 20:43:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 13 Jan 2014 20:43:46 +0000 (UTC) Cc: emacs-devel@gnu.org To: Paul Eggert Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jan 13 21:43:52 2014 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 1W2oMS-00083Q-Dw for ged-emacs-devel@m.gmane.org; Mon, 13 Jan 2014 21:43:52 +0100 Original-Received: from localhost ([::1]:44953 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2oMS-0002bL-39 for ged-emacs-devel@m.gmane.org; Mon, 13 Jan 2014 15:43:52 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:35256) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2oMI-0002b5-Bj for emacs-devel@gnu.org; Mon, 13 Jan 2014 15:43:49 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W2oMB-0001rv-2V for emacs-devel@gnu.org; Mon, 13 Jan 2014 15:43:42 -0500 Original-Received: from mtaout21.012.net.il ([80.179.55.169]:46602) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W2oMA-0001rG-QF for emacs-devel@gnu.org; Mon, 13 Jan 2014 15:43:34 -0500 Original-Received: from conversion-daemon.a-mtaout21.012.net.il by a-mtaout21.012.net.il (HyperSendmail v2007.08) id <0MZC00900X3F2J00@a-mtaout21.012.net.il> for emacs-devel@gnu.org; Mon, 13 Jan 2014 22:43:32 +0200 (IST) Original-Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout21.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MZC008JNXKKZ430@a-mtaout21.012.net.il>; Mon, 13 Jan 2014 22:43:32 +0200 (IST) X-012-Sender: halo1@inter.net.il X-detected-operating-system: by eggs.gnu.org: Solaris 10 X-Received-From: 80.179.55.169 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:168315 Archived-At: This trick: /* Possibly inefficient/inexact substitutes for _setjmp and _longjmp. Do not use sys_setjmp, as PNG supports only jmp_buf. The _longjmp substitute may munge the signal mask, but that should be OK here. MinGW (MS-Windows) uses _setjmp and defines setjmp to _setjmp in the system header setjmp.h; don't mess up that. */ #ifndef HAVE__SETJMP # define _setjmp(j) setjmp (j) # define _longjmp longjmp #endif causes compilation failures with MinGW64. That's because its _setjmp accepts 2 arguments, not one, and its setjmp.h system header does this: #define setjmp(BUF) _setjmp((BUF), __builtin_frame_address (0)) Because _setjmp accepts 2 arguments, the configure test for _setjmp fails, and HAVE__SETJMP is not defined. Then the above snippet in image.c defines a _macro_ _setjmp which accepts 1 argument, and that causes compilation errors when compiling this part: if (sys_setjmp (mgr->setjmp_buffer)) because sys_setjmp expands to setjmp, which expands to a call to _setjmp with 2 arguments. So I want to propose the fix below. Can it cause trouble to other platforms? Is there a better fix? === modified file 'src/image.c' --- src/image.c 2014-01-07 21:14:32 +0000 +++ src/image.c 2014-01-13 17:55:27 +0000 @@ -5613,8 +5613,10 @@ init_png_functions (void) substitute may munge the signal mask, but that should be OK here. MinGW (MS-Windows) uses _setjmp and defines setjmp to _setjmp in the system header setjmp.h; don't mess up that. */ -#ifndef HAVE__SETJMP -# define _setjmp(j) setjmp (j) +#ifdef HAVE__SETJMP +# define SETJMP(j) _setjmp (j) +#else /* !HAVE__SETJMP */ +# define SETJMP(j) setjmp (j) # define _longjmp longjmp #endif @@ -5810,7 +5812,7 @@ png_load_body (struct frame *f, struct i /* Set error jump-back. We come back here when the PNG library detects an error. */ - if (_setjmp (PNG_JMPBUF (png_ptr))) + if (SETJMP (PNG_JMPBUF (png_ptr))) { error: if (c->png_ptr)