all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Paul Eggert <eggert@cs.ucla.edu>
Cc: emacs-devel@gnu.org
Subject: _setjmp woes in image.c
Date: Mon, 13 Jan 2014 22:43:22 +0200	[thread overview]
Message-ID: <83ob3f62ad.fsf@gnu.org> (raw)

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)




             reply	other threads:[~2014-01-13 20:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13 20:43 Eli Zaretskii [this message]
2014-01-14  1:22 ` _setjmp woes in image.c Paul Eggert
2014-01-14 16:09   ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83ob3f62ad.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=eggert@cs.ucla.edu \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.