[issue28676] On macOS Sierra, warning: implicit declaration of function 'getentropy'

Gareth Rees report at bugs.python.org
Sat Nov 12 14:30:20 EST 2016


New submission from Gareth Rees:

On macOS Sierra (OSX 10.12.1):

    $ ./configure --with-pydebug && make
    [... lots of output omitted ...]
    gcc -c -Wno-unused-result -Wsign-compare -g -O0 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include    -DPy_BUILD_CORE -o Python/random.o Python/random.c
    Python/random.c:97:19: warning: implicit declaration of function 'getentropy' is
          invalid in C99 [-Wimplicit-function-declaration]
                res = getentropy(buffer, len);
                      ^
    1 warning generated.

This is because OSX 10.12.1 has getentropy() but does not have
getrandom(). You can see this in pyconfig.h:

    /* Define to 1 if you have the `getentropy' function. */
    #define HAVE_GETENTROPY 1

    /* Define to 1 if the getrandom() function is available */
    /* #undef HAVE_GETRANDOM */

and this means that in Python/random.c the header <sys/random.h> is
not included:

    #  ifdef HAVE_GETRANDOM
    #    include <sys/random.h>
    #  elif defined(HAVE_GETRANDOM_SYSCALL)
    #    include <sys/syscall.h>
    #  endif

It's necessary include <sys/random.h> if either HAVE_GETRANDOM or
HAVE_GETENTROPY is defined.

----------
components: Build, macOS
files: getentropy.patch
keywords: patch
messages: 280669
nosy: Gareth.Rees, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: On macOS Sierra, warning: implicit declaration of function 'getentropy'
type: compile error
versions: Python 3.7
Added file: http://bugs.python.org/file45465/getentropy.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28676>
_______________________________________


More information about the Python-bugs-list mailing list