office-gobmx/external/python3/macos-11.patch.0
Tor Lillqvist ff270d936d Guard against sysconf(_SC_OPEN_MAX) returning LONG_MAX
That seems to happen in a sandboxed process on macOS, at least. This
caused an apparent hang when invoking Python, for instance simply
through Tools > Macros > Run Macro... .

Change-Id: I6bc055b44f298251ed596084538b98442c215fce
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/107013
Tested-by: Jenkins
Reviewed-by: Tor Lillqvist <tml@collabora.com>
2020-12-02 08:44:08 +01:00

70 lines
2 KiB
Diff

-*- Mode: diff -*-
--- configure
+++ configure
@@ -9372,6 +9275,9 @@
esac
else
case `/usr/bin/arch` in
+ arm64)
+ MACOSX_DEFAULT_ARCH="arm64"
+ ;;
i386)
MACOSX_DEFAULT_ARCH="x86_64"
;;
--- Mac/Tools/pythonw.c
+++ Mac/Tools/pythonw.c
@@ -121,6 +121,8 @@
cpu_types[0] = CPU_TYPE_POWERPC;
#elif defined(__i386__)
cpu_types[0] = CPU_TYPE_X86;
+#elif defined(__arm64__)
+ cpu_types[0] = CPU_TYPE_ARM64;
#else
# error "Unknown CPU"
#endif
--- setup.py
+++ setup.py
@@ -670,7 +670,10 @@
add_dir_to_list(self.compiler.include_dirs,
sysconfig.get_config_var("INCLUDEDIR"))
- system_lib_dirs = ['/lib64', '/usr/lib64', '/lib', '/usr/lib']
+ if MACOS:
+ system_lib_dirs = ['/usr/lib', macosx_sdk_root()+'/usr/lib']
+ else:
+ system_lib_dirs = ['/lib64', '/usr/lib64', '/lib', '/usr/lib']
system_include_dirs = ['/usr/include']
# lib_dirs and inc_dirs are used to search for files;
# if a file is found in one of those directories, it can
--- Modules/_decimal/libmpdec/mpdecimal.h
+++ Modules/_decimal/libmpdec/mpdecimal.h
@@ -135,6 +135,9 @@
#elif defined(__x86_64__)
#define CONFIG_64
#define ASM
+ #elif defined(__arm64__)
+ #define CONFIG_64
+ #define ANSI
#else
#error "unknown architecture for universal build."
#endif
--- Modules/_posixsubprocess.c
+++ Modules/_posixsubprocess.c
@@ -31,6 +31,8 @@
# define SYS_getdents64 __NR_getdents64
#endif
+#include <limits.h>
+
#if defined(__sun) && defined(__SVR4)
/* readdir64 is used to work around Solaris 9 bug 6395699. */
# define readdir readdir64
@@ -202,7 +202,7 @@
#endif
#ifdef _SC_OPEN_MAX
local_max_fd = sysconf(_SC_OPEN_MAX);
- if (local_max_fd == -1)
+ if (local_max_fd == -1 || local_max_fd == LONG_MAX)
#endif
local_max_fd = 256; /* Matches legacy Lib/subprocess.py behavior. */
return local_max_fd;