Commits (6)
......@@ -35,7 +35,7 @@ GNULIB_MODULES='
environ execinfo explicit_bzero faccessat
fchmodat fcntl fcntl-h fdopendir
filemode filename filevercmp flexmember fpieee fstatat fsusage fsync futimens
getloadavg getopt-gnu gettime gettimeofday gitlog-to-changelog
getloadavg getopt-gnu getrandom gettime gettimeofday gitlog-to-changelog
ieee754-h ignore-value intprops largefile lstat
manywarnings memmem-simple mempcpy memrchr minmax mkostemp mktime nstrftime
pathmax pipe2 pselect pthread_sigmask
......@@ -4275,7 +4275,8 @@ pthread_sigmask strsignal setitimer timer_getoverrun \
sendto recvfrom getsockname getifaddrs freeifaddrs \
gai_strerror sync \
getpwent endpwent getgrent endgrent \
cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np)
cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np \
if test "$ac_cv_func_pthread_setname_np" = "yes"; then
......@@ -4813,11 +4813,9 @@ When @var{noerror} is non-@code{nil}, this function silently uses
@code{raw-text} coding instead.
@item (@code{iv-auto} @var{length})
This will generate an IV (Initialization Vector) of the specified
length using the GnuTLS @code{GNUTLS_RND_NONCE} generator and pass it
to the function. This ensures that the IV is unpredictable and
unlikely to be reused in the same session. The actual value of the IV
is returned by the function as described below.
This generates a random IV (Initialization Vector) of the specified
length and passes it to the function. This ensures that the IV is
unpredictable and unlikely to be reused in the same session.
@end table
......@@ -2339,7 +2339,19 @@ emit_static_object (const char *name, Lisp_Object obj)
strings cause of this funny bug that will affect all pre gcc10 era gccs:
https://gcc.gnu.org/ml/jit/2019-q3/msg00013.html */
ptrdiff_t count = SPECPDL_INDEX ();
/* Preserve uninterned symbols, this is specifically necessary for
CL macro expansion in dynamic scope code (bug#42088). See
`byte-compile-output-file-form'. */
specbind (intern_c_string ("print-escape-newlines"), Qt);
specbind (intern_c_string ("print-length"), Qnil);
specbind (intern_c_string ("print-level"), Qnil);
specbind (intern_c_string ("print-quoted"), Qt);
specbind (intern_c_string ("print-gensym"), Qt);
specbind (intern_c_string ("print-circle"), Qt);
Lisp_Object str = Fprin1_to_string (obj, Qnil);
unbind_to (count, Qnil);
ptrdiff_t len = SBYTES (str);
const char *p = SSDATA (str);
......@@ -4768,17 +4780,7 @@ DEFUN ("comp--register-subr", Fcomp__register_subr, Scomp__register_subr,
Lisp_Object tem =
make_subr (SYMBOL_NAME (name), minarg, maxarg, c_name, doc_idx, intspec,
LOADHIST_ATTACH (Fcons (Qdefun, name));
{ /* Handle automatic advice activation (bug#42038).
See `defalias'. */
Lisp_Object hook = Fget (name, Qdefalias_fset_function);
if (!NILP (hook))
call2 (hook, name, tem);
Ffset (name, tem);
Fdefalias (name, tem, Qnil);
return tem;
......@@ -21,6 +21,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include <config.h>
#include <stdlib.h>
#include <sys/random.h>
#include <unistd.h>
#include <filevercmp.h>
#include <intprops.h>
......@@ -5267,7 +5268,6 @@ extract_data_from_object (Lisp_Object spec,
else if (EQ (object, Qiv_auto))
/* Format: (iv-auto REQUIRED-LENGTH). */
if (! FIXNATP (start))
......@@ -5276,14 +5276,19 @@ extract_data_from_object (Lisp_Object spec,
EMACS_INT start_hold = XFIXNAT (start);
object = make_uninit_string (start_hold);
gnutls_rnd (GNUTLS_RND_NONCE, SSDATA (object), start_hold);
char *lim = SSDATA (object) + start_hold;
for (char *p = SSDATA (object); p < lim; p++)
ssize_t gotten = getrandom (p, lim - p, 0);
if (0 <= gotten)
p += gotten;
else if (errno != EINTR)
report_file_error ("Getting random data", Qnil);
*start_byte = 0;
*end_byte = start_hold;
error ("GnuTLS is not available, so `iv-auto' can't be used");
if (!STRINGP (object))
......@@ -27,6 +27,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#endif /* HAVE_PWD_H */
#include <limits.h>
#include <stdlib.h>
#include <sys/random.h>
#include <unistd.h>
#include <c-ctype.h>
......@@ -115,16 +116,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "process.h"
#include "cm.h"
#include "gnutls.h"
/* MS-Windows loads GnuTLS at run time, if available; we don't want to
do that during startup just to call gnutls_rnd. */
#if defined HAVE_GNUTLS && !defined WINDOWSNT
# include <gnutls/crypto.h>
# define emacs_gnutls_global_init() Qnil
# define gnutls_rnd(level, data, len) (-1)
# include <direct.h>
/* In process.h which conflicts with the local copy. */
......@@ -2278,9 +2269,7 @@ init_signals (void)
typedef unsigned int random_seed;
static void set_random_seed (random_seed arg) { srandom (arg); }
#elif defined HAVE_LRAND48
/* Although srand48 uses a long seed, this is unsigned long to avoid
undefined behavior on signed integer overflow in init_random. */
typedef unsigned long int random_seed;
typedef long int random_seed;
static void set_random_seed (random_seed arg) { srand48 (arg); }
typedef unsigned int random_seed;
......@@ -2307,23 +2296,14 @@ init_random (void)
/* First, try seeding the PRNG from the operating system's entropy
source. This approach is both fast and secure. */
/* FIXME: Perhaps getrandom can be used here too? */
success = w32_init_random (&v, sizeof v) == 0;
int fd = emacs_open ("/dev/urandom", O_RDONLY, 0);
if (0 <= fd)
success = emacs_read (fd, &v, sizeof v) == sizeof v;
close (fd);
verify (sizeof v <= 256);
success = getrandom (&v, sizeof v, 0) == sizeof v;
/* If that didn't work, try using GnuTLS, which is secure, but on
some systems, can be somewhat slow. */
if (!success)
success = EQ (emacs_gnutls_global_init (), Qt)
&& gnutls_rnd (GNUTLS_RND_NONCE, &v, sizeof v) == 0;
/* If _that_ didn't work, just use the current time value and PID.
/* If that didn't work, just use the current time value and PID.
It's at least better than XKCD 221. */
if (!success)
......@@ -26,6 +26,10 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */
#include "nsterm.h"
#include <pthread_np.h>
......@@ -221,6 +225,10 @@ sys_thread_set_name (const char *name)
# else
pthread_setname_np (pthread_self (), p_name);
# endif
/* The name will automatically be truncated if it exceeds a
system-specific length. */
pthread_set_name_np (pthread_self (), name);
......@@ -23,6 +23,8 @@
;;; Code:
(require 'cl-lib)
(defun comp-tests-ffuncall-callee-dyn-f (a b)
(list a b))
......@@ -35,6 +37,11 @@
(defun comp-tests-ffuncall-callee-opt-rest-dyn-f (a b &optional c &rest d)
(list a b c d))
(defun comp-tests-cl-macro-exp-f ()
(cl-loop for xxx in '(a b)
for yyy = xxx
collect xxx))
(provide 'comp-test-dyn-funcs)
;;; comp-test-funcs-dyn.el ends here
......@@ -574,4 +574,8 @@ https://lists.gnu.org/archive/html/bug-gnu-emacs/2020-03/msg00914.html."
(should (equal '(2 . many)
(func-arity #'comp-tests-ffuncall-callee-opt-rest-dyn-f))))
(ert-deftest comp-tests-cl-macro-exp ()
"Verify CL macro expansion (bug#42088)."
(should (equal (comp-tests-cl-macro-exp-f) '(a b))))
;;; comp-tests.el ends here