aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorPaul Eggert2012-09-15 00:06:56 -0700
committerPaul Eggert2012-09-15 00:06:56 -0700
commit0328b6de4a92676b4ad4616095ce19a4f51d1c4d (patch)
treefba6da827e1383b3ff6ee4b738d2ac74a5956dde /src/alloc.c
parent823751606a90e3850551b43e707d58bbf58033dc (diff)
downloademacs-0328b6de4a92676b4ad4616095ce19a4f51d1c4d.tar.gz
emacs-0328b6de4a92676b4ad4616095ce19a4f51d1c4d.zip
Port better to POSIX hosts lacking _setjmp.
* configure.ac (HAVE__SETJMP, HAVE_SIGSETJMP): New symbols. (_setjmp, _longjmp): Remove. * src/lisp.h: Include <setjmp.h> here, since we use its symbols here. All instances of '#include <setjmp.h>' removed, if the only reason for the instance was because "lisp.h" was included. (sys_jmp_buf, sys_setjmp, sys_longjmp): New symbols. Unless otherwise specified, replace all uses of jmp_buf, _setjmp, and _longjmp with the new symbols. Emacs already uses _setjmp if available, so this change affects only POSIXish hosts that have sigsetjmp but not _setjmp, such as some versions of Solaris and Unixware. (Also, POSIX-2008 marks _setjmp as obsolescent.) * src/image.c (_setjmp, _longjmp) [HAVE_PNG && !HAVE__SETJMP]: New macros. (png_load_body) [HAVE_PNG]: (PNG_LONGJMP) [HAVE_PNG && PNG_LIBPNG_VER < 10500]: (PNG_JMPBUF) [HAVE_PNG && PNG_LIBPNG_VER >= 10500]: Use _setjmp and _longjmp rather than sys_setjmp and sys_longjmp, since PNG requires jmp_buf. This is the only exception to the general rule that we now use sys_setjmp and sys_longjmp. This exception is OK since this code does not change the signal mask or longjmp out of a signal handler. Fixes: debbugs:12446
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 25cf03dfa2e..0bfbb0c88b1 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -24,7 +24,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
24 24
25#include <stdio.h> 25#include <stdio.h>
26#include <limits.h> /* For CHAR_BIT. */ 26#include <limits.h> /* For CHAR_BIT. */
27#include <setjmp.h>
28 27
29#ifdef ENABLE_CHECKING 28#ifdef ENABLE_CHECKING
30#include <signal.h> /* For SIGABRT. */ 29#include <signal.h> /* For SIGABRT. */
@@ -45,7 +44,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
45#include "frame.h" 44#include "frame.h"
46#include "blockinput.h" 45#include "blockinput.h"
47#include "termhooks.h" /* For struct terminal. */ 46#include "termhooks.h" /* For struct terminal. */
48#include <setjmp.h> 47
49#include <verify.h> 48#include <verify.h>
50 49
51/* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects. 50/* GC_CHECK_MARKED_OBJECTS means do sanity checks on allocated objects.
@@ -4764,14 +4763,14 @@ test_setjmp (void)
4764{ 4763{
4765 char buf[10]; 4764 char buf[10];
4766 register int x; 4765 register int x;
4767 jmp_buf jbuf; 4766 sys_jmp_buf jbuf;
4768 4767
4769 /* Arrange for X to be put in a register. */ 4768 /* Arrange for X to be put in a register. */
4770 sprintf (buf, "1"); 4769 sprintf (buf, "1");
4771 x = strlen (buf); 4770 x = strlen (buf);
4772 x = 2 * x - 1; 4771 x = 2 * x - 1;
4773 4772
4774 _setjmp (jbuf); 4773 sys_setjmp (jbuf);
4775 if (longjmps_done == 1) 4774 if (longjmps_done == 1)
4776 { 4775 {
4777 /* Came here after the longjmp at the end of the function. 4776 /* Came here after the longjmp at the end of the function.
@@ -4796,7 +4795,7 @@ test_setjmp (void)
4796 ++longjmps_done; 4795 ++longjmps_done;
4797 x = 2; 4796 x = 2;
4798 if (longjmps_done == 1) 4797 if (longjmps_done == 1)
4799 _longjmp (jbuf, 1); 4798 sys_longjmp (jbuf, 1);
4800} 4799}
4801 4800
4802#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ 4801#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */
@@ -4902,7 +4901,7 @@ mark_stack (void)
4902 /* jmp_buf may not be aligned enough on darwin-ppc64 */ 4901 /* jmp_buf may not be aligned enough on darwin-ppc64 */
4903 union aligned_jmpbuf { 4902 union aligned_jmpbuf {
4904 Lisp_Object o; 4903 Lisp_Object o;
4905 jmp_buf j; 4904 sys_jmp_buf j;
4906 } j; 4905 } j;
4907 volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base; 4906 volatile bool stack_grows_down_p = (char *) &j > (char *) stack_base;
4908#endif 4907#endif
@@ -4938,7 +4937,7 @@ mark_stack (void)
4938 } 4937 }
4939#endif /* GC_SETJMP_WORKS */ 4938#endif /* GC_SETJMP_WORKS */
4940 4939
4941 _setjmp (j.j); 4940 sys_setjmp (j.j);
4942 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; 4941 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j;
4943#endif /* not GC_SAVE_REGISTERS_ON_STACK */ 4942#endif /* not GC_SAVE_REGISTERS_ON_STACK */
4944#endif /* not HAVE___BUILTIN_UNWIND_INIT */ 4943#endif /* not HAVE___BUILTIN_UNWIND_INIT */