aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorJoakim Verona2012-09-10 16:03:53 +0200
committerJoakim Verona2012-09-10 16:03:53 +0200
commitb035a30e5cd2f34fedc04c253eeb5a11afed8145 (patch)
treeb9350cce389602f4967bdc1beed745929155ad5d /src/data.c
parent4a37733c693d59a9b83a3fb2d0c7f9461d149f60 (diff)
parenta31a4cdacb196cc96dcb9bd229edb1d635e01344 (diff)
downloademacs-b035a30e5cd2f34fedc04c253eeb5a11afed8145.tar.gz
emacs-b035a30e5cd2f34fedc04c253eeb5a11afed8145.zip
upstream
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c97
1 files changed, 36 insertions, 61 deletions
diff --git a/src/data.c b/src/data.c
index d8b7f42ea3f..a4cca0a3ee5 100644
--- a/src/data.c
+++ b/src/data.c
@@ -19,7 +19,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
19 19
20 20
21#include <config.h> 21#include <config.h>
22#include <signal.h>
23#include <stdio.h> 22#include <stdio.h>
24#include <setjmp.h> 23#include <setjmp.h>
25 24
@@ -37,17 +36,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#include "keymap.h" 36#include "keymap.h"
38 37
39#include <float.h> 38#include <float.h>
40/* If IEEE_FLOATING_POINT isn't defined, default it from FLT_*. */
41#ifndef IEEE_FLOATING_POINT
42#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \ 39#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
43 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) 40 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
44#define IEEE_FLOATING_POINT 1 41#define IEEE_FLOATING_POINT 1
45#else 42#else
46#define IEEE_FLOATING_POINT 0 43#define IEEE_FLOATING_POINT 0
47#endif 44#endif
48#endif
49
50#include <math.h>
51 45
52Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; 46Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
53static Lisp_Object Qsubr; 47static Lisp_Object Qsubr;
@@ -108,7 +102,7 @@ wrong_type_argument (register Lisp_Object predicate, register Lisp_Object value)
108 to try and do that by checking the tagbits, but nowadays all 102 to try and do that by checking the tagbits, but nowadays all
109 tagbits are potentially valid. */ 103 tagbits are potentially valid. */
110 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit) 104 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit)
111 * abort (); */ 105 * emacs_abort (); */
112 106
113 xsignal2 (Qwrong_type_argument, predicate, value); 107 xsignal2 (Qwrong_type_argument, predicate, value);
114} 108}
@@ -182,7 +176,7 @@ for example, (type-of 1) returns `integer'. */)
182 case Lisp_Misc_Float: 176 case Lisp_Misc_Float:
183 return Qfloat; 177 return Qfloat;
184 } 178 }
185 abort (); 179 emacs_abort ();
186 180
187 case Lisp_Vectorlike: 181 case Lisp_Vectorlike:
188 if (WINDOW_CONFIGURATIONP (object)) 182 if (WINDOW_CONFIGURATIONP (object))
@@ -217,7 +211,7 @@ for example, (type-of 1) returns `integer'. */)
217 return Qfloat; 211 return Qfloat;
218 212
219 default: 213 default:
220 abort (); 214 emacs_abort ();
221 } 215 }
222} 216}
223 217
@@ -551,7 +545,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
551 /* In set_internal, we un-forward vars when their value is 545 /* In set_internal, we un-forward vars when their value is
552 set to Qunbound. */ 546 set to Qunbound. */
553 return Qt; 547 return Qt;
554 default: abort (); 548 default: emacs_abort ();
555 } 549 }
556 550
557 return (EQ (valcontents, Qunbound) ? Qnil : Qt); 551 return (EQ (valcontents, Qunbound) ? Qnil : Qt);
@@ -864,7 +858,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents)
864 don't think anything will break. --lorentey */ 858 don't think anything will break. --lorentey */
865 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset 859 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
866 + (char *)FRAME_KBOARD (SELECTED_FRAME ())); 860 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
867 default: abort (); 861 default: emacs_abort ();
868 } 862 }
869} 863}
870 864
@@ -950,7 +944,7 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
950 break; 944 break;
951 945
952 default: 946 default:
953 abort (); /* goto def; */ 947 emacs_abort (); /* goto def; */
954 } 948 }
955} 949}
956 950
@@ -1055,7 +1049,7 @@ find_symbol_value (Lisp_Object symbol)
1055 /* FALLTHROUGH */ 1049 /* FALLTHROUGH */
1056 case SYMBOL_FORWARDED: 1050 case SYMBOL_FORWARDED:
1057 return do_symval_forwarding (SYMBOL_FWD (sym)); 1051 return do_symval_forwarding (SYMBOL_FWD (sym));
1058 default: abort (); 1052 default: emacs_abort ();
1059 } 1053 }
1060} 1054}
1061 1055
@@ -1265,7 +1259,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1265 store_symval_forwarding (/* sym, */ innercontents, newval, buf); 1259 store_symval_forwarding (/* sym, */ innercontents, newval, buf);
1266 break; 1260 break;
1267 } 1261 }
1268 default: abort (); 1262 default: emacs_abort ();
1269 } 1263 }
1270 return; 1264 return;
1271} 1265}
@@ -1316,7 +1310,7 @@ default_value (Lisp_Object symbol)
1316 /* For other variables, get the current value. */ 1310 /* For other variables, get the current value. */
1317 return do_symval_forwarding (valcontents); 1311 return do_symval_forwarding (valcontents);
1318 } 1312 }
1319 default: abort (); 1313 default: emacs_abort ();
1320 } 1314 }
1321} 1315}
1322 1316
@@ -1414,7 +1408,7 @@ for this variable. */)
1414 else 1408 else
1415 return Fset (symbol, value); 1409 return Fset (symbol, value);
1416 } 1410 }
1417 default: abort (); 1411 default: emacs_abort ();
1418 } 1412 }
1419} 1413}
1420 1414
@@ -1538,7 +1532,7 @@ The function `default-value' gets the default value and `set-default' sets it.
1538 else if (BUFFER_OBJFWDP (valcontents.fwd)) 1532 else if (BUFFER_OBJFWDP (valcontents.fwd))
1539 return variable; 1533 return variable;
1540 break; 1534 break;
1541 default: abort (); 1535 default: emacs_abort ();
1542 } 1536 }
1543 1537
1544 if (sym->constant) 1538 if (sym->constant)
@@ -1611,7 +1605,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1611 error ("Symbol %s may not be buffer-local", 1605 error ("Symbol %s may not be buffer-local",
1612 SDATA (SYMBOL_NAME (variable))); 1606 SDATA (SYMBOL_NAME (variable)));
1613 break; 1607 break;
1614 default: abort (); 1608 default: emacs_abort ();
1615 } 1609 }
1616 1610
1617 if (sym->constant) 1611 if (sym->constant)
@@ -1718,7 +1712,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
1718 if (blv->frame_local) 1712 if (blv->frame_local)
1719 return variable; 1713 return variable;
1720 break; 1714 break;
1721 default: abort (); 1715 default: emacs_abort ();
1722 } 1716 }
1723 1717
1724 /* Get rid of this buffer's alist element, if any. */ 1718 /* Get rid of this buffer's alist element, if any. */
@@ -1800,7 +1794,7 @@ frame-local bindings). */)
1800 error ("Symbol %s may not be frame-local", 1794 error ("Symbol %s may not be frame-local",
1801 SDATA (SYMBOL_NAME (variable))); 1795 SDATA (SYMBOL_NAME (variable)));
1802 break; 1796 break;
1803 default: abort (); 1797 default: emacs_abort ();
1804 } 1798 }
1805 1799
1806 if (sym->constant) 1800 if (sym->constant)
@@ -1877,18 +1871,18 @@ BUFFER defaults to the current buffer. */)
1877 } 1871 }
1878 return Qnil; 1872 return Qnil;
1879 } 1873 }
1880 default: abort (); 1874 default: emacs_abort ();
1881 } 1875 }
1882} 1876}
1883 1877
1884DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p, 1878DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p,
1885 1, 2, 0, 1879 1, 2, 0,
1886 doc: /* Non-nil if VARIABLE will be local in buffer BUFFER when set there. 1880 doc: /* Non-nil if VARIABLE is local in buffer BUFFER when set there.
1887More precisely, this means that setting the variable \(with `set' or`setq'), 1881BUFFER defaults to the current buffer.
1888while it does not have a `let'-style binding that was made in BUFFER, 1882
1889will produce a buffer local binding. See Info node 1883More precisely, return non-nil if either VARIABLE already has a local
1890`(elisp)Creating Buffer-Local'. 1884value in BUFFER, or if VARIABLE is automatically buffer-local (see
1891BUFFER defaults to the current buffer. */) 1885`make-variable-buffer-local'). */)
1892 (register Lisp_Object variable, Lisp_Object buffer) 1886 (register Lisp_Object variable, Lisp_Object buffer)
1893{ 1887{
1894 struct Lisp_Symbol *sym; 1888 struct Lisp_Symbol *sym;
@@ -1912,7 +1906,7 @@ BUFFER defaults to the current buffer. */)
1912 case SYMBOL_FORWARDED: 1906 case SYMBOL_FORWARDED:
1913 /* All BUFFER_OBJFWD slots become local if they are set. */ 1907 /* All BUFFER_OBJFWD slots become local if they are set. */
1914 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil); 1908 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil);
1915 default: abort (); 1909 default: emacs_abort ();
1916 } 1910 }
1917} 1911}
1918 1912
@@ -1956,7 +1950,7 @@ If the current binding is global (the default), the value is nil. */)
1956 return SYMBOL_BLV (sym)->where; 1950 return SYMBOL_BLV (sym)->where;
1957 else 1951 else
1958 return Qnil; 1952 return Qnil;
1959 default: abort (); 1953 default: emacs_abort ();
1960 } 1954 }
1961} 1955}
1962 1956
@@ -2272,7 +2266,7 @@ arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison)
2272 return Qnil; 2266 return Qnil;
2273 2267
2274 default: 2268 default:
2275 abort (); 2269 emacs_abort ();
2276 } 2270 }
2277} 2271}
2278 2272
@@ -2738,28 +2732,6 @@ Both must be integers or markers. */)
2738 return val; 2732 return val;
2739} 2733}
2740 2734
2741#ifndef HAVE_FMOD
2742double
2743fmod (double f1, double f2)
2744{
2745 double r = f1;
2746
2747 if (f2 < 0.0)
2748 f2 = -f2;
2749
2750 /* If the magnitude of the result exceeds that of the divisor, or
2751 the sign of the result does not agree with that of the dividend,
2752 iterate with the reduced value. This does not yield a
2753 particularly accurate result, but at least it will be in the
2754 range promised by fmod. */
2755 do
2756 r -= f2 * floor (r / f2);
2757 while (f2 <= (r < 0 ? -r : r) || ((r < 0) != (f1 < 0) && ! isnan (r)));
2758
2759 return r;
2760}
2761#endif /* ! HAVE_FMOD */
2762
2763DEFUN ("mod", Fmod, Smod, 2, 2, 0, 2735DEFUN ("mod", Fmod, Smod, 2, 2, 0,
2764 doc: /* Return X modulo Y. 2736 doc: /* Return X modulo Y.
2765The result falls between zero (inclusive) and Y (exclusive). 2737The result falls between zero (inclusive) and Y (exclusive).
@@ -3207,21 +3179,23 @@ syms_of_data (void)
3207 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; 3179 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1;
3208} 3180}
3209 3181
3210#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD 3182static _Noreturn void
3211_Noreturn 3183handle_arith_signal (int sig)
3212#endif
3213static void
3214arith_error (int signo)
3215{ 3184{
3216 sigsetmask (SIGEMPTYMASK); 3185 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3217
3218 SIGNAL_THREAD_CHECK (signo);
3219 xsignal0 (Qarith_error); 3186 xsignal0 (Qarith_error);
3220} 3187}
3221 3188
3189static void
3190deliver_arith_signal (int sig)
3191{
3192 handle_on_main_thread (sig, handle_arith_signal);
3193}
3194
3222void 3195void
3223init_data (void) 3196init_data (void)
3224{ 3197{
3198 struct sigaction action;
3225 /* Don't do this if just dumping out. 3199 /* Don't do this if just dumping out.
3226 We don't want to call `signal' in this case 3200 We don't want to call `signal' in this case
3227 so that we don't have trouble with dumping 3201 so that we don't have trouble with dumping
@@ -3230,5 +3204,6 @@ init_data (void)
3230 if (!initialized) 3204 if (!initialized)
3231 return; 3205 return;
3232#endif /* CANNOT_DUMP */ 3206#endif /* CANNOT_DUMP */
3233 signal (SIGFPE, arith_error); 3207 emacs_sigaction_init (&action, deliver_arith_signal);
3208 sigaction (SIGFPE, &action, 0);
3234} 3209}