@@ -2681,15 +2681,30 @@ index 4aa7e6559a..511d77024c 100644
26812681 sin(pi*x), giving accurate results for all finite x (especially x
26822682 integral or close to an integer). This is here for use in the
26832683diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
2684- index 12f72f525f..a2355bf93f 100644
2684+ index 12f72f525f..ec487c6d0e 100644
26852685--- a/Modules/posixmodule.c
26862686+++ b/Modules/posixmodule.c
2687- @@ -56,6 +56,28 @@
2687+ @@ -56,6 +56,8 @@
26882688 */
26892689 #if defined(__APPLE__)
26902690
26912691+ #include "TargetConditionals.h"
26922692+
2693+ #if defined(__has_builtin) && __has_builtin(__builtin_available)
2694+ # define HAVE_FSTATAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
2695+ # define HAVE_FACCESSAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
2696+ @@ -169,7 +171,6 @@
2697+ disguised Unix interface). Refer to the library manual and\n\
2698+ corresponding Unix manual entries for more information on calls.");
2699+
2700+ -
2701+ #ifdef HAVE_SYS_UIO_H
2702+ # include <sys/uio.h>
2703+ #endif
2704+ @@ -326,6 +327,26 @@
2705+ # endif /* _MSC_VER */
2706+ #endif /* ! __WATCOMC__ || __QNX__ */
2707+
26932708+ // iOS/tvOS/watchOS *define* a number of POSIX functions, but you can't use them
26942709+ // because iOS isn't a conventional multiprocess environment.
26952710+ #if TARGET_OS_IPHONE
@@ -2710,18 +2725,65 @@ index 12f72f525f..a2355bf93f 100644
27102725+ # undef HAVE_WAITPID
27112726+ #endif
27122727+
2713- #if defined(__has_builtin) && __has_builtin(__builtin_available)
2714- # define HAVE_FSTATAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
2715- # define HAVE_FACCESSAT_RUNTIME __builtin_available(macOS 10.10, iOS 8.0, *)
2716- @@ -169,7 +191,6 @@
2717- disguised Unix interface). Refer to the library manual and\n\
2718- corresponding Unix manual entries for more information on calls.");
2728+ _Py_IDENTIFIER(__fspath__);
27192729
2720- -
2721- #ifdef HAVE_SYS_UIO_H
2722- # include <sys/uio.h>
2723- #endif
2724- @@ -1509,7 +1530,9 @@
2730+ /*[clinic input]
2731+ @@ -549,27 +570,33 @@
2732+ }
2733+ }
2734+ }
2735+ + #endif
2736+
2737+ void
2738+ PyOS_BeforeFork(void)
2739+ {
2740+ + #ifdef HAVE_FORK
2741+ run_at_forkers(_PyInterpreterState_GET()->before_forkers, 1);
2742+
2743+ _PyImport_AcquireLock();
2744+ + #endif
2745+ }
2746+
2747+ void
2748+ PyOS_AfterFork_Parent(void)
2749+ {
2750+ + #ifdef HAVE_FORK
2751+ if (_PyImport_ReleaseLock() <= 0)
2752+ Py_FatalError("failed releasing import lock after fork");
2753+
2754+ run_at_forkers(_PyInterpreterState_GET()->after_forkers_parent, 0);
2755+ + #endif
2756+ }
2757+
2758+ void
2759+ PyOS_AfterFork_Child(void)
2760+ {
2761+ + #ifdef HAVE_FORK
2762+ _PyRuntimeState *runtime = &_PyRuntime;
2763+ _PyGILState_Reinit(runtime);
2764+ _PyEval_ReInitThreads(runtime);
2765+ @@ -579,8 +606,10 @@
2766+ _PyInterpreterState_DeleteExceptMain(runtime);
2767+
2768+ run_at_forkers(_PyInterpreterState_GET()->after_forkers_child, 0);
2769+ + #endif
2770+ }
2771+
2772+ + #ifdef HAVE_FORK
2773+ static int
2774+ register_at_forker(PyObject **lst, PyObject *func)
2775+ {
2776+ @@ -600,9 +629,7 @@
2777+ void
2778+ PyOS_AfterFork(void)
2779+ {
2780+ - #ifdef HAVE_FORK
2781+ PyOS_AfterFork_Child();
2782+ - #endif
2783+ }
2784+
2785+
2786+ @@ -1509,7 +1536,9 @@
27252787 */
27262788 #include <crt_externs.h>
27272789 #elif !defined(_MSC_VER) && (!defined(__WATCOMC__) || defined(__QNX__) || defined(__VXWORKS__))
@@ -2731,23 +2793,23 @@ index 12f72f525f..a2355bf93f 100644
27312793 #endif /* !_MSC_VER */
27322794
27332795 static PyObject *
2734- @@ -1525,6 +1548 ,7 @@
2796+ @@ -1525,6 +1554 ,7 @@
27352797 d = PyDict_New();
27362798 if (d == NULL)
27372799 return NULL;
27382800+ #if !TARGET_OS_TV && !TARGET_OS_WATCH
27392801 #ifdef MS_WINDOWS
27402802 /* _wenviron must be initialized in this way if the program is started
27412803 through main() instead of wmain(). */
2742- @@ -1580,6 +1604 ,7 @@
2804+ @@ -1580,6 +1610 ,7 @@
27432805 Py_DECREF(k);
27442806 Py_DECREF(v);
27452807 }
27462808+ #endif
27472809 return d;
27482810 }
27492811
2750- @@ -4739,7 +4764 ,12 @@
2812+ @@ -4739,7 +4770 ,12 @@
27512813 }
27522814
27532815 Py_BEGIN_ALLOW_THREADS
@@ -2760,15 +2822,15 @@ index 12f72f525f..a2355bf93f 100644
27602822 Py_END_ALLOW_THREADS
27612823 return result;
27622824 }
2763- @@ -13332,6 +13362 ,7 @@
2825+ @@ -13332,6 +13368 ,7 @@
27642826 int is_symlink;
27652827 int need_stat;
27662828 #endif
27672829+ #if !TARGET_OS_TV && !TARGET_OS_WATCH
27682830 #ifdef MS_WINDOWS
27692831 unsigned long dir_bits;
27702832 #endif
2771- @@ -13392,6 +13423 ,7 @@
2833+ @@ -13392,6 +13429 ,7 @@
27722834 #endif
27732835
27742836 return result;
0 commit comments