diff options
| author | Andrea Corallo | 2021-03-09 10:03:47 +0100 |
|---|---|---|
| committer | Andrea Corallo | 2021-03-09 10:03:47 +0100 |
| commit | 43b0df62cd5922df5495b3f4aee5b7beca14384f (patch) | |
| tree | 3c0bfa9526d08c9c85e646cd355467e3dfb439ac /src | |
| parent | 380ba045c48bfbb160da288b1bd50f82d3f999f0 (diff) | |
| parent | 9cbdf20316e1cec835a7dfe28877142e437976f4 (diff) | |
| download | emacs-43b0df62cd5922df5495b3f4aee5b7beca14384f.tar.gz emacs-43b0df62cd5922df5495b3f4aee5b7beca14384f.zip | |
Merge commit '9cbdf20316' into native-comp
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.in | 2 | ||||
| -rw-r--r-- | src/buffer.c | 4 | ||||
| -rw-r--r-- | src/eval.c | 2 | ||||
| -rw-r--r-- | src/fns.c | 53 | ||||
| -rw-r--r-- | src/marker.c | 7 |
5 files changed, 59 insertions, 9 deletions
diff --git a/src/Makefile.in b/src/Makefile.in index 9e105c157b9..8478dc14a85 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -431,7 +431,7 @@ base_obj = dispnew.o frame.o scroll.o xdisp.o menu.o $(XMENU_OBJ) window.o \ | |||
| 431 | thread.o systhread.o \ | 431 | thread.o systhread.o \ |
| 432 | $(if $(HYBRID_MALLOC),sheap.o) \ | 432 | $(if $(HYBRID_MALLOC),sheap.o) \ |
| 433 | $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ | 433 | $(MSDOS_OBJ) $(MSDOS_X_OBJ) $(NS_OBJ) $(CYGWIN_OBJ) $(FONT_OBJ) \ |
| 434 | $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) $(JSON_OBJ) $(GMP_OBJ) | 434 | $(W32_OBJ) $(WINDOW_SYSTEM_OBJ) $(XGSELOBJ) $(JSON_OBJ) |
| 435 | obj = $(base_obj) $(NS_OBJC_OBJ) | 435 | obj = $(base_obj) $(NS_OBJC_OBJ) |
| 436 | 436 | ||
| 437 | ## Object files used on some machine or other. | 437 | ## Object files used on some machine or other. |
diff --git a/src/buffer.c b/src/buffer.c index 5bd9b37702f..03c10cc7ae5 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1942,8 +1942,8 @@ cleaning up all windows currently displaying the buffer to be killed. */) | |||
| 1942 | } | 1942 | } |
| 1943 | /* Since we've unlinked the markers, the overlays can't be here any more | 1943 | /* Since we've unlinked the markers, the overlays can't be here any more |
| 1944 | either. */ | 1944 | either. */ |
| 1945 | b->overlays_before = NULL; | 1945 | set_buffer_overlays_before (b, NULL); |
| 1946 | b->overlays_after = NULL; | 1946 | set_buffer_overlays_after (b, NULL); |
| 1947 | 1947 | ||
| 1948 | /* Reset the local variables, so that this buffer's local values | 1948 | /* Reset the local variables, so that this buffer's local values |
| 1949 | won't be protected from GC. They would be protected | 1949 | won't be protected from GC. They would be protected |
diff --git a/src/eval.c b/src/eval.c index 10e53cf9aed..cf5ca3b4bbd 100644 --- a/src/eval.c +++ b/src/eval.c | |||
| @@ -221,7 +221,7 @@ init_eval_once (void) | |||
| 221 | /* Don't forget to update docs (lispref node "Local Variables"). */ | 221 | /* Don't forget to update docs (lispref node "Local Variables"). */ |
| 222 | if (!NATIVE_COMP_FLAG) | 222 | if (!NATIVE_COMP_FLAG) |
| 223 | { | 223 | { |
| 224 | max_specpdl_size = 1600; /* 1500 is not enough for cl-generic.el. */ | 224 | max_specpdl_size = 1800; /* See bug#46818. */ |
| 225 | max_lisp_eval_depth = 800; | 225 | max_lisp_eval_depth = 800; |
| 226 | } | 226 | } |
| 227 | else | 227 | else |
| @@ -54,10 +54,55 @@ DEFUN ("identity", Fidentity, Sidentity, 1, 1, 0, | |||
| 54 | return argument; | 54 | return argument; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | static Lisp_Object | ||
| 58 | ccall2 (Lisp_Object (f) (ptrdiff_t nargs, Lisp_Object *args), | ||
| 59 | Lisp_Object arg1, Lisp_Object arg2) | ||
| 60 | { | ||
| 61 | Lisp_Object args[2] = {arg1, arg2}; | ||
| 62 | return f (2, args); | ||
| 63 | } | ||
| 64 | |||
| 65 | static Lisp_Object | ||
| 66 | get_random_bignum (Lisp_Object limit) | ||
| 67 | { | ||
| 68 | /* This is a naive transcription into bignums of the fixnum algorithm. | ||
| 69 | I'd be quite surprised if that's anywhere near the best algorithm | ||
| 70 | for it. */ | ||
| 71 | while (true) | ||
| 72 | { | ||
| 73 | Lisp_Object val = make_fixnum (0); | ||
| 74 | Lisp_Object lim = limit; | ||
| 75 | int bits = 0; | ||
| 76 | int bitsperiteration = FIXNUM_BITS - 1; | ||
| 77 | do | ||
| 78 | { | ||
| 79 | /* Shift by one so it is a valid positive fixnum. */ | ||
| 80 | EMACS_INT rand = get_random () >> 1; | ||
| 81 | Lisp_Object lrand = make_fixnum (rand); | ||
| 82 | bits += bitsperiteration; | ||
| 83 | val = ccall2 (Flogior, | ||
| 84 | Fash (val, make_fixnum (bitsperiteration)), | ||
| 85 | lrand); | ||
| 86 | lim = Fash (lim, make_fixnum (- bitsperiteration)); | ||
| 87 | } | ||
| 88 | while (!EQ (lim, make_fixnum (0))); | ||
| 89 | /* Return the remainder, except reject the rare case where | ||
| 90 | get_random returns a number so close to INTMASK that the | ||
| 91 | remainder isn't random. */ | ||
| 92 | Lisp_Object remainder = Frem (val, limit); | ||
| 93 | if (!NILP (ccall2 (Fleq, | ||
| 94 | ccall2 (Fminus, val, remainder), | ||
| 95 | ccall2 (Fminus, | ||
| 96 | Fash (make_fixnum (1), make_fixnum (bits)), | ||
| 97 | limit)))) | ||
| 98 | return remainder; | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 57 | DEFUN ("random", Frandom, Srandom, 0, 1, 0, | 102 | DEFUN ("random", Frandom, Srandom, 0, 1, 0, |
| 58 | doc: /* Return a pseudo-random integer. | 103 | doc: /* Return a pseudo-random integer. |
| 59 | By default, return a fixnum; all fixnums are equally likely. | 104 | By default, return a fixnum; all fixnums are equally likely. |
| 60 | With positive fixnum LIMIT, return random integer in interval [0,LIMIT). | 105 | With positive integer LIMIT, return random integer in interval [0,LIMIT). |
| 61 | With argument t, set the random number seed from the system's entropy | 106 | With argument t, set the random number seed from the system's entropy |
| 62 | pool if available, otherwise from less-random volatile data such as the time. | 107 | pool if available, otherwise from less-random volatile data such as the time. |
| 63 | With a string argument, set the seed based on the string's contents. | 108 | With a string argument, set the seed based on the string's contents. |
| @@ -71,6 +116,12 @@ See Info node `(elisp)Random Numbers' for more details. */) | |||
| 71 | init_random (); | 116 | init_random (); |
| 72 | else if (STRINGP (limit)) | 117 | else if (STRINGP (limit)) |
| 73 | seed_random (SSDATA (limit), SBYTES (limit)); | 118 | seed_random (SSDATA (limit), SBYTES (limit)); |
| 119 | if (BIGNUMP (limit)) | ||
| 120 | { | ||
| 121 | if (0 > mpz_sgn (*xbignum_val (limit))) | ||
| 122 | xsignal2 (Qwrong_type_argument, Qnatnump, limit); | ||
| 123 | return get_random_bignum (limit); | ||
| 124 | } | ||
| 74 | 125 | ||
| 75 | val = get_random (); | 126 | val = get_random (); |
| 76 | if (FIXNUMP (limit) && 0 < XFIXNUM (limit)) | 127 | if (FIXNUMP (limit) && 0 < XFIXNUM (limit)) |
diff --git a/src/marker.c b/src/marker.c index 59791513170..2b137b14c8f 100644 --- a/src/marker.c +++ b/src/marker.c | |||
| @@ -634,16 +634,15 @@ set_marker_restricted_both (Lisp_Object marker, Lisp_Object buffer, | |||
| 634 | /* Detach a marker so that it no longer points anywhere and no longer | 634 | /* Detach a marker so that it no longer points anywhere and no longer |
| 635 | slows down editing. Do not free the marker, though, as a change | 635 | slows down editing. Do not free the marker, though, as a change |
| 636 | function could have inserted it into an undo list (Bug#30931). */ | 636 | function could have inserted it into an undo list (Bug#30931). */ |
| 637 | |||
| 637 | void | 638 | void |
| 638 | detach_marker (Lisp_Object marker) | 639 | detach_marker (Lisp_Object marker) |
| 639 | { | 640 | { |
| 640 | Fset_marker (marker, Qnil, Qnil); | 641 | Fset_marker (marker, Qnil, Qnil); |
| 641 | } | 642 | } |
| 642 | 643 | ||
| 643 | /* Remove MARKER from the chain of whatever buffer it is in, | 644 | /* Remove MARKER from the chain of whatever buffer it is in. Set its |
| 644 | leaving it points to nowhere. This is called during garbage | 645 | buffer NULL. */ |
| 645 | collection, so we must be careful to ignore and preserve | ||
| 646 | mark bits, including those in chain fields of markers. */ | ||
| 647 | 646 | ||
| 648 | void | 647 | void |
| 649 | unchain_marker (register struct Lisp_Marker *marker) | 648 | unchain_marker (register struct Lisp_Marker *marker) |