aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-08-03 12:52:39 -0500
committerAlex Gaynor <alex.gaynor@gmail.com>2017-08-03 13:52:39 -0400
commitd026b1b226f97991cbf1994521fd1260eb27a762 (patch)
tree12c7a4ad500dd83e5dde2b6ba4bc4b69d2a5dba7 /src
parent765e771b1148755eb2344dd46747c7f853c62a52 (diff)
downloadcryptography-d026b1b226f97991cbf1994521fd1260eb27a762.tar.gz
cryptography-d026b1b226f97991cbf1994521fd1260eb27a762.tar.bz2
cryptography-d026b1b226f97991cbf1994521fd1260eb27a762.zip
Fix weak linking of getentropy when compiling on older macOS (#3841)
* Fix weak linking of getentropy when compiling on older macOS We use weak linking in macOS to determine if the getentropy symbol is available. However, to do that we need to have a declaration that states the function is __attribute((weak_import)) at compile time. On macOS 10.12 this is provided in sys/random.h, but on older macOS the declaration doesn't exist at all, so we need to forward declare it ourselves. * update a comment and a style nit
Diffstat (limited to 'src')
-rw-r--r--src/_cffi_src/openssl/src/osrandom_engine.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/_cffi_src/openssl/src/osrandom_engine.h b/src/_cffi_src/openssl/src/osrandom_engine.h
index c400ea3e..077046d9 100644
--- a/src/_cffi_src/openssl/src/osrandom_engine.h
+++ b/src/_cffi_src/openssl/src/osrandom_engine.h
@@ -13,6 +13,9 @@
#ifdef __APPLE__
#include <sys/random.h>
+ /* To support weak linking we need to declare this as a weak import even if
+ * it's not present in sys/random (e.g. macOS < 10.12). */
+ extern int getentropy(void *buffer, size_t size) __attribute((weak_import));
#endif
#ifdef __linux__