...
 
Commits (43)
......@@ -53,9 +53,18 @@ archives.
To email a patch you can use a shell command like 'git format-patch -1'
to create a file, and then attach the file to your email. This nicely
packages the patch's commit message and changes. To send just one
such patch without additional remarks, you can use a command like
'git send-email --to=bug-gnu-emacs@gnu.org 0001-DESCRIPTION.patch'.
packages the patch's commit message and changes, and makes sure the
format and whitespace are not munged in transit by the various mail
agents. To send just one such patch without additional remarks, it is
also possible to use a command like
git send-email --to=bug-gnu-emacs@gnu.org 0001-DESCRIPTION.patch'.
However, we prefer the 'git format-patch' method with attachment, as
doing so delivers patches in the correct and easily-recognizable format
more reliably, and makes the job of applying the patches easier and less
error-prone. It also allows to send patches whose author is someone
other than the email sender.
Once the cumulative amount of your submissions exceeds about 15 lines
of non-trivial changes, we will need you to assign to the FSF the
......
......@@ -32,6 +32,7 @@
PKG_REQ='''mingw-w64-x86_64-giflib
mingw-w64-x86_64-gnutls
mingw-w64-x86_64-harfbuzz
mingw-w64-x86_64-jansson
mingw-w64-x86_64-lcms2
mingw-w64-x86_64-libjpeg-turbo
mingw-w64-x86_64-libpng
......
......@@ -1095,7 +1095,17 @@ EOF
echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
exit ;;
x86_64:Linux:*:*)
echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
set_cc_for_build
LIBCABI=$LIBC
if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
grep IS_X32 >/dev/null
then
LIBCABI="$LIBC"x32
fi
fi
echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI"
exit ;;
xtensa*:Linux:*:*)
echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
......
......@@ -2,7 +2,7 @@
# Configuration validation subroutine script.
# Copyright 1992-2020 Free Software Foundation, Inc.
timestamp='2020-05-04'
timestamp='2020-06-20'
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
......@@ -477,6 +477,10 @@ case $1 in
basic_machine=hppa-unknown
os=linux
;;
psp)
basic_machine=mipsallegrexel-sony
os=psp
;;
pw32)
basic_machine=i586-unknown
os=pw32
......@@ -1138,13 +1142,9 @@ case $cpu-$vendor in
cpu=nsx
vendor=tandem
;;
s390-*)
cpu=s390
vendor=ibm
;;
s390x-*)
cpu=s390x
vendor=ibm
mipsallegrexel-sony)
cpu=mipsallegrexel
vendor=sony
;;
tile*-*)
os=${os:-linux-gnu}
......@@ -1229,6 +1229,7 @@ case $cpu-$vendor in
| pyramid \
| riscv | riscv32 | riscv64 \
| rl78 | romp | rs6000 | rx \
| s390 | s390x \
| score \
| sh | shl \
| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
......@@ -1334,41 +1335,6 @@ case $os in
psos*)
os=psos
;;
# Now accept the basic system types.
# The portable systems comes first.
# Each alternative MUST end in a * to match a version number.
# sysv* is not here because it comes later, after sysvr4.
gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
| *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
| hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
| sym* | kopensolaris* | plan9* \
| amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
| aos* | aros* | cloudabi* | sortix* | twizzler* \
| nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
| clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
| knetbsd* | mirbsd* | netbsd* \
| bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
| ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
| bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
| ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
| udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
| chorusrdb* | cegcc* | glidix* \
| cygwin* | msys* | pe* | moss* | proelf* | rtems* \
| midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
| linux-newlib* | linux-musl* | linux-uclibc* \
| uxpv* | beos* | mpeix* | udk* | moxiebox* \
| interix* | uwin* | mks* | rhapsody* | darwin* \
| openstep* | oskit* | conix* | pw32* | nonstopux* \
| storm-chaos* | tops10* | tenex* | tops20* | its* \
| os2* | vos* | palmos* | uclinux* | nucleus* \
| morphos* | superux* | rtmk* | windiss* \
| powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
qnx*)
case $cpu in
x86 | i*86)
......@@ -1393,18 +1359,21 @@ case $os in
linux-dietlibc)
os=linux-dietlibc
;;
linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
lynx*178)
os=lynxos178
;;
lynx*5)
os=lynxos5
;;
lynxos*)
# don't get caught up in next wildcard
;;
lynx*)
os=lynxos
;;
mach)
# don't get caught up in next wildcard
;;
mac*)
os=`echo "$os" | sed -e 's|mac|macos|'`
;;
......@@ -1507,10 +1476,50 @@ case $os in
;;
ios)
;;
psp)
;;
none)
;;
*-eabi)
;;
# Now accept the basic system types.
# The portable systems comes first.
# Each alternative MUST end in a * to match a version number.
# sysv* is not here because it comes later, after sysvr4.
gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
| *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
| hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
| sym* | kopensolaris* | plan9* \
| amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
| aos* | aros* | cloudabi* | sortix* | twizzler* \
| nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
| clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
| knetbsd* | mirbsd* | netbsd* \
| bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \
| ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
| bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
| ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
| udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
| chorusrdb* | cegcc* | glidix* \
| cygwin* | msys* | pe* | moss* | proelf* | rtems* \
| midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
| linux-newlib* | linux-musl* | linux-uclibc* \
| uxpv* | beos* | mpeix* | udk* | moxiebox* \
| interix* | uwin* | mks* | rhapsody* | darwin* \
| openstep* | oskit* | conix* | pw32* | nonstopux* \
| storm-chaos* | tops10* | tenex* | tops20* | its* \
| os2* | vos* | palmos* | uclinux* | nucleus* \
| morphos* | superux* | rtmk* | windiss* \
| powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
| nsk* | powerunix* | genode*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
linux*)
os=`echo $os | sed -e 's|linux|linux-gnu|'`
;;
*)
echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
exit 1
......
......@@ -1174,19 +1174,20 @@ right-to-left paragraphs.
@findex display-fill-column-indicator-mode
@findex global-display-fill-column-indicator-mode
Emacs can add an indicator to display a fill column position. The
fill column indicator is a useful functionality specially in
prog-mode to indicate the position of an specific column.
fill column indicator is a useful functionality especially in
@code{prog-mode} to indicate the position of a specific column.
You can set the buffer-local variables @code{display-fill-column-indicator}
and @code{display-fill-column-indicator-character} to activate the
indicator and controls how the indicator looks.
You can set the buffer-local variables
@code{display-fill-column-indicator} and
@code{display-fill-column-indicator-character} to activate the
indicator and control how it looks, respectively.
Alternatively you can type @w{@kbd{M-x display-fill-column-indicator-mode}}
or @w{@kbd{M-x global-display-fill-column-indicator-mode}} which enables the
indicator locally and globally respectively and also chooses the
character to use if none is set already. It is possible to use the
first one to activate the indicator in a hook or the second one to
enable it globally.
or @w{@kbd{M-x global-display-fill-column-indicator-mode}} which
enables the indicator locally or globally, respectively, and also
chooses the character to use if none is already set. It is possible
to use the first one to activate the indicator in a hook and the
second one to enable it globally.
There are 2 buffer local variables and 1 face to customize this mode:
......@@ -1203,20 +1204,20 @@ Any other value disables the indicator. The default value is @code{t}.
@item display-fill-column-indicator-character
@vindex display-fill-column-indicator-character
Specifies the character used for the indicator. This character can be
any valid char including unicode ones if the actual font supports
them.
any valid character including Unicode ones if the font supports them.
When the mode is enabled through the functions
@code{display-fill-column-indicator-mode} or
@code{global-display-fill-column-indicator-mode}, the initialization
functions check if this variable is @code{non-nil}, otherwise the
initialization tries to set it to U+2502 or @samp{|}.
functions check if this variable is non-@code{nil}, otherwise the
initialization tries to set it to @code{U+2502} or @samp{|}.
@item fill-column-indicator
@vindex fill-column-indicator
Specifies the face used to display the indicator. It inherits its
default values from shadow but without background color. To change
the indicator color you need to set only the foreground color of this face.
default values from the face @code{shadow} but without background
color. To change the indicator color you need only set the foreground
color of this face.
@end table
@vindex indicate-buffer-boundaries
......
......@@ -959,8 +959,9 @@ For example, the following is invalid:
@example
@group
(require 'cl-lib)
(pcase (read-number "Enter an integer: ")
((or (and (pred evenp)
((or (and (pred cl-evenp)
e-num) ; @r{bind @code{e-num} to @var{expval}}
o-num) ; @r{bind @code{o-num} to @var{expval}}
(list e-num o-num)))
......@@ -984,9 +985,10 @@ Reworking the above example:
@example
@group
(require 'cl-lib)
(pcase (read-number "Enter an integer: ")
((and num ; @r{line 1}
(or (and (pred evenp) ; @r{line 2}
(or (and (pred cl-evenp) ; @r{line 2}
(let spin 'even)) ; @r{line 3}
(let spin 'odd))) ; @r{line 4}
(list spin num))) ; @r{line 5}
......
......@@ -3477,15 +3477,18 @@ You can browse the resulting @file{*Packages*} buffer to see what is
available, and then Emacs can automatically download and install the
packages that you select. @xref{Packages,,, emacs, The GNU Emacs Manual}.
There are other, non-GNU, Emacs Lisp package servers, including:
@uref{https://melpa.org, MELPA}; and
@uref{https://marmalade-repo.org, Marmalade}. To use additional
package servers, customize the @code{package-archives} variable. Be
aware that installing a package can run arbitrary code, so only add
sources that you trust. Also, packages hosted on non-GNU package
servers may encourage or require you to install and use non-free
software; for example, MELPA is known to host some packages that do
this.
There are other Emacs Lisp package archives. To use additional
archives, you can customize the @code{package-archives} variable.
Those archives have no affiliation with GNU Emacs, and we do not
monitor how they are maintained. They may pay close attention to
correctness and safety of the code, or they may give only cursory
attention.
Also, packages hosted on these other archives may encourage or require
you to install and use other nonfree programs. Unless you can verify
that a package is free software, and that it functions without
installing any nonfree software, we recommend for your freedom's sake
that you stay away from it.
The @uref{https://lists.gnu.org/mailman/listinfo/gnu-emacs-sources,
GNU Emacs sources mailing list}, which is gatewayed to the
......
This diff is collapsed.
......@@ -64,8 +64,8 @@ It was declared obsolete in Emacs 27.1.
** Emacs can support 24-bit color TTY without terminfo database.
If your text-mode terminal supports 24-bit true color, but your system
lacks the terminfo database, you can instruct Emacs to support 24-bit
true color by setting COLORTERM=truecolor in the environment. This is
useful on systems such as FreeBSD which ships only with 'etc/termcap'.
true color by setting 'COLORTERM=truecolor' in the environment. This is
useful on systems such as FreeBSD which ships only with "etc/termcap".
* Changes in Emacs 28.1
......@@ -115,6 +115,14 @@ setting the variable 'auto-save-visited-mode' buffer-locally to nil.
* Changes in Specialized Modes and Packages in Emacs 28.1
** Windows
*** The key prefix 'C-x 4 4' displays next command buffer in a new window.
** Frames
*** The key prefix 'C-x 5 5' displays next command buffer in a new frame.
** Tab Bars
*** The key prefix 'C-x t t' displays next command buffer in a new tab.
......@@ -165,6 +173,15 @@ directories with the help of new command 'dired-vc-next-action'.
** Change Logs and VC
*** More VC commands can be used from non-file buffers.
The relevant commands are those that don't change the VC state.
The non-file buffers which can use VC commands are those that have
their 'default-directory' under VC.
*** 'M-n' now works in minibuffer prompts of VC commands.
Typing 'M-n' in the minibuffer that prompts for a VC directory in VC
commands now retrieves directories of previously used VC projects.
*** New command 'vc-dir-root' uses the root directory without asking.
*** New commands 'vc-dir-mark-registered-files' (bound to '* r') and
......@@ -188,6 +205,11 @@ this user option.
+++
*** New command 'describe-keymap' describes keybindings in a keymap.
---
*** The command 'view-lossage' can now be invoked from the menu bar.
The menu-bar Help menu now has a "Show Recent Inputs" item under the
"Describe" sub-menu.
---
** The old non-SMIE indentation of 'sh-mode' has been removed.
......@@ -382,7 +404,6 @@ To enable, add it to appropriate entries in 'c-offsets-alist', e.g.:
** browse-url
*** Added support for custom URL handlers.
There is a new variable 'browse-url-default-handlers' and a user
option 'browse-url-handlers' being alists with '(REGEXP-OR-PREDICATE
. FUNCTION)' entries allowing to define different browsing FUNCTIONs
......@@ -396,7 +417,6 @@ Formerly, one could do the same by setting
supported but deprecated.
*** Categorization of browsing functions in internal vs. external.
All standard browsing functions such as 'browse-url-firefox',
'browse-url-mail', or 'eww' have been categorized into internal (URL
is browsed in Emacs) or external (an external application is spawned
......@@ -482,6 +502,21 @@ the function 'format-spec' documented under node "(elisp) Custom Format
Strings". The new syntax includes specifiers for padding and
truncation, amongst other things.
** bug-reference.el
---
*** Bug reference mode auto-setup. If 'bug-reference-mode' or
'bug-reference-prog-mode' have been activated, their respective hook
has been run and still 'bug-reference-bug-regexp' and
'bug-reference-url-format' aren't both set, it tries to guess
appropriate values for those two variables. There are two guessing
mechanisms so far: based on version control information of the current
buffer's file, and based on newsgroup/mail-folder name and several
news and mail message headers in Gnus buffers. Both mechanisms are
extensible with custom rules, see the variables
'bug-reference-setup-from-vc-alist' and
'bug-reference-setup-from-mail-alist'.
* New Modes and Packages in Emacs 28.1
......@@ -616,6 +651,11 @@ In order for the two functions to behave more consistently,
length, and also supports format specifications that include a
truncating precision field, such as '%.2a'.
---
** New function 'color-values-from-color-spec'.
This can be used to parse RGB color specs in several formats and
convert them to a list '(R G B)' of primary color values.
* Changes in Emacs 28.1 on Non-Free Operating Systems
......
......@@ -34,29 +34,13 @@ _GL_INLINE_HEADER_BEGIN
extern "C" {
#endif
/* Expand to code that computes the number of 1-bits of the local
variable 'x' of type TYPE (an unsigned integer type) and return it
from the current function. */
#define COUNT_ONE_BITS_GENERIC(TYPE) \
do \
{ \
int count = 0; \
int bits; \
for (bits = 0; bits < sizeof (TYPE) * CHAR_BIT; bits += 32) \
{ \
count += count_one_bits_32 (x); \
x = x >> 31 >> 1; \
} \
return count; \
} \
while (0)
/* Assuming the GCC builtin is BUILTIN and the MSC builtin is MSC_BUILTIN,
/* Assuming the GCC builtin is GCC_BUILTIN and the MSC builtin is MSC_BUILTIN,
expand to code that computes the number of 1-bits of the local
variable 'x' of type TYPE (an unsigned integer type) and return it
from the current function. */
#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
# define COUNT_ONE_BITS(BUILTIN, MSC_BUILTIN, TYPE) return BUILTIN (x)
# define COUNT_ONE_BITS(GCC_BUILTIN, MSC_BUILTIN, TYPE) \
return GCC_BUILTIN (x)
#else
/* Compute and return the number of 1-bits set in the least
......@@ -71,14 +55,46 @@ count_one_bits_32 (unsigned int x)
return (x >> 8) + (x & 0x00ff);
}
/* Expand to code that computes the number of 1-bits of the local
variable 'x' of type TYPE (an unsigned integer type) and return it
from the current function. */
# define COUNT_ONE_BITS_GENERIC(TYPE) \
do \
{ \
int count = 0; \
int bits; \
for (bits = 0; bits < sizeof (TYPE) * CHAR_BIT; bits += 32) \
{ \
count += count_one_bits_32 (x); \
x = x >> 31 >> 1; \
} \
return count; \
} \
while (0)
# if 1500 <= _MSC_VER && (defined _M_IX86 || defined _M_X64)
/* While gcc falls back to its own generic code if the machine
on which it's running doesn't support popcount, with Microsoft's
compiler we need to detect and fallback ourselves. */
# pragma intrinsic __cpuid
# pragma intrinsic __popcnt
# pragma intrinsic __popcnt64
# if 0
# include <intrin.h>
# else
/* Don't pollute the namespace with too many MSVC intrinsics. */
# pragma intrinsic (__cpuid)
# pragma intrinsic (__popcnt)
# if defined _M_X64
# pragma intrinsic (__popcnt64)
# endif
# endif
# if !defined _M_X64
static inline __popcnt64 (unsigned long long x)
{
return __popcnt ((unsigned int) (x >> 32)) + __popcnt ((unsigned int) x);
}
# endif
/* Return nonzero if popcount is supported. */
......@@ -90,25 +106,30 @@ popcount_supported (void)
{
if (popcount_support < 0)
{
/* Do as described in
<https://docs.microsoft.com/en-us/cpp/intrinsics/popcnt16-popcnt-popcnt64> */
int cpu_info[4];
__cpuid (cpu_info, 1);
popcount_support = (cpu_info[2] >> 23) & 1; /* See MSDN. */
popcount_support = (cpu_info[2] >> 23) & 1;
}
return popcount_support;
}
# define COUNT_ONE_BITS(BUILTIN, MSC_BUILTIN, TYPE) \
do \
{ \
if (popcount_supported ()) \
return MSC_BUILTIN (x); \
else \
COUNT_ONE_BITS_GENERIC (TYPE); \
} \
# define COUNT_ONE_BITS(GCC_BUILTIN, MSC_BUILTIN, TYPE) \
do \
{ \
if (popcount_supported ()) \
return MSC_BUILTIN (x); \
else \
COUNT_ONE_BITS_GENERIC (TYPE); \
} \
while (0)
# else
# define COUNT_ONE_BITS(BUILTIN, MSC_BUILTIN, TYPE) \
# define COUNT_ONE_BITS(GCC_BUILTIN, MSC_BUILTIN, TYPE) \
COUNT_ONE_BITS_GENERIC (TYPE)
# endif
#endif
......
......@@ -33,20 +33,28 @@
#include <stdio.h>
#include <stdlib.h>
#ifdef C_LOCALE
# include "c-snprintf.h"
# include "c-strtod.h"
# define PREFIX(name) c_ ## name
#else
# define PREFIX(name) name
#endif
#if LENGTH == 3
# define FLOAT long double
# define FLOAT_DIG LDBL_DIG
# define FLOAT_MIN LDBL_MIN
# define FLOAT_PREC_BOUND _GL_LDBL_PREC_BOUND
# define FTOASTR ldtoastr
# define FTOASTR PREFIX (ldtoastr)
# define PROMOTED_FLOAT long double
# define STRTOF strtold
# define STRTOF PREFIX (strtold)
#elif LENGTH == 2
# define FLOAT double
# define FLOAT_DIG DBL_DIG
# define FLOAT_MIN DBL_MIN
# define FLOAT_PREC_BOUND _GL_DBL_PREC_BOUND
# define FTOASTR dtoastr
# define FTOASTR PREFIX (dtoastr)
# define PROMOTED_FLOAT double
#else
# define LENGTH 1
......@@ -54,7 +62,7 @@
# define FLOAT_DIG FLT_DIG
# define FLOAT_MIN FLT_MIN
# define FLOAT_PREC_BOUND _GL_FLT_PREC_BOUND
# define FTOASTR ftoastr
# define FTOASTR PREFIX (ftoastr)
# define PROMOTED_FLOAT double
# if HAVE_STRTOF
# define STRTOF strtof
......@@ -65,13 +73,16 @@
may generate one or two extra digits, but that's better than not
working at all. */
#ifndef STRTOF
# define STRTOF strtod
# define STRTOF PREFIX (strtod)
#endif
/* On hosts where it's not known that snprintf works, use sprintf to
implement the subset needed here. Typically BUFSIZE is big enough
and there's little or no performance hit. */
#if ! GNULIB_SNPRINTF
#ifdef C_LOCALE
# undef snprintf
# define snprintf c_snprintf
#elif ! GNULIB_SNPRINTF
# undef snprintf
# define snprintf ftoastr_snprintf
static int
......
......@@ -18,6 +18,7 @@
/* Written by Paul Eggert. */
#ifndef _GL_FTOASTR_H
#define _GL_FTOASTR_H
#include "intprops.h"
#include <float.h>
......@@ -48,6 +49,12 @@ int ftoastr (char *buf, size_t bufsize, int flags, int width, float x);
int dtoastr (char *buf, size_t bufsize, int flags, int width, double x);
int ldtoastr (char *buf, size_t bufsize, int flags, int width, long double x);
/* The last two functions except that the formatting takes place in
the C locale. */
int c_dtoastr (char *buf, size_t bufsize, int flags, int width, double x);
int c_ldtoastr (char *buf, size_t bufsize, int flags, int width, long double x);
/* Flag values for ftoastr etc. These can be ORed together. */
enum
{
......
......@@ -512,7 +512,7 @@ getloadavg (double loadavg[], int nelem)
char const *ptr = ldavgbuf;
int fd, count, saved_errno;
fd = open (LINUX_LDAV_FILE, O_RDONLY);
fd = open (LINUX_LDAV_FILE, O_RDONLY | O_CLOEXEC);
if (fd == -1)
return -1;
count = read (fd, ldavgbuf, sizeof ldavgbuf - 1);
......@@ -550,7 +550,7 @@ getloadavg (double loadavg[], int nelem)
for (ptr++; '0' <= *ptr && *ptr <= '9'; ptr++)
numerator = 10 * numerator + (*ptr - '0'), denominator *= 10;
loadavg[elem++] = numerator / denominator;
loadavg[elem] = numerator / denominator;
}
return elem;
......@@ -567,15 +567,22 @@ getloadavg (double loadavg[], int nelem)
unsigned long int load_ave[3], scale;
int count;
FILE *fp;
fp = fopen (NETBSD_LDAV_FILE, "r");
if (fp == NULL)
return -1;
count = fscanf (fp, "%lu %lu %lu %lu\n",
char readbuf[4 * INT_BUFSIZE_BOUND (unsigned long int) + 1];
int fd = open (NETBSD_LDAV_FILE, O_RDONLY | O_CLOEXEC);
if (fd < 0)
return fd;
int nread = read (fd, readbuf, sizeof readbuf - 1);
int err = errno;
close (fd);
if (nread < 0)
{
errno = err;
return -1;
}
readbuf[nread] = '\0';
count = sscanf (readbuf, "%lu %lu %lu %lu\n",
&load_ave[0], &load_ave[1], &load_ave[2],
&scale);
(void) fclose (fp);
if (count != 4)
{
errno = ENOTSUP;
......@@ -869,27 +876,11 @@ getloadavg (double loadavg[], int nelem)
if (!getloadavg_initialized)
{
# ifndef SUNOS_5
/* Set the channel to close on exec, so it does not
litter any child's descriptor table. */
# ifndef O_CLOEXEC
# define O_CLOEXEC 0
# endif
int fd = open ("/dev/kmem", O_RDONLY | O_CLOEXEC);
if (0 <= fd)
{
# if F_DUPFD_CLOEXEC
if (fd <= STDERR_FILENO)
{
int fd1 = fcntl (fd, F_DUPFD_CLOEXEC, STDERR_FILENO + 1);
close (fd);
fd = fd1;
}
# endif
if (0 <= fd)
{
channel = fd;
getloadavg_initialized = true;
}
channel = fd;
getloadavg_initialized = true;
}
# else /* SUNOS_5 */
/* We pass 0 for the kernel, corefile, and swapfile names
......
/* Obtain a series of random bytes.
Copyright 2020 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
/* Written by Paul Eggert. */
#include <config.h>
#include <sys/random.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <unistd.h>
#if defined _WIN32 && ! defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN
# include <windows.h>
# include <bcrypt.h>
# if !HAVE_LIB_BCRYPT
# include <wincrypt.h>
# ifndef CRYPT_VERIFY_CONTEXT
# define CRYPT_VERIFY_CONTEXT 0xF0000000
# endif
# endif
#endif
#include "minmax.h"
#if defined _WIN32 && ! defined __CYGWIN__
/* Don't assume that UNICODE is not defined. */
# undef LoadLibrary
# define LoadLibrary LoadLibraryA
# undef CryptAcquireContext
# define CryptAcquireContext CryptAcquireContextA
# if !HAVE_LIB_BCRYPT
/* Avoid warnings from gcc -Wcast-function-type. */
# define GetProcAddress \
(void *) GetProcAddress
/* BCryptGenRandom with the BCRYPT_USE_SYSTEM_PREFERRED_RNG flag works only
starting with Windows 7. */
typedef NTSTATUS (WINAPI * BCryptGenRandomFuncType) (BCRYPT_ALG_HANDLE, UCHAR *, ULONG, ULONG);
static BCryptGenRandomFuncType BCryptGenRandomFunc = NULL;
static BOOL initialized = FALSE;
static void
initialize (void)
{
HMODULE bcrypt = LoadLibrary ("bcrypt.dll");
if (bcrypt != NULL)
{
BCryptGenRandomFunc =
(BCryptGenRandomFuncType) GetProcAddress (bcrypt, "BCryptGenRandom");
}
initialized = TRUE;
}
# else
# define BCryptGenRandomFunc BCryptGenRandom
# endif
#else
/* These devices exist on all platforms except native Windows. */
/* Name of a device through which the kernel returns high quality random
numbers, from an entropy pool. When the pool is empty, the call blocks
until entropy sources have added enough bits of entropy. */
# ifndef NAME_OF_RANDOM_DEVICE
# define NAME_OF_RANDOM_DEVICE "/dev/random"
# endif
/* Name of a device through which the kernel returns random or pseudo-random
numbers. It uses an entropy pool, but, in order to avoid blocking, adds
bits generated by a pseudo-random number generator, as needed. */
# ifndef NAME_OF_NONCE_DEVICE
# define NAME_OF_NONCE_DEVICE "/dev/urandom"
# endif
#endif
/* Set BUFFER (of size LENGTH) to random bytes under the control of FLAGS.
Return the number of bytes written (> 0).
Upon error, return -1 and set errno. */
ssize_t
getrandom (void *buffer, size_t length, unsigned int flags)
#undef getrandom
{
#if defined _WIN32 && ! defined __CYGWIN__
/* BCryptGenRandom, defined in <bcrypt.h>
<https://docs.microsoft.com/en-us/windows/win32/api/bcrypt/nf-bcrypt-bcryptgenrandom>
with the BCRYPT_USE_SYSTEM_PREFERRED_RNG flag
works in Windows 7 and newer. */
static int bcrypt_not_working /* = 0 */;
if (!bcrypt_not_working)
{
# if !HAVE_LIB_BCRYPT
if (!initialized)
initialize ();
# endif
if (BCryptGenRandomFunc != NULL
&& BCryptGenRandomFunc (NULL, buffer, length,
BCRYPT_USE_SYSTEM_PREFERRED_RNG)
== 0 /*STATUS_SUCCESS*/)
return length;
bcrypt_not_working = 1;
}
# if !HAVE_LIB_BCRYPT
/* CryptGenRandom, defined in <wincrypt.h>
<https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptgenrandom>
works in older releases as well, but is now deprecated.
CryptAcquireContext, defined in <wincrypt.h>
<https://docs.microsoft.com/en-us/windows/win32/api/wincrypt/nf-wincrypt-cryptacquirecontexta> */
{
static int crypt_initialized /* = 0 */;
static HCRYPTPROV provider;
if (!crypt_initialized)
{
if (CryptAcquireContext (&provider, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFY_CONTEXT))
crypt_initialized = 1;
else
crypt_initialized = -1;
}
if (crypt_initialized >= 0)
{
if (!CryptGenRandom (provider, length, buffer))
{
errno = EIO;
return -1;
}
return length;
}
}
# endif
errno = ENOSYS;
return -1;
#elif HAVE_GETRANDOM
return getrandom (buffer, length, flags);
#else
static int randfd[2] = { -1, -1 };
bool devrandom = (flags & GRND_RANDOM) != 0;
int fd = randfd[devrandom];
if (fd < 0)
{
static char const randdevice[][MAX (sizeof NAME_OF_NONCE_DEVICE,
sizeof NAME_OF_RANDOM_DEVICE)]
= { NAME_OF_NONCE_DEVICE, NAME_OF_RANDOM_DEVICE };
int oflags = (O_RDONLY + O_CLOEXEC
+ (flags & GRND_NONBLOCK ? O_NONBLOCK : 0));
fd = open (randdevice[devrandom], oflags);
if (fd < 0)
return fd;
randfd[devrandom] = fd;
}
return read (fd, buffer, length);
#endif
}
......@@ -33,9 +33,15 @@
#ifdef WINDOWS_NATIVE
/* Don't assume that UNICODE is not defined. */
# undef LoadLibrary
# define LoadLibrary LoadLibraryA
# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8)
/* Avoid warnings from gcc -Wcast-function-type. */
# define GetProcAddress \
(void *) GetProcAddress
# define GetProcAddress \
(void *) GetProcAddress
/* GetSystemTimePreciseAsFileTime was introduced only in Windows 8. */
typedef void (WINAPI * GetSystemTimePreciseAsFileTimeFuncType) (FILETIME *lpTime);
......@@ -54,6 +60,12 @@ initialize (void)
initialized = TRUE;
}
# else
# define GetSystemTimePreciseAsFileTimeFunc GetSystemTimePreciseAsFileTime
# endif
#endif
/* This is a wrapper for gettimeofday. It is used only on systems
......@@ -84,8 +96,10 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
<http://www.windowstimestamp.com/description>. */
FILETIME current_time;
# if !(_WIN32_WINNT >= _WIN32_WINNT_WIN8)
if (!initialized)
initialize ();
# endif
if (GetSystemTimePreciseAsFileTimeFunc != NULL)
GetSystemTimePreciseAsFileTimeFunc (&current_time);
else
......
......@@ -311,6 +311,7 @@ GNULIB_GETCWD = @GNULIB_GETCWD@
GNULIB_GETDELIM = @GNULIB_GETDELIM@
GNULIB_GETDOMAINNAME = @GNULIB_GETDOMAINNAME@
GNULIB_GETDTABLESIZE = @GNULIB_GETDTABLESIZE@
GNULIB_GETENTROPY = @GNULIB_GETENTROPY@
GNULIB_GETGROUPS = @GNULIB_GETGROUPS@
GNULIB_GETHOSTNAME = @GNULIB_GETHOSTNAME@
GNULIB_GETLINE = @GNULIB_GETLINE@
......@@ -320,6 +321,7 @@ GNULIB_GETLOGIN_R = @GNULIB_GETLOGIN_R@
GNULIB_GETOPT_POSIX = @GNULIB_GETOPT_POSIX@
GNULIB_GETPAGESIZE = @GNULIB_GETPAGESIZE@
GNULIB_GETPASS = @GNULIB_GETPASS@
GNULIB_GETRANDOM = @GNULIB_GETRANDOM@
GNULIB_GETSUBOPT = @GNULIB_GETSUBOPT@
GNULIB_GETTIMEOFDAY = @GNULIB_GETTIMEOFDAY@
GNULIB_GETUSERSHELL = @GNULIB_GETUSERSHELL@
......@@ -565,12 +567,14 @@ HAVE_FTELLO = @HAVE_FTELLO@
HAVE_FTRUNCATE = @HAVE_FTRUNCATE@
HAVE_FUTIMENS = @HAVE_FUTIMENS@
HAVE_GETDTABLESIZE = @HAVE_GETDTABLESIZE@
HAVE_GETENTROPY = @HAVE_GETENTROPY@
HAVE_GETGROUPS = @HAVE_GETGROUPS@
HAVE_GETHOSTNAME = @HAVE_GETHOSTNAME@
HAVE_GETLOGIN = @HAVE_GETLOGIN@
HAVE_GETOPT_H = @HAVE_GETOPT_H@
HAVE_GETPAGESIZE = @HAVE_GETPAGESIZE@
HAVE_GETPASS = @HAVE_GETPASS@
HAVE_GETRANDOM = @HAVE_GETRANDOM@
HAVE_GETSUBOPT = @HAVE_GETSUBOPT@
HAVE_GETTIMEOFDAY = @HAVE_GETTIMEOFDAY@
HAVE_GRANTPT = @HAVE_GRANTPT@
......@@ -667,6 +671,7 @@ HAVE_SYS_CDEFS_H = @HAVE_SYS_CDEFS_H@
HAVE_SYS_INTTYPES_H = @HAVE_SYS_INTTYPES_H@
HAVE_SYS_LOADAVG_H = @HAVE_SYS_LOADAVG_H@
HAVE_SYS_PARAM_H = @HAVE_SYS_PARAM_H@
HAVE_SYS_RANDOM_H = @HAVE_SYS_RANDOM_H@
HAVE_SYS_SELECT_H = @HAVE_SYS_SELECT_H@
HAVE_SYS_TIME_H = @HAVE_SYS_TIME_H@
HAVE_SYS_TYPES_H = @HAVE_SYS_TYPES_H@
......@@ -753,6 +758,7 @@ LIB_ACL = @LIB_ACL@
LIB_CLOCK_GETTIME = @LIB_CLOCK_GETTIME@
LIB_EACCESS = @LIB_EACCESS@
LIB_EXECINFO = @LIB_EXECINFO@
LIB_GETRANDOM = @LIB_GETRANDOM@
LIB_MATH = @LIB_MATH@
LIB_PTHREAD = @LIB_PTHREAD@
LIB_PTHREAD_SIGMASK = @LIB_PTHREAD_SIGMASK@
......@@ -782,6 +788,7 @@ NEXT_AS_FIRST_DIRECTIVE_STDINT_H = @NEXT_AS_FIRST_DIRECTIVE_STDINT_H@
NEXT_AS_FIRST_DIRECTIVE_STDIO_H = @NEXT_AS_FIRST_DIRECTIVE_STDIO_H@
NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = @NEXT_AS_FIRST_DIRECTIVE_STDLIB_H@
NEXT_AS_FIRST_DIRECTIVE_STRING_H = @NEXT_AS_FIRST_DIRECTIVE_STRING_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_RANDOM_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_RANDOM_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_SELECT_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H@
NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = @NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H@
......@@ -800,6 +807,7 @@ NEXT_STDINT_H = @NEXT_STDINT_H@
NEXT_STDIO_H = @NEXT_STDIO_H@
NEXT_STDLIB_H = @NEXT_STDLIB_H@
NEXT_STRING_H = @NEXT_STRING_H@
NEXT_SYS_RANDOM_H = @NEXT_SYS_RANDOM_H@
NEXT_SYS_SELECT_H = @NEXT_SYS_SELECT_H@
NEXT_SYS_STAT_H = @NEXT_SYS_STAT_H@
NEXT_SYS_TIME_H = @NEXT_SYS_TIME_H@
......@@ -884,6 +892,7 @@ REPLACE_GETLINE = @REPLACE_GETLINE@
REPLACE_GETLOGIN_R = @REPLACE_GETLOGIN_R@
REPLACE_GETPAGESIZE = @REPLACE_GETPAGESIZE@
REPLACE_GETPASS = @REPLACE_GETPASS@
REPLACE_GETRANDOM = @REPLACE_GETRANDOM@
REPLACE_GETTIMEOFDAY = @REPLACE_GETTIMEOFDAY@
REPLACE_GMTIME = @REPLACE_GMTIME@
REPLACE_INITSTATE = @REPLACE_INITSTATE@
......@@ -1003,6 +1012,7 @@ UINT64_MAX_EQ_ULONG_MAX = @UINT64_MAX_EQ_ULONG_MAX@
UNDEFINE_STRTOK_R = @UNDEFINE_STRTOK_R@
UNEXEC_OBJ = @UNEXEC_OBJ@
UNISTD_H_DEFINES_STRUCT_TIMESPEC = @UNISTD_H_DEFINES_STRUCT_TIMESPEC@
UNISTD_H_HAVE_SYS_RANDOM_H = @UNISTD_H_HAVE_SYS_RANDOM_H@
UNISTD_H_HAVE_WINSOCK2_H = @UNISTD_H_HAVE_WINSOCK2_H@
UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = @UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS@
USE_ACL = @USE_ACL@
......@@ -1072,7 +1082,6 @@ gamegroup = @gamegroup@
gameuser = @gameuser@
gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7 = @gl_GNULIB_ENABLED_03e0aaad4cb89ca757653bd367a6ccb7@
gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9 = @gl_GNULIB_ENABLED_2049e887c7e5308faad27b3f894bb8c9@
gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467 = @gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467@
gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b = @gl_GNULIB_ENABLED_260941c0e5dc67ec9e87d1fb321c300b@
gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31 = @gl_GNULIB_ENABLED_5264294aa0a5557541b53c8c741f7f31@
gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c = @gl_GNULIB_ENABLED_6099e9737f757db36c47fa9d9f02e88c@
......@@ -1086,7 +1095,6 @@ gl_GNULIB_ENABLED_getdtablesize = @gl_GNULIB_ENABLED_getdtablesize@
gl_GNULIB_ENABLED_getgroups = @gl_GNULIB_ENABLED_getgroups@
gl_GNULIB_ENABLED_lchmod = @gl_GNULIB_ENABLED_lchmod@
gl_GNULIB_ENABLED_malloca = @gl_GNULIB_ENABLED_malloca@
gl_GNULIB_ENABLED_open = @gl_GNULIB_ENABLED_open@
gl_GNULIB_ENABLED_strtoll = @gl_GNULIB_ENABLED_strtoll@
gl_GNULIB_ENABLED_utimens = @gl_GNULIB_ENABLED_utimens@
gl_LIBOBJS = @gl_LIBOBJS@
......@@ -1831,6 +1839,17 @@ EXTRA_libgnu_a_SOURCES += getopt.c getopt1.c
endif
## end gnulib module getopt-posix
## begin gnulib module getrandom
ifeq (,$(OMIT_GNULIB_MODULE_getrandom))
EXTRA_DIST += getrandom.c
EXTRA_libgnu_a_SOURCES += getrandom.c
endif
## end gnulib module getrandom
## begin gnulib module gettext-h
ifeq (,$(OMIT_GNULIB_MODULE_gettext-h))
......@@ -1988,9 +2007,7 @@ endif
## begin gnulib module libc-config
ifeq (,$(OMIT_GNULIB_MODULE_libc-config))
ifneq (,$(gl_GNULIB_ENABLED_21ee726a3540c09237a8e70c0baf7467))
endif
EXTRA_DIST += cdefs.h libc-config.h
endif
......@@ -2151,9 +2168,7 @@ endif
## begin gnulib module open
ifeq (,$(OMIT_GNULIB_MODULE_open))
ifneq (,$(gl_GNULIB_ENABLED_open))
endif
EXTRA_DIST += open.c
EXTRA_libgnu_a_SOURCES += open.c
......@@ -2906,6 +2921,40 @@ EXTRA_libgnu_a_SOURCES += symlink.c
endif
## end gnulib module symlink
## begin gnulib module sys_random
ifeq (,$(OMIT_GNULIB_MODULE_sys_random))
BUILT_SOURCES += sys/random.h
# We need the following in order to create <sys/random.h> when the system
# doesn't have one.
sys/random.h: sys_random.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H) $(WARN_ON_USE_H)
$(AM_V_at)$(MKDIR_P) sys
$(AM_V_GEN)rm -f $@-t $@ && \
{ echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
sed -e 's|@''GUARD_PREFIX''@|GL|g' \
-e 's|@''INCLUDE_NEXT''@|$(INCLUDE_NEXT)|g' \
-e 's|@''PRAGMA_SYSTEM_HEADER''@|@PRAGMA_SYSTEM_HEADER@|g' \
-e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \
-e 's|@''NEXT_SYS_RANDOM_H''@|$(NEXT_SYS_RANDOM_H)|g' \
-e 's|@''HAVE_SYS_RANDOM_H''@|$(HAVE_SYS_RANDOM_H)|g' \
-e 's/@''GNULIB_GETRANDOM''@/$(GNULIB_GETRANDOM)/g' \
-e 's/@''HAVE_GETRANDOM''@/$(HAVE_GETRANDOM)/g' \
-e 's/@''REPLACE_GETRANDOM''@/$(REPLACE_GETRANDOM)/g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
-e '/definition of _GL_ARG_NONNULL/r $(ARG_NONNULL_H)' \
-e '/definition of _GL_WARN_ON_USE/r $(WARN_ON_USE_H)' \
< $(srcdir)/sys_random.in.h; \
} > $@-t && \
mv -f $@-t $@
MOSTLYCLEANFILES += sys/random.h sys/random.h-t
MOSTLYCLEANDIRS += sys
EXTRA_DIST += sys_random.in.h
endif
## end gnulib module sys_random
## begin gnulib module sys_select
ifeq (,$(OMIT_GNULIB_MODULE_sys_select))
......@@ -3246,6 +3295,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's/@''GNULIB_GETCWD''@/$(GNULIB_GETCWD)/g' \
-e 's/@''GNULIB_GETDOMAINNAME''@/$(GNULIB_GETDOMAINNAME)/g' \
-e 's/@''GNULIB_GETDTABLESIZE''@/$(GNULIB_GETDTABLESIZE)/g' \
-e 's/@''GNULIB_GETENTROPY''@/$(GNULIB_GETENTROPY)/g' \
-e 's/@''GNULIB_GETGROUPS''@/$(GNULIB_GETGROUPS)/g' \
-e 's/@''GNULIB_GETHOSTNAME''@/$(GNULIB_GETHOSTNAME)/g' \
-e 's/@''GNULIB_GETLOGIN''@/$(GNULIB_GETLOGIN)/g' \
......@@ -3294,6 +3344,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''HAVE_FSYNC''@|$(HAVE_FSYNC)|g' \
-e 's|@''HAVE_FTRUNCATE''@|$(HAVE_FTRUNCATE)|g' \
-e 's|@''HAVE_GETDTABLESIZE''@|$(HAVE_GETDTABLESIZE)|g' \
-e 's|@''HAVE_GETENTROPY''@|$(HAVE_GETENTROPY)|g' \
-e 's|@''HAVE_GETGROUPS''@|$(HAVE_GETGROUPS)|g' \
-e 's|@''HAVE_GETHOSTNAME''@|$(HAVE_GETHOSTNAME)|g' \
-e 's|@''HAVE_GETPAGESIZE''@|$(HAVE_GETPAGESIZE)|g' \
......@@ -3363,6 +3414,7 @@ unistd.h: unistd.in.h $(top_builddir)/config.status $(CXXDEFS_H) $(ARG_NONNULL_H
-e 's|@''REPLACE_UNLINKAT''@|$(REPLACE_UNLINKAT)|g' \
-e 's|@''REPLACE_USLEEP''@|$(REPLACE_USLEEP)|g' \
-e 's|@''REPLACE_WRITE''@|$(REPLACE_WRITE)|g' \
-e 's|@''UNISTD_H_HAVE_SYS_RANDOM_H''@|$(UNISTD_H_HAVE_SYS_RANDOM_H)|g' \
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H''@|$(UNISTD_H_HAVE_WINSOCK2_H)|g' \
-e 's|@''UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS''@|$(UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS)|g' \
-e '/definitions of _GL_FUNCDECL_RPL/r $(CXXDEFS_H)' \
......
......@@ -180,4 +180,5 @@
/* A substitute for glibc <shlib-compat.h>, good enough for Gnulib. */
#define SHLIB_COMPAT(lib, introduced, obsoleted) 0
#define versioned_symbol(lib, local, symbol, version)
#define compat_symbol(lib, local, symbol, version) extern int dummy
#define versioned_symbol(lib, local, symbol, version) extern int dummy
......@@ -124,7 +124,7 @@ open (const char *filename, int flags, ...)
#endif
fd = orig_open (filename,
flags & ~(have_cloexec <= 0 ? O_CLOEXEC : 0), mode);
flags & ~(have_cloexec < 0 ? O_CLOEXEC : 0), mode);
if (flags & O_CLOEXEC)
{
......
......@@ -73,8 +73,9 @@ openat_proc_name (char buf[OPENAT_BUFFER_SIZE], int fd, char const *file)
problem is exhibited on code that built on Solaris 8 and
running on Solaris 10. */
int proc_self_fd = open ("/proc/self/fd",
O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK);
int proc_self_fd =
open ("/proc/self/fd",
O_SEARCH | O_DIRECTORY | O_NOCTTY | O_NONBLOCK | O_CLOEXEC);
if (proc_self_fd < 0)
proc_status = -1;
else
......
/* Substitute for <sys/random.h>.
Copyright (C) 2020 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see <https://www.gnu.org/licenses/>. */
# if __GNUC__ >= 3
@PRAGMA_SYSTEM_HEADER@
# endif
@PRAGMA_COLUMNS@
#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
#if @HAVE_SYS_RANDOM_H@
/* On Mac OS X 10.5, <sys/random.h> assumes prior inclusion of <sys/types.h>.
On Max OS X 10.13, <sys/random.h> assumes prior inclusion of a file that
includes <Availability.h>, such as <stdlib.h> or <unistd.h>. */
# if defined __APPLE__ && defined __MACH__ /* Mac OS X */
# include <sys/types.h>
# include <stdlib.h>
# endif
/* The include_next requires a split double-inclusion guard. */
# @INCLUDE_NEXT@ @NEXT_SYS_RANDOM_H@
#endif
#ifndef _@GUARD_PREFIX@_SYS_RANDOM_H
#define _@GUARD_PREFIX@_SYS_RANDOM_H
#include <sys/types.h>
/* Define the GRND_* constants. */
#ifndef GRND_NONBLOCK
# define GRND_NONBLOCK 1
# define GRND_RANDOM 2
#endif
/* The definitions of _GL_FUNCDECL_RPL etc. are copied here. */
/* The definition of _GL_ARG_NONNULL is copied here. */
/* The definition of _GL_WARN_ON_USE is copied here. */
/* Declare overridden functions. */
#if @GNULIB_GETRANDOM@
/* Fill a buffer with random bytes. */
# if @REPLACE_GETRANDOM@
# if !(defined __cplusplus && defined GNULIB_NAMESPACE)
# undef getrandom
# define getrandom rpl_getrandom
# endif
_GL_FUNCDECL_RPL (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags)
_GL_ARG_NONNULL ((1)));
_GL_CXXALIAS_RPL (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags));
# else
# if !@HAVE_GETRANDOM@
_GL_FUNCDECL_SYS (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags)
_GL_ARG_NONNULL ((1)));
# endif
_GL_CXXALIAS_SYS (getrandom, ssize_t,
(void *buffer, size_t length, unsigned int flags));
# endif
_GL_CXXALIASWARN (getrandom);
#elif defined GNULIB_POSIXCHECK
# undef getrandom
# if HAVE_RAW_DECL_GETRANDOM
_GL_WARN_ON_USE (getrandom, "getrandom is unportable - "
"use gnulib module getrandom for portability");
# endif
#endif
#endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */
#endif /* _@GUARD_PREFIX@_SYS_RANDOM_H */
This diff is collapsed.
......@@ -50,6 +50,9 @@ extern "C" {
We use a clever algorithm to get hard-to-predict names. */
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
/* Similar, except X_SUFFIX_LEN gives the number of Xs. */
extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
size_t x_suffix_len);
/* Similar to gen_tempname, but TRYFUNC is called for each temporary
name to try. If TRYFUNC returns a non-negative number, TRY_GEN_TEMPNAME
......@@ -57,6 +60,10 @@ extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
name is tried, or else TRY_GEN_TEMPNAME returns -1. */
extern int try_tempname (char *tmpl, int suffixlen, void *args,
int (*tryfunc) (char *, void *));
/* Similar, except X_SUFFIX_LEN gives the number of Xs. */
extern int try_tempname_len (char *tmpl, int suffixlen, void *args,
int (*tryfunc) (char *, void *),
size_t x_suffix_len);
#ifdef __cplusplus
}
......
......@@ -118,6 +118,17 @@
# include <netdb.h>
#endif
/* Mac OS X 10.13, Solaris 11.4, and Android 9.0 declare getentropy in
<sys/random.h>, not in <unistd.h>. */
/* But avoid namespace pollution on glibc systems. */
#if (@GNULIB_GETENTROPY@ || defined GNULIB_POSIXCHECK) \
&& ((defined __APPLE__ && defined __MACH__) || defined __sun \
|| defined __ANDROID__) \
&& @UNISTD_H_HAVE_SYS_RANDOM_H@ \
&& !defined __GLIBC__
# include <sys/random.h>
#endif
/* Android 4.3 declares fchownat in <sys/stat.h>, not in <unistd.h>. */
/* But avoid namespace pollution on glibc systems. */
#if (@GNULIB_FCHOWNAT@ || defined GNULIB_POSIXCHECK) && defined __ANDROID__ \
......@@ -763,6 +774,22 @@ _GL_WARN_ON_USE (getdtablesize, "getdtablesize is unportable - "
#endif
#if @GNULIB_GETENTROPY@
/* Fill a buffer with random bytes. */
# if !@HAVE_GETENTROPY@
_GL_FUNCDECL_SYS (getentropy, int, (void *buffer, size_t length));
# endif
_GL_CXXALIAS_SYS (getentropy, int, (void *buffer, size_t length));
_GL_CXXALIASWARN (getentropy);
#elif defined GNULIB_POSIXCHECK
# undef getentropy
# if HAVE_RAW_DECL_GETENTROPY
_GL_WARN_ON_USE (getentropy, "getentropy is unportable - "
"use gnulib module getentropy for portability");
# endif
#endif
#if @GNULIB_GETGROUPS@
/* Return the supplemental groups that the current process belongs to.
It is unspecified whether the effective group id is in the list.
......
......@@ -277,10 +277,22 @@ template <int w>
#endif
/* Assume that R always holds. Behavior is undefined if R is false,
fails to evaluate, or has side effects. Although assuming R can
help a compiler generate better code or diagnostics, performance
can suffer if R uses hard-to-optimize features such as function
calls not inlined by the compiler. */
fails to evaluate, or has side effects.
'assume (R)' is a directive from the programmer telling the
compiler that R is true so the compiler needn't generate code to
test R. This is why 'assume' is in verify.h: it's related to
static checking (in this case, static checking done by the
programmer), not dynamic checking.
'assume (R)' can affect compilation of all the code, not just code
that happens to be executed after the assume (R) is "executed".
For example, if the code mistakenly does 'assert (R); assume (R);'
the compiler is entitled to optimize away the 'assert (R)'.
Although assuming R can help a compiler generate better code or
diagnostics, performance can suffer if R uses hard-to-optimize
features such as function calls not inlined by the compiler. */
#if _GL_HAS_BUILTIN_UNREACHABLE
# define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
......
......@@ -396,7 +396,7 @@ Matches the visited file name against the elements of `auto-insert-alist'."
;; which might ask the user for something
(switch-to-buffer (current-buffer))
(if (and (consp action)
(not (eq (car action) 'lambda)))
(not (functionp action)))
(skeleton-insert action)
(funcall action)))))
(if (vectorp action)
......
......@@ -348,6 +348,7 @@ If SEQUENCE is empty, return INITIAL-VALUE and FUNCTION is not called."
(setq acc (funcall function acc elt)))
acc)))
;;;###autoload
(cl-defgeneric seq-every-p (pred sequence)
"Return non-nil if (PRED element) is non-nil for all elements of SEQUENCE."
(catch 'seq--break
......
......@@ -1070,6 +1070,22 @@ that variable should be nil."
(setq arg (1+ arg)))
(select-frame-set-input-focus frame)))
(defun other-frame-prefix ()
"Display the buffer of the next command in a new frame.
The next buffer is the buffer displayed by the next command invoked
immediately after this command (ignoring reading from the minibuffer).
Creates a new frame before displaying the buffer.
When `switch-to-buffer-obey-display-actions' is non-nil,
`switch-to-buffer' commands are also supported."
(interactive)
(display-buffer-override-next-command
(lambda (buffer alist)
(cons (display-buffer-pop-up-frame
buffer (append '((inhibit-same-window . t))
alist))
'frame)))
(message "Display next command buffer in a new frame..."))
(defun iconify-or-deiconify-frame ()
"Iconify the selected frame, or deiconify if it's currently an icon."
(interactive)
......@@ -2697,6 +2713,7 @@ See also `toggle-frame-maximized'."
(define-key ctl-x-5-map "1" 'delete-other-frames)
(define-key ctl-x-5-map "0" 'delete-frame)
(define-key ctl-x-5-map "o" 'other-frame)
(define-key ctl-x-5-map "5" 'other-frame-prefix)
(define-key global-map [f11] 'toggle-frame-fullscreen)
(define-key global-map [(meta f10)] 'toggle-frame-maximized)
(define-key esc-map [f10] 'toggle-frame-maximized)
......
......@@ -478,8 +478,7 @@ Otherwise, returns the Gnus Cloud data chunks."
(push (gnus-cloud-parse-chunk) chunks)
(forward-line 1))))
(if update
(progn
(mapc #'gnus-cloud-update-all chunks)
(prog1 (mapcar #'gnus-cloud-update-all chunks)
(setq gnus-cloud-sequence highest-sequence-seen))
chunks)))
......
......@@ -2265,7 +2265,8 @@ End of submatch 0, 1, and 3 are the same, so you can safely concat."
(match-string-no-properties 1)))
(defun Info-next ()
"Go to the next node of this node."
"Go to the \"next\" node, staying on the same hierarchical level.
This command doesn't descend into sub-nodes, like \\<Info-mode-map>\\[Info-forward-node] does."
(interactive)
;; In case another window is currently selected
(save-window-excursion
......@@ -2273,7 +2274,8 @@ End of submatch 0, 1, and 3 are the same, so you can safely concat."
(Info-goto-node (Info-extract-pointer "next"))))
(defun Info-prev ()
"Go to the previous node of this node."
"Go to the \"previous\" node, staying on the same hierarchical level.
This command doesn't go up to the parent node, like \\<Info-mode-map>\\[Info-backward-node] does."
(interactive)
;; In case another window is currently selected
(save-window-excursion
......@@ -2887,7 +2889,13 @@ N is the digit argument used to invoke this command."
(Info-goto-node (Info-extract-menu-counting nil)))))
(defun Info-forward-node (&optional not-down not-up no-error)
"Go forward one node, considering all nodes as forming one sequence."
"Go forward one node, considering all nodes as forming one sequence.
Interactively, if the current node has sub-nodes, descend into the first
sub-node; otherwise go to the \"next\" node, if it exists, else go \"up\"
to the parent node.
When called from Lisp, NOT-DOWN non-nil means don't descend into sub-nodes,
NOT-UP non-nil means don't go to parent nodes, and NO-ERROR non-nil means
don't signal a user-error if there's no node to go to."
(interactive)
(goto-char (point-min))
(forward-line 1)
......@@ -2922,7 +2930,9 @@ N is the digit argument used to invoke this command."
(t (user-error "No pointer forward from this node")))))
(defun Info-backward-node ()
"Go backward one node, considering all nodes as forming one sequence."
"Go backward one node, considering all nodes as forming one sequence.
If the current node has a \"previous\" node, go to it, descending into its
last sub-node, if any; otherwise go \"up\" to the parent node."
(interactive)
(let ((prevnode (Info-extract-pointer "prev[ious]*" t))
(upnode (Info-extract-pointer "up" t))
......