aboutsummaryrefslogtreecommitdiffstats
path: root/src/data.c
diff options
context:
space:
mode:
authorDaniel Colascione2012-09-17 04:07:36 -0800
committerDaniel Colascione2012-09-17 04:07:36 -0800
commit2ab329f3b5d52a39f0a45c3d9c129f1c19560142 (patch)
tree6dd6784d63e54cb18071df8e28fbdbc27d418728 /src/data.c
parentf701ab72dd55460d23c8b029550aa4d7ecef3cfa (diff)
parentbb7dce392f6d9d5fc4b9d7de09ff920a52f07669 (diff)
downloademacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.tar.gz
emacs-2ab329f3b5d52a39f0a45c3d9c129f1c19560142.zip
Merge from trunk
Diffstat (limited to 'src/data.c')
-rw-r--r--src/data.c112
1 files changed, 44 insertions, 68 deletions
diff --git a/src/data.c b/src/data.c
index d8b7f42ea3f..72d7c8ccf9a 100644
--- a/src/data.c
+++ b/src/data.c
@@ -19,9 +19,7 @@ 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>
25 23
26#include <intprops.h> 24#include <intprops.h>
27 25
@@ -37,17 +35,12 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
37#include "keymap.h" 35#include "keymap.h"
38 36
39#include <float.h> 37#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 \ 38#if (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
43 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128) 39 && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
44#define IEEE_FLOATING_POINT 1 40#define IEEE_FLOATING_POINT 1
45#else 41#else
46#define IEEE_FLOATING_POINT 0 42#define IEEE_FLOATING_POINT 0
47#endif 43#endif
48#endif
49
50#include <math.h>
51 44
52Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound; 45Lisp_Object Qnil, Qt, Qquote, Qlambda, Qunbound;
53static Lisp_Object Qsubr; 46static Lisp_Object Qsubr;
@@ -77,8 +70,8 @@ Lisp_Object Qchar_table_p, Qvector_or_char_table_p;
77Lisp_Object Qcdr; 70Lisp_Object Qcdr;
78static Lisp_Object Qad_advice_info, Qad_activate_internal; 71static Lisp_Object Qad_advice_info, Qad_activate_internal;
79 72
80Lisp_Object Qrange_error, Qdomain_error, Qsingularity_error; 73static Lisp_Object Qdomain_error, Qsingularity_error, Qunderflow_error;
81Lisp_Object Qoverflow_error, Qunderflow_error; 74Lisp_Object Qrange_error, Qoverflow_error;
82 75
83Lisp_Object Qfloatp; 76Lisp_Object Qfloatp;
84Lisp_Object Qnumberp, Qnumber_or_marker_p; 77Lisp_Object Qnumberp, Qnumber_or_marker_p;
@@ -108,7 +101,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 101 to try and do that by checking the tagbits, but nowadays all
109 tagbits are potentially valid. */ 102 tagbits are potentially valid. */
110 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit) 103 /* if ((unsigned int) XTYPE (value) >= Lisp_Type_Limit)
111 * abort (); */ 104 * emacs_abort (); */
112 105
113 xsignal2 (Qwrong_type_argument, predicate, value); 106 xsignal2 (Qwrong_type_argument, predicate, value);
114} 107}
@@ -182,7 +175,7 @@ for example, (type-of 1) returns `integer'. */)
182 case Lisp_Misc_Float: 175 case Lisp_Misc_Float:
183 return Qfloat; 176 return Qfloat;
184 } 177 }
185 abort (); 178 emacs_abort ();
186 179
187 case Lisp_Vectorlike: 180 case Lisp_Vectorlike:
188 if (WINDOW_CONFIGURATIONP (object)) 181 if (WINDOW_CONFIGURATIONP (object))
@@ -217,7 +210,7 @@ for example, (type-of 1) returns `integer'. */)
217 return Qfloat; 210 return Qfloat;
218 211
219 default: 212 default:
220 abort (); 213 emacs_abort ();
221 } 214 }
222} 215}
223 216
@@ -551,7 +544,7 @@ DEFUN ("boundp", Fboundp, Sboundp, 1, 1, 0,
551 /* In set_internal, we un-forward vars when their value is 544 /* In set_internal, we un-forward vars when their value is
552 set to Qunbound. */ 545 set to Qunbound. */
553 return Qt; 546 return Qt;
554 default: abort (); 547 default: emacs_abort ();
555 } 548 }
556 549
557 return (EQ (valcontents, Qunbound) ? Qnil : Qt); 550 return (EQ (valcontents, Qunbound) ? Qnil : Qt);
@@ -864,7 +857,7 @@ do_symval_forwarding (register union Lisp_Fwd *valcontents)
864 don't think anything will break. --lorentey */ 857 don't think anything will break. --lorentey */
865 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset 858 return *(Lisp_Object *)(XKBOARD_OBJFWD (valcontents)->offset
866 + (char *)FRAME_KBOARD (SELECTED_FRAME ())); 859 + (char *)FRAME_KBOARD (SELECTED_FRAME ()));
867 default: abort (); 860 default: emacs_abort ();
868 } 861 }
869} 862}
870 863
@@ -950,12 +943,14 @@ store_symval_forwarding (union Lisp_Fwd *valcontents, register Lisp_Object newva
950 break; 943 break;
951 944
952 default: 945 default:
953 abort (); /* goto def; */ 946 emacs_abort (); /* goto def; */
954 } 947 }
955} 948}
956 949
957/* Set up SYMBOL to refer to its global binding. 950/* Set up SYMBOL to refer to its global binding. This makes it safe
958 This makes it safe to alter the status of other bindings. */ 951 to alter the status of other bindings. BEWARE: this may be called
952 during the mark phase of GC, where we assume that Lisp_Object slots
953 of BLV are marked after this function has changed them. */
959 954
960void 955void
961swap_in_global_binding (struct Lisp_Symbol *symbol) 956swap_in_global_binding (struct Lisp_Symbol *symbol)
@@ -1014,7 +1009,7 @@ swap_in_symval_forwarding (struct Lisp_Symbol *symbol, struct Lisp_Buffer_Local_
1014 else 1009 else
1015 { 1010 {
1016 tem1 = assq_no_quit (var, BVAR (current_buffer, local_var_alist)); 1011 tem1 = assq_no_quit (var, BVAR (current_buffer, local_var_alist));
1017 XSETBUFFER (blv->where, current_buffer); 1012 set_blv_where (blv, Fcurrent_buffer ());
1018 } 1013 }
1019 } 1014 }
1020 if (!(blv->found = !NILP (tem1))) 1015 if (!(blv->found = !NILP (tem1)))
@@ -1055,7 +1050,7 @@ find_symbol_value (Lisp_Object symbol)
1055 /* FALLTHROUGH */ 1050 /* FALLTHROUGH */
1056 case SYMBOL_FORWARDED: 1051 case SYMBOL_FORWARDED:
1057 return do_symval_forwarding (SYMBOL_FWD (sym)); 1052 return do_symval_forwarding (SYMBOL_FWD (sym));
1058 default: abort (); 1053 default: emacs_abort ();
1059 } 1054 }
1060} 1055}
1061 1056
@@ -1168,7 +1163,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1168 the default binding is loaded, the loaded binding may be the 1163 the default binding is loaded, the loaded binding may be the
1169 wrong one. */ 1164 wrong one. */
1170 if (!EQ (blv->where, where) 1165 if (!EQ (blv->where, where)
1171 /* Also unload a global binding (if the var is local_if_set). */ 1166 /* Also unload a global binding (if the var is local_if_set). */
1172 || (EQ (blv->valcell, blv->defcell))) 1167 || (EQ (blv->valcell, blv->defcell)))
1173 { 1168 {
1174 /* The currently loaded binding is not necessarily valid. 1169 /* The currently loaded binding is not necessarily valid.
@@ -1265,7 +1260,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where,
1265 store_symval_forwarding (/* sym, */ innercontents, newval, buf); 1260 store_symval_forwarding (/* sym, */ innercontents, newval, buf);
1266 break; 1261 break;
1267 } 1262 }
1268 default: abort (); 1263 default: emacs_abort ();
1269 } 1264 }
1270 return; 1265 return;
1271} 1266}
@@ -1316,7 +1311,7 @@ default_value (Lisp_Object symbol)
1316 /* For other variables, get the current value. */ 1311 /* For other variables, get the current value. */
1317 return do_symval_forwarding (valcontents); 1312 return do_symval_forwarding (valcontents);
1318 } 1313 }
1319 default: abort (); 1314 default: emacs_abort ();
1320 } 1315 }
1321} 1316}
1322 1317
@@ -1414,7 +1409,7 @@ for this variable. */)
1414 else 1409 else
1415 return Fset (symbol, value); 1410 return Fset (symbol, value);
1416 } 1411 }
1417 default: abort (); 1412 default: emacs_abort ();
1418 } 1413 }
1419} 1414}
1420 1415
@@ -1538,7 +1533,7 @@ The function `default-value' gets the default value and `set-default' sets it.
1538 else if (BUFFER_OBJFWDP (valcontents.fwd)) 1533 else if (BUFFER_OBJFWDP (valcontents.fwd))
1539 return variable; 1534 return variable;
1540 break; 1535 break;
1541 default: abort (); 1536 default: emacs_abort ();
1542 } 1537 }
1543 1538
1544 if (sym->constant) 1539 if (sym->constant)
@@ -1611,7 +1606,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */)
1611 error ("Symbol %s may not be buffer-local", 1606 error ("Symbol %s may not be buffer-local",
1612 SDATA (SYMBOL_NAME (variable))); 1607 SDATA (SYMBOL_NAME (variable)));
1613 break; 1608 break;
1614 default: abort (); 1609 default: emacs_abort ();
1615 } 1610 }
1616 1611
1617 if (sym->constant) 1612 if (sym->constant)
@@ -1718,7 +1713,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */)
1718 if (blv->frame_local) 1713 if (blv->frame_local)
1719 return variable; 1714 return variable;
1720 break; 1715 break;
1721 default: abort (); 1716 default: emacs_abort ();
1722 } 1717 }
1723 1718
1724 /* Get rid of this buffer's alist element, if any. */ 1719 /* Get rid of this buffer's alist element, if any. */
@@ -1800,7 +1795,7 @@ frame-local bindings). */)
1800 error ("Symbol %s may not be frame-local", 1795 error ("Symbol %s may not be frame-local",
1801 SDATA (SYMBOL_NAME (variable))); 1796 SDATA (SYMBOL_NAME (variable)));
1802 break; 1797 break;
1803 default: abort (); 1798 default: emacs_abort ();
1804 } 1799 }
1805 1800
1806 if (sym->constant) 1801 if (sym->constant)
@@ -1877,18 +1872,18 @@ BUFFER defaults to the current buffer. */)
1877 } 1872 }
1878 return Qnil; 1873 return Qnil;
1879 } 1874 }
1880 default: abort (); 1875 default: emacs_abort ();
1881 } 1876 }
1882} 1877}
1883 1878
1884DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p, 1879DEFUN ("local-variable-if-set-p", Flocal_variable_if_set_p, Slocal_variable_if_set_p,
1885 1, 2, 0, 1880 1, 2, 0,
1886 doc: /* Non-nil if VARIABLE will be local in buffer BUFFER when set there. 1881 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'), 1882BUFFER defaults to the current buffer.
1888while it does not have a `let'-style binding that was made in BUFFER, 1883
1889will produce a buffer local binding. See Info node 1884More precisely, return non-nil if either VARIABLE already has a local
1890`(elisp)Creating Buffer-Local'. 1885value in BUFFER, or if VARIABLE is automatically buffer-local (see
1891BUFFER defaults to the current buffer. */) 1886`make-variable-buffer-local'). */)
1892 (register Lisp_Object variable, Lisp_Object buffer) 1887 (register Lisp_Object variable, Lisp_Object buffer)
1893{ 1888{
1894 struct Lisp_Symbol *sym; 1889 struct Lisp_Symbol *sym;
@@ -1912,7 +1907,7 @@ BUFFER defaults to the current buffer. */)
1912 case SYMBOL_FORWARDED: 1907 case SYMBOL_FORWARDED:
1913 /* All BUFFER_OBJFWD slots become local if they are set. */ 1908 /* All BUFFER_OBJFWD slots become local if they are set. */
1914 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil); 1909 return (BUFFER_OBJFWDP (SYMBOL_FWD (sym)) ? Qt : Qnil);
1915 default: abort (); 1910 default: emacs_abort ();
1916 } 1911 }
1917} 1912}
1918 1913
@@ -1956,7 +1951,7 @@ If the current binding is global (the default), the value is nil. */)
1956 return SYMBOL_BLV (sym)->where; 1951 return SYMBOL_BLV (sym)->where;
1957 else 1952 else
1958 return Qnil; 1953 return Qnil;
1959 default: abort (); 1954 default: emacs_abort ();
1960 } 1955 }
1961} 1956}
1962 1957
@@ -2272,7 +2267,7 @@ arithcompare (Lisp_Object num1, Lisp_Object num2, enum comparison comparison)
2272 return Qnil; 2267 return Qnil;
2273 2268
2274 default: 2269 default:
2275 abort (); 2270 emacs_abort ();
2276 } 2271 }
2277} 2272}
2278 2273
@@ -2738,28 +2733,6 @@ Both must be integers or markers. */)
2738 return val; 2733 return val;
2739} 2734}
2740 2735
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, 2736DEFUN ("mod", Fmod, Smod, 2, 2, 0,
2764 doc: /* Return X modulo Y. 2737 doc: /* Return X modulo Y.
2765The result falls between zero (inclusive) and Y (exclusive). 2738The result falls between zero (inclusive) and Y (exclusive).
@@ -3207,21 +3180,23 @@ syms_of_data (void)
3207 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1; 3180 XSYMBOL (intern_c_string ("most-negative-fixnum"))->constant = 1;
3208} 3181}
3209 3182
3210#ifndef FORWARD_SIGNAL_TO_MAIN_THREAD 3183static _Noreturn void
3211_Noreturn 3184handle_arith_signal (int sig)
3212#endif
3213static void
3214arith_error (int signo)
3215{ 3185{
3216 sigsetmask (SIGEMPTYMASK); 3186 pthread_sigmask (SIG_SETMASK, &empty_mask, 0);
3217
3218 SIGNAL_THREAD_CHECK (signo);
3219 xsignal0 (Qarith_error); 3187 xsignal0 (Qarith_error);
3220} 3188}
3221 3189
3190static void
3191deliver_arith_signal (int sig)
3192{
3193 handle_on_main_thread (sig, handle_arith_signal);
3194}
3195
3222void 3196void
3223init_data (void) 3197init_data (void)
3224{ 3198{
3199 struct sigaction action;
3225 /* Don't do this if just dumping out. 3200 /* Don't do this if just dumping out.
3226 We don't want to call `signal' in this case 3201 We don't want to call `signal' in this case
3227 so that we don't have trouble with dumping 3202 so that we don't have trouble with dumping
@@ -3230,5 +3205,6 @@ init_data (void)
3230 if (!initialized) 3205 if (!initialized)
3231 return; 3206 return;
3232#endif /* CANNOT_DUMP */ 3207#endif /* CANNOT_DUMP */
3233 signal (SIGFPE, arith_error); 3208 emacs_sigaction_init (&action, deliver_arith_signal);
3209 sigaction (SIGFPE, &action, 0);
3234} 3210}