* _setjmp woes in image.c
@ 2014-01-13 20:43 Eli Zaretskii
2014-01-14 1:22 ` Paul Eggert
0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2014-01-13 20:43 UTC (permalink / raw)
To: Paul Eggert; +Cc: emacs-devel
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)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-01-14 16:09 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-01-13 20:43 _setjmp woes in image.c Eli Zaretskii
2014-01-14 1:22 ` Paul Eggert
2014-01-14 16:09 ` Eli Zaretskii
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.