-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python314-devel: add compatibility patches for macOS < 10.15
- Loading branch information
1 parent
e0d531d
commit 27ca4c1
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
lang/python314-devel/files/patch-lib-memzero0-remove-memset-s.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
memset_s() is not available on macOS < 10.9, use simple volatile implementation. | ||
--- Modules/_hacl/Lib_Memzero0.c | ||
+++ Modules/_hacl/Lib_Memzero0.c | ||
@@ -8,6 +8,10 @@ | ||
#include <windows.h> | ||
#endif | ||
|
||
+#if defined(__APPLE__) && defined(__MACH__) | ||
+#include <AvailabilityMacros.h> | ||
+#endif | ||
+ | ||
#if (defined(__APPLE__) && defined(__MACH__)) || defined(__linux__) | ||
#define __STDC_WANT_LIB_EXT1__ 1 | ||
#include <string.h> | ||
@@ -37,7 +41,7 @@ void Lib_Memzero0_memzero0(void *dst, uint64_t len) { | ||
|
||
#ifdef _WIN32 | ||
SecureZeroMemory(dst, len_); | ||
- #elif defined(__APPLE__) && defined(__MACH__) | ||
+ #elif defined(__APPLE__) && defined(__MACH__) && defined(MAC_OS_X_VERSION_MIN_REQUIRED) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1090) | ||
memset_s(dst, len_, 0, len_); | ||
#elif (defined(__linux__) && !defined(LINUX_NO_EXPLICIT_BZERO)) || defined(__FreeBSD__) | ||
explicit_bzero(dst, len_); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
There is no support for aligned_malloc() in macOS < 10.15. Instead of blocking SIMD, just fallback to using _mm_malloc(). | ||
--- Modules/_hacl/include/krml/internal/target.h | ||
+++ Modules/_hacl/include/krml/internal/target.h | ||
@@ -19,6 +19,11 @@ | ||
# define inline __inline__ | ||
#endif | ||
|
||
+/* Include Apple-specific macros for use in defining KRML_ALIGNED_MALLOC. */ | ||
+#if defined(__APPLE__) && defined(__MACH__) | ||
+#include <AvailabilityMacros.h> | ||
+#endif | ||
+ | ||
/******************************************************************************/ | ||
/* Macros that KaRaMeL will generate. */ | ||
/******************************************************************************/ | ||
@@ -123,7 +128,8 @@ | ||
#endif | ||
|
||
/* MinGW-W64 does not support C11 aligned_alloc, but it supports | ||
- * MSVC's _aligned_malloc. | ||
+ * MSVC's _aligned_malloc. Also, fallback to use mm_malloc.h | ||
+ * implementation for macOS systems prior to 10.15 Catalina. | ||
*/ | ||
#ifndef KRML_ALIGNED_MALLOC | ||
# ifdef __MINGW32__ | ||
@@ -133,6 +139,11 @@ | ||
defined(_MSC_VER) || \ | ||
(defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR))) | ||
# define KRML_ALIGNED_MALLOC(X, Y) _aligned_malloc(Y, X) | ||
+# elif defined(__APPLE__) && defined(__MACH__) && \ | ||
+ defined(MAC_OS_X_VERSION_MIN_REQUIRED) && \ | ||
+ (MAC_OS_X_VERSION_MIN_REQUIRED < 101500) | ||
+# include <mm_malloc.h> | ||
+# define KRML_ALIGNED_MALLOC(X, Y) _mm_malloc(Y, X) | ||
# else | ||
# define KRML_ALIGNED_MALLOC(X, Y) aligned_alloc(X, Y) | ||
# endif |