aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2012-09-03 23:34:19 -0700
committerPaul Eggert2012-09-03 23:34:19 -0700
commitaf26b72c1187a93cdacc6abb6561f3c331346cef (patch)
tree12dd2afed044c50078a831bf3aaaa981d79586b8 /src
parent7b6c362efe6e32b6a3a68f6f827c9cc558a2fcf0 (diff)
downloademacs-af26b72c1187a93cdacc6abb6561f3c331346cef.tar.gz
emacs-af26b72c1187a93cdacc6abb6561f3c331346cef.zip
Be more systematic about _setjmp vs setjmp.
* alloc.c (test_setjmp, mark_stack): * image.c (PNG_LONGJMP) [PNG_LIBPNG_VER < 10500]: (PNG_JMPBUF) [! (PNG_LIBPNG_VER < 10500)]: (png_load, my_error_exit, jpeg_load): * process.c (send_process_trap, send_process): Uniformly prefer _setjmp and _longjmp to setjmp and longjmp. The underscored versions are up to 30x faster on some hosts. Formerly, the code used setjmp+longjmp sometimes and _setjmp+_longjmp at other times, with no particular reason to prefer setjmp+longjmp.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog14
-rw-r--r--src/alloc.c6
-rw-r--r--src/image.c14
-rw-r--r--src/process.c4
4 files changed, 26 insertions, 12 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 17dec525156..a8d6a4026a0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,17 @@
12012-09-04 Paul Eggert <eggert@cs.ucla.edu>
2
3 Be more systematic about _setjmp vs setjmp.
4 * alloc.c (test_setjmp, mark_stack):
5 * image.c (PNG_LONGJMP) [PNG_LIBPNG_VER < 10500]:
6 (PNG_JMPBUF) [! (PNG_LIBPNG_VER < 10500)]:
7 (png_load, my_error_exit, jpeg_load):
8 * process.c (send_process_trap, send_process):
9 Uniformly prefer _setjmp and _longjmp to setjmp and longjmp.
10 The underscored versions are up to 30x faster on some hosts.
11 Formerly, the code used setjmp+longjmp sometimes and
12 _setjmp+_longjmp at other times, with no particular reason to
13 prefer setjmp+longjmp.
14
12012-09-03 Paul Eggert <eggert@cs.ucla.edu> 152012-09-03 Paul Eggert <eggert@cs.ucla.edu>
2 16
3 Fix minor problem found by static checking. 17 Fix minor problem found by static checking.
diff --git a/src/alloc.c b/src/alloc.c
index 188a514376d..edecd51f1ac 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -4764,7 +4764,7 @@ test_setjmp (void)
4764 x = strlen (buf); 4764 x = strlen (buf);
4765 x = 2 * x - 1; 4765 x = 2 * x - 1;
4766 4766
4767 setjmp (jbuf); 4767 _setjmp (jbuf);
4768 if (longjmps_done == 1) 4768 if (longjmps_done == 1)
4769 { 4769 {
4770 /* Came here after the longjmp at the end of the function. 4770 /* Came here after the longjmp at the end of the function.
@@ -4789,7 +4789,7 @@ test_setjmp (void)
4789 ++longjmps_done; 4789 ++longjmps_done;
4790 x = 2; 4790 x = 2;
4791 if (longjmps_done == 1) 4791 if (longjmps_done == 1)
4792 longjmp (jbuf, 1); 4792 _longjmp (jbuf, 1);
4793} 4793}
4794 4794
4795#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */ 4795#endif /* not GC_SAVE_REGISTERS_ON_STACK && not GC_SETJMP_WORKS */
@@ -4931,7 +4931,7 @@ mark_stack (void)
4931 } 4931 }
4932#endif /* GC_SETJMP_WORKS */ 4932#endif /* GC_SETJMP_WORKS */
4933 4933
4934 setjmp (j.j); 4934 _setjmp (j.j);
4935 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j; 4935 end = stack_grows_down_p ? (char *) &j + sizeof j : (char *) &j;
4936#endif /* not GC_SAVE_REGISTERS_ON_STACK */ 4936#endif /* not GC_SAVE_REGISTERS_ON_STACK */
4937#endif /* not HAVE___BUILTIN_UNWIND_INIT */ 4937#endif /* not HAVE___BUILTIN_UNWIND_INIT */
diff --git a/src/image.c b/src/image.c
index a067dae7737..3e021677e09 100644
--- a/src/image.c
+++ b/src/image.c
@@ -5517,13 +5517,13 @@ init_png_functions (Lisp_Object libraries)
5517 5517
5518 5518
5519#if (PNG_LIBPNG_VER < 10500) 5519#if (PNG_LIBPNG_VER < 10500)
5520#define PNG_LONGJMP(ptr) (longjmp ((ptr)->jmpbuf, 1)) 5520#define PNG_LONGJMP(ptr) (_longjmp ((ptr)->jmpbuf, 1))
5521#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf) 5521#define PNG_JMPBUF(ptr) ((ptr)->jmpbuf)
5522#else 5522#else
5523/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */ 5523/* In libpng version 1.5, the jmpbuf member is hidden. (Bug#7908) */
5524#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1)) 5524#define PNG_LONGJMP(ptr) (fn_png_longjmp ((ptr), 1))
5525#define PNG_JMPBUF(ptr) \ 5525#define PNG_JMPBUF(ptr) \
5526 (*fn_png_set_longjmp_fn ((ptr), longjmp, sizeof (jmp_buf))) 5526 (*fn_png_set_longjmp_fn ((ptr), _longjmp, sizeof (jmp_buf)))
5527#endif 5527#endif
5528 5528
5529/* Error and warning handlers installed when the PNG library 5529/* Error and warning handlers installed when the PNG library
@@ -5696,7 +5696,7 @@ png_load (struct frame *f, struct image *img)
5696 5696
5697 /* Set error jump-back. We come back here when the PNG library 5697 /* Set error jump-back. We come back here when the PNG library
5698 detects an error. */ 5698 detects an error. */
5699 if (setjmp (PNG_JMPBUF (png_ptr))) 5699 if (_setjmp (PNG_JMPBUF (png_ptr)))
5700 { 5700 {
5701 error: 5701 error:
5702 if (png_ptr) 5702 if (png_ptr)
@@ -6114,7 +6114,7 @@ static _Noreturn void
6114my_error_exit (j_common_ptr cinfo) 6114my_error_exit (j_common_ptr cinfo)
6115{ 6115{
6116 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err; 6116 struct my_jpeg_error_mgr *mgr = (struct my_jpeg_error_mgr *) cinfo->err;
6117 longjmp (mgr->setjmp_buffer, 1); 6117 _longjmp (mgr->setjmp_buffer, 1);
6118} 6118}
6119 6119
6120 6120
@@ -6365,7 +6365,7 @@ jpeg_load (struct frame *f, struct image *img)
6365 cinfo.err = fn_jpeg_std_error (&mgr.pub); 6365 cinfo.err = fn_jpeg_std_error (&mgr.pub);
6366 mgr.pub.error_exit = my_error_exit; 6366 mgr.pub.error_exit = my_error_exit;
6367 6367
6368 if ((rc = setjmp (mgr.setjmp_buffer)) != 0) 6368 if ((rc = _setjmp (mgr.setjmp_buffer)) != 0)
6369 { 6369 {
6370 if (rc == 1) 6370 if (rc == 1)
6371 { 6371 {
@@ -6411,12 +6411,12 @@ jpeg_load (struct frame *f, struct image *img)
6411 if (!check_image_size (f, width, height)) 6411 if (!check_image_size (f, width, height))
6412 { 6412 {
6413 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil); 6413 image_error ("Invalid image size (see `max-image-size')", Qnil, Qnil);
6414 longjmp (mgr.setjmp_buffer, 2); 6414 _longjmp (mgr.setjmp_buffer, 2);
6415 } 6415 }
6416 6416
6417 /* Create X image and pixmap. */ 6417 /* Create X image and pixmap. */
6418 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap)) 6418 if (!x_create_x_image_and_pixmap (f, width, height, 0, &ximg, &img->pixmap))
6419 longjmp (mgr.setjmp_buffer, 2); 6419 _longjmp (mgr.setjmp_buffer, 2);
6420 6420
6421 /* Allocate colors. When color quantization is used, 6421 /* Allocate colors. When color quantization is used,
6422 cinfo.actual_number_of_colors has been set with the number of 6422 cinfo.actual_number_of_colors has been set with the number of
diff --git a/src/process.c b/src/process.c
index 04b6abe50a7..2d144b410ed 100644
--- a/src/process.c
+++ b/src/process.c
@@ -5431,7 +5431,7 @@ send_process_trap (int ignore)
5431{ 5431{
5432 SIGNAL_THREAD_CHECK (SIGPIPE); 5432 SIGNAL_THREAD_CHECK (SIGPIPE);
5433 sigunblock (sigmask (SIGPIPE)); 5433 sigunblock (sigmask (SIGPIPE));
5434 longjmp (send_process_frame, 1); 5434 _longjmp (send_process_frame, 1);
5435} 5435}
5436 5436
5437/* In send_process, when a write fails temporarily, 5437/* In send_process, when a write fails temporarily,
@@ -5634,7 +5634,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5634 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2, 5634 /* 2000-09-21: Emacs 20.7, sparc-sun-solaris-2.6, GCC 2.95.2,
5635 CFLAGS="-g -O": The value of the parameter `proc' is clobbered 5635 CFLAGS="-g -O": The value of the parameter `proc' is clobbered
5636 when returning with longjmp despite being declared volatile. */ 5636 when returning with longjmp despite being declared volatile. */
5637 if (!setjmp (send_process_frame)) 5637 if (!_setjmp (send_process_frame))
5638 { 5638 {
5639 p = XPROCESS (proc); /* Repair any setjmp clobbering. */ 5639 p = XPROCESS (proc); /* Repair any setjmp clobbering. */
5640 process_sent_to = proc; 5640 process_sent_to = proc;