bpo-32493: Fix uuid.uuid1() on FreeBSD. (GH-7099)


Use uuid_enc_be() if available to encode UUID to bytes as big endian.
(cherry picked from commit 17d8830312d82e7de42ab89739b0771f712645ff)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
diff --git a/configure.ac b/configure.ac
index 2535969..5948904 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2742,6 +2742,21 @@
   [AC_MSG_RESULT(no)]
 )
 
+# Little-endian FreeBSD, OpenBSD and NetBSD needs encoding into an octet
+# stream in big-endian byte-order
+AC_MSG_CHECKING(for uuid_enc_be)
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <uuid.h>]], [[
+#ifndef uuid_enc_be
+uuid_t uuid;
+unsigned char buf[sizeof(uuid)];
+uuid_enc_be(buf, &uuid);
+#endif
+]])],
+  [AC_DEFINE(HAVE_UUID_ENC_BE, 1, Define if uuid_enc_be() exists.)
+   AC_MSG_RESULT(yes)],
+  [AC_MSG_RESULT(no)]
+)
+
 # 'Real Time' functions on Solaris
 # posix4 on Solaris 2.6
 # pthread (first!) on Linux